diff options
Diffstat (limited to 'xfa/src/fwl')
79 files changed, 24715 insertions, 25069 deletions
diff --git a/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp b/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp index cc7ffd9f54..026acad0ed 100644 --- a/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp @@ -10,238 +10,225 @@ #include "../core/include/fwl_widgetimp.h"
#include "include/fwl_editimp.h"
#include "include/fwl_barcodeimp.h"
-IFWL_Barcode* IFWL_Barcode::Create()
-{
- return new IFWL_Barcode;
+IFWL_Barcode* IFWL_Barcode::Create() {
+ return new IFWL_Barcode;
}
-IFWL_Barcode::IFWL_Barcode()
-{
- m_pData = NULL;
-}
-IFWL_Barcode::~IFWL_Barcode()
-{
- if (m_pData) {
- delete (CFWL_BarcodeImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_Barcode::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_BarcodeImp(pOuter);
- ((CFWL_BarcodeImp*)m_pData)->SetInterface(this);
- return ((CFWL_BarcodeImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Barcode::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_BarcodeImp(properties, pOuter);
- ((CFWL_BarcodeImp*)m_pData)->SetInterface(this);
- return ((CFWL_BarcodeImp*)m_pData)->Initialize();
-}
-void IFWL_Barcode::SetType(BC_TYPE type)
-{
- ((CFWL_BarcodeImp*)m_pData)->SetType(type);
-}
-FX_BOOL IFWL_Barcode::IsProtectedType()
-{
- return ((CFWL_BarcodeImp*)m_pData)->IsProtectedType();
-}
-CFWL_BarcodeImp::CFWL_BarcodeImp(IFWL_Widget *pOuter )
- : CFWL_EditImp(pOuter)
- , m_pBarcodeEngine(NULL)
- , m_dwStatus(0)
- , m_type(BC_UNKNOWN)
-{
-}
-CFWL_BarcodeImp::CFWL_BarcodeImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_EditImp(properties, pOuter)
- , m_pBarcodeEngine(NULL)
- , m_dwStatus(0)
- , m_type(BC_UNKNOWN)
-{
-}
-CFWL_BarcodeImp::~CFWL_BarcodeImp()
-{
- ReleaseBarcodeEngine();
-}
-FWL_ERR CFWL_BarcodeImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_Barcode;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_BarcodeImp::GetClassID() const
-{
- return FWL_CLASSHASH_Barcode;
-}
-FWL_ERR CFWL_BarcodeImp::Initialize()
-{
- if (!m_pDelegate) {
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_BarcodeImpDelegate(this);
- }
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_EditImp::Initialize(), FWL_ERR_Indefinite);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_BarcodeImp::Finalize()
-{
- if (m_pDelegate) {
- delete (CFWL_BarcodeImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- ReleaseBarcodeEngine();
- return CFWL_EditImp::Finalize();
+IFWL_Barcode::IFWL_Barcode() {
+ m_pData = NULL;
}
-FWL_ERR CFWL_BarcodeImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- FWL_ERR ret = CFWL_EditImp::Update();
+IFWL_Barcode::~IFWL_Barcode() {
+ if (m_pData) {
+ delete (CFWL_BarcodeImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+FWL_ERR IFWL_Barcode::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_BarcodeImp(pOuter);
+ ((CFWL_BarcodeImp*)m_pData)->SetInterface(this);
+ return ((CFWL_BarcodeImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Barcode::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_BarcodeImp(properties, pOuter);
+ ((CFWL_BarcodeImp*)m_pData)->SetInterface(this);
+ return ((CFWL_BarcodeImp*)m_pData)->Initialize();
+}
+void IFWL_Barcode::SetType(BC_TYPE type) {
+ ((CFWL_BarcodeImp*)m_pData)->SetType(type);
+}
+FX_BOOL IFWL_Barcode::IsProtectedType() {
+ return ((CFWL_BarcodeImp*)m_pData)->IsProtectedType();
+}
+CFWL_BarcodeImp::CFWL_BarcodeImp(IFWL_Widget* pOuter)
+ : CFWL_EditImp(pOuter),
+ m_pBarcodeEngine(NULL),
+ m_dwStatus(0),
+ m_type(BC_UNKNOWN) {}
+CFWL_BarcodeImp::CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_EditImp(properties, pOuter),
+ m_pBarcodeEngine(NULL),
+ m_dwStatus(0),
+ m_type(BC_UNKNOWN) {}
+CFWL_BarcodeImp::~CFWL_BarcodeImp() {
+ ReleaseBarcodeEngine();
+}
+FWL_ERR CFWL_BarcodeImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_Barcode;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_BarcodeImp::GetClassID() const {
+ return FWL_CLASSHASH_Barcode;
+}
+FWL_ERR CFWL_BarcodeImp::Initialize() {
+ if (!m_pDelegate) {
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_BarcodeImpDelegate(this);
+ }
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_EditImp::Initialize(),
+ FWL_ERR_Indefinite);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_BarcodeImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_BarcodeImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ ReleaseBarcodeEngine();
+ return CFWL_EditImp::Finalize();
+}
+FWL_ERR CFWL_BarcodeImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ FWL_ERR ret = CFWL_EditImp::Update();
+ GenerateBarcodeImageCache();
+ return ret;
+}
+FWL_ERR CFWL_BarcodeImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
GenerateBarcodeImageCache();
- return ret;
-}
-FWL_ERR CFWL_BarcodeImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- GenerateBarcodeImageCache();
- if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) {
- return FWL_ERR_Succeeded;
- }
- CFX_Matrix mt;
- mt.e = m_rtClient.left;
- mt.f = m_rtClient.top;
- if (pMatrix) {
- mt.Concat(*pMatrix);
- }
- int32_t errorCode = 0;
- _FWL_RETURN_VALUE_IF_FAIL(m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix, errorCode), FWL_ERR_Indefinite);
- return FWL_ERR_Succeeded;
- }
- return CFWL_EditImp::DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_BarcodeImp::GenerateBarcodeImageCache()
-{
- if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) {
- return;
- }
- m_dwStatus = 0;;
- CreateBarcodeEngine();
- IFWL_BarcodeDP *pData = (IFWL_BarcodeDP*)m_pProperties->m_pDataProvider;
- _FWL_RETURN_IF_FAIL(pData);
- _FWL_RETURN_IF_FAIL(m_pBarcodeEngine);
- CFX_WideString wsText;
- _FWL_RETURN_IF_FAIL(GetText(wsText) == FWL_ERR_Succeeded);
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- IFWL_ThemeProvider *pTheme = GetAvailableTheme();
- IFX_Font* pFont = (IFX_Font*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_Font);
- CFX_Font* pCXFont = (CFX_Font*)(pFont ? pFont->GetDevFont() : NULL);
- if(pCXFont) {
- m_pBarcodeEngine->SetFont(pCXFont);
- }
- FX_FLOAT* pFontSize = (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FontSize);
- if(pFontSize) {
- m_pBarcodeEngine->SetFontSize(*pFontSize);
- }
- FX_ARGB* pFontColor = (FX_ARGB*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_TextColor);
- if(pFontColor) {
- m_pBarcodeEngine->SetFontColor(*pFontColor);
- }
- m_pBarcodeEngine->SetHeight(int32_t(m_rtClient.height));
- m_pBarcodeEngine->SetWidth(int32_t(m_rtClient.width));
- FX_DWORD dwAttributeMask = pData->GetBarcodeAttributeMask();
- if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) {
- m_pBarcodeEngine->SetCharEncoding (pData->GetCharEncoding());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) {
- m_pBarcodeEngine->SetModuleHeight (pData->GetModuleHeight());
+ if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) {
+ return FWL_ERR_Succeeded;
}
- if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) {
- m_pBarcodeEngine->SetModuleWidth (pData->GetModuleWidth());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH) {
- m_pBarcodeEngine->SetDataLength (pData->GetDataLength());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM) {
- m_pBarcodeEngine->SetCalChecksum (pData->GetCalChecksum());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM) {
- m_pBarcodeEngine->SetPrintChecksum (pData->GetPrintChecksum());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION) {
- m_pBarcodeEngine->SetTextLocation (pData->GetTextLocation());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO) {
- m_pBarcodeEngine->SetWideNarrowRatio (pData->GetWideNarrowRatio());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR) {
- m_pBarcodeEngine->SetStartChar (pData->GetStartChar());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR) {
- m_pBarcodeEngine->SetEndChar (pData->GetEndChar());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION) {
- m_pBarcodeEngine->SetVersion (pData->GetVersion());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) {
- m_pBarcodeEngine->SetErrorCorrectionLevel (pData->GetErrorCorrectionLevel());
- }
- if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) {
- m_pBarcodeEngine->SetTruncated (pData->GetTruncated());
+ CFX_Matrix mt;
+ mt.e = m_rtClient.left;
+ mt.f = m_rtClient.top;
+ if (pMatrix) {
+ mt.Concat(*pMatrix);
}
int32_t errorCode = 0;
- m_dwStatus = m_pBarcodeEngine->Encode(wsText, TRUE, errorCode) ? XFA_BCS_EncodeSuccess : 0;
-}
-void CFWL_BarcodeImp::CreateBarcodeEngine()
-{
- if ((m_pBarcodeEngine == NULL) && (m_type != BC_UNKNOWN)) {
- m_pBarcodeEngine = FX_Barcode_Create(m_type);
- }
-}
-void CFWL_BarcodeImp::ReleaseBarcodeEngine()
-{
- if (m_pBarcodeEngine) {
- m_pBarcodeEngine->Release();
- m_pBarcodeEngine = NULL;
- }
-}
-void CFWL_BarcodeImp::SetType(BC_TYPE type)
-{
- if (m_type == type) {
- return;
- }
- ReleaseBarcodeEngine();
- m_type = type;
- m_dwStatus = XFA_BCS_NeedUpdate;
-}
-FWL_ERR CFWL_BarcodeImp::SetText(const CFX_WideString &wsText)
-{
- ReleaseBarcodeEngine();
- m_dwStatus = XFA_BCS_NeedUpdate;
- return CFWL_EditImp::SetText(wsText);
-}
-FX_BOOL CFWL_BarcodeImp::IsProtectedType()
-{
- if (!m_pBarcodeEngine) {
- return TRUE;
- }
- BC_TYPE tEngineType = m_pBarcodeEngine->GetType();
- if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 || tEngineType == BC_DATAMATRIX) {
- return TRUE;
- }
- return FALSE;
-}
-CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp *pOwner)
- : CFWL_EditImpDelegate(pOwner)
-{
-}
-FWL_ERR CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- FX_DWORD dwFlag = pEvent->GetClassID();
- if (dwFlag == FWL_EVTHASH_EDT_TextChanged) {
- CFWL_BarcodeImp* pOwner = (CFWL_BarcodeImp*)m_pOwner;
- pOwner->ReleaseBarcodeEngine();
- pOwner->m_dwStatus = XFA_BCS_NeedUpdate;
- }
- return CFWL_EditImpDelegate::OnProcessEvent(pEvent);
+ _FWL_RETURN_VALUE_IF_FAIL(
+ m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix,
+ errorCode),
+ FWL_ERR_Indefinite);
+ return FWL_ERR_Succeeded;
+ }
+ return CFWL_EditImp::DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_BarcodeImp::GenerateBarcodeImageCache() {
+ if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) {
+ return;
+ }
+ m_dwStatus = 0;
+ ;
+ CreateBarcodeEngine();
+ IFWL_BarcodeDP* pData = (IFWL_BarcodeDP*)m_pProperties->m_pDataProvider;
+ _FWL_RETURN_IF_FAIL(pData);
+ _FWL_RETURN_IF_FAIL(m_pBarcodeEngine);
+ CFX_WideString wsText;
+ _FWL_RETURN_IF_FAIL(GetText(wsText) == FWL_ERR_Succeeded);
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ IFWL_ThemeProvider* pTheme = GetAvailableTheme();
+ IFX_Font* pFont = (IFX_Font*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_Font);
+ CFX_Font* pCXFont = (CFX_Font*)(pFont ? pFont->GetDevFont() : NULL);
+ if (pCXFont) {
+ m_pBarcodeEngine->SetFont(pCXFont);
+ }
+ FX_FLOAT* pFontSize =
+ (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FontSize);
+ if (pFontSize) {
+ m_pBarcodeEngine->SetFontSize(*pFontSize);
+ }
+ FX_ARGB* pFontColor =
+ (FX_ARGB*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_TextColor);
+ if (pFontColor) {
+ m_pBarcodeEngine->SetFontColor(*pFontColor);
+ }
+ m_pBarcodeEngine->SetHeight(int32_t(m_rtClient.height));
+ m_pBarcodeEngine->SetWidth(int32_t(m_rtClient.width));
+ FX_DWORD dwAttributeMask = pData->GetBarcodeAttributeMask();
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) {
+ m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) {
+ m_pBarcodeEngine->SetModuleHeight(pData->GetModuleHeight());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) {
+ m_pBarcodeEngine->SetModuleWidth(pData->GetModuleWidth());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH) {
+ m_pBarcodeEngine->SetDataLength(pData->GetDataLength());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM) {
+ m_pBarcodeEngine->SetCalChecksum(pData->GetCalChecksum());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM) {
+ m_pBarcodeEngine->SetPrintChecksum(pData->GetPrintChecksum());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION) {
+ m_pBarcodeEngine->SetTextLocation(pData->GetTextLocation());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO) {
+ m_pBarcodeEngine->SetWideNarrowRatio(pData->GetWideNarrowRatio());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR) {
+ m_pBarcodeEngine->SetStartChar(pData->GetStartChar());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR) {
+ m_pBarcodeEngine->SetEndChar(pData->GetEndChar());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION) {
+ m_pBarcodeEngine->SetVersion(pData->GetVersion());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) {
+ m_pBarcodeEngine->SetErrorCorrectionLevel(pData->GetErrorCorrectionLevel());
+ }
+ if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) {
+ m_pBarcodeEngine->SetTruncated(pData->GetTruncated());
+ }
+ int32_t errorCode = 0;
+ m_dwStatus = m_pBarcodeEngine->Encode(wsText, TRUE, errorCode)
+ ? XFA_BCS_EncodeSuccess
+ : 0;
+}
+void CFWL_BarcodeImp::CreateBarcodeEngine() {
+ if ((m_pBarcodeEngine == NULL) && (m_type != BC_UNKNOWN)) {
+ m_pBarcodeEngine = FX_Barcode_Create(m_type);
+ }
+}
+void CFWL_BarcodeImp::ReleaseBarcodeEngine() {
+ if (m_pBarcodeEngine) {
+ m_pBarcodeEngine->Release();
+ m_pBarcodeEngine = NULL;
+ }
+}
+void CFWL_BarcodeImp::SetType(BC_TYPE type) {
+ if (m_type == type) {
+ return;
+ }
+ ReleaseBarcodeEngine();
+ m_type = type;
+ m_dwStatus = XFA_BCS_NeedUpdate;
+}
+FWL_ERR CFWL_BarcodeImp::SetText(const CFX_WideString& wsText) {
+ ReleaseBarcodeEngine();
+ m_dwStatus = XFA_BCS_NeedUpdate;
+ return CFWL_EditImp::SetText(wsText);
+}
+FX_BOOL CFWL_BarcodeImp::IsProtectedType() {
+ if (!m_pBarcodeEngine) {
+ return TRUE;
+ }
+ BC_TYPE tEngineType = m_pBarcodeEngine->GetType();
+ if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 ||
+ tEngineType == BC_DATAMATRIX) {
+ return TRUE;
+ }
+ return FALSE;
+}
+CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner)
+ : CFWL_EditImpDelegate(pOwner) {}
+FWL_ERR CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ FX_DWORD dwFlag = pEvent->GetClassID();
+ if (dwFlag == FWL_EVTHASH_EDT_TextChanged) {
+ CFWL_BarcodeImp* pOwner = (CFWL_BarcodeImp*)m_pOwner;
+ pOwner->ReleaseBarcodeEngine();
+ pOwner->m_dwStatus = XFA_BCS_NeedUpdate;
+ }
+ return CFWL_EditImpDelegate::OnProcessEvent(pEvent);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp b/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp index b0307e883f..1ccab7af7f 100644 --- a/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp @@ -9,184 +9,164 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "include/fwl_caretimp.h"
-IFWL_Caret* IFWL_Caret::Create()
-{
- return new IFWL_Caret;
+IFWL_Caret* IFWL_Caret::Create() {
+ return new IFWL_Caret;
}
-IFWL_Caret::IFWL_Caret()
-{
- m_pData = NULL;
-}
-IFWL_Caret::~IFWL_Caret()
-{
- if (m_pData) {
- delete (CFWL_CaretImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_Caret::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_CaretImp(pOuter);
- ((CFWL_CaretImp*)m_pData)->SetInterface(this);
- return ((CFWL_CaretImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Caret::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_CaretImp(properties, pOuter);
- ((CFWL_CaretImp*)m_pData)->SetInterface(this);
- return ((CFWL_CaretImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag)
-{
- return ((CFWL_CaretImp*)m_pData)->ShowCaret(bFlag);
-}
-FWL_ERR IFWL_Caret::GetFrequency(FX_DWORD &elapse)
-{
- return ((CFWL_CaretImp*)m_pData)->GetFrequency(elapse);
-}
-FWL_ERR IFWL_Caret::SetFrequency(FX_DWORD elapse)
-{
- return ((CFWL_CaretImp*)m_pData)->SetFrequency(elapse);
-}
-FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill)
-{
- return ((CFWL_CaretImp*)m_pData)->SetColor(crFill);
-}
-CFWL_CaretImp::CFWL_CaretImp(IFWL_Widget *pOuter)
- : m_hTimer(NULL)
-{
- m_dwElapse = 400;
- m_pTimer = FX_NEW CFWL_CaretTimer(this);
- m_bSetColor = FALSE;
- SetStates(FWL_STATE_CAT_HightLight);
-}
-CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter): m_hTimer(NULL)
-{
- m_dwElapse = 400;
- m_pTimer = FX_NEW CFWL_CaretTimer(this);
- m_bSetColor = FALSE;
- SetStates(FWL_STATE_CAT_HightLight);
-}
-CFWL_CaretImp::~CFWL_CaretImp()
-{
- if (m_pTimer) {
- delete m_pTimer;
- m_pTimer = NULL;
- }
-}
-FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_Caret;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_CaretImp::GetClassID() const
-{
- return FWL_CLASSHASH_Caret;
-}
-FWL_ERR CFWL_CaretImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_CaretImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CaretImp::Finalize()
-{
- if (m_hTimer) {
- FWL_StopTimer(m_hTimer);
- m_hTimer = NULL;
- }
- if (m_pDelegate) {
- delete (CFWL_CaretImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_CaretImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
- return FWL_ERR_Succeeded;
+IFWL_Caret::IFWL_Caret() {
+ m_pData = NULL;
}
-FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag)
-{
- if (m_hTimer) {
- FWL_StopTimer(m_hTimer);
- m_hTimer = NULL;
- }
- if (bFlag) {
- m_hTimer = FWL_StartTimer((IFWL_Timer *)m_pTimer, m_dwElapse);
- }
- return SetStates(FWL_WGTSTATE_Invisible, !bFlag);
-}
-FWL_ERR CFWL_CaretImp::GetFrequency(FX_DWORD &elapse)
-{
- elapse = m_dwElapse;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CaretImp::SetFrequency(FX_DWORD elapse)
-{
- m_dwElapse = elapse;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill)
-{
- m_bSetColor = TRUE;
- m_crFill = crFill;
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_CaretImp::DrawCaretBK(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFX_RectF rect;
- GetWidgetRect(rect);
- rect.Set(0, 0, rect.width, rect.height);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = rect;
- if (m_bSetColor) {
- param.m_pData = &m_crFill;
- }
- if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) {
- return FWL_ERR_Succeeded;
- }
- param.m_iPart = FWL_PART_CAT_Background;
- param.m_dwStates = FWL_PARTSTATE_CAT_HightLight;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶m);
+IFWL_Caret::~IFWL_Caret() {
+ if (m_pData) {
+ delete (CFWL_CaretImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+FWL_ERR IFWL_Caret::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CaretImp(pOuter);
+ ((CFWL_CaretImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CaretImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Caret::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CaretImp(properties, pOuter);
+ ((CFWL_CaretImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CaretImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag) {
+ return ((CFWL_CaretImp*)m_pData)->ShowCaret(bFlag);
+}
+FWL_ERR IFWL_Caret::GetFrequency(FX_DWORD& elapse) {
+ return ((CFWL_CaretImp*)m_pData)->GetFrequency(elapse);
+}
+FWL_ERR IFWL_Caret::SetFrequency(FX_DWORD elapse) {
+ return ((CFWL_CaretImp*)m_pData)->SetFrequency(elapse);
+}
+FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill) {
+ return ((CFWL_CaretImp*)m_pData)->SetColor(crFill);
+}
+CFWL_CaretImp::CFWL_CaretImp(IFWL_Widget* pOuter) : m_hTimer(NULL) {
+ m_dwElapse = 400;
+ m_pTimer = FX_NEW CFWL_CaretTimer(this);
+ m_bSetColor = FALSE;
+ SetStates(FWL_STATE_CAT_HightLight);
+}
+CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : m_hTimer(NULL) {
+ m_dwElapse = 400;
+ m_pTimer = FX_NEW CFWL_CaretTimer(this);
+ m_bSetColor = FALSE;
+ SetStates(FWL_STATE_CAT_HightLight);
+}
+CFWL_CaretImp::~CFWL_CaretImp() {
+ if (m_pTimer) {
+ delete m_pTimer;
+ m_pTimer = NULL;
+ }
+}
+FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_Caret;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_CaretImp::GetClassID() const {
+ return FWL_CLASSHASH_Caret;
+}
+FWL_ERR CFWL_CaretImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_CaretImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CaretImp::Finalize() {
+ if (m_hTimer) {
+ FWL_StopTimer(m_hTimer);
+ m_hTimer = NULL;
+ }
+ if (m_pDelegate) {
+ delete (CFWL_CaretImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) {
+ if (m_hTimer) {
+ FWL_StopTimer(m_hTimer);
+ m_hTimer = NULL;
+ }
+ if (bFlag) {
+ m_hTimer = FWL_StartTimer((IFWL_Timer*)m_pTimer, m_dwElapse);
+ }
+ return SetStates(FWL_WGTSTATE_Invisible, !bFlag);
+}
+FWL_ERR CFWL_CaretImp::GetFrequency(FX_DWORD& elapse) {
+ elapse = m_dwElapse;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CaretImp::SetFrequency(FX_DWORD elapse) {
+ m_dwElapse = elapse;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill) {
+ m_bSetColor = TRUE;
+ m_crFill = crFill;
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFX_RectF rect;
+ GetWidgetRect(rect);
+ rect.Set(0, 0, rect.width, rect.height);
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_pGraphics = pGraphics;
+ param.m_rtPart = rect;
+ if (m_bSetColor) {
+ param.m_pData = &m_crFill;
+ }
+ if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) {
return FWL_ERR_Succeeded;
-}
-CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp *m_pCaret)
-{
- this->m_pCaret = m_pCaret;
-}
-int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer)
-{
- if (m_pCaret->GetStates() & FWL_STATE_CAT_HightLight) {
- m_pCaret->SetStates(FWL_STATE_CAT_HightLight, FALSE);
- } else {
- m_pCaret->SetStates(FWL_STATE_CAT_HightLight);
- }
- CFX_RectF rt;
- m_pCaret->GetWidgetRect(rt);
- rt.Set(0, 0, rt.width + 1, rt.height);
- m_pCaret->Repaint(&rt);
- return 1;
-}
-CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- return 1;
-}
-FWL_ERR CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+ }
+ param.m_iPart = FWL_PART_CAT_Background;
+ param.m_dwStates = FWL_PARTSTATE_CAT_HightLight;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶m);
+ return FWL_ERR_Succeeded;
+}
+CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* m_pCaret) {
+ this->m_pCaret = m_pCaret;
+}
+int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer) {
+ if (m_pCaret->GetStates() & FWL_STATE_CAT_HightLight) {
+ m_pCaret->SetStates(FWL_STATE_CAT_HightLight, FALSE);
+ } else {
+ m_pCaret->SetStates(FWL_STATE_CAT_HightLight);
+ }
+ CFX_RectF rt;
+ m_pCaret->GetWidgetRect(rt);
+ rt.Set(0, 0, rt.width + 1, rt.height);
+ m_pCaret->Repaint(&rt);
+ return 1;
+}
+CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ return 1;
+}
+FWL_ERR CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp index 1ba0851bb6..8fb17ce534 100644 --- a/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp @@ -10,597 +10,584 @@ #include "../core/include/fwl_widgetimp.h"
#include "../core/include/fwl_widgetmgrimp.h"
#include "include/fwl_checkboximp.h"
-#define FWL_CKB_CaptionMargin 5
-IFWL_CheckBox* IFWL_CheckBox::Create()
-{
- return new IFWL_CheckBox;
+#define FWL_CKB_CaptionMargin 5
+IFWL_CheckBox* IFWL_CheckBox::Create() {
+ return new IFWL_CheckBox;
}
-IFWL_CheckBox::IFWL_CheckBox()
-{
+IFWL_CheckBox::IFWL_CheckBox() {
+ m_pData = NULL;
+}
+IFWL_CheckBox::~IFWL_CheckBox() {
+ if (m_pData) {
+ delete (CFWL_CheckBoxImp*)m_pData;
m_pData = NULL;
+ }
}
-IFWL_CheckBox::~IFWL_CheckBox()
-{
- if (m_pData) {
- delete (CFWL_CheckBoxImp*)m_pData;
- m_pData = NULL;
- }
+FWL_ERR IFWL_CheckBox::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CheckBoxImp(pOuter);
+ ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_CheckBox::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_CheckBoxImp(pOuter);
- ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
+FWL_ERR IFWL_CheckBox::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CheckBoxImp(properties, pOuter);
+ ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_CheckBox::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_CheckBoxImp(properties, pOuter);
- ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
+int32_t IFWL_CheckBox::GetCheckState() {
+ return ((CFWL_CheckBoxImp*)m_pData)->GetCheckState();
}
-int32_t IFWL_CheckBox::GetCheckState()
-{
- return ((CFWL_CheckBoxImp*)m_pData)->GetCheckState();
+FWL_ERR IFWL_CheckBox::SetCheckState(int32_t iCheck) {
+ return ((CFWL_CheckBoxImp*)m_pData)->SetCheckState(iCheck);
}
-FWL_ERR IFWL_CheckBox::SetCheckState(int32_t iCheck)
-{
- return ((CFWL_CheckBoxImp*)m_pData)->SetCheckState(iCheck);
+IFWL_RadioButton* IFWL_RadioButton::Create() {
+ return new IFWL_RadioButton;
}
-IFWL_RadioButton* IFWL_RadioButton::Create()
-{
- return new IFWL_RadioButton;
+IFWL_RadioButton::IFWL_RadioButton() {
+ m_pData = NULL;
}
-IFWL_RadioButton::IFWL_RadioButton()
-{
+IFWL_RadioButton::~IFWL_RadioButton() {
+ if (m_pData) {
+ delete (CFWL_CheckBoxImp*)m_pData;
m_pData = NULL;
-}
-IFWL_RadioButton::~IFWL_RadioButton()
-{
- if (m_pData) {
- delete (CFWL_CheckBoxImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_RadioButton::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_CheckBoxImp(pOuter);
- ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_RadioButton::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_CheckBoxImp(properties, pOuter);
- ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
-}
-CFWL_CheckBoxImp::CFWL_CheckBoxImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_dwTTOStyles(FDE_TTOSTYLE_SingleLine)
- , m_iTTOAlign(FDE_TTOALIGNMENT_Center)
- , m_bBtnDown(FALSE)
-{
- m_rtClient.Reset();
- m_rtBox.Reset();
- m_rtCaption.Reset();
- m_rtFocus.Reset();
-}
-CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_dwTTOStyles(FDE_TTOSTYLE_SingleLine)
- , m_iTTOAlign(FDE_TTOALIGNMENT_Center)
- , m_bBtnDown(FALSE)
-{
- m_rtClient.Reset();
- m_rtBox.Reset();
- m_rtCaption.Reset();
- m_rtFocus.Reset();
-}
-CFWL_CheckBoxImp::~CFWL_CheckBoxImp()
-{
-}
-FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) ? FWL_CLASS_RadioButton : FWL_CLASS_CheckBox;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_CheckBoxImp::GetClassID() const
-{
- return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton ? FWL_CLASSHASH_RadioButton : FWL_CLASSHASH_CheckBox;
-}
-FWL_ERR CFWL_CheckBoxImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_CheckBoxImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CheckBoxImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_CheckBoxImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
- CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
- if (wsCaption.GetLength() > 0) {
- CFX_SizeF sz = CalcTextSize(wsCaption,
- m_pProperties->m_pThemeProvider,
- m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine);
- rect.Set(0, 0, sz.x, sz.y);
- }
- rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin);
- IFWL_CheckBoxDP *pData = (IFWL_CheckBoxDP*)m_pProperties->m_pDataProvider;
- FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface);
- rect.width += fCheckBox;
- if (rect.height < fCheckBox) {
- rect.height = fCheckBox;
- }
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CheckBoxImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
+ }
+}
+FWL_ERR IFWL_RadioButton::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CheckBoxImp(pOuter);
+ ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_RadioButton::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CheckBoxImp(properties, pOuter);
+ ((CFWL_CheckBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CheckBoxImp*)m_pData)->Initialize();
+}
+CFWL_CheckBoxImp::CFWL_CheckBoxImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
+ m_iTTOAlign(FDE_TTOALIGNMENT_Center),
+ m_bBtnDown(FALSE) {
+ m_rtClient.Reset();
+ m_rtBox.Reset();
+ m_rtCaption.Reset();
+ m_rtFocus.Reset();
+}
+CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
+ m_iTTOAlign(FDE_TTOALIGNMENT_Center),
+ m_bBtnDown(FALSE) {
+ m_rtClient.Reset();
+ m_rtBox.Reset();
+ m_rtCaption.Reset();
+ m_rtFocus.Reset();
+}
+CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {}
+FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton)
+ ? FWL_CLASS_RadioButton
+ : FWL_CLASS_CheckBox;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_CheckBoxImp::GetClassID() const {
+ return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton
+ ? FWL_CLASSHASH_RadioButton
+ : FWL_CLASSHASH_CheckBox;
+}
+FWL_ERR CFWL_CheckBoxImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_CheckBoxImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CheckBoxImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_CheckBoxImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- UpdateTextOutStyles();
- Layout();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_CKB_Border, m_pProperties->m_pThemeProvider, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_CKB_Edge, pTheme, pMatrix);
- }
- int32_t dwStates = GetPartStates();
- {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CKB_Background;
- param.m_dwStates = dwStates;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- param.m_rtPart = m_rtClient;
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- param.m_pData = &m_rtFocus;
- }
- pTheme->DrawBackground(¶m);
- param.m_iPart = FWL_PART_CKB_CheckBox;
- param.m_rtPart = m_rtBox;
- pTheme->DrawBackground(¶m);
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
- {
- CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
- int32_t iLen = wsCaption.GetLength();
- _FWL_RETURN_VALUE_IF_FAIL(iLen > 0, FWL_ERR_Indefinite);
- CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_CKB_Caption;
- textParam.m_dwStates = dwStates;
- textParam.m_pGraphics = pGraphics;
- if(pMatrix) {
- textParam.m_matrix.Concat(*pMatrix);
- }
- textParam.m_rtPart = m_rtCaption;
- textParam.m_wsText = wsCaption;
- textParam.m_dwTTOStyles = m_dwTTOStyles;
- textParam.m_iTTOAlign = m_iTTOAlign;
- pTheme->DrawText(&textParam);
- }
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_CheckBoxImp::GetCheckState()
-{
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State)
- && ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Neutral)) {
- return 2;
- }
- if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Checked) {
- return 1;
- }
- return 0;
-}
-FWL_ERR CFWL_CheckBoxImp::SetCheckState(int32_t iCheck)
-{
- m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
- switch(iCheck) {
- case 0: {
- break;
- }
- case 1: {
- m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
- break;
- }
- case 2: {
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
- m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
- }
- break;
- }
- default: {
- }
- }
- Repaint(&m_rtClient);
- return FWL_ERR_Succeeded;
-}
-void CFWL_CheckBoxImp::Layout()
-{
- int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f);
- int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f);
- m_pProperties->m_rtWidget.width = (FX_FLOAT)width;
- m_pProperties->m_rtWidget.height = (FX_FLOAT)height;
- GetClientRect(m_rtClient);
- FX_FLOAT fBoxTop = m_rtClient.top;
- FX_FLOAT fBoxLeft = m_rtClient.left;
- FX_FLOAT fTextLeft = 0.0, fTextRight = 0.0;
- FX_FLOAT fClientRight = m_rtClient.right();
- FX_FLOAT fClientBottom = m_rtClient.bottom();
- _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
- IFWL_CheckBoxDP *pData = (IFWL_CheckBoxDP*)m_pProperties->m_pDataProvider;
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider,
+ FWL_ERR_Indefinite);
+ CFX_WideString wsCaption;
+ m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ if (wsCaption.GetLength() > 0) {
+ CFX_SizeF sz = CalcTextSize(
+ wsCaption, m_pProperties->m_pThemeProvider,
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine);
+ rect.Set(0, 0, sz.x, sz.y);
+ }
+ rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin);
+ IFWL_CheckBoxDP* pData = (IFWL_CheckBoxDP*)m_pProperties->m_pDataProvider;
FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface);
- switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) {
- case FWL_STYLEEXT_CKB_Top: {
- fBoxTop = m_rtClient.top;
- break;
- }
- case FWL_STYLEEXT_CKB_Bottom: {
- fBoxTop = fClientBottom - fCheckBox;
- break;
- }
- case FWL_STYLEEXT_CKB_VCenter:
- default: {
- fBoxTop = m_rtClient.top + (m_rtClient.height - fCheckBox) / 2;
- fBoxTop = FXSYS_floor(fBoxTop);
- }
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_LeftText) {
- fBoxLeft = fClientRight - fCheckBox;
- fTextLeft = m_rtClient.left;
- fTextRight = fBoxLeft;
- } else {
- fTextLeft = fBoxLeft + fCheckBox;
- fTextRight = fClientRight;
- }
- m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox);
- m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft, m_rtClient.height);
- m_rtCaption.Inflate(-FWL_CKB_CaptionMargin, -FWL_CKB_CaptionMargin);
- CFX_RectF rtFocus;
- rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, m_rtCaption.height);
+ rect.width += fCheckBox;
+ if (rect.height < fCheckBox) {
+ rect.height = fCheckBox;
+ }
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CheckBoxImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ UpdateTextOutStyles();
+ Layout();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_CKB_Border, m_pProperties->m_pThemeProvider,
+ pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_CKB_Edge, pTheme, pMatrix);
+ }
+ int32_t dwStates = GetPartStates();
+ {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_CKB_Background;
+ param.m_dwStates = dwStates;
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = m_rtClient;
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ param.m_pData = &m_rtFocus;
+ }
+ pTheme->DrawBackground(¶m);
+ param.m_iPart = FWL_PART_CKB_CheckBox;
+ param.m_rtPart = m_rtBox;
+ pTheme->DrawBackground(¶m);
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
+ {
CFX_WideString wsCaption;
m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
- if (wsCaption.IsEmpty()) {
- m_rtFocus.Set(0, 0, 0, 0);
+ int32_t iLen = wsCaption.GetLength();
+ _FWL_RETURN_VALUE_IF_FAIL(iLen > 0, FWL_ERR_Indefinite);
+ CFWL_ThemeText textParam;
+ textParam.m_pWidget = m_pInterface;
+ textParam.m_iPart = FWL_PART_CKB_Caption;
+ textParam.m_dwStates = dwStates;
+ textParam.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ textParam.m_matrix.Concat(*pMatrix);
+ }
+ textParam.m_rtPart = m_rtCaption;
+ textParam.m_wsText = wsCaption;
+ textParam.m_dwTTOStyles = m_dwTTOStyles;
+ textParam.m_iTTOAlign = m_iTTOAlign;
+ pTheme->DrawText(&textParam);
+ }
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_CheckBoxImp::GetCheckState() {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) &&
+ ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Neutral)) {
+ return 2;
+ }
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Checked) {
+ return 1;
+ }
+ return 0;
+}
+FWL_ERR CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) {
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
+ switch (iCheck) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
+ break;
+ }
+ case 2: {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
+ }
+ break;
+ }
+ default: {}
+ }
+ Repaint(&m_rtClient);
+ return FWL_ERR_Succeeded;
+}
+void CFWL_CheckBoxImp::Layout() {
+ int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f);
+ int32_t height = int32_t(m_pProperties->m_rtWidget.height + 0.5f);
+ m_pProperties->m_rtWidget.width = (FX_FLOAT)width;
+ m_pProperties->m_rtWidget.height = (FX_FLOAT)height;
+ GetClientRect(m_rtClient);
+ FX_FLOAT fBoxTop = m_rtClient.top;
+ FX_FLOAT fBoxLeft = m_rtClient.left;
+ FX_FLOAT fTextLeft = 0.0, fTextRight = 0.0;
+ FX_FLOAT fClientRight = m_rtClient.right();
+ FX_FLOAT fClientBottom = m_rtClient.bottom();
+ _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
+ IFWL_CheckBoxDP* pData = (IFWL_CheckBoxDP*)m_pProperties->m_pDataProvider;
+ FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface);
+ switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) {
+ case FWL_STYLEEXT_CKB_Top: {
+ fBoxTop = m_rtClient.top;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Bottom: {
+ fBoxTop = fClientBottom - fCheckBox;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_VCenter:
+ default: {
+ fBoxTop = m_rtClient.top + (m_rtClient.height - fCheckBox) / 2;
+ fBoxTop = FXSYS_floor(fBoxTop);
+ }
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_LeftText) {
+ fBoxLeft = fClientRight - fCheckBox;
+ fTextLeft = m_rtClient.left;
+ fTextRight = fBoxLeft;
+ } else {
+ fTextLeft = fBoxLeft + fCheckBox;
+ fTextRight = fClientRight;
+ }
+ m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox);
+ m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft,
+ m_rtClient.height);
+ m_rtCaption.Inflate(-FWL_CKB_CaptionMargin, -FWL_CKB_CaptionMargin);
+ CFX_RectF rtFocus;
+ rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width,
+ m_rtCaption.height);
+ CFX_WideString wsCaption;
+ m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ if (wsCaption.IsEmpty()) {
+ m_rtFocus.Set(0, 0, 0, 0);
+ } else {
+ CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles,
+ m_iTTOAlign, rtFocus);
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) {
+ FX_FLOAT fWidth = FX_MAX(m_rtCaption.width, rtFocus.width);
+ FX_FLOAT fHeight = FX_MIN(m_rtCaption.height, rtFocus.height);
+ FX_FLOAT fLeft = m_rtCaption.left;
+ FX_FLOAT fTop = m_rtCaption.top;
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_HLayoutMask) ==
+ FWL_STYLEEXT_CKB_Center) {
+ fLeft = m_rtCaption.left + (m_rtCaption.width - fWidth) / 2;
+ } else if ((m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_CKB_HLayoutMask) == FWL_STYLEEXT_CKB_Right) {
+ fLeft = m_rtCaption.right() - fWidth;
+ }
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) ==
+ FWL_STYLEEXT_CKB_VCenter) {
+ fTop = m_rtCaption.top + (m_rtCaption.height - fHeight) / 2;
+ } else if ((m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) {
+ fTop = m_rtCaption.bottom() - fHeight;
+ }
+ m_rtFocus.Set(fLeft, fTop, fWidth, fHeight);
} else {
- CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, m_iTTOAlign, rtFocus);
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) {
- FX_FLOAT fWidth = FX_MAX(m_rtCaption.width, rtFocus.width);
- FX_FLOAT fHeight = FX_MIN(m_rtCaption.height, rtFocus.height);
- FX_FLOAT fLeft = m_rtCaption.left;
- FX_FLOAT fTop = m_rtCaption.top;
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_HLayoutMask) == FWL_STYLEEXT_CKB_Center) {
- fLeft = m_rtCaption.left + (m_rtCaption.width - fWidth) / 2;
- } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_HLayoutMask) == FWL_STYLEEXT_CKB_Right) {
- fLeft = m_rtCaption.right() - fWidth;
- }
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_VCenter) {
- fTop = m_rtCaption.top + (m_rtCaption.height - fHeight) / 2;
- } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) == FWL_STYLEEXT_CKB_Bottom) {
- fTop = m_rtCaption.bottom() - fHeight;
- }
- m_rtFocus.Set(fLeft, fTop, fWidth, fHeight);
- } else {
- m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height);
+ m_rtFocus.Set(rtFocus.left, rtFocus.top, rtFocus.width, rtFocus.height);
+ }
+ m_rtFocus.Inflate(1, 1);
+ }
+}
+FX_DWORD CFWL_CheckBoxImp::GetPartStates() {
+ int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked;
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Neutral) {
+ dwStates = FWL_PARTSTATE_CKB_Neutral;
+ } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Checked) {
+ dwStates = FWL_PARTSTATE_CKB_Checked;
+ }
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ dwStates |= FWL_PARTSTATE_CKB_Disabled;
+ } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) {
+ dwStates |= FWL_PARTSTATE_CKB_Hovered;
+ } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
+ dwStates |= FWL_PARTSTATE_CKB_Pressed;
+ } else {
+ dwStates |= FWL_PARTSTATE_CKB_Normal;
+ }
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ dwStates |= FWL_PARTSTATE_CKB_Focused;
+ }
+ return dwStates;
+}
+void CFWL_CheckBoxImp::UpdateTextOutStyles() {
+ m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ switch (m_pProperties->m_dwStyleExes &
+ (FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) {
+ case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Top: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Top: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Top: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_TopRight;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_VCenter: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_VCenter: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_VCenter: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Bottom: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Bottom: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter;
+ break;
+ }
+ case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Bottom: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight;
+ break;
+ }
+ default: {}
+ }
+ m_dwTTOStyles = 0;
+ if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
+ m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) {
+ m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap;
+ } else {
+ m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
+ }
+}
+void CFWL_CheckBoxImp::NextStates() {
+ FX_DWORD dwFirststate = m_pProperties->m_dwStates;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) {
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Unchecked) {
+ IFWL_WidgetMgr* pWMgr = FWL_GetWidgetMgr();
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)pWMgr;
+ if (!pWidgetMgr->IsFormDisabled()) {
+ CFX_PtrArray radioarr;
+ pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr);
+ IFWL_CheckBox* pCheckBox = NULL;
+ int32_t iCount = radioarr.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ pCheckBox = (IFWL_CheckBox*)radioarr[i];
+ if (pCheckBox != m_pInterface &&
+ pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
+ pCheckBox->SetCheckState(0);
+ CFX_RectF rt;
+ pCheckBox->GetWidgetRect(rt);
+ rt.left = rt.top = 0;
+ m_pWidgetMgr->RepaintWidget(pCheckBox, &rt);
+ break;
+ }
}
- m_rtFocus.Inflate(1, 1);
- }
-}
-FX_DWORD CFWL_CheckBoxImp::GetPartStates()
-{
- int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked;
- if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Neutral) {
- dwStates = FWL_PARTSTATE_CKB_Neutral;
- } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Checked) {
- dwStates = FWL_PARTSTATE_CKB_Checked;
- }
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- dwStates |= FWL_PARTSTATE_CKB_Disabled;
- } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered ) {
- dwStates |= FWL_PARTSTATE_CKB_Hovered;
- } else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed ) {
- dwStates |= FWL_PARTSTATE_CKB_Pressed;
+ }
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
+ }
+ } else {
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Neutral) {
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
+ }
+ } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
+ FWL_STATE_CKB_Checked) {
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
} else {
- dwStates |= FWL_PARTSTATE_CKB_Normal;
- }
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- dwStates |= FWL_PARTSTATE_CKB_Focused;
- }
- return dwStates;
-}
-void CFWL_CheckBoxImp::UpdateTextOutStyles()
-{
- m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- switch (m_pProperties->m_dwStyleExes & (FWL_STYLEEXT_CKB_HLayoutMask | FWL_STYLEEXT_CKB_VLayoutMask)) {
- case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Top: {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
- break;
- }
- case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Top: {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
- break;
- }
- case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Top: {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopRight;
- break;
- }
- case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_VCenter: {
- m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
- break;
- }
- case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_VCenter: {
- m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- break;
- }
- case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_VCenter: {
- m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight;
- break;
- }
- case FWL_STYLEEXT_CKB_Left | FWL_STYLEEXT_CKB_Bottom: {
- m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft;
- break;
- }
- case FWL_STYLEEXT_CKB_Center | FWL_STYLEEXT_CKB_Bottom: {
- m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter;
- break;
- }
- case FWL_STYLEEXT_CKB_Right | FWL_STYLEEXT_CKB_Bottom: {
- m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight;
- break;
- }
- default: {
- }
- }
- m_dwTTOStyles = 0;
- if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
- m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) {
- m_dwTTOStyles |= FDE_TTOSTYLE_LineWrap;
- } else {
- m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
- }
-}
-void CFWL_CheckBoxImp::NextStates()
-{
- FX_DWORD dwFirststate = m_pProperties->m_dwStates;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) {
- if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Unchecked) {
- IFWL_WidgetMgr *pWMgr = FWL_GetWidgetMgr();
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr* )pWMgr;
- if (!pWidgetMgr->IsFormDisabled()) {
- CFX_PtrArray radioarr;
- pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr);
- IFWL_CheckBox *pCheckBox = NULL;
- int32_t iCount = radioarr.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- pCheckBox = (IFWL_CheckBox *)radioarr[i];
- if (pCheckBox != m_pInterface && pCheckBox->GetStates() & FWL_STATE_CKB_Checked) {
- pCheckBox->SetCheckState(0);
- CFX_RectF rt;
- pCheckBox->GetWidgetRect(rt);
- rt.left = rt.top = 0;
- m_pWidgetMgr->RepaintWidget(pCheckBox, &rt);
- break;
- }
- }
- }
- m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
+ } else {
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
+ }
+ }
+ }
+ Repaint(&m_rtClient);
+ FX_DWORD dwLaststate = m_pProperties->m_dwStates;
+ if (dwFirststate != dwLaststate) {
+ CFWL_EvtCkbCheckStateChanged wmCheckBoxState;
+ wmCheckBoxState.m_pSrcTarget = m_pInterface;
+ DispatchEvent(&wmCheckBoxState);
+ }
+}
+CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_Activate: {
+ OnActivate(pMessage);
+ break;
+ }
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
}
- } else {
- if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Neutral) {
- m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
- m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
- }
- } else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) == FWL_STATE_CKB_Checked) {
- m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
- } else {
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) {
- m_pProperties->m_dwStates |= FWL_STATE_CKB_Neutral;
- } else {
- m_pProperties->m_dwStates |= FWL_STATE_CKB_Checked;
- }
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- }
- Repaint(&m_rtClient);
- FX_DWORD dwLaststate = m_pProperties->m_dwStates;
- if (dwFirststate != dwLaststate) {
- CFWL_EvtCkbCheckStateChanged wmCheckBoxState;
- wmCheckBoxState.m_pSrcTarget = m_pInterface;
- DispatchEvent(&wmCheckBoxState);
- }
-}
-CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
- OnActivate(pMessage);
- break;
- }
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_MsgKey *pKey = (CFWL_MsgKey*)pMessage;
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
- OnKeyDown((CFWL_MsgKey*)pKey);
- }
- break;
- }
- default: {
- iRet = 0;
- }
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message *pMsg)
-{
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&(m_pOwner->m_rtClient));
-}
-void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet )
-{
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- m_pOwner->Repaint(&(m_pOwner->m_rtClient));
-}
-void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- return;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- m_pOwner->m_bBtnDown = TRUE;
- m_pOwner->m_pProperties->m_dwStates &= ~ FWL_STATE_CKB_Hovered;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
- m_pOwner->Repaint(&(m_pOwner->m_rtClient));
-}
-void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- if (!m_pOwner->m_bBtnDown) {
- return;
- }
- m_pOwner->m_bBtnDown = FALSE;
- if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return;
- }
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
- m_pOwner->NextStates();
-}
-void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- return;
- }
- FX_BOOL bRepaint = FALSE;
- if (m_pOwner->m_bBtnDown) {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) {
- bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered)) {
- bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
- }
- } else {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
- bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
- bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
- }
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
}
- } else {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
- bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
- }
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave(pMsg);
+ break;
}
+ default: {}
+ }
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ CFWL_MsgKey* pKey = (CFWL_MsgKey*)pMessage;
+ if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ OnKeyDown((CFWL_MsgKey*)pKey);
+ }
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
+}
+FWL_ERR CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message* pMsg) {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
+ m_pOwner->Repaint(&(m_pOwner->m_rtClient));
+}
+void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ }
+ m_pOwner->Repaint(&(m_pOwner->m_rtClient));
+}
+void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ return;
+ }
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ m_pOwner->SetFocus(TRUE);
+ }
+ m_pOwner->m_bBtnDown = TRUE;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
+ m_pOwner->Repaint(&(m_pOwner->m_rtClient));
+}
+void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (!m_pOwner->m_bBtnDown) {
+ return;
+ }
+ m_pOwner->m_bBtnDown = FALSE;
+ if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return;
+ }
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
+ m_pOwner->NextStates();
+}
+void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ return;
+ }
+ FX_BOOL bRepaint = FALSE;
+ if (m_pOwner->m_bBtnDown) {
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) {
+ bRepaint = TRUE;
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
+ }
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered)) {
+ bRepaint = TRUE;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+ }
+ } else {
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
+ bRepaint = TRUE;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
+ }
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
+ bRepaint = TRUE;
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ }
}
- if (bRepaint) {
- m_pOwner->Repaint(&(m_pOwner->m_rtBox));
- }
-}
-void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_bBtnDown) {
+ } else {
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
+ bRepaint = TRUE;
m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+ }
}
+ }
+ if (bRepaint) {
m_pOwner->Repaint(&(m_pOwner->m_rtBox));
+ }
}
-void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey *pMsg)
-{
- if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
- m_pOwner->DispatchKeyEvent(pMsg);
- return;
- }
- if (pMsg->m_dwKeyCode == FWL_VKEY_Return || pMsg->m_dwKeyCode == FWL_VKEY_Space) {
- m_pOwner->NextStates();
- }
+void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_bBtnDown) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+ }
+ m_pOwner->Repaint(&(m_pOwner->m_rtBox));
+}
+void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+ if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
+ m_pOwner->DispatchKeyEvent(pMsg);
+ return;
+ }
+ if (pMsg->m_dwKeyCode == FWL_VKEY_Return ||
+ pMsg->m_dwKeyCode == FWL_VKEY_Space) {
+ m_pOwner->NextStates();
+ }
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp index 6ca86e7d4a..45c3cae8d8 100644 --- a/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp @@ -18,1974 +18,1875 @@ #include "include/fwl_listboximp.h"
#include "include/fwl_formproxyimp.h"
#include "include/fwl_comboboximp.h"
-IFWL_ComboBox* IFWL_ComboBox::Create()
-{
- return new IFWL_ComboBox;
+IFWL_ComboBox* IFWL_ComboBox::Create() {
+ return new IFWL_ComboBox;
}
-IFWL_ComboBox::IFWL_ComboBox()
-{
+IFWL_ComboBox::IFWL_ComboBox() {
+ m_pData = NULL;
+}
+IFWL_ComboBox::~IFWL_ComboBox() {
+ if (m_pData) {
+ delete (CFWL_ComboBoxImp*)m_pData;
m_pData = NULL;
+ }
}
-IFWL_ComboBox::~IFWL_ComboBox()
-{
- if (m_pData) {
- delete (CFWL_ComboBoxImp*)m_pData;
- m_pData = NULL;
- }
+FWL_ERR IFWL_ComboBox::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ComboBoxImp(pOuter);
+ ((CFWL_ComboBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ComboBoxImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_ComboBox::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ComboBoxImp(pOuter);
- ((CFWL_ComboBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_ComboBoxImp*)m_pData)->Initialize();
+FWL_ERR IFWL_ComboBox::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ComboBoxImp(properties, pOuter);
+ ((CFWL_ComboBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ComboBoxImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_ComboBox::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ComboBoxImp(properties, pOuter);
- ((CFWL_ComboBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_ComboBoxImp*)m_pData)->Initialize();
+int32_t IFWL_ComboBox::GetCurSel() {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetCurSel();
}
-int32_t IFWL_ComboBox::GetCurSel()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetCurSel();
+FWL_ERR IFWL_ComboBox::SetCurSel(int32_t iSel) {
+ return ((CFWL_ComboBoxImp*)m_pData)->SetCurSel(iSel);
}
-FWL_ERR IFWL_ComboBox::SetCurSel(int32_t iSel)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->SetCurSel(iSel);
+FWL_ERR IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
+ return ((CFWL_ComboBoxImp*)m_pData)->SetEditText(wsText);
}
-FWL_ERR IFWL_ComboBox::SetEditText(const CFX_WideString &wsText)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->SetEditText(wsText);
+int32_t IFWL_ComboBox::GetEditTextLength() const {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetEditTextLength();
}
-int32_t IFWL_ComboBox::GetEditTextLength() const
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetEditTextLength();
+FWL_ERR IFWL_ComboBox::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetEditText(wsText, nStart, nCount);
}
-FWL_ERR IFWL_ComboBox::GetEditText(CFX_WideString &wsText, int32_t nStart, int32_t nCount) const
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetEditText(wsText, nStart, nCount);
-}
-FWL_ERR IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->SetEditSelRange(nStart, nCount);
-}
-int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t &nStart)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetEditSelRange(nIndex, nStart);
-}
-int32_t IFWL_ComboBox::GetEditLimit()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetEditLimit();
-}
-FWL_ERR IFWL_ComboBox::SetEditLimit(int32_t nLimit)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->SetEditLimit(nLimit);
-}
-FWL_ERR IFWL_ComboBox::EditDoClipboard(int32_t iCmd)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditDoClipboard(iCmd);
-}
-FX_BOOL IFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditRedo(bsRecord);
-}
-FX_BOOL IFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditUndo(bsRecord);
-}
-IFWL_ListBox* IFWL_ComboBox::GetListBoxt()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetListBoxt();
-}
-FX_BOOL IFWL_ComboBox::AfterFocusShowDropList()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->AfterFocusShowDropList();
-}
-FX_ERR IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->OpenDropDownList(bActivate);
-}
-FX_BOOL IFWL_ComboBox::EditCanUndo()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCanUndo();
-}
-FX_BOOL IFWL_ComboBox::EditCanRedo()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCanRedo();
-}
-FX_BOOL IFWL_ComboBox::EditUndo()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditUndo();
-}
-FX_BOOL IFWL_ComboBox::EditRedo()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditRedo();
-}
-FX_BOOL IFWL_ComboBox::EditCanCopy()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCanCopy();
-}
-FX_BOOL IFWL_ComboBox::EditCanCut()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCanCut();
-}
-FX_BOOL IFWL_ComboBox::EditCanSelectAll()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCanSelectAll();
-}
-FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString &wsCopy)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCopy(wsCopy);
-}
-FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString &wsCut)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditCut(wsCut);
-}
-FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString &wsPaste)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditPaste(wsPaste);
+FWL_ERR IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
+ return ((CFWL_ComboBoxImp*)m_pData)->SetEditSelRange(nStart, nCount);
}
-FX_BOOL IFWL_ComboBox::EditSelectAll()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditSelectAll();
+int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetEditSelRange(nIndex, nStart);
}
-FX_BOOL IFWL_ComboBox::EditDelete()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditDelete();
+int32_t IFWL_ComboBox::GetEditLimit() {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetEditLimit();
}
-FX_BOOL IFWL_ComboBox::EditDeSelect()
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditDeSelect();
+FWL_ERR IFWL_ComboBox::SetEditLimit(int32_t nLimit) {
+ return ((CFWL_ComboBoxImp*)m_pData)->SetEditLimit(nLimit);
}
-FWL_ERR IFWL_ComboBox::GetBBox(CFX_RectF &rect)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->GetBBox(rect);
+FWL_ERR IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditDoClipboard(iCmd);
}
-FWL_ERR IFWL_ComboBox::EditModifyStylesEx(FX_DWORD dwStylesExAdded,
- FX_DWORD dwStylesExRemoved)
-{
- return ((CFWL_ComboBoxImp*)m_pData)->EditModifyStylesEx(dwStylesExAdded,
- dwStylesExRemoved);
-}
-CFWL_ComboEdit::CFWL_ComboEdit(IFWL_Widget *pOuter)
- : CFWL_EditImp(pOuter)
-{
- FXSYS_assert(pOuter != NULL);
- m_pOuter = (CFWL_ComboBoxImp*)(((IFWL_TargetData*)pOuter)->GetData());
+FX_BOOL IFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditRedo(bsRecord);
}
-CFWL_ComboEdit::CFWL_ComboEdit(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_EditImp(properties, pOuter)
-{
- FXSYS_assert(pOuter != NULL);
- m_pOuter = (CFWL_ComboBoxImp*)(((IFWL_TargetData*)pOuter)->GetData());
+FX_BOOL IFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditUndo(bsRecord);
}
-
-CFWL_ComboEditDelegate::CFWL_ComboEditDelegate(CFWL_ComboEdit *pOwner)
- : CFWL_EditImpDelegate(pOwner)
- , m_pOwner(pOwner)
-{
-}
-int32_t CFWL_ComboEditDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- FX_BOOL backDefault = TRUE;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- if (dwMsgCode == FWL_MSGHASH_SetFocus) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- backDefault = FALSE;
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) &&
- ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
- m_pOwner->SetSelected();
- m_pOwner->SetComboBoxFocus(TRUE);
- }
- break;
- }
- default: {
- }
- }
- if (!backDefault) {
- return 1;
- }
- return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+IFWL_ListBox* IFWL_ComboBox::GetListBoxt() {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetListBoxt();
}
-void CFWL_ComboEdit::ClearSelected()
-{
- ClearSelections();
- Repaint(&m_rtClient);
+FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() {
+ return ((CFWL_ComboBoxImp*)m_pData)->AfterFocusShowDropList();
}
-void CFWL_ComboEdit::SetSelected()
-{
- FlagFocus(TRUE);
- EndCaret();
- AddSelRange(0);
+FX_ERR IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
+ return ((CFWL_ComboBoxImp*)m_pData)->OpenDropDownList(bActivate);
}
-void CFWL_ComboEdit::EndCaret()
-{
- m_pEdtEngine->MoveCaretPos(MC_End);
+FX_BOOL IFWL_ComboBox::EditCanUndo() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCanUndo();
}
-void CFWL_ComboEdit::FlagFocus(FX_BOOL bSet)
-{
- if (bSet) {
- m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- ShowCaret(FALSE);
- }
-};
-void CFWL_ComboEdit::SetComboBoxFocus(FX_BOOL bSet)
-{
- m_pOuter->SetFocus(bSet);
-}
-CFWL_ComboList::CFWL_ComboList(IFWL_Widget *pOuter)
- : CFWL_ListBoxImp(pOuter)
- , m_bNotifyOwner(TRUE)
-{
- FXSYS_assert(pOuter != NULL);
-}
-CFWL_ComboList::CFWL_ComboList(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_ListBoxImp(properties, pOuter)
- , m_bNotifyOwner(TRUE)
-{
- FXSYS_assert(pOuter != NULL);
-}
-FWL_ERR CFWL_ComboList::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ListBoxImp::Initialize(), FWL_ERR_Indefinite);
- if (m_pDelegate) {
- delete (CFWL_ComboListDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ComboListDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboList::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_ComboListDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_ListBoxImp::Finalize();
+FX_BOOL IFWL_ComboBox::EditCanRedo() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCanRedo();
}
-int32_t CFWL_ComboList::MatchItem(const CFX_WideString &wsMatch)
-{
- if (wsMatch.IsEmpty()) {
- return -1;
- }
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, -1);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- CFX_WideString wsText;
- pData->GetItemText(m_pInterface, hItem, wsText);
- FX_STRSIZE pos = wsText.Find((const FX_WCHAR*)wsMatch);
- if (!pos) {
- return i;
- }
- }
- return -1;
+FX_BOOL IFWL_ComboBox::EditUndo() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditUndo();
}
-void CFWL_ComboList::ChangeSelected(int32_t iSel)
-{
- _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel);
- CFX_RectF rtInvalidate;
- rtInvalidate.Reset();
- FWL_HLISTITEM hOld = GetSelItem(0);
- int32_t iOld = pData->GetItemIndex(m_pInterface, hOld);
- if (iOld == iSel) {
- return;
- } else if (iOld > -1) {
- GetItemRect(iOld, rtInvalidate);
- SetSelItem(hOld, FALSE);
- }
- if (hItem) {
- CFX_RectF rect;
- GetItemRect(iSel, rect);
- rtInvalidate.Union(rect);
- FWL_HLISTITEM hSel = pData->GetItem(m_pInterface, iSel);
- SetSelItem(hSel, TRUE);
- }
- if (!rtInvalidate.IsEmpty()) {
- Repaint(&rtInvalidate);
- }
+FX_BOOL IFWL_ComboBox::EditRedo() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditRedo();
}
-int32_t CFWL_ComboList::CountItems()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, 0);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- return pData->CountItems(m_pInterface);
-}
-void CFWL_ComboList::GetItemRect(int32_t nIndex, CFX_RectF &rtItem)
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, nIndex);
- pData->GetItemRect(m_pInterface, hItem, rtItem);
-}
-void CFWL_ComboList::ClientToOuter(FX_FLOAT &fx, FX_FLOAT &fy)
-{
- fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top;
- IFWL_Widget *pOwner = GetOwner();
- _FWL_RETURN_IF_FAIL(pOwner);
- pOwner->TransformTo(m_pOuter, fx, fy);
-}
-void CFWL_ComboList::SetFocus(FX_BOOL bSet)
-{
- CFWL_WidgetImp::SetFocus(bSet);
-}
-CFWL_ComboListDelegate::CFWL_ComboListDelegate(CFWL_ComboList *pOwner)
- : CFWL_ListBoxImpDelegate(pOwner)
- , m_pOwner(pOwner)
-{
-}
-int32_t CFWL_ComboListDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwHashCode = pMessage->GetClassID();
- FX_BOOL backDefault = TRUE;
- if (dwHashCode == FWL_MSGHASH_SetFocus || dwHashCode == FWL_MSGHASH_KillFocus) {
- OnDropListFocusChanged(pMessage, dwHashCode == FWL_MSGHASH_SetFocus);
- } else if (dwHashCode == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
- CFX_RectF rect;
- m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
- pMsg->m_fx -= rect.left;
- pMsg->m_fy -= rect.top;
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pVertScrollBar->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMsg);
- }
- }
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_MouseMove: {
- backDefault = FALSE;
- OnDropListMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonDown: {
- backDefault = FALSE;
- OnDropListLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- backDefault = FALSE;
- OnDropListLButtonUp(pMsg);
- break;
- }
- default: {
- }
- }
- } else if (dwHashCode == FWL_MSGHASH_Key) {
- CFWL_MsgKey *pMsg = (CFWL_MsgKey*)pMessage;
- backDefault = !OnDropListKey(pMsg);
- }
- if (!backDefault) {
- return 1;
- }
- return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage);
-}
-void CFWL_ComboListDelegate::OnDropListFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet )
-{
- if (!bSet) {
- CFWL_MsgKillFocus *pKill = (CFWL_MsgKillFocus*)pMsg;
- CFWL_ComboBoxImp *pOuter = (CFWL_ComboBoxImp*)(((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData());
- if (pKill->m_pSetFocus == (IFWL_Widget*)m_pOwner->m_pOuter || (IFWL_Widget*)pKill->m_pSetFocus == (IFWL_Widget*)pOuter->m_pEdit) {
- pOuter->ShowDropList(FALSE);
- }
- }
+FX_BOOL IFWL_ComboBox::EditCanCopy() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCanCopy();
}
-int32_t CFWL_ComboListDelegate::OnDropListMouseMove(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->m_bNotifyOwner) {
- m_pOwner->m_bNotifyOwner = FALSE;
- }
- if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
- CFX_RectF rect;
- m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return 1;
- }
- }
- FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (hItem) {
- _FWL_RETURN_VALUE_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider, 0);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pOwner->m_pProperties->m_pDataProvider;
- int32_t iSel = pData->GetItemIndex(m_pOwner->m_pInterface, hItem);
- CFWL_EvtCmbHoverChanged event;
- event.m_pSrcTarget = m_pOwner->m_pOuter;
- event.m_iCurHover = iSel;
- m_pOwner->DispatchEvent(&event);
- m_pOwner->ChangeSelected(iSel);
- }
- } else if (m_pOwner->m_bNotifyOwner) {
- m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
- CFWL_ComboBoxImp *pOuter = (CFWL_ComboBoxImp*)(((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData());
- pOuter->m_pDelegate->OnProcessMessage(pMsg);
- }
- return 1;
+FX_BOOL IFWL_ComboBox::EditCanCut() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCanCut();
}
-int32_t CFWL_ComboListDelegate::OnDropListLButtonDown(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return 0;
- }
- CFWL_ComboBoxImp *pOuter = (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
- pOuter->ShowDropList(FALSE);
- return 1;
+FX_BOOL IFWL_ComboBox::EditCanSelectAll() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCanSelectAll();
}
-int32_t CFWL_ComboListDelegate::OnDropListLButtonUp(CFWL_MsgMouse *pMsg)
-{
- CFWL_ComboBoxImp *pOuter = (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
- if (m_pOwner->m_bNotifyOwner) {
- m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
- pOuter->m_pDelegate->OnProcessMessage(pMsg);
- } else {
- if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
- CFX_RectF rect;
- m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return 1;
- }
- }
- pOuter->ShowDropList(FALSE);
- FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (hItem) {
- pOuter->ProcessSelChanged(TRUE);
- }
- }
- return 1;
+FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCopy(wsCopy);
}
-int32_t CFWL_ComboListDelegate::OnDropListKey(CFWL_MsgKey *pKey)
-{
- CFWL_ComboBoxImp *pOuter = (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
- FX_BOOL bPropagate = FALSE;
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
- FX_DWORD dwKeyCode = pKey->m_dwKeyCode;
- switch (dwKeyCode) {
- case FWL_VKEY_Return:
- case FWL_VKEY_Escape: {
- pOuter->ShowDropList(FALSE);
- return 1;
- }
- case FWL_VKEY_Up:
- case FWL_VKEY_Down: {
- OnDropListKeyDown(pKey);
- IFWL_WidgetDelegate *pDelegate = pOuter->SetDelegate(NULL);
- pOuter->ProcessSelChanged(FALSE);
- return 1;
- }
- default: {
- bPropagate = TRUE;
- }
- }
- } else if (pKey->m_dwCmd == FWL_MSGKEYCMD_Char) {
- bPropagate = TRUE;
- }
- if (bPropagate) {
- pKey->m_pDstTarget = (IFWL_Widget*)m_pOwner->m_pOuter;
- pOuter->m_pDelegate->OnProcessMessage(pKey);
- return 1;
- }
- return 0;
+FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditCut(wsCut);
}
-void CFWL_ComboListDelegate::OnDropListKeyDown(CFWL_MsgKey *pKey)
-{
- FX_DWORD dwKeyCode = pKey->m_dwKeyCode;
- switch(dwKeyCode) {
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Home:
- case FWL_VKEY_End: {
- CFWL_ComboBoxImp *pOuter = (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pOwner->m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pOwner->m_pInterface, pOuter->m_iCurSel);
- hItem = m_pOwner->GetItem(hItem, dwKeyCode);
- if (!hItem) {
- break;
- }
- m_pOwner->SetSelection(hItem, hItem, TRUE);
- m_pOwner->ScrollToVisible(hItem);
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0,
- 0,
- m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
- m_pOwner->Repaint(&rtInvalidate);
- break;
- }
- default: {
- }
- }
+FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditPaste(wsPaste);
}
-CFWL_ComboBoxImp::CFWL_ComboBoxImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_pEdit(NULL)
- , m_pListBox(NULL)
- , m_pForm(NULL)
- , m_bLButtonDown(FALSE)
- , m_iCurSel(-1)
- , m_iBtnState(FWL_PARTSTATE_CMB_Normal)
- , m_fComboFormHandler(0)
- , m_bNeedShowList(FALSE)
-{
- m_rtClient.Reset();
- m_rtBtn.Reset();
- m_rtHandler.Reset();
-}
-CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_pEdit(NULL)
- , m_pListBox(NULL)
- , m_pForm(NULL)
- , m_bLButtonDown(FALSE)
- , m_iCurSel(-1)
- , m_iBtnState(FWL_PARTSTATE_CMB_Normal)
- , m_fComboFormHandler(0)
- , m_bNeedShowList(FALSE)
-{
- m_rtClient.Reset();
- m_rtBtn.Reset();
- m_rtHandler.Reset();
-}
-CFWL_ComboBoxImp::~CFWL_ComboBoxImp()
-{
- if (m_pEdit) {
- m_pEdit->Release();
- m_pEdit = NULL;
- }
- if (m_pListBox) {
- m_pListBox->Release();
- m_pListBox = NULL;
- }
+FX_BOOL IFWL_ComboBox::EditSelectAll() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditSelectAll();
}
-FWL_ERR CFWL_ComboBoxImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_ComboBox;
- return FWL_ERR_Succeeded;
+FX_BOOL IFWL_ComboBox::EditDelete() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditDelete();
}
-FX_DWORD CFWL_ComboBoxImp::GetClassID() const
-{
- return FWL_CLASSHASH_ComboBox;
+FX_BOOL IFWL_ComboBox::EditDeSelect() {
+ return ((CFWL_ComboBoxImp*)m_pData)->EditDeSelect();
}
-FWL_ERR CFWL_ComboBoxImp::Initialize()
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_Initialize();
- }
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_WGTSTATE_Invisible);
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ComboBoxImpDelegate(this);
- CFWL_WidgetImpProperties prop;
- prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) {
- prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
- }
- prop.m_pDataProvider = m_pProperties->m_pDataProvider;
- CFWL_ComboList *pList = FX_NEW CFWL_ComboList(prop, m_pInterface);
- m_pListBox = IFWL_ListBox::Create();
- pList->SetInterface(m_pListBox);
- ((IFWL_TargetData*)m_pListBox)->SetData(pList);
- pList->Initialize();
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
- CFWL_ComboEdit *pEdit = FX_NEW CFWL_ComboEdit(m_pInterface);
- m_pEdit = IFWL_Edit::Create();
- pEdit->SetInterface(m_pEdit);
- ((IFWL_TargetData*)m_pEdit)->SetData(pEdit);
- pEdit->Initialize();
- pEdit->SetOuter(m_pInterface);
- }
- if (m_pEdit) {
- m_pEdit->SetParent(m_pInterface);
- }
- SetStates(m_pProperties->m_dwStates);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
+ return ((CFWL_ComboBoxImp*)m_pData)->GetBBox(rect);
}
-FWL_ERR CFWL_ComboBoxImp::Finalize()
-{
- if (m_pEdit) {
- m_pEdit->Finalize();
- }
- m_pListBox->Finalize();
- if ( m_pDelegate) {
- delete (CFWL_ComboBoxImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Reset();
- FX_BOOL bIsDropDown = IsDropDownStyle();
- if (bIsDropDown && m_pEdit) {
- m_pEdit->GetWidgetRect(rect, TRUE);
- } else {
- rect.width = 100;
- rect.height = 16;
- }
- if (!m_pProperties->m_pThemeProvider) {
- ReSetTheme();
- }
- FX_FLOAT *pFWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_VALUE_IF_FAIL(pFWidth, FWL_ERR_Indefinite);
- rect.Inflate(0, 0, *pFWidth, 0);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_ComboBox::EditModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ return ((CFWL_ComboBoxImp*)m_pData)
+ ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
-FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
- }
- FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown;
- FX_BOOL bRemoveDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown;
- if (bAddDropDown && !m_pEdit) {
- CFWL_ComboEdit *pEdit = FX_NEW CFWL_ComboEdit(m_pInterface);
- m_pEdit = IFWL_Edit::Create();
- pEdit->SetInterface(m_pEdit);
- ((IFWL_TargetData*)m_pEdit)->SetData(pEdit);
- pEdit->Initialize();
- pEdit->SetOuter(m_pInterface);
- m_pEdit->SetParent(m_pInterface);
- } else if (bRemoveDropDown && m_pEdit) {
- m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
- return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+CFWL_ComboEdit::CFWL_ComboEdit(IFWL_Widget* pOuter) : CFWL_EditImp(pOuter) {
+ FXSYS_assert(pOuter != NULL);
+ m_pOuter = (CFWL_ComboBoxImp*)(((IFWL_TargetData*)pOuter)->GetData());
}
-FWL_ERR CFWL_ComboBoxImp::Update()
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_Update();
- }
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- ReSetTheme();
- FX_BOOL bDropDown = IsDropDownStyle();
- if (bDropDown && m_pEdit) {
- ReSetEditAlignment();
- }
- if (m_pProperties->m_pThemeProvider == NULL) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- Layout();
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- m_fComboFormHandler = *(FX_FLOAT *) m_pProperties->m_pThemeProvider->GetCapacity(&part, FWL_WGTCAPACITY_CMB_ComboFormHandler);
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ComboBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_HitTest(fx, fy);
- }
- return CFWL_WidgetImp::HitTest(fx, fy);
+CFWL_ComboEdit::CFWL_ComboEdit(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_EditImp(properties, pOuter) {
+ FXSYS_assert(pOuter != NULL);
+ m_pOuter = (CFWL_ComboBoxImp*)(((IFWL_TargetData*)pOuter)->GetData());
}
-FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_DrawWidget(pGraphics, pMatrix);
- }
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- FX_BOOL bIsDropDown = IsDropDownStyle();
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_CMB_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_CMB_Edge, pTheme, pMatrix);
- }
- if (!bIsDropDown) {
- CFX_RectF rtTextBk(m_rtClient);
- rtTextBk.width -= m_rtBtn.width;
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_Background;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- param.m_rtPart = rtTextBk;
- if (m_iCurSel >= 0) {
- IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->m_pProperties->m_pDataProvider;
- void* p = pData->GetItemData(m_pListBox, pData->GetItem(m_pListBox, m_iCurSel));
- if (p != NULL) {
- param.m_pData = p;
- }
- }
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- param.m_dwStates = FWL_PARTSTATE_CMB_Disabled;
- } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && (m_iCurSel >= 0)) {
- param.m_dwStates = FWL_PARTSTATE_CMB_Selected;
- } else {
- param.m_dwStates = FWL_PARTSTATE_CMB_Normal;
- }
- pTheme->DrawBackground(¶m);
- if (m_iCurSel >= 0) {
- _FWL_RETURN_VALUE_IF_FAIL(m_pListBox, FWL_ERR_Indefinite);
- CFX_WideString wsText;
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->GetItemText(hItem, wsText);
- CFWL_ThemeText param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_Caption;
- param.m_dwStates = m_iBtnState;
- param.m_pGraphics = pGraphics;
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = rtTextBk;
- param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) ? FWL_PARTSTATE_CMB_Selected : FWL_PARTSTATE_CMB_Normal;
- param.m_wsText = wsText;
- param.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- param.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
- pTheme->DrawText(¶m);
- }
- }
- {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_DropDownButton;
- param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ? FWL_PARTSTATE_CMB_Disabled : m_iBtnState;
- param.m_pGraphics = pGraphics;
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = m_rtBtn;
- pTheme->DrawBackground(¶m);
+
+CFWL_ComboEditDelegate::CFWL_ComboEditDelegate(CFWL_ComboEdit* pOwner)
+ : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
+int32_t CFWL_ComboEditDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ FX_BOOL backDefault = TRUE;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ if (dwMsgCode == FWL_MSGHASH_SetFocus) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ }
+ backDefault = FALSE;
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) &&
+ ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
+ m_pOwner->SetSelected();
+ m_pOwner->SetComboBoxFocus(TRUE);
+ }
+ break;
+ }
+ default: {}
+ }
+ if (!backDefault) {
+ return 1;
+ }
+ return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+}
+void CFWL_ComboEdit::ClearSelected() {
+ ClearSelections();
+ Repaint(&m_rtClient);
+}
+void CFWL_ComboEdit::SetSelected() {
+ FlagFocus(TRUE);
+ EndCaret();
+ AddSelRange(0);
+}
+void CFWL_ComboEdit::EndCaret() {
+ m_pEdtEngine->MoveCaretPos(MC_End);
+}
+void CFWL_ComboEdit::FlagFocus(FX_BOOL bSet) {
+ if (bSet) {
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ } else {
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ ShowCaret(FALSE);
+ }
+};
+void CFWL_ComboEdit::SetComboBoxFocus(FX_BOOL bSet) {
+ m_pOuter->SetFocus(bSet);
+}
+CFWL_ComboList::CFWL_ComboList(IFWL_Widget* pOuter)
+ : CFWL_ListBoxImp(pOuter), m_bNotifyOwner(TRUE) {
+ FXSYS_assert(pOuter != NULL);
+}
+CFWL_ComboList::CFWL_ComboList(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) {
+ FXSYS_assert(pOuter != NULL);
+}
+FWL_ERR CFWL_ComboList::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ListBoxImp::Initialize(),
+ FWL_ERR_Indefinite);
+ if (m_pDelegate) {
+ delete (CFWL_ComboListDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ComboListDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboList::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_ComboListDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_ListBoxImp::Finalize();
+}
+int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) {
+ if (wsMatch.IsEmpty()) {
+ return -1;
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, -1);
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ CFX_WideString wsText;
+ pData->GetItemText(m_pInterface, hItem, wsText);
+ FX_STRSIZE pos = wsText.Find((const FX_WCHAR*)wsMatch);
+ if (!pos) {
+ return i;
+ }
+ }
+ return -1;
+}
+void CFWL_ComboList::ChangeSelected(int32_t iSel) {
+ _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel);
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Reset();
+ FWL_HLISTITEM hOld = GetSelItem(0);
+ int32_t iOld = pData->GetItemIndex(m_pInterface, hOld);
+ if (iOld == iSel) {
+ return;
+ } else if (iOld > -1) {
+ GetItemRect(iOld, rtInvalidate);
+ SetSelItem(hOld, FALSE);
+ }
+ if (hItem) {
+ CFX_RectF rect;
+ GetItemRect(iSel, rect);
+ rtInvalidate.Union(rect);
+ FWL_HLISTITEM hSel = pData->GetItem(m_pInterface, iSel);
+ SetSelItem(hSel, TRUE);
+ }
+ if (!rtInvalidate.IsEmpty()) {
+ Repaint(&rtInvalidate);
+ }
+}
+int32_t CFWL_ComboList::CountItems() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, 0);
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ return pData->CountItems(m_pInterface);
+}
+void CFWL_ComboList::GetItemRect(int32_t nIndex, CFX_RectF& rtItem) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, nIndex);
+ pData->GetItemRect(m_pInterface, hItem, rtItem);
+}
+void CFWL_ComboList::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
+ fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top;
+ IFWL_Widget* pOwner = GetOwner();
+ _FWL_RETURN_IF_FAIL(pOwner);
+ pOwner->TransformTo(m_pOuter, fx, fy);
+}
+void CFWL_ComboList::SetFocus(FX_BOOL bSet) {
+ CFWL_WidgetImp::SetFocus(bSet);
+}
+CFWL_ComboListDelegate::CFWL_ComboListDelegate(CFWL_ComboList* pOwner)
+ : CFWL_ListBoxImpDelegate(pOwner), m_pOwner(pOwner) {}
+int32_t CFWL_ComboListDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwHashCode = pMessage->GetClassID();
+ FX_BOOL backDefault = TRUE;
+ if (dwHashCode == FWL_MSGHASH_SetFocus ||
+ dwHashCode == FWL_MSGHASH_KillFocus) {
+ OnDropListFocusChanged(pMessage, dwHashCode == FWL_MSGHASH_SetFocus);
+ } else if (dwHashCode == FWL_MSGHASH_Mouse) {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
+ CFX_RectF rect;
+ m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ pMsg->m_fx -= rect.left;
+ pMsg->m_fy -= rect.top;
+ IFWL_WidgetDelegate* pDelegate =
+ m_pOwner->m_pVertScrollBar->SetDelegate(NULL);
+ return pDelegate->OnProcessMessage(pMsg);
+ }
+ }
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_MouseMove: {
+ backDefault = FALSE;
+ OnDropListMouseMove(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ backDefault = FALSE;
+ OnDropListLButtonDown(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ backDefault = FALSE;
+ OnDropListLButtonUp(pMsg);
+ break;
+ }
+ default: {}
+ }
+ } else if (dwHashCode == FWL_MSGHASH_Key) {
+ CFWL_MsgKey* pMsg = (CFWL_MsgKey*)pMessage;
+ backDefault = !OnDropListKey(pMsg);
+ }
+ if (!backDefault) {
+ return 1;
+ }
+ return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage);
+}
+void CFWL_ComboListDelegate::OnDropListFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ if (!bSet) {
+ CFWL_MsgKillFocus* pKill = (CFWL_MsgKillFocus*)pMsg;
+ CFWL_ComboBoxImp* pOuter =
+ (CFWL_ComboBoxImp*)(((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData());
+ if (pKill->m_pSetFocus == (IFWL_Widget*)m_pOwner->m_pOuter ||
+ (IFWL_Widget*)pKill->m_pSetFocus == (IFWL_Widget*)pOuter->m_pEdit) {
+ pOuter->ShowDropList(FALSE);
+ }
+ }
+}
+int32_t CFWL_ComboListDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_pOwner->m_bNotifyOwner) {
+ m_pOwner->m_bNotifyOwner = FALSE;
}
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider *pThemeProvider)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pThemeProvider, FWL_ERR_Indefinite);
- m_pProperties->m_pThemeProvider = pThemeProvider;
- if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox)) {
- m_pListBox->SetThemeProvider(pThemeProvider);
+ if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
+ CFX_RectF rect;
+ m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return 1;
+ }
}
- if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit)) {
- m_pEdit->SetThemeProvider(pThemeProvider);
+ FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider, 0);
+ IFWL_ListBoxDP* pData =
+ (IFWL_ListBoxDP*)m_pOwner->m_pProperties->m_pDataProvider;
+ int32_t iSel = pData->GetItemIndex(m_pOwner->m_pInterface, hItem);
+ CFWL_EvtCmbHoverChanged event;
+ event.m_pSrcTarget = m_pOwner->m_pOuter;
+ event.m_iCurHover = iSel;
+ m_pOwner->DispatchEvent(&event);
+ m_pOwner->ChangeSelected(iSel);
+ }
+ } else if (m_pOwner->m_bNotifyOwner) {
+ m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ CFWL_ComboBoxImp* pOuter =
+ (CFWL_ComboBoxImp*)(((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData());
+ pOuter->m_pDelegate->OnProcessMessage(pMsg);
+ }
+ return 1;
+}
+int32_t CFWL_ComboListDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return 0;
+ }
+ CFWL_ComboBoxImp* pOuter =
+ (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
+ pOuter->ShowDropList(FALSE);
+ return 1;
+}
+int32_t CFWL_ComboListDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
+ CFWL_ComboBoxImp* pOuter =
+ (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
+ if (m_pOwner->m_bNotifyOwner) {
+ m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ pOuter->m_pDelegate->OnProcessMessage(pMsg);
+ } else {
+ if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
+ CFX_RectF rect;
+ m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return 1;
+ }
}
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ComboBoxImp::GetCurSel()
-{
- return m_iCurSel;
-}
-FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel)
-{
- int32_t iCount = ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->CountItems();
- FX_BOOL bClearSel = iSel < 0 || iSel >= iCount;
- FX_BOOL bDropDown = IsDropDownStyle();
- if (bDropDown && m_pEdit) {
- if (bClearSel) {
- m_pEdit->SetText(CFX_WideString());
- } else {
- CFX_WideString wsText;
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel);
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->GetItemText(hItem, wsText);
- m_pEdit->SetText(wsText);
- }
- m_pEdit->Update();
+ pOuter->ShowDropList(FALSE);
+ FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (hItem) {
+ pOuter->ProcessSelChanged(TRUE);
}
- m_iCurSel = bClearSel ? -1 : iSel;
- return FWL_ERR_Succeeded;
+ }
+ return 1;
}
-FWL_ERR CFWL_ComboBoxImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
+int32_t CFWL_ComboListDelegate::OnDropListKey(CFWL_MsgKey* pKey) {
+ CFWL_ComboBoxImp* pOuter =
+ (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
+ FX_BOOL bPropagate = FALSE;
+ if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ FX_DWORD dwKeyCode = pKey->m_dwKeyCode;
+ switch (dwKeyCode) {
+ case FWL_VKEY_Return:
+ case FWL_VKEY_Escape: {
+ pOuter->ShowDropList(FALSE);
+ return 1;
+ }
+ case FWL_VKEY_Up:
+ case FWL_VKEY_Down: {
+ OnDropListKeyDown(pKey);
+ IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL);
+ pOuter->ProcessSelChanged(FALSE);
+ return 1;
+ }
+ default: { bPropagate = TRUE; }
+ }
+ } else if (pKey->m_dwCmd == FWL_MSGKEYCMD_Char) {
+ bPropagate = TRUE;
+ }
+ if (bPropagate) {
+ pKey->m_pDstTarget = (IFWL_Widget*)m_pOwner->m_pOuter;
+ pOuter->m_pDelegate->OnProcessMessage(pKey);
+ return 1;
+ }
+ return 0;
+}
+void CFWL_ComboListDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) {
+ FX_DWORD dwKeyCode = pKey->m_dwKeyCode;
+ switch (dwKeyCode) {
+ case FWL_VKEY_Up:
+ case FWL_VKEY_Down:
+ case FWL_VKEY_Home:
+ case FWL_VKEY_End: {
+ CFWL_ComboBoxImp* pOuter =
+ (CFWL_ComboBoxImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
+ IFWL_ListBoxDP* pData =
+ (IFWL_ListBoxDP*)m_pOwner->m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem =
+ pData->GetItem(m_pOwner->m_pInterface, pOuter->m_iCurSel);
+ hItem = m_pOwner->GetItem(hItem, dwKeyCode);
+ if (!hItem) {
+ break;
+ }
+ m_pOwner->SetSelection(hItem, hItem, TRUE);
+ m_pOwner->ScrollToVisible(hItem);
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
+ m_pOwner->m_pProperties->m_rtWidget.height);
+ m_pOwner->Repaint(&rtInvalidate);
+ break;
+ }
+ default: {}
+ }
+}
+CFWL_ComboBoxImp::CFWL_ComboBoxImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_pEdit(NULL),
+ m_pListBox(NULL),
+ m_pForm(NULL),
+ m_bLButtonDown(FALSE),
+ m_iCurSel(-1),
+ m_iBtnState(FWL_PARTSTATE_CMB_Normal),
+ m_fComboFormHandler(0),
+ m_bNeedShowList(FALSE) {
+ m_rtClient.Reset();
+ m_rtBtn.Reset();
+ m_rtHandler.Reset();
+}
+CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_pEdit(NULL),
+ m_pListBox(NULL),
+ m_pForm(NULL),
+ m_bLButtonDown(FALSE),
+ m_iCurSel(-1),
+ m_iBtnState(FWL_PARTSTATE_CMB_Normal),
+ m_fComboFormHandler(0),
+ m_bNeedShowList(FALSE) {
+ m_rtClient.Reset();
+ m_rtBtn.Reset();
+ m_rtHandler.Reset();
+}
+CFWL_ComboBoxImp::~CFWL_ComboBoxImp() {
+ if (m_pEdit) {
+ m_pEdit->Release();
+ m_pEdit = NULL;
+ }
+ if (m_pListBox) {
+ m_pListBox->Release();
+ m_pListBox = NULL;
+ }
+}
+FWL_ERR CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_ComboBox;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ComboBoxImp::GetClassID() const {
+ return FWL_CLASSHASH_ComboBox;
+}
+FWL_ERR CFWL_ComboBoxImp::Initialize() {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_Initialize();
+ }
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_WGTSTATE_Invisible);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ComboBoxImpDelegate(this);
+ CFWL_WidgetImpProperties prop;
+ prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) {
+ prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
+ }
+ prop.m_pDataProvider = m_pProperties->m_pDataProvider;
+ CFWL_ComboList* pList = FX_NEW CFWL_ComboList(prop, m_pInterface);
+ m_pListBox = IFWL_ListBox::Create();
+ pList->SetInterface(m_pListBox);
+ ((IFWL_TargetData*)m_pListBox)->SetData(pList);
+ pList->Initialize();
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
+ CFWL_ComboEdit* pEdit = FX_NEW CFWL_ComboEdit(m_pInterface);
+ m_pEdit = IFWL_Edit::Create();
+ pEdit->SetInterface(m_pEdit);
+ ((IFWL_TargetData*)m_pEdit)->SetData(pEdit);
+ pEdit->Initialize();
+ pEdit->SetOuter(m_pInterface);
+ }
+ if (m_pEdit) {
+ m_pEdit->SetParent(m_pInterface);
+ }
+ SetStates(m_pProperties->m_dwStates);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImp::Finalize() {
+ if (m_pEdit) {
+ m_pEdit->Finalize();
+ }
+ m_pListBox->Finalize();
+ if (m_pDelegate) {
+ delete (CFWL_ComboBoxImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Reset();
FX_BOOL bIsDropDown = IsDropDownStyle();
if (bIsDropDown && m_pEdit) {
- m_pEdit->SetStates(dwStates, bSet);
- }
- if (m_pListBox) {
- m_pListBox->SetStates(dwStates, bSet);
- }
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
-}
-FWL_ERR CFWL_ComboBoxImp::SetEditText(const CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
- m_pEdit->SetText(wsText);
- return m_pEdit->Update();
-}
-int32_t CFWL_ComboBoxImp::GetEditTextLength() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, -1);
- return m_pEdit->GetTextLength();
-}
-FWL_ERR CFWL_ComboBoxImp::GetEditText(CFX_WideString &wsText, int32_t nStart , int32_t nCount ) const
-{
- if (m_pEdit) {
- return m_pEdit->GetText(wsText, nStart, nCount);
- } else if (m_pListBox) {
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
- return m_pListBox->GetItemText(hItem, wsText);
- }
- return FWL_ERR_Indefinite;
-}
-FWL_ERR CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
- ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())->ClearSelected();
- m_pEdit->AddSelRange(nStart, nCount);
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ComboBoxImp::GetEditSelRange(int32_t nIndex, int32_t &nStart)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, -1);
- return m_pEdit->GetSelRange(nIndex, nStart);
-}
-int32_t CFWL_ComboBoxImp::GetEditLimit()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, -1);
- return m_pEdit->GetLimit();
-}
-FWL_ERR CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
- return m_pEdit->SetLimit(nLimit);
-}
-FWL_ERR CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
- return m_pEdit->DoClipboard(iCmd);
-}
-FX_BOOL CFWL_ComboBoxImp::EditRedo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FALSE);
- return m_pEdit->Redo(bsRecord);
-}
-FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FALSE);
- return m_pEdit->Undo(bsRecord);
-}
-IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pListBox, FALSE);
- return m_pListBox;
-}
-FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList()
-{
- if (!m_bNeedShowList) {
- return FALSE;
- }
- if (m_pEdit) {
- MatchEditText();
- }
- ShowDropList(TRUE);
- m_bNeedShowList = FALSE;
- return TRUE;
-}
-FX_ERR CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate)
-{
- ShowDropList(bActivate);
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_ComboBoxImp::EditCanUndo()
-{
- return m_pEdit->CanUndo();
-}
-FX_BOOL CFWL_ComboBoxImp::EditCanRedo()
-{
- return m_pEdit->CanRedo();
-}
-FX_BOOL CFWL_ComboBoxImp::EditUndo()
-{
- return m_pEdit->Undo();
-}
-FX_BOOL CFWL_ComboBoxImp::EditRedo()
-{
- return m_pEdit->Redo();
-}
-FX_BOOL CFWL_ComboBoxImp::EditCanCopy()
-{
- return m_pEdit->CountSelRanges() > 0;
-}
-FX_BOOL CFWL_ComboBoxImp::EditCanCut()
-{
- if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
- return FALSE;
- }
- return m_pEdit->CountSelRanges() > 0;
-}
-FX_BOOL CFWL_ComboBoxImp::EditCanSelectAll()
-{
- return m_pEdit->GetTextLength() > 0;
-}
-FX_BOOL CFWL_ComboBoxImp::EditCopy(CFX_WideString &wsCopy)
-{
- return m_pEdit->Copy(wsCopy);
-}
-FX_BOOL CFWL_ComboBoxImp::EditCut(CFX_WideString &wsCut)
-{
- return m_pEdit->Cut(wsCut);
-}
-FX_BOOL CFWL_ComboBoxImp::EditPaste(const CFX_WideString &wsPaste)
-{
- return m_pEdit->Paste(wsPaste);
-}
-FX_BOOL CFWL_ComboBoxImp::EditSelectAll()
-{
- return (m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded) ? TRUE : FALSE;
-}
-FX_BOOL CFWL_ComboBoxImp::EditDelete()
-{
- return (m_pEdit->ClearText() == FWL_ERR_Succeeded) ? TRUE : FALSE;
-}
-FX_BOOL CFWL_ComboBoxImp::EditDeSelect()
-{
- return (m_pEdit->ClearSelections() == FWL_ERR_Succeeded) ? TRUE : FALSE;
-}
-FWL_ERR CFWL_ComboBoxImp::GetBBox(CFX_RectF &rect)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_GetBBox(rect);
- }
- rect = m_pProperties->m_rtWidget;
- if (m_pListBox && IsDropListShowed()) {
- CFX_RectF rtList;
- m_pListBox->GetWidgetRect(rtList);
- rtList.Offset(rect.left, rect.top);
- rect.Union(rtList);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBoxImp::EditModifyStylesEx(FX_DWORD dwStylesExAdded,
- FX_DWORD dwStylesExRemoved)
-{
- if (m_pEdit != NULL) {
- return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+ m_pEdit->GetWidgetRect(rect, TRUE);
} else {
- return FWL_ERR_Parameter_Invalid;
- }
-}
-FX_FLOAT CFWL_ComboBoxImp::GetListHeight()
-{
- return ((IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider)->GetListHeight(m_pInterface);
-}
-void CFWL_ComboBoxImp::DrawStretchHandler(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
+ rect.width = 100;
+ rect.height = 16;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ ReSetTheme();
+ }
+ FX_FLOAT* pFWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_VALUE_IF_FAIL(pFWidth, FWL_ERR_Indefinite);
+ rect.Inflate(0, 0, *pFWidth, 0);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+ }
+ FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown;
+ FX_BOOL bRemoveDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown;
+ if (bAddDropDown && !m_pEdit) {
+ CFWL_ComboEdit* pEdit = FX_NEW CFWL_ComboEdit(m_pInterface);
+ m_pEdit = IFWL_Edit::Create();
+ pEdit->SetInterface(m_pEdit);
+ ((IFWL_TargetData*)m_pEdit)->SetData(pEdit);
+ pEdit->Initialize();
+ pEdit->SetOuter(m_pInterface);
+ m_pEdit->SetParent(m_pInterface);
+ } else if (bRemoveDropDown && m_pEdit) {
+ m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+FWL_ERR CFWL_ComboBoxImp::Update() {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_Update();
+ }
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ ReSetTheme();
+ FX_BOOL bDropDown = IsDropDownStyle();
+ if (bDropDown && m_pEdit) {
+ ReSetEditAlignment();
+ }
+ if (m_pProperties->m_pThemeProvider == NULL) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ Layout();
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ m_fComboFormHandler =
+ *(FX_FLOAT*)m_pProperties->m_pThemeProvider->GetCapacity(
+ &part, FWL_WGTCAPACITY_CMB_ComboFormHandler);
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ComboBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_HitTest(fx, fy);
+ }
+ return CFWL_WidgetImp::HitTest(fx, fy);
+}
+FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_DrawWidget(pGraphics, pMatrix);
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ FX_BOOL bIsDropDown = IsDropDownStyle();
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_CMB_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_CMB_Edge, pTheme, pMatrix);
+ }
+ if (!bIsDropDown) {
+ CFX_RectF rtTextBk(m_rtClient);
+ rtTextBk.width -= m_rtBtn.width;
CFWL_ThemeBackground param;
- param.m_pGraphics = pGraphics;
- param.m_iPart = FWL_PART_CMB_StretcgHandler;
- param.m_dwStates = FWL_PARTSTATE_CMB_Normal;
param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_CMB_Background;
+ param.m_pGraphics = pGraphics;
if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- param.m_rtPart = m_rtHandler;
- m_pProperties->m_pThemeProvider->DrawBackground(¶m);
-}
-void CFWL_ComboBoxImp::ShowDropList(FX_BOOL bActivate)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_ShowDropList(bActivate);
- }
- FX_BOOL bDropList = IsDropListShowed();
- if(bDropList == bActivate) {
- return;
- }
- if (!m_pForm) {
- InitProxyForm();
- }
- m_pListProxyDelegate->Reset();
- if (bActivate) {
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->ChangeSelected(m_iCurSel);
- ReSetListItemAlignment();
- FX_DWORD dwStyleAdd = m_pProperties->m_dwStyleExes & (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
- m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
- m_pListBox->GetWidgetRect(m_rtList, TRUE);
- FX_FLOAT fHeight = GetListHeight();
- if (fHeight > 0) {
- if (m_rtList.height > GetListHeight()) {
- m_rtList.height = GetListHeight();
- m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0);
- }
- }
- CFX_RectF rtAnchor;
- rtAnchor.Set(0,
- 0,
- m_pProperties->m_rtWidget.width,
- m_pProperties->m_rtWidget.height);
- FX_FLOAT fMinHeight = 0;
- FX_FLOAT fMaxHeight = m_rtList.height;
- if (m_rtList.width < m_rtClient.width) {
- m_rtList.width = m_rtClient.width;
- }
- m_rtProxy = m_rtList;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
- m_rtProxy.height += m_fComboFormHandler;
- }
- GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2;
- TransformTo(NULL, fx, fy);
- m_bUpFormHandler = fy > m_rtProxy.top;
- if (m_bUpFormHandler) {
- m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler);
- m_rtList.top = m_fComboFormHandler;
- } else {
- m_rtHandler.Set(0, m_rtList.height, m_rtList.width, m_fComboFormHandler);
- }
- }
- m_pForm->SetWidgetRect(m_rtProxy);
- m_pForm->Update();
- m_pListBox->SetWidgetRect(m_rtList);
- m_pListBox->Update();
- CFWL_EvtCmbPreDropDown ev;
- ev.m_pSrcTarget = m_pInterface;
- DispatchEvent(&ev);
- m_fItemHeight = ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->m_fItemHeight;
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->SetFocus(TRUE);
- m_pForm->DoModal();
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->SetFocus(FALSE);
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = rtTextBk;
+ if (m_iCurSel >= 0) {
+ IFWL_ListBoxDP* pData =
+ (IFWL_ListBoxDP*)((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)
+ ->GetData())
+ ->m_pProperties->m_pDataProvider;
+ void* p =
+ pData->GetItemData(m_pListBox, pData->GetItem(m_pListBox, m_iCurSel));
+ if (p != NULL) {
+ param.m_pData = p;
+ }
+ }
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ param.m_dwStates = FWL_PARTSTATE_CMB_Disabled;
+ } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) &&
+ (m_iCurSel >= 0)) {
+ param.m_dwStates = FWL_PARTSTATE_CMB_Selected;
} else {
- m_pForm->EndDoModal();
- CFWL_EvtCmbCloseUp ev;
- ev.m_pSrcTarget = m_pInterface;
- DispatchEvent(&ev);
- m_bLButtonDown = FALSE;
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->m_bNotifyOwner = TRUE;
- SetFocus(TRUE);
- }
-}
-FX_BOOL CFWL_ComboBoxImp::IsDropListShowed()
-{
- return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
-}
-FX_BOOL CFWL_ComboBoxImp::IsDropDownStyle() const
-{
- return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown;
-}
-void CFWL_ComboBoxImp::MatchEditText()
-{
- CFX_WideString wsText;
- m_pEdit->GetText(wsText);
- int32_t iMatch = ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->MatchItem(wsText);
- if (iMatch != m_iCurSel) {
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->ChangeSelected(iMatch);
- if (iMatch >= 0) {
- SynchrEditText(iMatch);
- }
- } else if (iMatch >= 0) {
- ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())->SetSelected();
+ param.m_dwStates = FWL_PARTSTATE_CMB_Normal;
+ }
+ pTheme->DrawBackground(¶m);
+ if (m_iCurSel >= 0) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pListBox, FWL_ERR_Indefinite);
+ CFX_WideString wsText;
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->GetItemText(hItem, wsText);
+ CFWL_ThemeText param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_CMB_Caption;
+ param.m_dwStates = m_iBtnState;
+ param.m_pGraphics = pGraphics;
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = rtTextBk;
+ param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
+ ? FWL_PARTSTATE_CMB_Selected
+ : FWL_PARTSTATE_CMB_Normal;
+ param.m_wsText = wsText;
+ param.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ param.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ pTheme->DrawText(¶m);
+ }
+ }
+ {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_CMB_DropDownButton;
+ param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+ ? FWL_PARTSTATE_CMB_Disabled
+ : m_iBtnState;
+ param.m_pGraphics = pGraphics;
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = m_rtBtn;
+ pTheme->DrawBackground(¶m);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ _FWL_RETURN_VALUE_IF_FAIL(pThemeProvider, FWL_ERR_Indefinite);
+ m_pProperties->m_pThemeProvider = pThemeProvider;
+ if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox)) {
+ m_pListBox->SetThemeProvider(pThemeProvider);
+ }
+ if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit)) {
+ m_pEdit->SetThemeProvider(pThemeProvider);
+ }
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ComboBoxImp::GetCurSel() {
+ return m_iCurSel;
+}
+FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) {
+ int32_t iCount = ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->CountItems();
+ FX_BOOL bClearSel = iSel < 0 || iSel >= iCount;
+ FX_BOOL bDropDown = IsDropDownStyle();
+ if (bDropDown && m_pEdit) {
+ if (bClearSel) {
+ m_pEdit->SetText(CFX_WideString());
+ } else {
+ CFX_WideString wsText;
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel);
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->GetItemText(hItem, wsText);
+ m_pEdit->SetText(wsText);
}
- m_iCurSel = iMatch;
-}
-void CFWL_ComboBoxImp::SynchrEditText(int32_t iListItem)
-{
- CFX_WideString wsText;
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iListItem);
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->GetItemText(hItem, wsText);
- m_pEdit->SetText(wsText);
m_pEdit->Update();
+ }
+ m_iCurSel = bClearSel ? -1 : iSel;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ FX_BOOL bIsDropDown = IsDropDownStyle();
+ if (bIsDropDown && m_pEdit) {
+ m_pEdit->SetStates(dwStates, bSet);
+ }
+ if (m_pListBox) {
+ m_pListBox->SetStates(dwStates, bSet);
+ }
+ return CFWL_WidgetImp::SetStates(dwStates, bSet);
+}
+FWL_ERR CFWL_ComboBoxImp::SetEditText(const CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
+ m_pEdit->SetText(wsText);
+ return m_pEdit->Update();
+}
+int32_t CFWL_ComboBoxImp::GetEditTextLength() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, -1);
+ return m_pEdit->GetTextLength();
+}
+FWL_ERR CFWL_ComboBoxImp::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ if (m_pEdit) {
+ return m_pEdit->GetText(wsText, nStart, nCount);
+ } else if (m_pListBox) {
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
+ return m_pListBox->GetItemText(hItem, wsText);
+ }
+ return FWL_ERR_Indefinite;
+}
+FWL_ERR CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
+ ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())->ClearSelected();
+ m_pEdit->AddSelRange(nStart, nCount);
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ComboBoxImp::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, -1);
+ return m_pEdit->GetSelRange(nIndex, nStart);
+}
+int32_t CFWL_ComboBoxImp::GetEditLimit() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, -1);
+ return m_pEdit->GetLimit();
+}
+FWL_ERR CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
+ return m_pEdit->SetLimit(nLimit);
+}
+FWL_ERR CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
+ return m_pEdit->DoClipboard(iCmd);
+}
+FX_BOOL CFWL_ComboBoxImp::EditRedo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FALSE);
+ return m_pEdit->Redo(bsRecord);
+}
+FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FALSE);
+ return m_pEdit->Undo(bsRecord);
+}
+IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pListBox, FALSE);
+ return m_pListBox;
+}
+FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() {
+ if (!m_bNeedShowList) {
+ return FALSE;
+ }
+ if (m_pEdit) {
+ MatchEditText();
+ }
+ ShowDropList(TRUE);
+ m_bNeedShowList = FALSE;
+ return TRUE;
+}
+FX_ERR CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate) {
+ ShowDropList(bActivate);
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_ComboBoxImp::EditCanUndo() {
+ return m_pEdit->CanUndo();
+}
+FX_BOOL CFWL_ComboBoxImp::EditCanRedo() {
+ return m_pEdit->CanRedo();
+}
+FX_BOOL CFWL_ComboBoxImp::EditUndo() {
+ return m_pEdit->Undo();
+}
+FX_BOOL CFWL_ComboBoxImp::EditRedo() {
+ return m_pEdit->Redo();
+}
+FX_BOOL CFWL_ComboBoxImp::EditCanCopy() {
+ return m_pEdit->CountSelRanges() > 0;
+}
+FX_BOOL CFWL_ComboBoxImp::EditCanCut() {
+ if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
+ return FALSE;
+ }
+ return m_pEdit->CountSelRanges() > 0;
+}
+FX_BOOL CFWL_ComboBoxImp::EditCanSelectAll() {
+ return m_pEdit->GetTextLength() > 0;
+}
+FX_BOOL CFWL_ComboBoxImp::EditCopy(CFX_WideString& wsCopy) {
+ return m_pEdit->Copy(wsCopy);
+}
+FX_BOOL CFWL_ComboBoxImp::EditCut(CFX_WideString& wsCut) {
+ return m_pEdit->Cut(wsCut);
+}
+FX_BOOL CFWL_ComboBoxImp::EditPaste(const CFX_WideString& wsPaste) {
+ return m_pEdit->Paste(wsPaste);
+}
+FX_BOOL CFWL_ComboBoxImp::EditSelectAll() {
+ return (m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded) ? TRUE : FALSE;
+}
+FX_BOOL CFWL_ComboBoxImp::EditDelete() {
+ return (m_pEdit->ClearText() == FWL_ERR_Succeeded) ? TRUE : FALSE;
+}
+FX_BOOL CFWL_ComboBoxImp::EditDeSelect() {
+ return (m_pEdit->ClearSelections() == FWL_ERR_Succeeded) ? TRUE : FALSE;
+}
+FWL_ERR CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_GetBBox(rect);
+ }
+ rect = m_pProperties->m_rtWidget;
+ if (m_pListBox && IsDropListShowed()) {
+ CFX_RectF rtList;
+ m_pListBox->GetWidgetRect(rtList);
+ rtList.Offset(rect.left, rect.top);
+ rect.Union(rtList);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImp::EditModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ if (m_pEdit != NULL) {
+ return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+ } else {
+ return FWL_ERR_Parameter_Invalid;
+ }
+}
+FX_FLOAT CFWL_ComboBoxImp::GetListHeight() {
+ return ((IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider)
+ ->GetListHeight(m_pInterface);
+}
+void CFWL_ComboBoxImp::DrawStretchHandler(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground param;
+ param.m_pGraphics = pGraphics;
+ param.m_iPart = FWL_PART_CMB_StretcgHandler;
+ param.m_dwStates = FWL_PARTSTATE_CMB_Normal;
+ param.m_pWidget = m_pInterface;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = m_rtHandler;
+ m_pProperties->m_pThemeProvider->DrawBackground(¶m);
+}
+void CFWL_ComboBoxImp::ShowDropList(FX_BOOL bActivate) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_ShowDropList(bActivate);
+ }
+ FX_BOOL bDropList = IsDropListShowed();
+ if (bDropList == bActivate) {
+ return;
+ }
+ if (!m_pForm) {
+ InitProxyForm();
+ }
+ m_pListProxyDelegate->Reset();
+ if (bActivate) {
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->ChangeSelected(m_iCurSel);
+ ReSetListItemAlignment();
+ FX_DWORD dwStyleAdd = m_pProperties->m_dwStyleExes &
+ (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
+ m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
+ m_pListBox->GetWidgetRect(m_rtList, TRUE);
+ FX_FLOAT fHeight = GetListHeight();
+ if (fHeight > 0) {
+ if (m_rtList.height > GetListHeight()) {
+ m_rtList.height = GetListHeight();
+ m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0);
+ }
+ }
+ CFX_RectF rtAnchor;
+ rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ FX_FLOAT fMinHeight = 0;
+ FX_FLOAT fMaxHeight = m_rtList.height;
+ if (m_rtList.width < m_rtClient.width) {
+ m_rtList.width = m_rtClient.width;
+ }
+ m_rtProxy = m_rtList;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
+ m_rtProxy.height += m_fComboFormHandler;
+ }
+ GetPopupPos(fMinHeight, m_rtProxy.height, rtAnchor, m_rtProxy);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) {
+ FX_FLOAT fx = 0;
+ FX_FLOAT fy = m_rtClient.top + m_rtClient.height / 2;
+ TransformTo(NULL, fx, fy);
+ m_bUpFormHandler = fy > m_rtProxy.top;
+ if (m_bUpFormHandler) {
+ m_rtHandler.Set(0, 0, m_rtList.width, m_fComboFormHandler);
+ m_rtList.top = m_fComboFormHandler;
+ } else {
+ m_rtHandler.Set(0, m_rtList.height, m_rtList.width,
+ m_fComboFormHandler);
+ }
+ }
+ m_pForm->SetWidgetRect(m_rtProxy);
+ m_pForm->Update();
+ m_pListBox->SetWidgetRect(m_rtList);
+ m_pListBox->Update();
+ CFWL_EvtCmbPreDropDown ev;
+ ev.m_pSrcTarget = m_pInterface;
+ DispatchEvent(&ev);
+ m_fItemHeight = ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->m_fItemHeight;
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->SetFocus(TRUE);
+ m_pForm->DoModal();
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->SetFocus(FALSE);
+ } else {
+ m_pForm->EndDoModal();
+ CFWL_EvtCmbCloseUp ev;
+ ev.m_pSrcTarget = m_pInterface;
+ DispatchEvent(&ev);
+ m_bLButtonDown = FALSE;
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->m_bNotifyOwner = TRUE;
+ SetFocus(TRUE);
+ }
+}
+FX_BOOL CFWL_ComboBoxImp::IsDropListShowed() {
+ return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
+}
+FX_BOOL CFWL_ComboBoxImp::IsDropDownStyle() const {
+ return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown;
+}
+void CFWL_ComboBoxImp::MatchEditText() {
+ CFX_WideString wsText;
+ m_pEdit->GetText(wsText);
+ int32_t iMatch = ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->MatchItem(wsText);
+ if (iMatch != m_iCurSel) {
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->ChangeSelected(iMatch);
+ if (iMatch >= 0) {
+ SynchrEditText(iMatch);
+ }
+ } else if (iMatch >= 0) {
((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())->SetSelected();
-}
-void CFWL_ComboBoxImp::Layout()
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_Layout();
+ }
+ m_iCurSel = iMatch;
+}
+void CFWL_ComboBoxImp::SynchrEditText(int32_t iListItem) {
+ CFX_WideString wsText;
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iListItem);
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->GetItemText(hItem, wsText);
+ m_pEdit->SetText(wsText);
+ m_pEdit->Update();
+ ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())->SetSelected();
+}
+void CFWL_ComboBoxImp::Layout() {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_Layout();
+ }
+ GetClientRect(m_rtClient);
+ FX_FLOAT* pFWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_IF_FAIL(pFWidth);
+ FX_FLOAT fBtn = *pFWidth;
+ m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn,
+ m_rtClient.height);
+ FX_BOOL bIsDropDown = IsDropDownStyle();
+ if (bIsDropDown && m_pEdit) {
+ CFX_RectF rtEdit;
+ rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
+ m_rtClient.height);
+ m_pEdit->SetWidgetRect(rtEdit);
+ if (m_iCurSel >= 0) {
+ CFX_WideString wsText;
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->GetItemText(hItem, wsText);
+ m_pEdit->LockUpdate();
+ m_pEdit->SetText(wsText);
+ m_pEdit->UnlockUpdate();
}
- GetClientRect(m_rtClient);
- FX_FLOAT *pFWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_IF_FAIL(pFWidth);
- FX_FLOAT fBtn = *pFWidth;
- m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, m_rtClient.height);
- FX_BOOL bIsDropDown = IsDropDownStyle();
- if (bIsDropDown && m_pEdit) {
- CFX_RectF rtEdit;
- rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, m_rtClient.height);
- m_pEdit->SetWidgetRect(rtEdit);
- if (m_iCurSel >= 0) {
- CFX_WideString wsText;
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->GetItemText(hItem, wsText);
- m_pEdit->LockUpdate();
- m_pEdit->SetText(wsText);
- m_pEdit->UnlockUpdate();
- }
+ m_pEdit->Update();
+ }
+}
+void CFWL_ComboBoxImp::ReSetTheme() {
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (!pTheme) {
+ pTheme = GetAvailableTheme();
+ m_pProperties->m_pThemeProvider = pTheme;
+ }
+ if (m_pListBox) {
+ if (!m_pListBox->GetThemeProvider() && pTheme->IsValidWidget(m_pListBox)) {
+ m_pListBox->SetThemeProvider(pTheme);
+ }
+ }
+ if (m_pEdit) {
+ if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit)) {
+ m_pEdit->SetThemeProvider(pTheme);
+ }
+ }
+}
+void CFWL_ComboBoxImp::ReSetEditAlignment() {
+ _FWL_RETURN_IF_FAIL(m_pEdit);
+ FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes;
+ FX_DWORD dwAdd = 0;
+ switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) {
+ case FWL_STYLEEXT_CMB_EditHCenter: {
+ dwAdd |= FWL_STYLEEXT_EDT_HCenter;
+ break;
+ }
+ case FWL_STYLEEXT_CMB_EditHFar: {
+ dwAdd |= FWL_STYLEEXT_EDT_HFar;
+ break;
+ }
+ default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; }
+ }
+ switch (dwStylExes & FWL_STYLEEXT_CMB_EditVAlignMask) {
+ case FWL_STYLEEXT_CMB_EditVCenter: {
+ dwAdd |= FWL_STYLEEXT_EDT_VCenter;
+ break;
+ }
+ case FWL_STYLEEXT_CMB_EditVFar: {
+ dwAdd |= FWL_STYLEEXT_EDT_VFar;
+ break;
+ }
+ default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; }
+ }
+ if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) {
+ dwAdd |= FWL_STYLEEXT_EDT_Justified;
+ }
+ if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) {
+ dwAdd |= FWL_STYLEEXT_EDT_Distributed;
+ }
+ m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
+ FWL_STYLEEXT_EDT_HAlignModeMask |
+ FWL_STYLEEXT_EDT_VAlignMask);
+}
+void CFWL_ComboBoxImp::ReSetListItemAlignment() {
+ _FWL_RETURN_IF_FAIL(m_pListBox);
+ FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes;
+ FX_DWORD dwAdd = 0;
+ switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) {
+ case FWL_STYLEEXT_CMB_ListItemCenterAlign: {
+ dwAdd |= FWL_STYLEEXT_LTB_CenterAlign;
+ }
+ case FWL_STYLEEXT_CMB_ListItemRightAlign: {
+ dwAdd |= FWL_STYLEEXT_LTB_RightAlign;
+ }
+ default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; }
+ }
+ m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask);
+}
+void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp) {
+ IFWL_ComboBoxDP* pDatas = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ m_iCurSel = pDatas->GetItemIndex(m_pInterface, m_pListBox->GetSelItem(0));
+ FX_BOOL bDropDown = IsDropDownStyle();
+ if (bDropDown) {
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
+ if (hItem) {
+ CFX_WideString wsText;
+ pData->GetItemText(m_pInterface, hItem, wsText);
+ if (m_pEdit) {
+ m_pEdit->SetText(wsText);
m_pEdit->Update();
- }
-}
-void CFWL_ComboBoxImp::ReSetTheme()
-{
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (!pTheme) {
- pTheme = GetAvailableTheme();
- m_pProperties->m_pThemeProvider = pTheme;
- }
- if (m_pListBox) {
- if (!m_pListBox->GetThemeProvider() && pTheme->IsValidWidget(m_pListBox)) {
- m_pListBox->SetThemeProvider(pTheme);
- }
- }
- if (m_pEdit) {
- if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit)) {
- m_pEdit->SetThemeProvider(pTheme);
- }
- }
-}
-void CFWL_ComboBoxImp::ReSetEditAlignment()
-{
- _FWL_RETURN_IF_FAIL(m_pEdit);
- FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes;
- FX_DWORD dwAdd = 0;
- switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) {
- case FWL_STYLEEXT_CMB_EditHCenter: {
- dwAdd |= FWL_STYLEEXT_EDT_HCenter;
- break;
- }
- case FWL_STYLEEXT_CMB_EditHFar: {
- dwAdd |= FWL_STYLEEXT_EDT_HFar;
- break;
- }
- default: {
- dwAdd |= FWL_STYLEEXT_EDT_HNear;
- }
- }
- switch (dwStylExes & FWL_STYLEEXT_CMB_EditVAlignMask) {
- case FWL_STYLEEXT_CMB_EditVCenter: {
- dwAdd |= FWL_STYLEEXT_EDT_VCenter;
- break;
- }
- case FWL_STYLEEXT_CMB_EditVFar: {
- dwAdd |= FWL_STYLEEXT_EDT_VFar;
- break;
- }
- default: {
- dwAdd |= FWL_STYLEEXT_EDT_VNear;
- }
- }
- if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) {
- dwAdd |= FWL_STYLEEXT_EDT_Justified;
- }
- if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) {
- dwAdd |= FWL_STYLEEXT_EDT_Distributed;
- }
- m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
- FWL_STYLEEXT_EDT_HAlignModeMask |
- FWL_STYLEEXT_EDT_VAlignMask);
-}
-void CFWL_ComboBoxImp::ReSetListItemAlignment()
-{
- _FWL_RETURN_IF_FAIL(m_pListBox);
- FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes;
- FX_DWORD dwAdd = 0;
- switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) {
- case FWL_STYLEEXT_CMB_ListItemCenterAlign: {
- dwAdd |= FWL_STYLEEXT_LTB_CenterAlign;
- }
- case FWL_STYLEEXT_CMB_ListItemRightAlign: {
- dwAdd |= FWL_STYLEEXT_LTB_RightAlign;
- }
- default: {
- dwAdd |= FWL_STYLEEXT_LTB_LeftAlign;
- }
- }
- m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask);
-}
-void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp)
-{
- IFWL_ComboBoxDP *pDatas = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
- m_iCurSel = pDatas->GetItemIndex(m_pInterface, m_pListBox->GetSelItem(0));
- FX_BOOL bDropDown = IsDropDownStyle();
- if (bDropDown) {
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
- if (hItem) {
- CFX_WideString wsText;
- pData->GetItemText(m_pInterface, hItem, wsText);
- if (m_pEdit) {
- m_pEdit->SetText(wsText);
- m_pEdit->Update();
- ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())->SetSelected();
- }
- CFWL_EvtCmbSelChanged ev;
- ev.bLButtonUp = bLButtonUp;
- ev.m_pSrcTarget = m_pInterface;
- ev.iArraySels.Add(m_iCurSel);
- DispatchEvent(&ev);
- }
- } else {
- Repaint(&m_rtClient);
- }
-}
-void CFWL_ComboBoxImp::InitProxyForm()
-{
- _FWL_RETURN_IF_FAIL(!m_pForm);
- _FWL_RETURN_IF_FAIL(m_pListBox);
- CFWL_WidgetImpProperties propForm;
- propForm.m_pOwner = m_pInterface;
- propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
- propForm.m_dwStates = FWL_WGTSTATE_Invisible;
- m_pProxy = FX_NEW CFWL_FormProxyImp(propForm, m_pListBox);
- m_pForm = IFWL_Form::Create();
- m_pProxy->SetInterface(m_pForm);
- ((IFWL_TargetData*)m_pForm)->SetData(m_pProxy);
- m_pProxy->Initialize();
- m_pListBox->SetParent((IFWL_Widget*)m_pForm);
- m_pListProxyDelegate = FX_NEW CFWL_ComboProxyImpDelegate(m_pForm, this);
- m_pProxy->SetDelegate((IFWL_WidgetDelegate*)m_pListProxyDelegate);
-}
-FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_WGTSTATE_Invisible);
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ComboBoxImpDelegate(this);
- DisForm_InitComboList();
+ ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pEdit)->GetData())
+ ->SetSelected();
+ }
+ CFWL_EvtCmbSelChanged ev;
+ ev.bLButtonUp = bLButtonUp;
+ ev.m_pSrcTarget = m_pInterface;
+ ev.iArraySels.Add(m_iCurSel);
+ DispatchEvent(&ev);
+ }
+ } else {
+ Repaint(&m_rtClient);
+ }
+}
+void CFWL_ComboBoxImp::InitProxyForm() {
+ _FWL_RETURN_IF_FAIL(!m_pForm);
+ _FWL_RETURN_IF_FAIL(m_pListBox);
+ CFWL_WidgetImpProperties propForm;
+ propForm.m_pOwner = m_pInterface;
+ propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
+ propForm.m_dwStates = FWL_WGTSTATE_Invisible;
+ m_pProxy = FX_NEW CFWL_FormProxyImp(propForm, m_pListBox);
+ m_pForm = IFWL_Form::Create();
+ m_pProxy->SetInterface(m_pForm);
+ ((IFWL_TargetData*)m_pForm)->SetData(m_pProxy);
+ m_pProxy->Initialize();
+ m_pListBox->SetParent((IFWL_Widget*)m_pForm);
+ m_pListProxyDelegate = FX_NEW CFWL_ComboProxyImpDelegate(m_pForm, this);
+ m_pProxy->SetDelegate((IFWL_WidgetDelegate*)m_pListProxyDelegate);
+}
+FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_WGTSTATE_Invisible);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ComboBoxImpDelegate(this);
+ DisForm_InitComboList();
+ DisForm_InitComboEdit();
+ return FWL_ERR_Succeeded;
+}
+void CFWL_ComboBoxImp::DisForm_InitComboList() {
+ if (m_pListBox) {
+ return;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_pParent = (IFWL_Widget*)this->m_pInterface;
+ prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
+ prop.m_dwStates = FWL_WGTSTATE_Invisible;
+ prop.m_pDataProvider = m_pProperties->m_pDataProvider;
+ prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ CFWL_ComboList* pList = FX_NEW CFWL_ComboList(prop, m_pInterface);
+ m_pListBox = IFWL_ListBox::Create();
+ pList->SetInterface(m_pListBox);
+ ((IFWL_TargetData*)m_pListBox)->SetData(pList);
+ pList->Initialize();
+}
+void CFWL_ComboBoxImp::DisForm_InitComboEdit() {
+ if (m_pEdit) {
+ return;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_pParent = (IFWL_Widget*)this->m_pInterface;
+ prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) == 0) {
+ }
+ CFWL_ComboEdit* pEdit = FX_NEW CFWL_ComboEdit(prop, m_pInterface);
+ m_pEdit = IFWL_Edit::Create();
+ pEdit->SetInterface(m_pEdit);
+ ((IFWL_TargetData*)m_pEdit)->SetData(pEdit);
+ pEdit->Initialize();
+ pEdit->SetOuter(m_pInterface);
+}
+void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) {
+ FX_BOOL bDropList = DisForm_IsDropListShowed();
+ if (bDropList == bActivate) {
+ return;
+ }
+ if (bActivate) {
+ CFWL_EvtCmbPreDropDown preEvent;
+ preEvent.m_pSrcTarget = m_pInterface;
+ DispatchEvent(&preEvent);
+ CFWL_ComboList* pComboList =
+ (CFWL_ComboList*)(((IFWL_TargetData*)m_pListBox)->GetData());
+ int32_t iItems = pComboList->CountItems();
+ if (iItems < 1) {
+ return;
+ }
+ ReSetListItemAlignment();
+ pComboList->ChangeSelected(m_iCurSel);
+ FX_FLOAT fItemHeight = pComboList->GetItemHeigt();
+ FX_FLOAT fBorder = GetBorderSize();
+ FX_DWORD nWhere = 0;
+ FX_FLOAT fPopupRet = 0.0f;
+ FX_FLOAT fPopupMin = 0.0f;
+ if (iItems > 3) {
+ fPopupMin = fItemHeight * 3 + fBorder * 2;
+ }
+ FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2;
+ CFX_RectF rtList;
+ rtList.left = m_rtClient.left;
+ rtList.width = m_pProperties->m_rtWidget.width;
+ rtList.top = 0;
+ rtList.height = 0;
+ GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList);
+ m_pListBox->SetWidgetRect(rtList);
+ m_pListBox->Update();
+ } else {
+ SetFocus(TRUE);
+ }
+ m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
+ if (bActivate) {
+ CFWL_EvtCmbPostDropDown postEvent;
+ postEvent.m_pSrcTarget = m_pInterface;
+ DispatchEvent(&postEvent);
+ }
+ CFX_RectF rect;
+ m_pListBox->GetWidgetRect(rect);
+ rect.Inflate(2, 2);
+ Repaint(&rect);
+}
+FX_BOOL CFWL_ComboBoxImp::DisForm_IsDropListShowed() {
+ return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
+}
+FWL_ERR CFWL_ComboBoxImp::DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ if (!m_pEdit) {
DisForm_InitComboEdit();
- return FWL_ERR_Succeeded;
-}
-void CFWL_ComboBoxImp::DisForm_InitComboList()
-{
- if (m_pListBox) {
- return;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_pParent = (IFWL_Widget*)this->m_pInterface;
- prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
- prop.m_dwStates = FWL_WGTSTATE_Invisible;
- prop.m_pDataProvider = m_pProperties->m_pDataProvider;
- prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- CFWL_ComboList *pList = FX_NEW CFWL_ComboList(prop, m_pInterface);
- m_pListBox = IFWL_ListBox::Create();
- pList->SetInterface(m_pListBox);
- ((IFWL_TargetData*)m_pListBox)->SetData(pList);
- pList->Initialize();
-}
-void CFWL_ComboBoxImp::DisForm_InitComboEdit()
-{
- if (m_pEdit) {
- return;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_pParent = (IFWL_Widget*)this->m_pInterface;
- prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) == 0) {
- }
- CFWL_ComboEdit *pEdit = FX_NEW CFWL_ComboEdit(prop, m_pInterface);
- m_pEdit = IFWL_Edit::Create();
- pEdit->SetInterface(m_pEdit);
- ((IFWL_TargetData*)m_pEdit)->SetData(pEdit);
- pEdit->Initialize();
- pEdit->SetOuter(m_pInterface);
-}
-void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate)
-{
- FX_BOOL bDropList = DisForm_IsDropListShowed();
- if(bDropList == bActivate) {
- return;
- }
- if (bActivate) {
- CFWL_EvtCmbPreDropDown preEvent;
- preEvent.m_pSrcTarget = m_pInterface;
- DispatchEvent(&preEvent);
- CFWL_ComboList* pComboList = (CFWL_ComboList*)(((IFWL_TargetData*)m_pListBox)->GetData());
- int32_t iItems = pComboList->CountItems();
- if (iItems < 1) {
- return;
- }
- ReSetListItemAlignment();
- pComboList->ChangeSelected(m_iCurSel);
- FX_FLOAT fItemHeight = pComboList->GetItemHeigt();
- FX_FLOAT fBorder = GetBorderSize();
- FX_DWORD nWhere = 0;
- FX_FLOAT fPopupRet = 0.0f;
- FX_FLOAT fPopupMin = 0.0f;
- if (iItems > 3) {
- fPopupMin = fItemHeight * 3 + fBorder * 2;
- }
- FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2;
- CFX_RectF rtList;
- rtList.left = m_rtClient.left;
- rtList.width = m_pProperties->m_rtWidget.width;
- rtList.top = 0;
- rtList.height = 0;
- GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList);
- m_pListBox->SetWidgetRect(rtList);
- m_pListBox->Update();
- } else {
- SetFocus(TRUE);
- }
- m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
- if (bActivate) {
- CFWL_EvtCmbPostDropDown postEvent;
- postEvent.m_pSrcTarget = m_pInterface;
- DispatchEvent(&postEvent);
- }
- CFX_RectF rect;
+ }
+ FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown;
+ FX_BOOL bDelDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown;
+ dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
+ m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
+ if (bAddDropDown) {
+ m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly);
+ } else if (bDelDropDown) {
+ m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0);
+ }
+ return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+FWL_ERR CFWL_ComboBoxImp::DisForm_Update() {
+ if (m_iLock) {
+ return FWL_ERR_Indefinite;
+ }
+ if (m_pEdit) {
+ ReSetEditAlignment();
+ }
+ ReSetTheme();
+ Layout();
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ComboBoxImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ CFX_RectF rect;
+ rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width,
+ m_pProperties->m_rtWidget.height);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Edit;
+ }
+ if (m_rtBtn.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ if (DisForm_IsDropListShowed()) {
m_pListBox->GetWidgetRect(rect);
- rect.Inflate(2, 2);
- Repaint(&rect);
-}
-FX_BOOL CFWL_ComboBoxImp::DisForm_IsDropListShowed()
-{
- return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
-}
-FWL_ERR CFWL_ComboBoxImp::DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- if (!m_pEdit) {
- DisForm_InitComboEdit();
- }
- FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown;
- FX_BOOL bDelDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown;
- dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
- m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
- if (bAddDropDown) {
- m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly);
- } else if (bDelDropDown) {
- m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0);
- }
- return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-FWL_ERR CFWL_ComboBoxImp::DisForm_Update()
-{
- if (m_iLock) {
- return FWL_ERR_Indefinite;
- }
- if (m_pEdit) {
- ReSetEditAlignment();
- }
- ReSetTheme();
- Layout();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ComboBoxImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- CFX_RectF rect;
- rect.Set(0,
- 0,
- m_pProperties->m_rtWidget.width - m_rtBtn.width,
- m_pProperties->m_rtWidget.height);
if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edit;
- }
- if (m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
+ return FWL_WGTHITTEST_Client;
+ }
+ }
+ return FWL_WGTHITTEST_Unknown;
+}
+FWL_ERR CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ CFX_Matrix mtOrg;
+ mtOrg.Set(1, 0, 0, 1, 0, 0);
+ if (pMatrix) {
+ mtOrg = *pMatrix;
+ }
+ FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed();
+ pGraphics->SaveGraphState();
+ pGraphics->ConcatMatrix(&mtOrg);
+ if (!m_rtBtn.IsEmpty(0.1f)) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = (IFWL_Widget*)this->m_pInterface;
+ param.m_iPart = FWL_PART_CMB_DropDownButton;
+ param.m_dwStates = m_iBtnState;
+ param.m_pGraphics = pGraphics;
+ param.m_rtPart = m_rtBtn;
+ pTheme->DrawBackground(¶m);
+ }
+ pGraphics->RestoreGraphState();
+ if (m_pEdit) {
+ CFX_RectF rtEdit;
+ m_pEdit->GetWidgetRect(rtEdit);
+ CFX_Matrix mt;
+ mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
+ mt.Concat(mtOrg);
+ m_pEdit->DrawWidget(pGraphics, &mt);
+ }
+ if (bListShowed) {
+ CFX_RectF rtList;
+ m_pListBox->GetWidgetRect(rtList);
+ CFX_Matrix mt;
+ mt.Set(1, 0, 0, 1, rtList.left, rtList.top);
+ mt.Concat(mtOrg);
+ m_pListBox->DrawWidget(pGraphics, &mt);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) {
+ rect = m_pProperties->m_rtWidget;
+ if (m_pListBox && DisForm_IsDropListShowed()) {
+ CFX_RectF rtList;
+ m_pListBox->GetWidgetRect(rtList);
+ rtList.Offset(rect.left, rect.top);
+ rect.Union(rtList);
+ }
+ return FWL_ERR_Succeeded;
+}
+void CFWL_ComboBoxImp::DisForm_Layout() {
+ GetClientRect(m_rtClient);
+ m_rtContent = m_rtClient;
+ FX_FLOAT* pFWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_IF_FAIL(pFWidth);
+ FX_FLOAT borderWidth = 0;
+ { borderWidth = FWL_PART_CMB_Border; }
+ FX_FLOAT fBtn = *pFWidth;
+ if (!(this->GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
+ m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
+ fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
+ }
+ CFX_RectF* pUIMargin = (CFX_RectF*)GetThemeCapacity(FWL_WGTCAPACITY_UIMargin);
+ if (pUIMargin) {
+ m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
+ pUIMargin->height);
+ }
+ FX_BOOL bIsDropDown = IsDropDownStyle();
+ if (bIsDropDown && m_pEdit) {
+ CFX_RectF rtEdit;
+ rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
+ m_rtContent.height);
+ m_pEdit->SetWidgetRect(rtEdit);
+ if (m_iCurSel >= 0) {
+ CFX_WideString wsText;
+ IFWL_ComboBoxDP* pData = (IFWL_ComboBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())
+ ->GetItemText(hItem, wsText);
+ m_pEdit->LockUpdate();
+ m_pEdit->SetText(wsText);
+ m_pEdit->UnlockUpdate();
}
- if (DisForm_IsDropListShowed()) {
- m_pListBox->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
+ m_pEdit->Update();
+ }
+}
+CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_OnProcessMessage(pMessage);
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ FX_BOOL iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
}
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FWL_ERR CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- CFX_Matrix mtOrg;
- mtOrg.Set(1, 0, 0, 1, 0, 0);
- if (pMatrix) {
- mtOrg = *pMatrix;
- }
- FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed();
- pGraphics->SaveGraphState();
- pGraphics->ConcatMatrix(&mtOrg);
- if (!m_rtBtn.IsEmpty(0.1f)) {
- CFWL_ThemeBackground param;
- param.m_pWidget = (IFWL_Widget*)this->m_pInterface;
- param.m_iPart = FWL_PART_CMB_DropDownButton;
- param.m_dwStates = m_iBtnState;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = m_rtBtn;
- pTheme->DrawBackground(¶m);
- }
- pGraphics->RestoreGraphState();
- if (m_pEdit) {
- CFX_RectF rtEdit;
- m_pEdit->GetWidgetRect(rtEdit);
- CFX_Matrix mt;
- mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
- mt.Concat(mtOrg);
- m_pEdit->DrawWidget(pGraphics, &mt);
- }
- if (bListShowed) {
- CFX_RectF rtList;
- m_pListBox->GetWidgetRect(rtList);
- CFX_Matrix mt;
- mt.Set(1, 0, 0, 1, rtList.left, rtList.top);
- mt.Concat(mtOrg);
- m_pListBox->DrawWidget(pGraphics, &mt);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF &rect)
-{
- rect = m_pProperties->m_rtWidget;
- if (m_pListBox && DisForm_IsDropListShowed()) {
- CFX_RectF rtList;
- m_pListBox->GetWidgetRect(rtList);
- rtList.Offset(rect.left, rect.top);
- rect.Union(rtList);
- }
- return FWL_ERR_Succeeded;
-}
-void CFWL_ComboBoxImp::DisForm_Layout()
-{
- GetClientRect(m_rtClient);
- m_rtContent = m_rtClient;
- FX_FLOAT *pFWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_IF_FAIL(pFWidth);
- FX_FLOAT borderWidth = 0;
- {
- borderWidth = FWL_PART_CMB_Border;
- }
- FX_FLOAT fBtn = *pFWidth;
- if (!(this->GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
- m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
- fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
- }
- CFX_RectF* pUIMargin = (CFX_RectF*)GetThemeCapacity(FWL_WGTCAPACITY_UIMargin);
- if (pUIMargin) {
- m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, pUIMargin->height);
- }
- FX_BOOL bIsDropDown = IsDropDownStyle();
- if (bIsDropDown && m_pEdit) {
- CFX_RectF rtEdit;
- rtEdit.Set(m_rtContent.left,
- m_rtContent.top, m_rtContent.width - fBtn, m_rtContent.height);
- m_pEdit->SetWidgetRect(rtEdit);
- if (m_iCurSel >= 0) {
- CFX_WideString wsText;
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pListBox)->GetData())->GetItemText(hItem, wsText);
- m_pEdit->LockUpdate();
- m_pEdit->SetText(wsText);
- m_pEdit->UnlockUpdate();
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- m_pEdit->Update();
- }
-}
-CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_OnProcessMessage(pMessage);
- }
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- FX_BOOL iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch(dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_Key: {
- OnKey((CFWL_MsgKey*)pMessage);
- break;
- }
- default: {
- iRet = 0;
- }
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- FX_DWORD dwFlag = pEvent->GetClassID();
- if (dwFlag == FWL_EVTHASH_LTB_DrawItem) {
- CFWL_EvtCmbDrawItem pTemp;
- pTemp.m_pSrcTarget = m_pOwner->m_pInterface;
- pTemp.m_pGraphics = ((CFWL_EvtLtbDrawItem *)pEvent)->m_pGraphics;
- pTemp.m_index = ((CFWL_EvtLtbDrawItem *)pEvent)->m_index;
- pTemp.m_rtItem = ((CFWL_EvtLtbDrawItem *)pEvent)->m_rect;
- m_pOwner->DispatchEvent(&pTemp);
- } else if (dwFlag == FWL_EVTHASH_Scroll) {
- FX_DWORD dwScrollCode = ((CFWL_EvtScroll*)pEvent)->m_iScrollCode;
- FX_FLOAT fPos = ((CFWL_EvtScroll*)pEvent)->m_fPos;
- CFWL_EvtScroll pScrollEv;
- pScrollEv.m_pSrcTarget = m_pOwner->m_pInterface;
- pScrollEv.m_iScrollCode = dwScrollCode;
- pScrollEv.m_fPos = fPos;
- m_pOwner->DispatchEvent(&pScrollEv);
- } else if (dwFlag == FWL_EVTHASH_EDT_TextChanged) {
- CFWL_EvtCmbEditChanged pTemp;
- pTemp.m_pSrcTarget = m_pOwner->m_pInterface;
- pTemp.wsInsert = ((CFWL_EvtEdtTextChanged *)pEvent)->wsInsert;
- pTemp.wsDelete = ((CFWL_EvtEdtTextChanged *)pEvent)->wsDelete;
- pTemp.nChangeType = ((CFWL_EvtEdtTextChanged *)pEvent)->nChangeType;
- m_pOwner->DispatchEvent(&pTemp);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet )
-{
- IFWL_Target *pDstTarget = pMsg->m_pDstTarget;
- IFWL_Target *pSrcTarget = pMsg->m_pSrcTarget;
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if (bDropDown && pSrcTarget != (IFWL_Widget*)m_pOwner->m_pListBox) {
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdit);
- ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pOwner->m_pEdit)->GetData())->SetSelected();
- } else {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
}
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- if (bDropDown && pDstTarget != (IFWL_Widget*)m_pOwner->m_pListBox) {
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdit);
- ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pOwner->m_pEdit)->GetData())->FlagFocus(FALSE);
- ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pOwner->m_pEdit)->GetData())->ClearSelected();
- } else {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- }
-}
-void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- return;
- }
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
- FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
- if (bClickBtn) {
- if (bDropDown && m_pOwner->m_pEdit) {
- m_pOwner->MatchEditText();
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave(pMsg);
+ break;
}
- m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Pressed;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- m_pOwner->ShowDropList(TRUE);
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
-}
-void CFWL_ComboBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->m_bLButtonDown = FALSE;
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Hovered;
+ default: {}
+ }
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ OnKey((CFWL_MsgKey*)pMessage);
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
+}
+FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ FX_DWORD dwFlag = pEvent->GetClassID();
+ if (dwFlag == FWL_EVTHASH_LTB_DrawItem) {
+ CFWL_EvtCmbDrawItem pTemp;
+ pTemp.m_pSrcTarget = m_pOwner->m_pInterface;
+ pTemp.m_pGraphics = ((CFWL_EvtLtbDrawItem*)pEvent)->m_pGraphics;
+ pTemp.m_index = ((CFWL_EvtLtbDrawItem*)pEvent)->m_index;
+ pTemp.m_rtItem = ((CFWL_EvtLtbDrawItem*)pEvent)->m_rect;
+ m_pOwner->DispatchEvent(&pTemp);
+ } else if (dwFlag == FWL_EVTHASH_Scroll) {
+ FX_DWORD dwScrollCode = ((CFWL_EvtScroll*)pEvent)->m_iScrollCode;
+ FX_FLOAT fPos = ((CFWL_EvtScroll*)pEvent)->m_fPos;
+ CFWL_EvtScroll pScrollEv;
+ pScrollEv.m_pSrcTarget = m_pOwner->m_pInterface;
+ pScrollEv.m_iScrollCode = dwScrollCode;
+ pScrollEv.m_fPos = fPos;
+ m_pOwner->DispatchEvent(&pScrollEv);
+ } else if (dwFlag == FWL_EVTHASH_EDT_TextChanged) {
+ CFWL_EvtCmbEditChanged pTemp;
+ pTemp.m_pSrcTarget = m_pOwner->m_pInterface;
+ pTemp.wsInsert = ((CFWL_EvtEdtTextChanged*)pEvent)->wsInsert;
+ pTemp.wsDelete = ((CFWL_EvtEdtTextChanged*)pEvent)->wsDelete;
+ pTemp.nChangeType = ((CFWL_EvtEdtTextChanged*)pEvent)->nChangeType;
+ m_pOwner->DispatchEvent(&pTemp);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ IFWL_Target* pDstTarget = pMsg->m_pDstTarget;
+ IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget;
+ FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if (bDropDown && pSrcTarget != (IFWL_Widget*)m_pOwner->m_pListBox) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdit);
+ ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pOwner->m_pEdit)->GetData())
+ ->SetSelected();
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
-}
-void CFWL_ComboBoxImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- int32_t iOldState = m_pOwner->m_iBtnState;
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown ? FWL_PARTSTATE_CMB_Pressed : FWL_PARTSTATE_CMB_Hovered;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ if (bDropDown && pDstTarget != (IFWL_Widget*)m_pOwner->m_pListBox) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdit);
+ ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pOwner->m_pEdit)->GetData())
+ ->FlagFocus(FALSE);
+ ((CFWL_ComboEdit*)((IFWL_TargetData*)m_pOwner->m_pEdit)->GetData())
+ ->ClearSelected();
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
- }
- if ( (iOldState != m_pOwner->m_iBtnState) &&
- !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == FWL_WGTSTATE_Disabled)) {
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
- }
-}
-void CFWL_ComboBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- if (!m_pOwner->IsDropListShowed() &&
- !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == FWL_WGTSTATE_Disabled)) {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
- }
-}
-void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey *pMsg)
-{
- FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
- if (dwKeyCode == FWL_VKEY_Tab) {
- m_pOwner->DispatchKeyEvent(pMsg);
- return;
- }
- FX_BOOL bSubCtrlKey = pMsg->m_pDstTarget == m_pOwner->m_pInterface;
- if (bSubCtrlKey) {
- DoSubCtrlKey(pMsg);
- }
-}
-void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey *pMsg)
-{
- FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
- FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up;
- FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down;
- if (bUp || bDown) {
- int32_t iCount = ((CFWL_ComboList*)((IFWL_TargetData*)m_pOwner->m_pListBox)->GetData())->CountItems();
- if (iCount < 1) {
- return;
- }
- FX_BOOL bMatchEqual = FALSE;
- int32_t iCurSel = m_pOwner->m_iCurSel;
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- if (bDropDown && m_pOwner->m_pEdit) {
- CFX_WideString wsText;
- m_pOwner->m_pEdit->GetText(wsText);
- iCurSel = ((CFWL_ComboList*)((IFWL_TargetData*)m_pOwner->m_pListBox)->GetData())->MatchItem(wsText);
- if (iCurSel >= 0) {
- CFX_WideString wsTemp;
- IFWL_ComboBoxDP *pData = (IFWL_ComboBoxDP *)m_pOwner->m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel);
- ((CFWL_ComboList*)((IFWL_TargetData*)m_pOwner->m_pListBox)->GetData())->GetItemText(hItem, wsTemp);
- bMatchEqual = wsText.Equal(wsTemp);
- }
- }
- if (iCurSel < 0) {
- iCurSel = 0;
- } else if (!bDropDown || bMatchEqual) {
- if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
- return;
- }
- if (bUp) {
- iCurSel --;
- } else {
- iCurSel ++;
- }
- }
- m_pOwner->m_iCurSel = iCurSel;
- if (bDropDown && m_pOwner->m_pEdit) {
- m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
- } else {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- return;
- }
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- if (bDropDown) {
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMsg);
- }
-}
-int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- FX_BOOL backDefault = TRUE;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- backDefault = FALSE;
- DisForm_OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- backDefault = FALSE;
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch(dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- DisForm_OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_Key: {
- backDefault = FALSE;
- CFWL_MsgKey *pKey = (CFWL_MsgKey*)pMessage;
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) {
- break;
- }
- if (m_pOwner->DisForm_IsDropListShowed() && pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
- FX_DWORD dwKeyCode = pKey->m_dwKeyCode;
- FX_BOOL bListKey = dwKeyCode == FWL_VKEY_Up ||
- dwKeyCode == FWL_VKEY_Down ||
- dwKeyCode == FWL_VKEY_Return ||
- dwKeyCode == FWL_VKEY_Escape;
- if (bListKey) {
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pListBox->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMessage);
- break;
- }
- }
- DisForm_OnKey((CFWL_MsgKey*)pMessage);
- break;
- }
- default: {
- }
- }
- if (!backDefault) {
- return 1;
- }
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
-}
-void CFWL_ComboBoxImpDelegate::DisForm_OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- FX_BOOL bDropDown = m_pOwner->DisForm_IsDropListShowed();
- CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
- FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
- if (bClickBtn) {
- if (m_pOwner->DisForm_IsDropListShowed()) {
- m_pOwner->DisForm_ShowDropList(FALSE);
- return;
- }
- {
- if (m_pOwner->m_pEdit) {
- m_pOwner->MatchEditText();
- }
- m_pOwner->DisForm_ShowDropList(TRUE);
- }
- }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ }
+}
+void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ return;
+ }
+ FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
+ CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
+ FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
+ if (bClickBtn) {
+ if (bDropDown && m_pOwner->m_pEdit) {
+ m_pOwner->MatchEditText();
+ }
+ m_pOwner->m_bLButtonDown = TRUE;
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Pressed;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ m_pOwner->ShowDropList(TRUE);
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+}
+void CFWL_ComboBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_pOwner->m_bLButtonDown = FALSE;
+ if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Hovered;
+ } else {
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+}
+void CFWL_ComboBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ int32_t iOldState = m_pOwner->m_iBtnState;
+ if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown
+ ? FWL_PARTSTATE_CMB_Pressed
+ : FWL_PARTSTATE_CMB_Hovered;
+ } else {
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ }
+ if ((iOldState != m_pOwner->m_iBtnState) &&
+ !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
+ FWL_WGTSTATE_Disabled)) {
+ m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+ }
}
-void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet)
-{
- IFWL_Target *pDstTarget = pMsg->m_pDstTarget;
- IFWL_Target *pSrcTarget = pMsg->m_pSrcTarget;
+void CFWL_ComboBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ if (!m_pOwner->IsDropListShowed() &&
+ !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
+ FWL_WGTSTATE_Disabled)) {
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+ }
+}
+void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey* pMsg) {
+ FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
+ if (dwKeyCode == FWL_VKEY_Tab) {
+ m_pOwner->DispatchKeyEvent(pMsg);
+ return;
+ }
+ FX_BOOL bSubCtrlKey = pMsg->m_pDstTarget == m_pOwner->m_pInterface;
+ if (bSubCtrlKey) {
+ DoSubCtrlKey(pMsg);
+ }
+}
+void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
+ FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
+ FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up;
+ FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down;
+ if (bUp || bDown) {
+ int32_t iCount =
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pOwner->m_pListBox)->GetData())
+ ->CountItems();
+ if (iCount < 1) {
+ return;
+ }
+ FX_BOOL bMatchEqual = FALSE;
+ int32_t iCurSel = m_pOwner->m_iCurSel;
FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) {
- CFWL_MsgSetFocus msg;
- msg.m_pDstTarget = m_pOwner->m_pEdit;
- msg.m_pSrcTarget = NULL;
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(&msg);
- }
+ if (bDropDown && m_pOwner->m_pEdit) {
+ CFX_WideString wsText;
+ m_pOwner->m_pEdit->GetText(wsText);
+ iCurSel =
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pOwner->m_pListBox)->GetData())
+ ->MatchItem(wsText);
+ if (iCurSel >= 0) {
+ CFX_WideString wsTemp;
+ IFWL_ComboBoxDP* pData =
+ (IFWL_ComboBoxDP*)m_pOwner->m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel);
+ ((CFWL_ComboList*)((IFWL_TargetData*)m_pOwner->m_pListBox)->GetData())
+ ->GetItemText(hItem, wsTemp);
+ bMatchEqual = wsText.Equal(wsTemp);
+ }
+ }
+ if (iCurSel < 0) {
+ iCurSel = 0;
+ } else if (!bDropDown || bMatchEqual) {
+ if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
+ return;
+ }
+ if (bUp) {
+ iCurSel--;
+ } else {
+ iCurSel++;
+ }
+ }
+ m_pOwner->m_iCurSel = iCurSel;
+ if (bDropDown && m_pOwner->m_pEdit) {
+ m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_pOwner->DisForm_ShowDropList(FALSE);
- CFWL_MsgKillFocus msg;
- msg.m_pDstTarget = NULL;
- msg.m_pSrcTarget = m_pOwner->m_pEdit;
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(&msg);
- }
-}
-void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey *pMsg)
-{
- FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
- FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up;
- FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down;
- if (bUp || bDown) {
- CFWL_ComboList* pComboList = ((CFWL_ComboList*)((IFWL_TargetData*)(m_pOwner->m_pListBox))->GetData());
- int32_t iCount = pComboList->CountItems();
- if (iCount < 1) {
- return;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ return;
+ }
+ FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
+ if (bDropDown) {
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMsg);
+ }
+}
+int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
+ CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ FX_BOOL backDefault = TRUE;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ backDefault = FALSE;
+ DisForm_OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ backDefault = FALSE;
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ DisForm_OnLButtonDown(pMsg);
+ break;
}
- FX_BOOL bMatchEqual = FALSE;
- int32_t iCurSel = m_pOwner->m_iCurSel;
- if (m_pOwner->m_pEdit) {
- CFX_WideString wsText;
- m_pOwner->m_pEdit->GetText(wsText);
- iCurSel = pComboList->MatchItem(wsText);
- if (iCurSel >= 0) {
- CFX_WideString wsTemp;
- FWL_HLISTITEM item = m_pOwner->m_pListBox->GetSelItem(iCurSel);
- m_pOwner->m_pListBox->GetItemText(item, wsTemp);
- bMatchEqual = wsText.Equal(wsTemp);
- }
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- if (iCurSel < 0) {
- iCurSel = 0;
- } else if (bMatchEqual) {
- if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
- return;
- }
- if (bUp) {
- iCurSel --;
- } else {
- iCurSel ++;
- }
- }
- m_pOwner->m_iCurSel = iCurSel;
- m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
- return;
- }
- if (m_pOwner->m_pEdit) {
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMsg);
- }
-}
-CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form *pForm, CFWL_ComboBoxImp *pComboBox)
- : m_pForm(pForm)
- , m_pComboBox(pComboBox)
- , m_bLButtonDown(FALSE)
- , m_bLButtonUpSelf(FALSE)
- , m_fStartPos(0)
-{
-}
-int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- if (dwMsgCode == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch(dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- default: {
- }
+ default: {}
+ }
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ backDefault = FALSE;
+ CFWL_MsgKey* pKey = (CFWL_MsgKey*)pMessage;
+ if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) {
+ break;
+ }
+ if (m_pOwner->DisForm_IsDropListShowed() &&
+ pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ FX_DWORD dwKeyCode = pKey->m_dwKeyCode;
+ FX_BOOL bListKey =
+ dwKeyCode == FWL_VKEY_Up || dwKeyCode == FWL_VKEY_Down ||
+ dwKeyCode == FWL_VKEY_Return || dwKeyCode == FWL_VKEY_Escape;
+ if (bListKey) {
+ IFWL_WidgetDelegate* pDelegate =
+ m_pOwner->m_pListBox->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMessage);
+ break;
}
+ }
+ DisForm_OnKey((CFWL_MsgKey*)pMessage);
+ break;
}
- if (dwMsgCode == FWL_MSGHASH_Deactivate) {
- OnDeactive((CFWL_MsgDeactivate*)pMessage);
- }
- if (dwMsgCode == FWL_MSGHASH_KillFocus || dwMsgCode == FWL_MSGHASH_SetFocus) {
- OnFocusChanged((CFWL_MsgKillFocus*)pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ default: {}
+ }
+ if (!backDefault) {
+ return 1;
+ }
+ return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+}
+void CFWL_ComboBoxImpDelegate::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ FX_BOOL bDropDown = m_pOwner->DisForm_IsDropListShowed();
+ CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
+ FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
+ if (bClickBtn) {
+ if (m_pOwner->DisForm_IsDropListShowed()) {
+ m_pOwner->DisForm_ShowDropList(FALSE);
+ return;
}
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
-}
-FWL_ERR CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
- return FWL_ERR_Succeeded;
-}
-void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- IFWL_NoteThread *pThread = m_pForm->GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- CFX_RectF rtWidget;
- m_pForm->GetWidgetRect(rtWidget);
- rtWidget.left = rtWidget.top = 0;
- if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_bLButtonDown = TRUE;
- pDriver->SetGrab(m_pForm, TRUE);
- } else {
- m_bLButtonDown = FALSE;
- pDriver->SetGrab(m_pForm, FALSE);
- m_pComboBox->ShowDropList(FALSE);
+ {
+ if (m_pOwner->m_pEdit) {
+ m_pOwner->MatchEditText();
+ }
+ m_pOwner->DisForm_ShowDropList(TRUE);
+ }
+ }
+}
+void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ IFWL_Target* pDstTarget = pMsg->m_pDstTarget;
+ IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget;
+ FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) {
+ CFWL_MsgSetFocus msg;
+ msg.m_pDstTarget = m_pOwner->m_pEdit;
+ msg.m_pSrcTarget = NULL;
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(&msg);
+ }
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ m_pOwner->DisForm_ShowDropList(FALSE);
+ CFWL_MsgKillFocus msg;
+ msg.m_pDstTarget = NULL;
+ msg.m_pSrcTarget = m_pOwner->m_pEdit;
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(&msg);
+ }
+}
+void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) {
+ FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
+ FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up;
+ FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down;
+ if (bUp || bDown) {
+ CFWL_ComboList* pComboList =
+ ((CFWL_ComboList*)((IFWL_TargetData*)(m_pOwner->m_pListBox))
+ ->GetData());
+ int32_t iCount = pComboList->CountItems();
+ if (iCount < 1) {
+ return;
+ }
+ FX_BOOL bMatchEqual = FALSE;
+ int32_t iCurSel = m_pOwner->m_iCurSel;
+ if (m_pOwner->m_pEdit) {
+ CFX_WideString wsText;
+ m_pOwner->m_pEdit->GetText(wsText);
+ iCurSel = pComboList->MatchItem(wsText);
+ if (iCurSel >= 0) {
+ CFX_WideString wsTemp;
+ FWL_HLISTITEM item = m_pOwner->m_pListBox->GetSelItem(iCurSel);
+ m_pOwner->m_pListBox->GetItemText(item, wsTemp);
+ bMatchEqual = wsText.Equal(wsTemp);
+ }
+ }
+ if (iCurSel < 0) {
+ iCurSel = 0;
+ } else if (bMatchEqual) {
+ if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
return;
- }
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- IFWL_AdapterCursorMgr *pCursorMgr = pNative->GetCursorMgr();
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_pForm->TransformTo(NULL, pMsg->m_fx, pMsg->m_fy);
- m_fStartPos = pMsg->m_fy;
-}
-void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
+ }
+ if (bUp) {
+ iCurSel--;
+ } else {
+ iCurSel++;
+ }
+ }
+ m_pOwner->m_iCurSel = iCurSel;
+ m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
+ return;
+ }
+ if (m_pOwner->m_pEdit) {
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMsg);
+ }
+}
+CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(
+ IFWL_Form* pForm,
+ CFWL_ComboBoxImp* pComboBox)
+ : m_pForm(pForm),
+ m_pComboBox(pComboBox),
+ m_bLButtonDown(FALSE),
+ m_bLButtonUpSelf(FALSE),
+ m_fStartPos(0) {}
+int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ if (dwMsgCode == FWL_MSGHASH_Mouse) {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
+ }
+ default: {}
+ }
+ }
+ if (dwMsgCode == FWL_MSGHASH_Deactivate) {
+ OnDeactive((CFWL_MsgDeactivate*)pMessage);
+ }
+ if (dwMsgCode == FWL_MSGHASH_KillFocus || dwMsgCode == FWL_MSGHASH_SetFocus) {
+ OnFocusChanged((CFWL_MsgKillFocus*)pMessage,
+ dwMsgCode == FWL_MSGHASH_SetFocus);
+ }
+ return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+}
+FWL_ERR CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
+ return FWL_ERR_Succeeded;
+}
+void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ CFX_RectF rtWidget;
+ m_pForm->GetWidgetRect(rtWidget);
+ rtWidget.left = rtWidget.top = 0;
+ if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_bLButtonDown = TRUE;
+ pDriver->SetGrab(m_pForm, TRUE);
+ } else {
m_bLButtonDown = FALSE;
- IFWL_NoteThread *pThread = m_pForm->GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
pDriver->SetGrab(m_pForm, FALSE);
- if (m_bLButtonUpSelf) {
- CFX_RectF rect;
- m_pForm->GetWidgetRect(rect);
- rect.left = rect.top = 0;
- if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && m_pComboBox->IsDropListShowed()) {
- m_pComboBox->ShowDropList(FALSE);
- }
- } else {
- m_bLButtonUpSelf = TRUE;
- }
-}
-void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- IFWL_AdapterCursorMgr *pCursorMgr = pNative->GetCursorMgr();
- FWL_CURSORTYPE cursorType = FWL_CURSORTYPE_Arrow;
- if (m_pComboBox->m_rtHandler.Contains(pMsg->m_fx, pMsg->m_fy)) {
- cursorType = FWL_CURSORTYPE_SizeNS;
- }
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(cursorType);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!m_bLButtonDown) {
- return;
- }
- m_pForm->TransformTo(NULL, pMsg->m_fx, pMsg->m_fy);
- FX_FLOAT fChanged = pMsg->m_fy - m_fStartPos;
- if (m_pComboBox->m_bUpFormHandler) {
- fChanged = m_fStartPos - pMsg->m_fy;
- }
- if (m_pComboBox->m_rtList.height + fChanged < m_pComboBox->m_fItemHeight) {
- return;
- }
- m_pComboBox->m_rtList.height += fChanged;
- m_pComboBox->m_rtProxy.height += fChanged;
- if (m_pComboBox->m_bUpFormHandler) {
- m_pComboBox->m_rtProxy.top -= fChanged;
- m_pComboBox->m_rtHandler.Set(0,
- 0,
- m_pComboBox->m_rtList.width,
- m_pComboBox->m_fComboFormHandler);
- } else {
- m_pComboBox->m_rtHandler.Set(0,
- m_pComboBox->m_rtList.height,
- m_pComboBox->m_rtList.width,
- m_pComboBox->m_fComboFormHandler);
- }
- m_pForm->SetWidgetRect(m_pComboBox->m_rtProxy);
- m_pComboBox->m_pListBox->SetWidgetRect(m_pComboBox->m_rtList);
- m_pComboBox->m_pListBox->Update();
- m_fStartPos = pMsg->m_fy;
-}
-void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate *pMsg)
-{
m_pComboBox->ShowDropList(FALSE);
-}
-void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus *pMsg, FX_BOOL bSet )
-{
- if (!bSet) {
- if (pMsg->m_pSetFocus == NULL) {
- m_pComboBox->ShowDropList(FALSE);
- }
- }
+ return;
+ }
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr();
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_pForm->TransformTo(NULL, pMsg->m_fx, pMsg->m_fy);
+ m_fStartPos = pMsg->m_fy;
+}
+void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_bLButtonDown = FALSE;
+ IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ pDriver->SetGrab(m_pForm, FALSE);
+ if (m_bLButtonUpSelf) {
+ CFX_RectF rect;
+ m_pForm->GetWidgetRect(rect);
+ rect.left = rect.top = 0;
+ if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
+ m_pComboBox->IsDropListShowed()) {
+ m_pComboBox->ShowDropList(FALSE);
+ }
+ } else {
+ m_bLButtonUpSelf = TRUE;
+ }
+}
+void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr();
+ FWL_CURSORTYPE cursorType = FWL_CURSORTYPE_Arrow;
+ if (m_pComboBox->m_rtHandler.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ cursorType = FWL_CURSORTYPE_SizeNS;
+ }
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(cursorType);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!m_bLButtonDown) {
+ return;
+ }
+ m_pForm->TransformTo(NULL, pMsg->m_fx, pMsg->m_fy);
+ FX_FLOAT fChanged = pMsg->m_fy - m_fStartPos;
+ if (m_pComboBox->m_bUpFormHandler) {
+ fChanged = m_fStartPos - pMsg->m_fy;
+ }
+ if (m_pComboBox->m_rtList.height + fChanged < m_pComboBox->m_fItemHeight) {
+ return;
+ }
+ m_pComboBox->m_rtList.height += fChanged;
+ m_pComboBox->m_rtProxy.height += fChanged;
+ if (m_pComboBox->m_bUpFormHandler) {
+ m_pComboBox->m_rtProxy.top -= fChanged;
+ m_pComboBox->m_rtHandler.Set(0, 0, m_pComboBox->m_rtList.width,
+ m_pComboBox->m_fComboFormHandler);
+ } else {
+ m_pComboBox->m_rtHandler.Set(0, m_pComboBox->m_rtList.height,
+ m_pComboBox->m_rtList.width,
+ m_pComboBox->m_fComboFormHandler);
+ }
+ m_pForm->SetWidgetRect(m_pComboBox->m_rtProxy);
+ m_pComboBox->m_pListBox->SetWidgetRect(m_pComboBox->m_rtList);
+ m_pComboBox->m_pListBox->Update();
+ m_fStartPos = pMsg->m_fy;
+}
+void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate* pMsg) {
+ m_pComboBox->ShowDropList(FALSE);
+}
+void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg,
+ FX_BOOL bSet) {
+ if (!bSet) {
+ if (pMsg->m_pSetFocus == NULL) {
+ m_pComboBox->ShowDropList(FALSE);
+ }
+ }
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp b/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp index 4c30244410..7bf4f0d8aa 100644 --- a/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp @@ -15,1188 +15,1154 @@ #include "include/fwl_editimp.h"
#include "include/fwl_monthcalendarimp.h"
#include "include/fwl_datetimepickerimp.h"
-#define FWL_DTP_WIDTH 100
-#define FWL_DTP_HEIGHT 20
-IFWL_DateTimePicker* IFWL_DateTimePicker::Create()
-{
- return new IFWL_DateTimePicker;
-}
-FWL_ERR IFWL_DateTimeForm::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_FormProxyImp(properties, pOuter);
- ((CFWL_FormProxyImp*)m_pData)->SetInterface(this);
- return ((CFWL_FormProxyImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_DateTimeCalender::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_DateTimeCalendar(properties, pOuter);
- ((CFWL_DateTimeCalendar*)m_pData)->SetInterface(this);
- return ((CFWL_DateTimeCalendar*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_DateTimeEdit::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_DateTimeEdit(properties, pOuter);
- ((CFWL_DateTimeEdit*)m_pData)->SetInterface(this);
- return ((CFWL_DateTimeEdit*)m_pData)->Initialize();
-}
-IFWL_DateTimePicker::IFWL_DateTimePicker()
-{
+#define FWL_DTP_WIDTH 100
+#define FWL_DTP_HEIGHT 20
+IFWL_DateTimePicker* IFWL_DateTimePicker::Create() {
+ return new IFWL_DateTimePicker;
+}
+FWL_ERR IFWL_DateTimeForm::Initialize(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_FormProxyImp(properties, pOuter);
+ ((CFWL_FormProxyImp*)m_pData)->SetInterface(this);
+ return ((CFWL_FormProxyImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_DateTimeCalender::Initialize(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_DateTimeCalendar(properties, pOuter);
+ ((CFWL_DateTimeCalendar*)m_pData)->SetInterface(this);
+ return ((CFWL_DateTimeCalendar*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_DateTimeEdit::Initialize(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_DateTimeEdit(properties, pOuter);
+ ((CFWL_DateTimeEdit*)m_pData)->SetInterface(this);
+ return ((CFWL_DateTimeEdit*)m_pData)->Initialize();
+}
+IFWL_DateTimePicker::IFWL_DateTimePicker() {
+ m_pData = NULL;
+}
+IFWL_DateTimePicker::~IFWL_DateTimePicker() {
+ if (m_pData) {
+ delete (CFWL_DateTimePickerImp*)m_pData;
m_pData = NULL;
+ }
}
-IFWL_DateTimePicker::~IFWL_DateTimePicker()
-{
- if (m_pData) {
- delete (CFWL_DateTimePickerImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_DateTimePicker::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_DateTimePickerImp(pOuter);
- ((CFWL_DateTimePickerImp*)m_pData)->SetInterface(this);
- return ((CFWL_DateTimePickerImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_DateTimePicker::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_DateTimePickerImp(properties, pOuter);
- ((CFWL_DateTimePickerImp*)m_pData)->SetInterface(this);
- return ((CFWL_DateTimePickerImp*)m_pData)->Initialize();
-}
-int32_t IFWL_DateTimePicker::CountSelRanges()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->GetDataTimeEdit()->CountSelRanges();
-}
-int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t &nStart)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->GetDataTimeEdit()->GetSelRange(nIndex, nStart);
-}
-FWL_ERR IFWL_DateTimePicker::GetCurSel(int32_t &iYear, int32_t &iMonth, int32_t &iDay)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->GetCurSel(iYear, iMonth, iDay);
-}
-FWL_ERR IFWL_DateTimePicker::SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->SetCurSel(iYear, iMonth, iDay);
-}
-FWL_ERR IFWL_DateTimePicker::SetEditText(const CFX_WideString &wsText)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->SetEditText(wsText);
-}
-FWL_ERR IFWL_DateTimePicker::GetEditText(CFX_WideString &wsText, int32_t nStart, int32_t nCount) const
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->GetEditText(wsText, nStart, nCount);
-}
-FX_BOOL IFWL_DateTimePicker::CanUndo()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->CanUndo();
-}
-FX_BOOL IFWL_DateTimePicker::CanRedo()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->CanRedo();
-}
-FX_BOOL IFWL_DateTimePicker::Undo()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->Undo();
-}
-FX_BOOL IFWL_DateTimePicker::Redo()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->Redo();
-}
-FX_BOOL IFWL_DateTimePicker::CanCopy()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->CanCopy();
-}
-FX_BOOL IFWL_DateTimePicker::CanCut()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->CanCut();
-}
-FX_BOOL IFWL_DateTimePicker::CanSelectAll()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->CanSelectAll();
-}
-FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString &wsCopy)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->Copy(wsCopy);
-}
-FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString &wsCut)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->Cut(wsCut);
-}
-FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString &wsPaste)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->Paste(wsPaste);
-}
-FX_BOOL IFWL_DateTimePicker::SelectAll()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->SelectAll();
-}
-FX_BOOL IFWL_DateTimePicker::Delete()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->Delete();
-}
-FX_BOOL IFWL_DateTimePicker::DeSelect()
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->DeSelect();
-}
-FWL_ERR IFWL_DateTimePicker::GetBBox(CFX_RectF &rect)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->GetBBox(rect);
-}
-FWL_ERR IFWL_DateTimePicker::SetEditLimit(int32_t nLimit)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->SetEditLimit(nLimit);
-}
-FWL_ERR IFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- return ((CFWL_DateTimePickerImp*)m_pData)->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_EditImp(properties, pOuter)
-{
-}
-FWL_ERR CFWL_DateTimeEdit::Initialize()
-{
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_DateTimeEditDelegate(this);
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_EditImp::Initialize(), FWL_ERR_Indefinite);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimeEdit::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_DateTimeEditDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_EditImp::Finalize();
-}
-CFWL_DateTimeEditDelegate::CFWL_DateTimeEditDelegate(CFWL_DateTimeEdit *pOwner)
- : CFWL_EditImpDelegate(pOwner)
- , m_pOwner(pOwner)
-{
+FWL_ERR IFWL_DateTimePicker::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_DateTimePickerImp(pOuter);
+ ((CFWL_DateTimePickerImp*)m_pData)->SetInterface(this);
+ return ((CFWL_DateTimePickerImp*)m_pData)->Initialize();
}
-int32_t CFWL_DateTimeEditDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_OnProcessMessage(pMessage);
- }
- FX_DWORD dwHashCode = pMessage->GetClassID();
- if (dwHashCode == FWL_MSGHASH_SetFocus || dwHashCode == FWL_MSGHASH_KillFocus) {
- IFWL_Widget *pOuter = m_pOwner->GetOuter();
- IFWL_WidgetDelegate *pDelegate = pOuter->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMessage);
- }
- return 1;
-}
-int32_t CFWL_DateTimeEditDelegate::DisForm_OnProcessMessage(CFWL_Message *pMessage)
-{
- FX_DWORD dwHashCode = pMessage->GetClassID();
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- if (dwHashCode == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse *pMouse = (CFWL_MsgMouse*)pMessage;
- if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown || pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- }
- CFWL_DateTimePickerImp *pDateTime = (CFWL_DateTimePickerImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
- if (pDateTime->IsMonthCalendarShowed()) {
- CFX_RectF rtInvalidate;
- pDateTime->GetWidgetRect(rtInvalidate);
- pDateTime->ShowMonthCalendar(FALSE);
- rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top);
- pDateTime->Repaint(&rtInvalidate);
- }
- }
- } else if (dwHashCode == FWL_MSGHASH_Key) {
- return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+FWL_ERR IFWL_DateTimePicker::Initialize(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_DateTimePickerImp(properties, pOuter);
+ ((CFWL_DateTimePickerImp*)m_pData)->SetInterface(this);
+ return ((CFWL_DateTimePickerImp*)m_pData)->Initialize();
+}
+int32_t IFWL_DateTimePicker::CountSelRanges() {
+ return ((CFWL_DateTimePickerImp*)m_pData)
+ ->GetDataTimeEdit()
+ ->CountSelRanges();
+}
+int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ return ((CFWL_DateTimePickerImp*)m_pData)
+ ->GetDataTimeEdit()
+ ->GetSelRange(nIndex, nStart);
+}
+FWL_ERR IFWL_DateTimePicker::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->GetCurSel(iYear, iMonth, iDay);
+}
+FWL_ERR IFWL_DateTimePicker::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->SetCurSel(iYear, iMonth, iDay);
+}
+FWL_ERR IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->SetEditText(wsText);
+}
+FWL_ERR IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ return ((CFWL_DateTimePickerImp*)m_pData)
+ ->GetEditText(wsText, nStart, nCount);
+}
+FX_BOOL IFWL_DateTimePicker::CanUndo() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->CanUndo();
+}
+FX_BOOL IFWL_DateTimePicker::CanRedo() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->CanRedo();
+}
+FX_BOOL IFWL_DateTimePicker::Undo() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->Undo();
+}
+FX_BOOL IFWL_DateTimePicker::Redo() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->Redo();
+}
+FX_BOOL IFWL_DateTimePicker::CanCopy() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->CanCopy();
+}
+FX_BOOL IFWL_DateTimePicker::CanCut() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->CanCut();
+}
+FX_BOOL IFWL_DateTimePicker::CanSelectAll() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->CanSelectAll();
+}
+FX_BOOL IFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->Copy(wsCopy);
+}
+FX_BOOL IFWL_DateTimePicker::Cut(CFX_WideString& wsCut) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->Cut(wsCut);
+}
+FX_BOOL IFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->Paste(wsPaste);
+}
+FX_BOOL IFWL_DateTimePicker::SelectAll() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->SelectAll();
+}
+FX_BOOL IFWL_DateTimePicker::Delete() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->Delete();
+}
+FX_BOOL IFWL_DateTimePicker::DeSelect() {
+ return ((CFWL_DateTimePickerImp*)m_pData)->DeSelect();
+}
+FWL_ERR IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->GetBBox(rect);
+}
+FWL_ERR IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
+ return ((CFWL_DateTimePickerImp*)m_pData)->SetEditLimit(nLimit);
+}
+FWL_ERR IFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ return ((CFWL_DateTimePickerImp*)m_pData)
+ ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_EditImp(properties, pOuter) {}
+FWL_ERR CFWL_DateTimeEdit::Initialize() {
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_DateTimeEditDelegate(this);
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_EditImp::Initialize(),
+ FWL_ERR_Indefinite);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimeEdit::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_DateTimeEditDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_EditImp::Finalize();
+}
+CFWL_DateTimeEditDelegate::CFWL_DateTimeEditDelegate(CFWL_DateTimeEdit* pOwner)
+ : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
+int32_t CFWL_DateTimeEditDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_OnProcessMessage(pMessage);
+ }
+ FX_DWORD dwHashCode = pMessage->GetClassID();
+ if (dwHashCode == FWL_MSGHASH_SetFocus ||
+ dwHashCode == FWL_MSGHASH_KillFocus) {
+ IFWL_Widget* pOuter = m_pOwner->GetOuter();
+ IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMessage);
+ }
+ return 1;
+}
+int32_t CFWL_DateTimeEditDelegate::DisForm_OnProcessMessage(
+ CFWL_Message* pMessage) {
+ FX_DWORD dwHashCode = pMessage->GetClassID();
+ if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ if (dwHashCode == FWL_MSGHASH_Mouse) {
+ CFWL_MsgMouse* pMouse = (CFWL_MsgMouse*)pMessage;
+ if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown ||
+ pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) {
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
}
- }
- return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
-}
-CFWL_DateTimeCalendar::CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_MonthCalendarImp(properties, pOuter)
-{
-}
-FWL_ERR CFWL_DateTimeCalendar::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_MonthCalendarImp::Initialize(), FWL_ERR_Indefinite);
- if (m_pDelegate) {
- delete (CFWL_MonthCalendarImpDelegate*)m_pDelegate;
- }
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_DateTimeCalendarDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimeCalendar::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_DateTimeCalendarDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_MonthCalendarImp::Finalize();
-}
-CFWL_DateTimeCalendarDelegate::CFWL_DateTimeCalendarDelegate(CFWL_DateTimeCalendar *pOwner)
- : CFWL_MonthCalendarImpDelegate(pOwner)
- , m_pOwner(pOwner)
-{
- m_bFlag = FALSE;
-}
-int32_t CFWL_DateTimeCalendarDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- FX_DWORD dwCode = pMessage->GetClassID();
- if (dwCode == FWL_MSGHASH_SetFocus || dwCode == FWL_MSGHASH_KillFocus) {
- IFWL_Widget *pOuter = m_pOwner->GetOuter();
- IFWL_WidgetDelegate *pDelegate = pOuter->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMessage);
- } else if (dwCode == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) {
- OnLButtonDownEx(pMsg);
- return 1;
- } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
- OnLButtonUpEx(pMsg);
- return 1;
+ CFWL_DateTimePickerImp* pDateTime =
+ (CFWL_DateTimePickerImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)
+ ->GetData();
+ if (pDateTime->IsMonthCalendarShowed()) {
+ CFX_RectF rtInvalidate;
+ pDateTime->GetWidgetRect(rtInvalidate);
+ pDateTime->ShowMonthCalendar(FALSE);
+ rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top);
+ pDateTime->Repaint(&rtInvalidate);
}
- }
- return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
-}
-void CFWL_DateTimeCalendarDelegate::OnLButtonDownEx(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = FWL_PARTSTATE_MCD_Pressed;
- m_pOwner->PrevMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates |= FWL_PARTSTATE_MCD_Pressed;
- m_pOwner->NextMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday ) == 0) {
- m_pOwner->JumpToToday();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- } else {
- IFWL_DateTimePicker *pIPicker = (IFWL_DateTimePicker *)m_pOwner->m_pOuter;
- CFWL_DateTimePickerImp *pPicker = (CFWL_DateTimePickerImp *)((IFWL_TargetData *)pIPicker)->GetData();
- if (pPicker->IsMonthCalendarShowed()) {
- m_bFlag = 1;
- }
- }
-}
-void CFWL_DateTimeCalendarDelegate::OnLButtonUpEx(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_OnLButtonUpEx(pMsg);
- }
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
- return;
- }
- if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
- return;
- }
- if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return;
- }
- int32_t iOldSel = 0;
- if (m_pOwner->m_arrSelDays.GetSize() > 0) {
- iOldSel = m_pOwner->m_arrSelDays[0];
- }
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- CFX_RectF rt;
- IFWL_DateTimePicker *pIPicker = (IFWL_DateTimePicker *)m_pOwner->m_pOuter;
- CFWL_DateTimePickerImp *pPicker = (CFWL_DateTimePickerImp *)((IFWL_TargetData *)pIPicker)->GetData();
- pPicker->m_pForm->GetWidgetRect(rt);
- rt.Set(0, 0, rt.width, rt.height);
- if (iCurSel > 0) {
- LPDATEINFO lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
- CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
- lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
- rtInvalidate.Union(lpDatesInfo->rect);
- }
- m_pOwner->AddSelDay(iCurSel);
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pOuter);
- pPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, iCurSel);
- pPicker->ShowMonthCalendar(FALSE);
- } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) {
- IFWL_DateTimePicker *pIPicker = (IFWL_DateTimePicker *)m_pOwner->m_pOuter;
- CFWL_DateTimePickerImp *pPicker = (CFWL_DateTimePickerImp *)((IFWL_TargetData *)pIPicker)->GetData();
- pPicker->ShowMonthCalendar(FALSE);
- }
- m_bFlag = 0;
-}
-void CFWL_DateTimeCalendarDelegate::OnMouseMoveEx(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
- return;
- }
- FX_BOOL bRepaint = FALSE;
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, 0, 0);
- if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
- int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- bRepaint = m_pOwner->m_iHovered != iHover;
- if (bRepaint) {
- if (m_pOwner->m_iHovered > 0) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
- if (iHover > 0) {
- CFX_RectF rtDay;
- m_pOwner->GetDayRect(iHover, rtDay);
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = rtDay;
- } else {
- rtInvalidate.Union(rtDay);
- }
- }
- }
- m_pOwner->m_iHovered = iHover;
- CFWL_Event_DtpHoverChanged ev;
- ev.hoverday = iHover;
- m_pOwner->DispatchEvent(&ev);
- } else {
- bRepaint = m_pOwner->m_iHovered > 0;
- if (bRepaint) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
- m_pOwner->m_iHovered = -1;
- }
- if (bRepaint && !rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
-}
-int32_t CFWL_DateTimeCalendarDelegate::DisForm_OnProcessMessage(CFWL_Message *pMessage)
-{
- if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
- DisForm_OnLButtonUpEx(pMsg);
- return 1;
- }
- }
- return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
-}
-void CFWL_DateTimeCalendarDelegate::DisForm_OnLButtonUpEx(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = 0;
- m_pOwner->Repaint(&(m_pOwner->m_rtLBtn));
- return;
- }
- if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates = 0;
- m_pOwner->Repaint(&(m_pOwner->m_rtRBtn));
- return;
- }
- if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return;
- }
- int32_t iOldSel = 0;
- if (m_pOwner->m_arrSelDays.GetSize() > 0) {
- iOldSel = m_pOwner->m_arrSelDays[0];
- }
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (iCurSel > 0) {
- LPDATEINFO lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
- CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
- lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
- rtInvalidate.Union(lpDatesInfo->rect);
+ }
+ } else if (dwHashCode == FWL_MSGHASH_Key) {
+ return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+ }
+ }
+ return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+}
+CFWL_DateTimeCalendar::CFWL_DateTimeCalendar(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_MonthCalendarImp(properties, pOuter) {}
+FWL_ERR CFWL_DateTimeCalendar::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_MonthCalendarImp::Initialize(),
+ FWL_ERR_Indefinite);
+ if (m_pDelegate) {
+ delete (CFWL_MonthCalendarImpDelegate*)m_pDelegate;
+ }
+ m_pDelegate =
+ (IFWL_WidgetDelegate*)FX_NEW CFWL_DateTimeCalendarDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimeCalendar::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_DateTimeCalendarDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_MonthCalendarImp::Finalize();
+}
+CFWL_DateTimeCalendarDelegate::CFWL_DateTimeCalendarDelegate(
+ CFWL_DateTimeCalendar* pOwner)
+ : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) {
+ m_bFlag = FALSE;
+}
+int32_t CFWL_DateTimeCalendarDelegate::OnProcessMessage(
+ CFWL_Message* pMessage) {
+ FX_DWORD dwCode = pMessage->GetClassID();
+ if (dwCode == FWL_MSGHASH_SetFocus || dwCode == FWL_MSGHASH_KillFocus) {
+ IFWL_Widget* pOuter = m_pOwner->GetOuter();
+ IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL);
+ return pDelegate->OnProcessMessage(pMessage);
+ } else if (dwCode == FWL_MSGHASH_Mouse) {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) {
+ OnLButtonDownEx(pMsg);
+ return 1;
+ } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
+ OnLButtonUpEx(pMsg);
+ return 1;
+ }
+ }
+ return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
+}
+void CFWL_DateTimeCalendarDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iLBtnPartStates = FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->PrevMonth();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iRBtnPartStates |= FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->NextMonth();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) ==
+ 0) {
+ m_pOwner->JumpToToday();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ } else {
+ IFWL_DateTimePicker* pIPicker = (IFWL_DateTimePicker*)m_pOwner->m_pOuter;
+ CFWL_DateTimePickerImp* pPicker =
+ (CFWL_DateTimePickerImp*)((IFWL_TargetData*)pIPicker)->GetData();
+ if (pPicker->IsMonthCalendarShowed()) {
+ m_bFlag = 1;
+ }
+ }
+}
+void CFWL_DateTimeCalendarDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_OnLButtonUpEx(pMsg);
+ }
+ if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iLBtnPartStates = 0;
+ m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
+ return;
+ }
+ if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iRBtnPartStates = 0;
+ m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
+ return;
+ }
+ if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return;
+ }
+ int32_t iOldSel = 0;
+ if (m_pOwner->m_arrSelDays.GetSize() > 0) {
+ iOldSel = m_pOwner->m_arrSelDays[0];
+ }
+ int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ CFX_RectF rt;
+ IFWL_DateTimePicker* pIPicker = (IFWL_DateTimePicker*)m_pOwner->m_pOuter;
+ CFWL_DateTimePickerImp* pPicker =
+ (CFWL_DateTimePickerImp*)((IFWL_TargetData*)pIPicker)->GetData();
+ pPicker->m_pForm->GetWidgetRect(rt);
+ rt.Set(0, 0, rt.width, rt.height);
+ if (iCurSel > 0) {
+ LPDATEINFO lpDatesInfo =
+ (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ CFX_RectF rtInvalidate(lpDatesInfo->rect);
+ if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
+ lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ rtInvalidate.Union(lpDatesInfo->rect);
+ }
+ m_pOwner->AddSelDay(iCurSel);
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pOuter);
+ pPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth,
+ iCurSel);
+ pPicker->ShowMonthCalendar(FALSE);
+ } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) {
+ IFWL_DateTimePicker* pIPicker = (IFWL_DateTimePicker*)m_pOwner->m_pOuter;
+ CFWL_DateTimePickerImp* pPicker =
+ (CFWL_DateTimePickerImp*)((IFWL_TargetData*)pIPicker)->GetData();
+ pPicker->ShowMonthCalendar(FALSE);
+ }
+ m_bFlag = 0;
+}
+void CFWL_DateTimeCalendarDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
+ return;
+ }
+ FX_BOOL bRepaint = FALSE;
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, 0, 0);
+ if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ bRepaint = m_pOwner->m_iHovered != iHover;
+ if (bRepaint) {
+ if (m_pOwner->m_iHovered > 0) {
+ m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
+ }
+ if (iHover > 0) {
+ CFX_RectF rtDay;
+ m_pOwner->GetDayRect(iHover, rtDay);
+ if (rtInvalidate.IsEmpty()) {
+ rtInvalidate = rtDay;
+ } else {
+ rtInvalidate.Union(rtDay);
}
- m_pOwner->AddSelDay(iCurSel);
- CFWL_DateTimePickerImp *pDateTime = (CFWL_DateTimePickerImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)->GetData();
- pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth, iCurSel);
- pDateTime->ShowMonthCalendar(FALSE);
- }
-}
-CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_bLBtnDown(FALSE)
- , m_iBtnState(1)
- , m_iYear(-1)
- , m_iMonth(-1)
- , m_iDay(-1)
- , m_pEdit(NULL)
- , m_pMonthCal(NULL)
- , m_pForm(FALSE)
-{
- m_rtBtn.Set(0, 0, 0, 0);
-}
-CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_WidgetImp(properties, pOuter)
- , m_bLBtnDown(FALSE)
- , m_iBtnState(1)
- , m_iYear(-1)
- , m_iMonth(-1)
- , m_iDay(-1)
- , m_pEdit(NULL)
- , m_pMonthCal(NULL)
- , m_pForm(FALSE)
-{
- m_rtBtn.Set(0, 0, 0, 0);
-}
-CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp()
-{
- if (m_pEdit) {
- m_pEdit->Release();
- m_pEdit = NULL;
- }
- if (m_pMonthCal) {
- m_pMonthCal->Release();
- m_pMonthCal = NULL;
- }
- if (m_pForm) {
- m_pForm->Release();
- m_pForm = NULL;
- }
-}
-FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_DateTimePicker;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_DateTimePickerImp::GetClassID() const
-{
- return FWL_CLASSHASH_DateTimePicker;
-}
-FWL_ERR CFWL_DateTimePickerImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_DateTimePickerImpDelegate(this);
- m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
- CFWL_WidgetImpProperties propMonth;
- propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
- propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
- propMonth.m_pDataProvider = &m_MonthCalendarDP;
- propMonth.m_pParent = m_pInterface;
- propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pMonthCal = new IFWL_DateTimeCalender();
- m_pMonthCal->Initialize(propMonth, m_pInterface);
+ }
+ }
+ m_pOwner->m_iHovered = iHover;
+ CFWL_Event_DtpHoverChanged ev;
+ ev.hoverday = iHover;
+ m_pOwner->DispatchEvent(&ev);
+ } else {
+ bRepaint = m_pOwner->m_iHovered > 0;
+ if (bRepaint) {
+ m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
+ }
+ m_pOwner->m_iHovered = -1;
+ }
+ if (bRepaint && !rtInvalidate.IsEmpty()) {
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+}
+int32_t CFWL_DateTimeCalendarDelegate::DisForm_OnProcessMessage(
+ CFWL_Message* pMessage) {
+ if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
+ DisForm_OnLButtonUpEx(pMsg);
+ return 1;
+ }
+ }
+ return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
+}
+void CFWL_DateTimeCalendarDelegate::DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iLBtnPartStates = 0;
+ m_pOwner->Repaint(&(m_pOwner->m_rtLBtn));
+ return;
+ }
+ if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iRBtnPartStates = 0;
+ m_pOwner->Repaint(&(m_pOwner->m_rtRBtn));
+ return;
+ }
+ if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return;
+ }
+ int32_t iOldSel = 0;
+ if (m_pOwner->m_arrSelDays.GetSize() > 0) {
+ iOldSel = m_pOwner->m_arrSelDays[0];
+ }
+ int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (iCurSel > 0) {
+ LPDATEINFO lpDatesInfo =
+ (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ CFX_RectF rtInvalidate(lpDatesInfo->rect);
+ if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
+ lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ rtInvalidate.Union(lpDatesInfo->rect);
+ }
+ m_pOwner->AddSelDay(iCurSel);
+ CFWL_DateTimePickerImp* pDateTime =
+ (CFWL_DateTimePickerImp*)((IFWL_TargetData*)m_pOwner->m_pOuter)
+ ->GetData();
+ pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth,
+ iCurSel);
+ pDateTime->ShowMonthCalendar(FALSE);
+ }
+}
+CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_bLBtnDown(FALSE),
+ m_iBtnState(1),
+ m_iYear(-1),
+ m_iMonth(-1),
+ m_iDay(-1),
+ m_pEdit(NULL),
+ m_pMonthCal(NULL),
+ m_pForm(FALSE) {
+ m_rtBtn.Set(0, 0, 0, 0);
+}
+CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_bLBtnDown(FALSE),
+ m_iBtnState(1),
+ m_iYear(-1),
+ m_iMonth(-1),
+ m_iDay(-1),
+ m_pEdit(NULL),
+ m_pMonthCal(NULL),
+ m_pForm(FALSE) {
+ m_rtBtn.Set(0, 0, 0, 0);
+}
+CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {
+ if (m_pEdit) {
+ m_pEdit->Release();
+ m_pEdit = NULL;
+ }
+ if (m_pMonthCal) {
+ m_pMonthCal->Release();
+ m_pMonthCal = NULL;
+ }
+ if (m_pForm) {
+ m_pForm->Release();
+ m_pForm = NULL;
+ }
+}
+FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_DateTimePicker;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_DateTimePickerImp::GetClassID() const {
+ return FWL_CLASSHASH_DateTimePicker;
+}
+FWL_ERR CFWL_DateTimePickerImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate =
+ (IFWL_WidgetDelegate*)FX_NEW CFWL_DateTimePickerImpDelegate(this);
+ m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
+ CFWL_WidgetImpProperties propMonth;
+ propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
+ propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
+ propMonth.m_pDataProvider = &m_MonthCalendarDP;
+ propMonth.m_pParent = m_pInterface;
+ propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ m_pMonthCal = new IFWL_DateTimeCalender();
+ m_pMonthCal->Initialize(propMonth, m_pInterface);
+ CFX_RectF rtMonthCal;
+ m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
+ rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
+ m_pMonthCal->SetWidgetRect(rtMonthCal);
+ CFWL_WidgetImpProperties propEdit;
+ propEdit.m_pParent = m_pInterface;
+ propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ m_pEdit = new IFWL_DateTimeEdit();
+ m_pEdit->Initialize(propEdit, m_pInterface);
+ RegisterEventTarget(m_pMonthCal);
+ RegisterEventTarget(m_pEdit);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::Finalize() {
+ if (m_pEdit) {
+ m_pEdit->Finalize();
+ }
+ if (m_pMonthCal) {
+ m_pMonthCal->Finalize();
+ }
+ if (m_pForm) {
+ m_pForm->Finalize();
+ }
+ UnregisterEventTarget();
+ if (m_pDelegate) {
+ delete (CFWL_DateTimePickerImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_GetWidgetRect(rect, bAutoSize);
+ }
+ if (bAutoSize) {
+ rect.Set(0, 0, FWL_DTP_WIDTH, FWL_DTP_HEIGHT);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::Update() {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_Update();
+ }
+ if (m_iLock) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
+ GetClientRect(m_rtClient);
+ FX_FLOAT* pFWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_VALUE_IF_FAIL(pFWidth, FWL_ERR_Indefinite);
+ FX_FLOAT fBtn = *pFWidth;
+ m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1,
+ m_rtClient.height - 1);
+ CFX_RectF rtEdit;
+ rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
+ m_rtClient.height);
+ m_pEdit->SetWidgetRect(rtEdit);
+ ReSetEditAlignment();
+ m_pEdit->Update();
+ if (!(m_pMonthCal->GetThemeProvider())) {
+ m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
+ }
+ if (m_pProperties->m_pDataProvider) {
+ IFWL_DateTimePickerDP* pData =
+ (IFWL_DateTimePickerDP*)m_pProperties->m_pDataProvider;
+ pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear,
+ m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
+ }
+ CFX_RectF rtMonthCal;
+ m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
+ CFX_RectF rtPopUp;
+ rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT,
+ rtMonthCal.width, rtMonthCal.height);
+ m_pMonthCal->SetWidgetRect(rtPopUp);
+ m_pMonthCal->Update();
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_HitTest(fx, fy);
+ }
+ if (m_rtClient.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ if (IsMonthCalendarShowed()) {
+ CFX_RectF rect;
+ m_pMonthCal->GetWidgetRect(rect);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ }
+ return FWL_WGTHITTEST_Unknown;
+}
+FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_DTP_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_DTP_Edge, pTheme, pMatrix);
+ }
+ if (!m_rtBtn.IsEmpty()) {
+ DrawDropDownButton(pGraphics, pTheme, pMatrix);
+ }
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_DrawWidget(pGraphics, pMatrix);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) {
+ m_pProperties->m_pThemeProvider = pTP;
+ m_pMonthCal->SetThemeProvider(pTP);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ iYear = m_iYear;
+ iMonth = m_iMonth;
+ iDay = m_iDay;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ _FWL_RETURN_VALUE_IF_FAIL(iYear > 0 && iYear < 3000, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(iMonth > 0 && iMonth < 13, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(iDay > 0 && iDay < 32, FWL_ERR_Indefinite);
+ m_iYear = iYear;
+ m_iMonth = iMonth;
+ m_iDay = iDay;
+ m_pMonthCal->SetSelect(iYear, iMonth, iDay);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
+ int32_t iRet = m_pEdit->SetText(wsText);
+ Repaint(&m_rtClient);
+ CFWL_Event_DtpEditChanged ev;
+ ev.m_wsText = wsText;
+ DispatchEvent(&ev);
+ return iRet;
+}
+FWL_ERR CFWL_DateTimePickerImp::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ if (m_pEdit) {
+ return m_pEdit->GetText(wsText, nStart, nCount);
+ }
+ return FWL_ERR_Indefinite;
+}
+FX_BOOL CFWL_DateTimePickerImp::CanUndo() {
+ return m_pEdit->CanUndo();
+}
+FX_BOOL CFWL_DateTimePickerImp::CanRedo() {
+ return m_pEdit->CanRedo();
+}
+FX_BOOL CFWL_DateTimePickerImp::Undo() {
+ return m_pEdit->Undo();
+}
+FX_BOOL CFWL_DateTimePickerImp::Redo() {
+ return m_pEdit->Redo();
+}
+FX_BOOL CFWL_DateTimePickerImp::CanCopy() {
+ int32_t nCount = m_pEdit->CountSelRanges();
+ return nCount > 0;
+}
+FX_BOOL CFWL_DateTimePickerImp::CanCut() {
+ if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
+ return FALSE;
+ }
+ int32_t nCount = m_pEdit->CountSelRanges();
+ return nCount > 0;
+}
+FX_BOOL CFWL_DateTimePickerImp::CanSelectAll() {
+ return m_pEdit->GetTextLength() > 0;
+}
+FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString& wsCopy) {
+ return m_pEdit->Copy(wsCopy);
+}
+FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString& wsCut) {
+ return m_pEdit->Cut(wsCut);
+}
+FX_BOOL CFWL_DateTimePickerImp::Paste(const CFX_WideString& wsPaste) {
+ return m_pEdit->Paste(wsPaste);
+}
+FX_BOOL CFWL_DateTimePickerImp::SelectAll() {
+ return (m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded) ? TRUE : FALSE;
+}
+FX_BOOL CFWL_DateTimePickerImp::Delete() {
+ return (m_pEdit->ClearText() == FWL_ERR_Succeeded) ? TRUE : FALSE;
+}
+FX_BOOL CFWL_DateTimePickerImp::DeSelect() {
+ return (m_pEdit->ClearSelections() == FWL_ERR_Succeeded) ? TRUE : FALSE;
+}
+FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_GetBBox(rect);
+ }
+ rect = m_pProperties->m_rtWidget;
+ if (IsMonthCalendarShowed()) {
+ CFX_RectF rtMonth;
+ m_pMonthCal->GetWidgetRect(rtMonth);
+ rtMonth.Offset(m_pProperties->m_rtWidget.left,
+ m_pProperties->m_rtWidget.top);
+ rect.Union(rtMonth);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) {
+ return m_pEdit->SetLimit(nLimit);
+}
+FWL_ERR CFWL_DateTimePickerImp::ModifyEditStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) ==
+ FWL_STYLEEXT_DTP_Spin) {
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
+ prop.m_pParent = m_pInterface;
+ prop.m_rtWidget = m_rtBtn;
+ IFWL_SpinButton* pSpin = IFWL_SpinButton::Create();
+ pSpin->Initialize(prop, m_pInterface);
+ } else {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_DTP_DropDownButton;
+ param.m_dwStates = m_iBtnState;
+ param.m_pGraphics = pGraphics;
+ param.m_rtPart = m_rtBtn;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶m);
+ }
+}
+void CFWL_DateTimePickerImp::FormatDateString(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay,
+ CFX_WideString& wsText) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) ==
+ FWL_STYLEEXT_DTP_ShortDateFormat) {
+ wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay);
+ } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) ==
+ FWL_STYLEEXT_DTP_LongDateFormat) {
+ wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay);
+ } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) ==
+ FWL_STYLEEXT_DTP_TimeFormat) {
+ }
+}
+void CFWL_DateTimePickerImp::ShowMonthCalendar(FX_BOOL bActivate) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_ShowMonthCalendar(bActivate);
+ }
+ if (IsMonthCalendarShowed() == bActivate) {
+ return;
+ }
+ if (!m_pForm) {
+ InitProxyForm();
+ }
+ if (bActivate) {
+ CFX_RectF rtMonth;
+ m_pMonthCal->GetWidgetRect(rtMonth);
+ CFX_RectF rtAnchor;
+ rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
+ m_pForm->SetWidgetRect(rtMonth);
+ rtMonth.left = rtMonth.top = 0;
+ m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
+ m_pMonthCal->SetWidgetRect(rtMonth);
+ m_pMonthCal->Update();
+ m_pForm->DoModal();
+ } else {
+ m_pForm->EndDoModal();
+ }
+}
+FX_BOOL CFWL_DateTimePickerImp::IsMonthCalendarShowed() {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_IsMonthCalendarShowed();
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(m_pForm, FALSE);
+ return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
+}
+void CFWL_DateTimePickerImp::ReSetEditAlignment() {
+ _FWL_RETURN_IF_FAIL(m_pEdit);
+ FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes;
+ FX_DWORD dwAdd = 0;
+ switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) {
+ case FWL_STYLEEXT_DTP_EditHCenter: {
+ dwAdd |= FWL_STYLEEXT_EDT_HCenter;
+ break;
+ }
+ case FWL_STYLEEXT_DTP_EditHFar: {
+ dwAdd |= FWL_STYLEEXT_EDT_HFar;
+ break;
+ }
+ default: { dwAdd |= FWL_STYLEEXT_EDT_HNear; }
+ }
+ switch (dwStylExes & FWL_STYLEEXT_DTP_EditVAlignMask) {
+ case FWL_STYLEEXT_DTP_EditVCenter: {
+ dwAdd |= FWL_STYLEEXT_EDT_VCenter;
+ break;
+ }
+ case FWL_STYLEEXT_DTP_EditVFar: {
+ dwAdd |= FWL_STYLEEXT_EDT_VFar;
+ break;
+ }
+ default: { dwAdd |= FWL_STYLEEXT_EDT_VNear; }
+ }
+ if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) {
+ dwAdd |= FWL_STYLEEXT_EDT_Justified;
+ }
+ if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) {
+ dwAdd |= FWL_STYLEEXT_EDT_Distributed;
+ }
+ m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
+ FWL_STYLEEXT_EDT_HAlignModeMask |
+ FWL_STYLEEXT_EDT_VAlignMask);
+}
+void CFWL_DateTimePickerImp::ProcessSelChanged(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ m_iYear = iYear;
+ m_iMonth = iMonth;
+ m_iDay = iDay;
+ CFX_WideString wsText;
+ FormatDateString(m_iYear, m_iMonth, m_iDay, wsText);
+ m_pEdit->SetText(wsText);
+ m_pEdit->Update();
+ Repaint(&m_rtClient);
+ CFWL_Event_DtpSelectChanged ev;
+ ev.m_pSrcTarget = m_pInterface;
+ ev.iYear = m_iYear;
+ ev.iMonth = m_iMonth;
+ ev.iDay = m_iDay;
+ DispatchEvent(&ev);
+}
+void CFWL_DateTimePickerImp::InitProxyForm() {
+ _FWL_RETURN_IF_FAIL(!m_pForm);
+ _FWL_RETURN_IF_FAIL(m_pMonthCal);
+ CFWL_WidgetImpProperties propForm;
+ propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
+ propForm.m_dwStates = FWL_WGTSTATE_Invisible;
+ propForm.m_pOwner = m_pInterface;
+ m_pForm = new IFWL_DateTimeForm();
+ m_pForm->Initialize(propForm, m_pMonthCal);
+ m_pMonthCal->SetParent((IFWL_Widget*)m_pForm);
+}
+IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() {
+ return m_pEdit;
+}
+FWL_ERR CFWL_DateTimePickerImp::DisForm_Initialize() {
+ m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
+ DisForm_InitDateTimeCalendar();
+ DisForm_InitDateTimeEdit();
+ RegisterEventTarget(m_pMonthCal);
+ RegisterEventTarget(m_pEdit);
+ return FWL_ERR_Succeeded;
+}
+void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() {
+ if (m_pMonthCal) {
+ return;
+ }
+ CFWL_WidgetImpProperties propMonth;
+ propMonth.m_dwStyles =
+ FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
+ propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
+ propMonth.m_pParent = (IFWL_Widget*)this;
+ propMonth.m_pDataProvider = &m_MonthCalendarDP;
+ propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ m_pMonthCal = new IFWL_DateTimeCalender();
+ m_pMonthCal->Initialize(propMonth, m_pInterface);
+ CFX_RectF rtMonthCal;
+ m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
+ rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
+ m_pMonthCal->SetWidgetRect(rtMonthCal);
+}
+void CFWL_DateTimePickerImp::DisForm_InitDateTimeEdit() {
+ if (m_pEdit) {
+ return;
+ }
+ CFWL_WidgetImpProperties propEdit;
+ propEdit.m_pParent = (IFWL_Widget*)this;
+ propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ m_pEdit = new IFWL_DateTimeEdit();
+ m_pEdit->Initialize(propEdit, m_pInterface);
+}
+FX_BOOL CFWL_DateTimePickerImp::DisForm_IsMonthCalendarShowed() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pMonthCal, FALSE);
+ return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
+}
+void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate) {
+ FX_BOOL bShowed = IsMonthCalendarShowed();
+ if (bShowed == bActivate) {
+ return;
+ }
+ if (bActivate) {
CFX_RectF rtMonthCal;
m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
- rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
+ FX_DWORD dwPos = 0;
+ FX_FLOAT fPopupHeight = 0.0f;
+ FX_FLOAT fPopupMin = rtMonthCal.height;
+ FX_FLOAT fPopupMax = rtMonthCal.height;
+ CFX_RectF rtAnchor(m_pProperties->m_rtWidget);
+ rtAnchor.width = rtMonthCal.width;
+ rtMonthCal.left = m_rtClient.left;
+ rtMonthCal.top = rtAnchor.Height();
+ GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal);
m_pMonthCal->SetWidgetRect(rtMonthCal);
- CFWL_WidgetImpProperties propEdit;
- propEdit.m_pParent = m_pInterface;
- propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pEdit = new IFWL_DateTimeEdit();
- m_pEdit->Initialize(propEdit, m_pInterface);
- RegisterEventTarget(m_pMonthCal);
- RegisterEventTarget(m_pEdit);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::Finalize()
-{
- if (m_pEdit) {
- m_pEdit->Finalize();
- }
- if (m_pMonthCal) {
- m_pMonthCal->Finalize();
- }
- if (m_pForm) {
- m_pForm->Finalize();
- }
- UnregisterEventTarget();
- if ( m_pDelegate) {
- delete (CFWL_DateTimePickerImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_GetWidgetRect(rect, bAutoSize);
- }
- if (bAutoSize) {
- rect.Set(0, 0, FWL_DTP_WIDTH, FWL_DTP_HEIGHT);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::Update()
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_Update();
- }
- if (m_iLock) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) {
+ m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
}
- m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
- GetClientRect(m_rtClient);
- FX_FLOAT *pFWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_VALUE_IF_FAIL(pFWidth, FWL_ERR_Indefinite);
- FX_FLOAT fBtn = *pFWidth;
- m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, m_rtClient.height - 1);
- CFX_RectF rtEdit;
- rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, m_rtClient.height);
- m_pEdit->SetWidgetRect(rtEdit);
- ReSetEditAlignment();
- m_pEdit->Update();
- if (!(m_pMonthCal->GetThemeProvider())) {
- m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
- }
- if (m_pProperties->m_pDataProvider) {
- IFWL_DateTimePickerDP *pData = (IFWL_DateTimePickerDP*)m_pProperties->m_pDataProvider;
- pData->GetToday(m_pInterface,
- m_MonthCalendarDP.m_iCurYear,
- m_MonthCalendarDP.m_iCurMonth,
- m_MonthCalendarDP.m_iCurDay);
- }
- CFX_RectF rtMonthCal;
- m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
- CFX_RectF rtPopUp;
- rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, rtMonthCal.width, rtMonthCal.height);
- m_pMonthCal->SetWidgetRect(rtPopUp);
m_pMonthCal->Update();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_HitTest(fx, fy);
- }
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- if (IsMonthCalendarShowed()) {
- CFX_RectF rect;
- m_pMonthCal->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_DTP_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_DTP_Edge, pTheme, pMatrix);
- }
- if (!m_rtBtn.IsEmpty()) {
- DrawDropDownButton(pGraphics, pTheme, pMatrix);
- }
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_DrawWidget(pGraphics, pMatrix);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider *pTP)
-{
- m_pProperties->m_pThemeProvider = pTP;
- m_pMonthCal->SetThemeProvider(pTP);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::GetCurSel(int32_t &iYear, int32_t &iMonth, int32_t &iDay)
-{
- iYear = m_iYear;
- iMonth = m_iMonth;
- iDay = m_iDay;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- _FWL_RETURN_VALUE_IF_FAIL(iYear > 0 && iYear < 3000, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(iMonth > 0 && iMonth < 13, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(iDay > 0 && iDay < 32, FWL_ERR_Indefinite);
- m_iYear = iYear;
- m_iMonth = iMonth;
- m_iDay = iDay;
- m_pMonthCal->SetSelect(iYear, iMonth, iDay);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::SetEditText(const CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdit, FWL_ERR_Indefinite);
- int32_t iRet = m_pEdit->SetText(wsText);
- Repaint(&m_rtClient);
- CFWL_Event_DtpEditChanged ev;
- ev.m_wsText = wsText;
- DispatchEvent(&ev);
- return iRet;
-}
-FWL_ERR CFWL_DateTimePickerImp::GetEditText(CFX_WideString &wsText, int32_t nStart, int32_t nCount) const
-{
- if (m_pEdit) {
- return m_pEdit->GetText(wsText, nStart, nCount);
- }
- return FWL_ERR_Indefinite;
-}
-FX_BOOL CFWL_DateTimePickerImp::CanUndo()
-{
- return m_pEdit->CanUndo();
-}
-FX_BOOL CFWL_DateTimePickerImp::CanRedo()
-{
- return m_pEdit->CanRedo();
-}
-FX_BOOL CFWL_DateTimePickerImp::Undo()
-{
- return m_pEdit->Undo();
-}
-FX_BOOL CFWL_DateTimePickerImp::Redo()
-{
- return m_pEdit->Redo();
-}
-FX_BOOL CFWL_DateTimePickerImp::CanCopy()
-{
- int32_t nCount = m_pEdit->CountSelRanges();
- return nCount > 0;
-}
-FX_BOOL CFWL_DateTimePickerImp::CanCut()
-{
- if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
- return FALSE;
+ }
+ m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
+ if (bActivate) {
+ CFWL_MsgSetFocus msg;
+ msg.m_pDstTarget = m_pMonthCal;
+ msg.m_pSrcTarget = m_pEdit;
+ IFWL_WidgetDelegate* pDelegate = m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(&msg);
+ }
+ CFX_RectF rtInvalidate, rtCal;
+ rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ m_pMonthCal->GetWidgetRect(rtCal);
+ rtInvalidate.Union(rtCal);
+ rtInvalidate.Inflate(2, 2);
+ Repaint(&rtInvalidate);
+}
+FX_DWORD CFWL_DateTimePickerImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ CFX_RectF rect;
+ rect.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Edit;
+ }
+ if (DisForm_IsNeedShowButton()) {
+ rect.width += m_fBtn;
+ }
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ if (IsMonthCalendarShowed()) {
+ m_pMonthCal->GetWidgetRect(rect);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
}
- int32_t nCount = m_pEdit->CountSelRanges();
- return nCount > 0;
-}
-FX_BOOL CFWL_DateTimePickerImp::CanSelectAll()
-{
- return m_pEdit->GetTextLength() > 0;
-}
-FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString &wsCopy)
-{
- return m_pEdit->Copy(wsCopy);
-}
-FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString &wsCut)
-{
- return m_pEdit->Cut(wsCut);
-}
-FX_BOOL CFWL_DateTimePickerImp::Paste(const CFX_WideString &wsPaste)
-{
- return m_pEdit->Paste(wsPaste);
-}
-FX_BOOL CFWL_DateTimePickerImp::SelectAll()
-{
- return (m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded) ? TRUE : FALSE;
+ }
+ return FWL_WGTHITTEST_Unknown;
}
-FX_BOOL CFWL_DateTimePickerImp::Delete()
-{
- return (m_pEdit->ClearText() == FWL_ERR_Succeeded) ? TRUE : FALSE;
+FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() {
+ FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
+ m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
+ m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
+ return bFocus;
}
-FX_BOOL CFWL_DateTimePickerImp::DeSelect()
-{
- return (m_pEdit->ClearSelections() == FWL_ERR_Succeeded) ? TRUE : FALSE;
-}
-FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF &rect)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_GetBBox(rect);
- }
- rect = m_pProperties->m_rtWidget;
- if (IsMonthCalendarShowed()) {
- CFX_RectF rtMonth;
- m_pMonthCal->GetWidgetRect(rtMonth);
- rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top);
- rect.Union(rtMonth);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit)
-{
- return m_pEdit->SetLimit(nLimit);
-}
-FWL_ERR CFWL_DateTimePickerImp::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == FWL_STYLEEXT_DTP_Spin) {
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
- prop.m_pParent = m_pInterface;
- prop.m_rtWidget = m_rtBtn;
- IFWL_SpinButton *pSpin = IFWL_SpinButton::Create();
- pSpin->Initialize(prop, m_pInterface);
- } else {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_DTP_DropDownButton;
- param.m_dwStates = m_iBtnState;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = m_rtBtn;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
+FWL_ERR CFWL_DateTimePickerImp::DisForm_Update() {
+ if (m_iLock) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
+ GetClientRect(m_rtClient);
+ m_pEdit->SetWidgetRect(m_rtClient);
+ ReSetEditAlignment();
+ m_pEdit->Update();
+ if (m_pMonthCal->GetThemeProvider() == NULL) {
+ m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
+ }
+ if (m_pProperties->m_pDataProvider) {
+ IFWL_DateTimePickerDP* pData =
+ (IFWL_DateTimePickerDP*)m_pProperties->m_pDataProvider;
+ pData->GetToday((IFWL_Widget*)this, m_MonthCalendarDP.m_iCurYear,
+ m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
+ }
+ FX_FLOAT* pWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_VALUE_IF_FAIL(pWidth, 0);
+ m_fBtn = *pWidth;
+ CFX_RectF rtMonthCal;
+ m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
+ CFX_RectF rtPopUp;
+ rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT,
+ rtMonthCal.width, rtMonthCal.height);
+ m_pMonthCal->SetWidgetRect(rtPopUp);
+ m_pMonthCal->Update();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
+ rect = m_pProperties->m_rtWidget;
+ if (DisForm_IsNeedShowButton()) {
+ rect.width += m_fBtn;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) {
+ rect = m_pProperties->m_rtWidget;
+ if (DisForm_IsNeedShowButton()) {
+ rect.width += m_fBtn;
+ }
+ if (IsMonthCalendarShowed()) {
+ CFX_RectF rtMonth;
+ m_pMonthCal->GetWidgetRect(rtMonth);
+ rtMonth.Offset(m_pProperties->m_rtWidget.left,
+ m_pProperties->m_rtWidget.top);
+ rect.Union(rtMonth);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ if (m_pEdit) {
+ CFX_RectF rtEdit;
+ m_pEdit->GetWidgetRect(rtEdit);
+ CFX_Matrix mt;
+ mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
+ if (pMatrix) {
+ mt.Concat(*pMatrix);
+ }
+ m_pEdit->DrawWidget(pGraphics, &mt);
+ }
+ if (IsMonthCalendarShowed()) {
+ CFX_RectF rtMonth;
+ m_pMonthCal->GetWidgetRect(rtMonth);
+ CFX_Matrix mt;
+ mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top);
+ if (pMatrix) {
+ mt.Concat(*pMatrix);
+ }
+ m_pMonthCal->DrawWidget(pGraphics, &mt);
+ }
+ return FWL_ERR_Succeeded;
+}
+CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate(
+ CFWL_DateTimePickerImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage(
+ CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMouse = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMouse->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMouse);
+ break;
}
- pTheme->DrawBackground(¶m);
- }
-}
-void CFWL_DateTimePickerImp::FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay, CFX_WideString &wsText)
-{
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_ShortDateFormat) == FWL_STYLEEXT_DTP_ShortDateFormat) {
- wsText.Format(L"%d-%d-%d", iYear, iMonth, iDay);
- } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_LongDateFormat) == FWL_STYLEEXT_DTP_LongDateFormat) {
- wsText.Format(L"%d Year %d Month %d Day", iYear, iMonth, iDay);
- } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat) == FWL_STYLEEXT_DTP_TimeFormat) {
- }
-}
-void CFWL_DateTimePickerImp::ShowMonthCalendar(FX_BOOL bActivate)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_ShowMonthCalendar(bActivate);
- }
- if(IsMonthCalendarShowed() == bActivate) {
- return;
- }
- if (!m_pForm) {
- InitProxyForm();
- }
- if (bActivate) {
- CFX_RectF rtMonth;
- m_pMonthCal->GetWidgetRect(rtMonth);
- CFX_RectF rtAnchor;
- rtAnchor.Set(0,
- 0,
- m_pProperties->m_rtWidget.width,
- m_pProperties->m_rtWidget.height);
- GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
- m_pForm->SetWidgetRect(rtMonth);
- rtMonth.left = rtMonth.top = 0;
- m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
- m_pMonthCal->SetWidgetRect(rtMonth);
- m_pMonthCal->Update();
- m_pForm->DoModal();
- } else {
- m_pForm->EndDoModal();
- }
-}
-FX_BOOL CFWL_DateTimePickerImp::IsMonthCalendarShowed()
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_IsMonthCalendarShowed();
- }
- _FWL_RETURN_VALUE_IF_FAIL(m_pForm, FALSE);
- return !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
-}
-void CFWL_DateTimePickerImp::ReSetEditAlignment()
-{
- _FWL_RETURN_IF_FAIL(m_pEdit);
- FX_DWORD dwStylExes = m_pProperties->m_dwStyleExes;
- FX_DWORD dwAdd = 0;
- switch (dwStylExes & FWL_STYLEEXT_DTP_EditHAlignMask) {
- case FWL_STYLEEXT_DTP_EditHCenter: {
- dwAdd |= FWL_STYLEEXT_EDT_HCenter;
- break;
- }
- case FWL_STYLEEXT_DTP_EditHFar: {
- dwAdd |= FWL_STYLEEXT_EDT_HFar;
- break;
- }
- default: {
- dwAdd |= FWL_STYLEEXT_EDT_HNear;
- }
- }
- switch (dwStylExes & FWL_STYLEEXT_DTP_EditVAlignMask) {
- case FWL_STYLEEXT_DTP_EditVCenter: {
- dwAdd |= FWL_STYLEEXT_EDT_VCenter;
- break;
- }
- case FWL_STYLEEXT_DTP_EditVFar: {
- dwAdd |= FWL_STYLEEXT_EDT_VFar;
- break;
- }
- default: {
- dwAdd |= FWL_STYLEEXT_EDT_VNear;
- }
- }
- if (dwStylExes & FWL_STYLEEXT_DTP_EditJustified) {
- dwAdd |= FWL_STYLEEXT_EDT_Justified;
- }
- if (dwStylExes & FWL_STYLEEXT_DTP_EditDistributed) {
- dwAdd |= FWL_STYLEEXT_EDT_Distributed;
- }
- m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
- FWL_STYLEEXT_EDT_HAlignModeMask |
- FWL_STYLEEXT_EDT_VAlignMask);
-}
-void CFWL_DateTimePickerImp::ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- m_iYear = iYear;
- m_iMonth = iMonth;
- m_iDay = iDay;
- CFX_WideString wsText;
- FormatDateString(m_iYear, m_iMonth, m_iDay, wsText);
- m_pEdit->SetText(wsText);
- m_pEdit->Update();
- Repaint(&m_rtClient);
- CFWL_Event_DtpSelectChanged ev;
- ev.m_pSrcTarget = m_pInterface;
- ev.iYear = m_iYear;
- ev.iMonth = m_iMonth;
- ev.iDay = m_iDay;
- DispatchEvent(&ev);
-}
-void CFWL_DateTimePickerImp::InitProxyForm()
-{
- _FWL_RETURN_IF_FAIL(!m_pForm);
- _FWL_RETURN_IF_FAIL(m_pMonthCal);
- CFWL_WidgetImpProperties propForm;
- propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
- propForm.m_dwStates = FWL_WGTSTATE_Invisible;
- propForm.m_pOwner = m_pInterface;
- m_pForm = new IFWL_DateTimeForm();
- m_pForm->Initialize(propForm, m_pMonthCal);
- m_pMonthCal->SetParent((IFWL_Widget*)m_pForm);
-}
-IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit()
-{
- return m_pEdit;
-}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_Initialize()
-{
- m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
- DisForm_InitDateTimeCalendar();
- DisForm_InitDateTimeEdit();
- RegisterEventTarget(m_pMonthCal);
- RegisterEventTarget(m_pEdit);
- return FWL_ERR_Succeeded;
-}
-void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar()
-{
- if (m_pMonthCal) {
- return;
- }
- CFWL_WidgetImpProperties propMonth;
- propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken;
- propMonth.m_dwStates = FWL_WGTSTATE_Invisible;
- propMonth.m_pParent = (IFWL_Widget*)this;
- propMonth.m_pDataProvider = &m_MonthCalendarDP;
- propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pMonthCal = new IFWL_DateTimeCalender();
- m_pMonthCal->Initialize(propMonth, m_pInterface);
- CFX_RectF rtMonthCal;
- m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
- rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height);
- m_pMonthCal->SetWidgetRect(rtMonthCal);
-}
-void CFWL_DateTimePickerImp::DisForm_InitDateTimeEdit()
-{
- if (m_pEdit) {
- return;
- }
- CFWL_WidgetImpProperties propEdit;
- propEdit.m_pParent = (IFWL_Widget*)this;
- propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pEdit = new IFWL_DateTimeEdit();
- m_pEdit->Initialize(propEdit, m_pInterface);
-}
-FX_BOOL CFWL_DateTimePickerImp::DisForm_IsMonthCalendarShowed()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pMonthCal, FALSE);
- return !(m_pMonthCal->GetStates() & FWL_WGTSTATE_Invisible);
-}
-void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate)
-{
- FX_BOOL bShowed = IsMonthCalendarShowed();
- if(bShowed == bActivate) {
- return;
- }
- if (bActivate) {
- CFX_RectF rtMonthCal;
- m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
- FX_DWORD dwPos = 0;
- FX_FLOAT fPopupHeight = 0.0f;
- FX_FLOAT fPopupMin = rtMonthCal.height;
- FX_FLOAT fPopupMax = rtMonthCal.height;
- CFX_RectF rtAnchor(m_pProperties->m_rtWidget);
- rtAnchor.width = rtMonthCal.width;
- rtMonthCal.left = m_rtClient.left;
- rtMonthCal.top = rtAnchor.Height();
- GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal);
- m_pMonthCal->SetWidgetRect(rtMonthCal);
- if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0) {
- m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMouse);
+ break;
}
- m_pMonthCal->Update();
- }
- m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
- if (bActivate) {
- CFWL_MsgSetFocus msg;
- msg.m_pDstTarget = m_pMonthCal;
- msg.m_pSrcTarget = m_pEdit;
- IFWL_WidgetDelegate *pDelegate = m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(&msg);
- }
- CFX_RectF rtInvalidate, rtCal;
- rtInvalidate.Set(0,
- 0,
- m_pProperties->m_rtWidget.width,
- m_pProperties->m_rtWidget.height);
- m_pMonthCal->GetWidgetRect(rtCal);
- rtInvalidate.Union(rtCal);
- rtInvalidate.Inflate(2, 2);
- Repaint(&rtInvalidate);
-}
-FX_DWORD CFWL_DateTimePickerImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- CFX_RectF rect;
- rect.Set(0, 0, m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edit;
- }
- if (DisForm_IsNeedShowButton()) {
- rect.width += m_fBtn;
- }
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- if (IsMonthCalendarShowed()) {
- m_pMonthCal->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMouse);
+ break;
}
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton()
-{
- FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
- m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused ||
- m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
- return bFocus ;
-}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_Update()
-{
- if (m_iLock) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
- GetClientRect(m_rtClient);
- m_pEdit->SetWidgetRect(m_rtClient);
- ReSetEditAlignment();
- m_pEdit->Update();
- if (m_pMonthCal->GetThemeProvider() == NULL) {
- m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
- }
- if (m_pProperties->m_pDataProvider) {
- IFWL_DateTimePickerDP *pData = (IFWL_DateTimePickerDP*)m_pProperties->m_pDataProvider;
- pData->GetToday((IFWL_Widget*)this,
- m_MonthCalendarDP.m_iCurYear,
- m_MonthCalendarDP.m_iCurMonth,
- m_MonthCalendarDP.m_iCurDay);
- }
- FX_FLOAT *pWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_VALUE_IF_FAIL(pWidth, 0);
- m_fBtn = *pWidth;
- CFX_RectF rtMonthCal;
- m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
- CFX_RectF rtPopUp;
- rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT, rtMonthCal.width, rtMonthCal.height);
- m_pMonthCal->SetWidgetRect(rtPopUp);
- m_pMonthCal->Update();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize)
-{
- rect = m_pProperties->m_rtWidget;
- if (DisForm_IsNeedShowButton()) {
- rect.width += m_fBtn;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF &rect)
-{
- rect = m_pProperties->m_rtWidget;
- if (DisForm_IsNeedShowButton()) {
- rect.width += m_fBtn;
- }
- if (IsMonthCalendarShowed()) {
- CFX_RectF rtMonth;
- m_pMonthCal->GetWidgetRect(rtMonth);
- rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top);
- rect.Union(rtMonth);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- if (m_pEdit) {
- CFX_RectF rtEdit;
- m_pEdit->GetWidgetRect(rtEdit);
- CFX_Matrix mt;
- mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
- if (pMatrix) {
- mt.Concat(*pMatrix);
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave(pMouse);
+ break;
}
- m_pEdit->DrawWidget(pGraphics, &mt);
- }
- if (IsMonthCalendarShowed()) {
- CFX_RectF rtMonth;
- m_pMonthCal->GetWidgetRect(rtMonth);
- CFX_Matrix mt;
- mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top);
- if (pMatrix) {
- mt.Concat(*pMatrix);
- }
- m_pMonthCal->DrawWidget(pGraphics, &mt);
- }
- return FWL_ERR_Succeeded;
-}
-CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate(CFWL_DateTimePickerImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMouse = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMouse->m_dwCmd;
- switch(dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMouse);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMouse);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMouse);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMouse);
- break;
- }
- default: {
- }
- }
- break;
- }
- default: {
- iRet = 0;
- }
- }
- if(dwMsgCode == FWL_MSGHASH_Key && m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMessage);
- }
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
-}
-FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet)
-{
- _FWL_RETURN_IF_FAIL(pMsg);
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_OnFocusChanged(pMsg, bSet);
- }
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- if(pMsg->m_pSrcTarget == (IFWL_Widget*)m_pOwner->m_pMonthCal && m_pOwner->IsMonthCalendarShowed()) {
- m_pOwner->ShowMonthCalendar(FALSE);
- }
+ default: {}
+ }
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ if (dwMsgCode == FWL_MSGHASH_Key &&
+ m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ return pDelegate->OnProcessMessage(pMessage);
+ }
+ return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+}
+FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget(
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ _FWL_RETURN_IF_FAIL(pMsg);
+ if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ return DisForm_OnFocusChanged(pMsg, bSet);
+ }
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(pMsg);
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->IsMonthCalendarShowed()) {
- m_pOwner->ShowMonthCalendar(FALSE);
- CFWL_Event_DtpCloseUp ev;
- m_pOwner->DispatchEvent(&ev);
- } else {
- if (!(m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) {
- m_pOwner->ShowMonthCalendar(TRUE);
- CFWL_Event_DtpDropDown ev;
- m_pOwner->DispatchEvent(&ev);
- } else {
- }
- m_pOwner->m_bLBtnDown = TRUE;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- }
-}
-void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(pMsg);
- m_pOwner->m_bLBtnDown = FALSE;
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Hovered;
- } else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
-}
-void CFWL_DateTimePickerImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ if (pMsg->m_pSrcTarget == (IFWL_Widget*)m_pOwner->m_pMonthCal &&
+ m_pOwner->IsMonthCalendarShowed()) {
+ m_pOwner->ShowMonthCalendar(FALSE);
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(pMsg);
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ m_pOwner->SetFocus(TRUE);
+ }
+ if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_pOwner->IsMonthCalendarShowed()) {
+ m_pOwner->ShowMonthCalendar(FALSE);
+ CFWL_Event_DtpCloseUp ev;
+ m_pOwner->DispatchEvent(&ev);
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+ if (!(m_pOwner->m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_DTP_TimeFormat)) {
+ m_pOwner->ShowMonthCalendar(TRUE);
+ CFWL_Event_DtpDropDown ev;
+ m_pOwner->DispatchEvent(&ev);
+ } else {
+ }
+ m_pOwner->m_bLBtnDown = TRUE;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ }
+}
+void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(pMsg);
+ m_pOwner->m_bLBtnDown = FALSE;
+ if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Hovered;
+ } else {
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtBtn);
}
-void CFWL_DateTimePickerImpDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(pMsg);
+void CFWL_DateTimePickerImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ } else {
m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
-}
-void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet)
-{
- CFX_RectF rtInvalidate(m_pOwner->m_rtBtn);
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if ( m_pOwner->m_pEdit && !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
- m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width,
- 0,
- m_pOwner->m_fBtn,
- m_pOwner->m_pProperties->m_rtWidget.height - 1);
- }
- rtInvalidate = m_pOwner->m_rtBtn;
- pMsg->m_pDstTarget = m_pOwner->m_pEdit;
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMsg);
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_pOwner->m_rtBtn.Set(0, 0, 0, 0);
- if (m_pOwner->DisForm_IsMonthCalendarShowed()) {
- m_pOwner->ShowMonthCalendar(FALSE);
- }
- if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
- pMsg->m_pSrcTarget = m_pOwner->m_pEdit;
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMsg);
- }
- }
- rtInvalidate.Inflate(2, 2);
- m_pOwner->Repaint(&rtInvalidate);
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+}
+void CFWL_DateTimePickerImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(pMsg);
+ m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
+ m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+}
+void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ CFX_RectF rtInvalidate(m_pOwner->m_rtBtn);
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if (m_pOwner->m_pEdit &&
+ !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
+ m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width, 0,
+ m_pOwner->m_fBtn,
+ m_pOwner->m_pProperties->m_rtWidget.height - 1);
+ }
+ rtInvalidate = m_pOwner->m_rtBtn;
+ pMsg->m_pDstTarget = m_pOwner->m_pEdit;
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMsg);
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ m_pOwner->m_rtBtn.Set(0, 0, 0, 0);
+ if (m_pOwner->DisForm_IsMonthCalendarShowed()) {
+ m_pOwner->ShowMonthCalendar(FALSE);
+ }
+ if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
+ pMsg->m_pSrcTarget = m_pOwner->m_pEdit;
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMsg);
+ }
+ }
+ rtInvalidate.Inflate(2, 2);
+ m_pOwner->Repaint(&rtInvalidate);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp index b161f82960..e73cc5f7e0 100644 --- a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp @@ -14,2231 +14,2193 @@ #include "include/fwl_scrollbarimp.h"
#include "include/fwl_editimp.h"
#include "include/fwl_caretimp.h"
-IFWL_Edit* IFWL_Edit::Create()
-{
- return new IFWL_Edit;
+IFWL_Edit* IFWL_Edit::Create() {
+ return new IFWL_Edit;
}
-IFWL_Edit::IFWL_Edit()
-{
- m_pData = NULL;
+IFWL_Edit::IFWL_Edit() {
+ m_pData = NULL;
}
-IFWL_Edit::~IFWL_Edit()
-{
- if (m_pData) {
- delete (CFWL_EditImp*)m_pData;
- m_pData = NULL;
- }
+IFWL_Edit::~IFWL_Edit() {
+ if (m_pData) {
+ delete (CFWL_EditImp*)m_pData;
+ m_pData = NULL;
+ }
}
-FWL_ERR IFWL_Edit::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_EditImp(pOuter);
- ((CFWL_EditImp*)m_pData)->SetInterface(this);
- return ((CFWL_EditImp*)m_pData)->Initialize();
+FWL_ERR IFWL_Edit::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_EditImp(pOuter);
+ ((CFWL_EditImp*)m_pData)->SetInterface(this);
+ return ((CFWL_EditImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_Edit::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_EditImp(properties, pOuter);
- ((CFWL_EditImp*)m_pData)->SetInterface(this);
- return ((CFWL_EditImp*)m_pData)->Initialize();
+FWL_ERR IFWL_Edit::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_EditImp(properties, pOuter);
+ ((CFWL_EditImp*)m_pData)->SetInterface(this);
+ return ((CFWL_EditImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_Edit::SetText(const CFX_WideString &wsText)
-{
- return ((CFWL_EditImp*)m_pData)->SetText(wsText);
+FWL_ERR IFWL_Edit::SetText(const CFX_WideString& wsText) {
+ return ((CFWL_EditImp*)m_pData)->SetText(wsText);
}
-int32_t IFWL_Edit::GetTextLength() const
-{
- return ((CFWL_EditImp*)m_pData)->GetTextLength();
+int32_t IFWL_Edit::GetTextLength() const {
+ return ((CFWL_EditImp*)m_pData)->GetTextLength();
}
-FWL_ERR IFWL_Edit::GetText(CFX_WideString &wsText, int32_t nStart, int32_t nCount) const
-{
- return ((CFWL_EditImp*)m_pData)->GetText(wsText, nStart, nCount);
+FWL_ERR IFWL_Edit::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ return ((CFWL_EditImp*)m_pData)->GetText(wsText, nStart, nCount);
}
-FWL_ERR IFWL_Edit::ClearText()
-{
- return ((CFWL_EditImp*)m_pData)->ClearText();
+FWL_ERR IFWL_Edit::ClearText() {
+ return ((CFWL_EditImp*)m_pData)->ClearText();
}
-int32_t IFWL_Edit::GetCaretPos() const
-{
- return ((CFWL_EditImp*)m_pData)->GetCaretPos();
+int32_t IFWL_Edit::GetCaretPos() const {
+ return ((CFWL_EditImp*)m_pData)->GetCaretPos();
}
-int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore)
-{
- return ((CFWL_EditImp*)m_pData)->SetCaretPos(nIndex, bBefore);
+int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
+ return ((CFWL_EditImp*)m_pData)->SetCaretPos(nIndex, bBefore);
}
-FWL_ERR IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount)
-{
- return ((CFWL_EditImp*)m_pData)->AddSelRange(nStart, nCount);
+FWL_ERR IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
+ return ((CFWL_EditImp*)m_pData)->AddSelRange(nStart, nCount);
}
-int32_t IFWL_Edit::CountSelRanges()
-{
- return ((CFWL_EditImp*)m_pData)->CountSelRanges();
+int32_t IFWL_Edit::CountSelRanges() {
+ return ((CFWL_EditImp*)m_pData)->CountSelRanges();
}
-int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t &nStart)
-{
- return ((CFWL_EditImp*)m_pData)->GetSelRange(nIndex, nStart);
+int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ return ((CFWL_EditImp*)m_pData)->GetSelRange(nIndex, nStart);
}
-FWL_ERR IFWL_Edit::ClearSelections()
-{
- return ((CFWL_EditImp*)m_pData)->ClearSelections();
+FWL_ERR IFWL_Edit::ClearSelections() {
+ return ((CFWL_EditImp*)m_pData)->ClearSelections();
}
-int32_t IFWL_Edit::GetLimit()
-{
- return ((CFWL_EditImp*)m_pData)->GetLimit();
+int32_t IFWL_Edit::GetLimit() {
+ return ((CFWL_EditImp*)m_pData)->GetLimit();
}
-FWL_ERR IFWL_Edit::SetLimit(int32_t nLimit)
-{
- return ((CFWL_EditImp*)m_pData)->SetLimit(nLimit);
+FWL_ERR IFWL_Edit::SetLimit(int32_t nLimit) {
+ return ((CFWL_EditImp*)m_pData)->SetLimit(nLimit);
}
-FWL_ERR IFWL_Edit::SetAliasChar(FX_WCHAR wAlias)
-{
- return ((CFWL_EditImp*)m_pData)->SetAliasChar(wAlias);
+FWL_ERR IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
+ return ((CFWL_EditImp*)m_pData)->SetAliasChar(wAlias);
}
-FWL_ERR IFWL_Edit::SetFormatString(const CFX_WideString &wsFormat)
-{
- return ((CFWL_EditImp*)m_pData)->SetFormatString(wsFormat);
+FWL_ERR IFWL_Edit::SetFormatString(const CFX_WideString& wsFormat) {
+ return ((CFWL_EditImp*)m_pData)->SetFormatString(wsFormat);
}
-FWL_ERR IFWL_Edit::Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen)
-{
- return ((CFWL_EditImp*)m_pData)->Insert(nStart, lpText, nLen);
+FWL_ERR IFWL_Edit::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
+ return ((CFWL_EditImp*)m_pData)->Insert(nStart, lpText, nLen);
}
-FWL_ERR IFWL_Edit::DeleteSelections()
-{
- return ((CFWL_EditImp*)m_pData)->DeleteSelections();
+FWL_ERR IFWL_Edit::DeleteSelections() {
+ return ((CFWL_EditImp*)m_pData)->DeleteSelections();
}
-FWL_ERR IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount)
-{
- return ((CFWL_EditImp*)m_pData)->DeleteRange(nStart, nCount);
+FWL_ERR IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
+ return ((CFWL_EditImp*)m_pData)->DeleteRange(nStart, nCount);
}
-FWL_ERR IFWL_Edit::ReplaceSelections(const CFX_WideStringC &wsReplace)
-{
- return ((CFWL_EditImp*)m_pData)->ReplaceSelections(wsReplace);
+FWL_ERR IFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) {
+ return ((CFWL_EditImp*)m_pData)->ReplaceSelections(wsReplace);
}
-FWL_ERR IFWL_Edit::Replace(int32_t nStart, int32_t nLen, const CFX_WideStringC &wsReplace)
-{
- return ((CFWL_EditImp*)m_pData)->Replace(nStart, nLen, wsReplace);
+FWL_ERR IFWL_Edit::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
+ return ((CFWL_EditImp*)m_pData)->Replace(nStart, nLen, wsReplace);
}
-FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd)
-{
- return ((CFWL_EditImp*)m_pData)->DoClipboard(iCmd);
+FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd) {
+ return ((CFWL_EditImp*)m_pData)->DoClipboard(iCmd);
}
-FX_BOOL IFWL_Edit::Copy(CFX_WideString &wsCopy)
-{
- return ((CFWL_EditImp*)m_pData)->Copy(wsCopy);
+FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) {
+ return ((CFWL_EditImp*)m_pData)->Copy(wsCopy);
}
-FX_BOOL IFWL_Edit::Cut(CFX_WideString &wsCut)
-{
- return ((CFWL_EditImp*)m_pData)->Cut(wsCut);
+FX_BOOL IFWL_Edit::Cut(CFX_WideString& wsCut) {
+ return ((CFWL_EditImp*)m_pData)->Cut(wsCut);
}
-FX_BOOL IFWL_Edit::Paste(const CFX_WideString &wsPaste)
-{
- return ((CFWL_EditImp*)m_pData)->Paste(wsPaste);
+FX_BOOL IFWL_Edit::Paste(const CFX_WideString& wsPaste) {
+ return ((CFWL_EditImp*)m_pData)->Paste(wsPaste);
}
-FX_BOOL IFWL_Edit::Delete()
-{
- return ((CFWL_EditImp*)m_pData)->Delete();
+FX_BOOL IFWL_Edit::Delete() {
+ return ((CFWL_EditImp*)m_pData)->Delete();
}
-FX_BOOL IFWL_Edit::Redo(const CFX_ByteStringC& bsRecord)
-{
- return ((CFWL_EditImp*)m_pData)->Redo(bsRecord);
+FX_BOOL IFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) {
+ return ((CFWL_EditImp*)m_pData)->Redo(bsRecord);
}
-FX_BOOL IFWL_Edit::Undo(const CFX_ByteStringC& bsRecord)
-{
- return ((CFWL_EditImp*)m_pData)->Undo(bsRecord);
+FX_BOOL IFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
+ return ((CFWL_EditImp*)m_pData)->Undo(bsRecord);
}
-FX_BOOL IFWL_Edit::Undo()
-{
- return ((CFWL_EditImp*)m_pData)->Undo();
+FX_BOOL IFWL_Edit::Undo() {
+ return ((CFWL_EditImp*)m_pData)->Undo();
}
-FX_BOOL IFWL_Edit::Redo()
-{
- return ((CFWL_EditImp*)m_pData)->Redo();
+FX_BOOL IFWL_Edit::Redo() {
+ return ((CFWL_EditImp*)m_pData)->Redo();
}
-FX_BOOL IFWL_Edit::CanUndo()
-{
- return ((CFWL_EditImp*)m_pData)->CanUndo();
+FX_BOOL IFWL_Edit::CanUndo() {
+ return ((CFWL_EditImp*)m_pData)->CanUndo();
}
-FX_BOOL IFWL_Edit::CanRedo()
-{
- return ((CFWL_EditImp*)m_pData)->CanRedo();
+FX_BOOL IFWL_Edit::CanRedo() {
+ return ((CFWL_EditImp*)m_pData)->CanRedo();
}
-FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant)
-{
- return ((CFWL_EditImp*)m_pData)->SetTabWidth(fTabWidth, bEquidistant);
+FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+ return ((CFWL_EditImp*)m_pData)->SetTabWidth(fTabWidth, bEquidistant);
}
-FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget *pOuter)
-{
- return ((CFWL_EditImp*)m_pData)->SetOuter(pOuter);
+FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget* pOuter) {
+ return ((CFWL_EditImp*)m_pData)->SetOuter(pOuter);
}
-FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax)
-{
- return ((CFWL_EditImp*)m_pData)->SetNumberRange(iMin, iMax);
+FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
+ return ((CFWL_EditImp*)m_pData)->SetNumberRange(iMin, iMax);
}
-FWL_ERR IFWL_Edit::SetBackColor(FX_DWORD dwColor)
-{
- return ((CFWL_EditImp*)m_pData)->SetBackgroundColor(dwColor);
+FWL_ERR IFWL_Edit::SetBackColor(FX_DWORD dwColor) {
+ return ((CFWL_EditImp*)m_pData)->SetBackgroundColor(dwColor);
}
-FWL_ERR IFWL_Edit::SetFont(const CFX_WideString &wsFont, FX_FLOAT fSize)
-{
- return ((CFWL_EditImp*)m_pData)->SetFont(wsFont, fSize);
+FWL_ERR IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+ return ((CFWL_EditImp*)m_pData)->SetFont(wsFont, fSize);
}
-void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset)
-{
- return ((CFWL_EditImp*)m_pData)->SetScrollOffset(fScrollOffset);
+void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
+ return ((CFWL_EditImp*)m_pData)->SetScrollOffset(fScrollOffset);
}
-FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray &sSuggest)
-{
- return ((CFWL_EditImp*)m_pData)->GetSuggestWords(pointf, sSuggest);
+FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf,
+ CFX_ByteStringArray& sSuggest) {
+ return ((CFWL_EditImp*)m_pData)->GetSuggestWords(pointf, sSuggest);
}
-FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, const CFX_ByteStringC& bsReplace)
-{
- return ((CFWL_EditImp*)m_pData)->ReplaceSpellCheckWord(pointf, bsReplace);
+FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
+ const CFX_ByteStringC& bsReplace) {
+ return ((CFWL_EditImp*)m_pData)->ReplaceSpellCheckWord(pointf, bsReplace);
}
#define FWL_EDIT_Margin 3
-CFWL_EditImp::CFWL_EditImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_fVAlignOffset(0.0f)
- , m_fScrollOffsetX(0.0f)
- , m_fScrollOffsetY(0.0f)
- , m_pEdtEngine(NULL)
- , m_bLButtonDown(FALSE)
- , m_nSelStart(0)
- , m_nLimit(-1)
- , m_fFontSize(0)
- , m_pVertScrollBar(NULL)
- , m_pHorzScrollBar(NULL)
- , m_pCaret(NULL)
- , m_iMin(-1)
- , m_iMax(0xFFFFFFF)
- , m_bSetRange(FALSE)
- , m_pTextField(NULL)
- , m_backColor(0)
- , m_updateBackColor(FALSE)
- , m_iCurRecord(-1)
- , m_iMaxRecord(128)
- , m_fSpaceAbove(0)
- , m_fSpaceBelow(0)
-{
- m_rtClient.Reset();
- m_rtEngine.Reset();
- m_rtStatic.Reset();
-}
-CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_fVAlignOffset(0.0f)
- , m_fScrollOffsetX(0.0f)
- , m_fScrollOffsetY(0.0f)
- , m_pEdtEngine(NULL)
- , m_bLButtonDown(FALSE)
- , m_nSelStart(0)
- , m_nLimit(-1)
- , m_fFontSize(0)
- , m_pVertScrollBar(NULL)
- , m_pHorzScrollBar(NULL)
- , m_pCaret(NULL)
- , m_iMin(-1)
- , m_iMax(0xFFFFFFF)
- , m_bSetRange(FALSE)
- , m_pTextField(NULL)
- , m_backColor(0)
- , m_updateBackColor(FALSE)
- , m_iCurRecord(-1)
- , m_iMaxRecord(128)
- , m_fSpaceAbove(0)
- , m_fSpaceBelow(0)
-{
- m_rtClient.Reset();
- m_rtEngine.Reset();
- m_rtStatic.Reset();
-}
-CFWL_EditImp::~CFWL_EditImp()
-{
+CFWL_EditImp::CFWL_EditImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_fVAlignOffset(0.0f),
+ m_fScrollOffsetX(0.0f),
+ m_fScrollOffsetY(0.0f),
+ m_pEdtEngine(NULL),
+ m_bLButtonDown(FALSE),
+ m_nSelStart(0),
+ m_nLimit(-1),
+ m_fFontSize(0),
+ m_pVertScrollBar(NULL),
+ m_pHorzScrollBar(NULL),
+ m_pCaret(NULL),
+ m_iMin(-1),
+ m_iMax(0xFFFFFFF),
+ m_bSetRange(FALSE),
+ m_pTextField(NULL),
+ m_backColor(0),
+ m_updateBackColor(FALSE),
+ m_iCurRecord(-1),
+ m_iMaxRecord(128),
+ m_fSpaceAbove(0),
+ m_fSpaceBelow(0) {
+ m_rtClient.Reset();
+ m_rtEngine.Reset();
+ m_rtStatic.Reset();
+}
+CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_fVAlignOffset(0.0f),
+ m_fScrollOffsetX(0.0f),
+ m_fScrollOffsetY(0.0f),
+ m_pEdtEngine(NULL),
+ m_bLButtonDown(FALSE),
+ m_nSelStart(0),
+ m_nLimit(-1),
+ m_fFontSize(0),
+ m_pVertScrollBar(NULL),
+ m_pHorzScrollBar(NULL),
+ m_pCaret(NULL),
+ m_iMin(-1),
+ m_iMax(0xFFFFFFF),
+ m_bSetRange(FALSE),
+ m_pTextField(NULL),
+ m_backColor(0),
+ m_updateBackColor(FALSE),
+ m_iCurRecord(-1),
+ m_iMaxRecord(128),
+ m_fSpaceAbove(0),
+ m_fSpaceBelow(0) {
+ m_rtClient.Reset();
+ m_rtEngine.Reset();
+ m_rtStatic.Reset();
+}
+CFWL_EditImp::~CFWL_EditImp() {
+ if (m_pEdtEngine) {
+ m_pEdtEngine->Release();
+ m_pEdtEngine = NULL;
+ }
+ if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->Release();
+ m_pHorzScrollBar = NULL;
+ }
+ if (m_pVertScrollBar) {
+ m_pVertScrollBar->Release();
+ m_pVertScrollBar = NULL;
+ }
+ if (m_pCaret) {
+ m_pCaret->Release();
+ m_pCaret = NULL;
+ }
+ ClearRecord();
+}
+FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_Edit;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_EditImp::GetClassID() const {
+ return FWL_CLASSHASH_Edit;
+}
+FWL_ERR CFWL_EditImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ if (!m_pDelegate) {
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_EditImpDelegate(this);
+ }
+ InitCaret();
+ if (!m_pEdtEngine) {
+ InitEngine();
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::Finalize() {
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ ShowCaret(FALSE);
+ }
+ if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->Finalize();
+ }
+ if (m_pVertScrollBar) {
+ m_pVertScrollBar->Finalize();
+ }
+ if (m_pDelegate) {
+ delete (CFWL_EditImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
if (m_pEdtEngine) {
- m_pEdtEngine->Release();
- m_pEdtEngine = NULL;
- }
- if (m_pHorzScrollBar) {
- m_pHorzScrollBar->Release();
- m_pHorzScrollBar = NULL;
- }
- if (m_pVertScrollBar) {
- m_pVertScrollBar->Release();
- m_pVertScrollBar = NULL;
- }
- if (m_pCaret) {
- m_pCaret->Release();
- m_pCaret = NULL;
- }
- ClearRecord();
-}
-FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_Edit;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_EditImp::GetClassID() const
-{
- return FWL_CLASSHASH_Edit;
-}
-FWL_ERR CFWL_EditImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- if (!m_pDelegate) {
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_EditImpDelegate(this);
- }
- InitCaret();
- if (!m_pEdtEngine) {
- InitEngine();
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::Finalize()
-{
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- ShowCaret(FALSE);
- }
- if (m_pHorzScrollBar) {
- m_pHorzScrollBar->Finalize();
- }
- if (m_pVertScrollBar) {
- m_pVertScrollBar->Finalize();
- }
- if ( m_pDelegate) {
- delete (CFWL_EditImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- if (m_pEdtEngine) {
- int32_t iTextLen = m_pEdtEngine->GetTextLength();
- if (iTextLen > 0) {
- CFX_WideString wsText;
- m_pEdtEngine->GetText(wsText, 0);
- CFX_SizeF sz = CalcTextSize(wsText,
- m_pProperties->m_pThemeProvider,
- m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine);
- rect.Set(0, 0, sz.x, sz.y);
- }
- }
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- if (IsShowScrollBar(TRUE)) {
- FX_FLOAT *pfWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- rect.width += *pfWidth;
- rect.width += FWL_EDIT_Margin;
- }
- if (IsShowScrollBar(FALSE)) {
- FX_FLOAT *pfWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- rect.height += *pfWidth;
- rect.height += FWL_EDIT_Margin;
- }
- }
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- ShowCaret(FALSE);
- }
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
-}
-FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF &rect)
-{
- return CFWL_WidgetImp::SetWidgetRect(rect);
-}
-FWL_ERR CFWL_EditImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- Layout();
- if (m_rtClient.IsEmpty()) {
- return FWL_ERR_Indefinite;
- }
- UpdateEditEngine();
- UpdateVAlignment();
- UpdateScroll();
- InitCaret();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
+ int32_t iTextLen = m_pEdtEngine->GetTextLength();
+ if (iTextLen > 0) {
+ CFX_WideString wsText;
+ m_pEdtEngine->GetText(wsText, 0);
+ CFX_SizeF sz = CalcTextSize(
+ wsText, m_pProperties->m_pThemeProvider,
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine);
+ rect.Set(0, 0, sz.x, sz.y);
+ }
+ }
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- if (IsShowScrollBar(TRUE)) {
- CFX_RectF rect;
- m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_VScrollBar;
- }
- }
- if (IsShowScrollBar(FALSE)) {
- CFX_RectF rect;
- m_pHorzScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_HScrollBar;
- }
- }
- }
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edit;
- }
- return FWL_WGTHITTEST_Unknown;
-}
-#define FX_EDIT_ISLATINWORD(u) (u == 0x2D || (u <= 0x005A && u >= 0x0041) || (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0) || u == 0x0027)
-static void AddSquigglyPath(CFX_Path& PathData, FX_FLOAT fStartX, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep)
-{
- PathData.MoveTo(fStartX, fY);
- FX_FLOAT fx;
- int32_t i;
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- PathData.LineTo(fx, fY + (i & 1)*fStep);
- }
-}
-void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData, int32_t nStart, int32_t nCount, FX_FLOAT fOffSetX, FX_FLOAT fOffSetY)
-{
- FX_FLOAT fStartX = 0.0f;
- FX_FLOAT fEndX = 0.0f;
- FX_FLOAT fY = 0.0f;
- FX_FLOAT fStep = 0.0f;
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- CFX_RectFArray rectArray;
- CFX_RectF rectText;
- const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams();
- FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * txtEdtParams->fFontSize / 1000;
- pPage->CalcRangeRectArray(nStart, nCount, rectArray);
- for (int i = 0; i < rectArray.GetSize(); i++) {
- rectText = rectArray.GetAt(i);
- fY = rectText.top + fAsent + fOffSetY;
- fStep = txtEdtParams->fFontSize / 16.0f;
- fStartX = rectText.left + fOffSetX;
- fEndX = fStartX + rectText.Width();
- AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
- }
-}
-int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount)
-{
- return 0;
-}
-FX_BOOL CFWL_EditImp::GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray &sSuggest)
-{
- int32_t nWordCount = 0;
- int32_t nWordStart = GetWordAtPoint(pointf, nWordCount);
- if (nWordCount < 1) {
- return FALSE;
- }
- CFX_WideString wsSpell;
- GetText(wsSpell, nWordStart, nWordCount);
- CFX_ByteString sLatinWord;
- for (int i = 0; i < nWordCount; i++) {
- if (!FX_EDIT_ISLATINWORD(wsSpell[i])) {
- break;
- }
- sLatinWord += (FX_CHAR)wsSpell[i];
- }
- if (sLatinWord.IsEmpty()) {
- return FALSE;
- }
- CFWL_EvtEdtCheckWord checkWordEvent;
- checkWordEvent.m_pSrcTarget = m_pInterface;
- checkWordEvent.bsWord = sLatinWord;
- checkWordEvent.bCheckWord = TRUE;
- DispatchEvent(&checkWordEvent);
- if (checkWordEvent.bCheckWord) {
- return FALSE;
- }
- CFWL_EvtEdtGetSuggestWords suggestWordsEvent;
- suggestWordsEvent.m_pSrcTarget = m_pInterface;
- suggestWordsEvent.bsWord = sLatinWord;
- suggestWordsEvent.bsArraySuggestWords = sSuggest;
- suggestWordsEvent.bSuggestWords = FALSE;
- DispatchEvent(&checkWordEvent);
- return suggestWordsEvent.bSuggestWords;
-}
-FX_BOOL CFWL_EditImp::ReplaceSpellCheckWord(CFX_PointF pointf, const CFX_ByteStringC& bsReplace)
-{
- int32_t nWordCount = 0;
- int32_t nWordStart = GetWordAtPoint(pointf, nWordCount);
- if (nWordCount < 1) {
- return FALSE;
- }
- CFX_WideString wsSpell;
- GetText(wsSpell, nWordStart, nWordCount);
- for (int i = 0; i < nWordCount; i++) {
- if (!FX_EDIT_ISLATINWORD(wsSpell[i])) {
- nWordCount = i;
- break;
- }
- }
- int32_t nDestLen = bsReplace.GetLength();
- CFX_WideString wsDest;
- FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen);
- for (int32_t i = 0; i < nDestLen; i++) {
- pBuffer[i] = bsReplace[i];
- }
- wsDest.ReleaseBuffer(nDestLen);
- Replace(nWordStart, nWordCount, wsDest);
- return TRUE;
-}
-void CFWL_EditImp::DrawSpellCheck(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- pGraphics->SaveGraphState();
+ if (IsShowScrollBar(TRUE)) {
+ FX_FLOAT* pfWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ rect.width += *pfWidth;
+ rect.width += FWL_EDIT_Margin;
+ }
+ if (IsShowScrollBar(FALSE)) {
+ FX_FLOAT* pfWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ rect.height += *pfWidth;
+ rect.height += FWL_EDIT_Margin;
+ }
+ }
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+ ShowCaret(FALSE);
+ }
+ return CFWL_WidgetImp::SetStates(dwStates, bSet);
+}
+FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) {
+ return CFWL_WidgetImp::SetWidgetRect(rect);
+}
+FWL_ERR CFWL_EditImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ Layout();
+ if (m_rtClient.IsEmpty()) {
+ return FWL_ERR_Indefinite;
+ }
+ UpdateEditEngine();
+ UpdateVAlignment();
+ UpdateScroll();
+ InitCaret();
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
+ if (IsShowScrollBar(TRUE)) {
+ CFX_RectF rect;
+ m_pVertScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_VScrollBar;
+ }
+ }
+ if (IsShowScrollBar(FALSE)) {
+ CFX_RectF rect;
+ m_pHorzScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_HScrollBar;
+ }
+ }
+ }
+ if (m_rtClient.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Edit;
+ }
+ return FWL_WGTHITTEST_Unknown;
+}
+#define FX_EDIT_ISLATINWORD(u) \
+ (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
+ (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0) || \
+ u == 0x0027)
+static void AddSquigglyPath(CFX_Path& PathData,
+ FX_FLOAT fStartX,
+ FX_FLOAT fEndX,
+ FX_FLOAT fY,
+ FX_FLOAT fStep) {
+ PathData.MoveTo(fStartX, fY);
+ FX_FLOAT fx;
+ int32_t i;
+ for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
+ PathData.LineTo(fx, fY + (i & 1) * fStep);
+ }
+}
+void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData,
+ int32_t nStart,
+ int32_t nCount,
+ FX_FLOAT fOffSetX,
+ FX_FLOAT fOffSetY) {
+ FX_FLOAT fStartX = 0.0f;
+ FX_FLOAT fEndX = 0.0f;
+ FX_FLOAT fY = 0.0f;
+ FX_FLOAT fStep = 0.0f;
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ CFX_RectFArray rectArray;
+ CFX_RectF rectText;
+ const FDE_TXTEDTPARAMS* txtEdtParams = m_pEdtEngine->GetEditParams();
+ FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() *
+ txtEdtParams->fFontSize / 1000;
+ pPage->CalcRangeRectArray(nStart, nCount, rectArray);
+ for (int i = 0; i < rectArray.GetSize(); i++) {
+ rectText = rectArray.GetAt(i);
+ fY = rectText.top + fAsent + fOffSetY;
+ fStep = txtEdtParams->fFontSize / 16.0f;
+ fStartX = rectText.left + fOffSetX;
+ fEndX = fStartX + rectText.Width();
+ AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
+ }
+}
+int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) {
+ return 0;
+}
+FX_BOOL CFWL_EditImp::GetSuggestWords(CFX_PointF pointf,
+ CFX_ByteStringArray& sSuggest) {
+ int32_t nWordCount = 0;
+ int32_t nWordStart = GetWordAtPoint(pointf, nWordCount);
+ if (nWordCount < 1) {
+ return FALSE;
+ }
+ CFX_WideString wsSpell;
+ GetText(wsSpell, nWordStart, nWordCount);
+ CFX_ByteString sLatinWord;
+ for (int i = 0; i < nWordCount; i++) {
+ if (!FX_EDIT_ISLATINWORD(wsSpell[i])) {
+ break;
+ }
+ sLatinWord += (FX_CHAR)wsSpell[i];
+ }
+ if (sLatinWord.IsEmpty()) {
+ return FALSE;
+ }
+ CFWL_EvtEdtCheckWord checkWordEvent;
+ checkWordEvent.m_pSrcTarget = m_pInterface;
+ checkWordEvent.bsWord = sLatinWord;
+ checkWordEvent.bCheckWord = TRUE;
+ DispatchEvent(&checkWordEvent);
+ if (checkWordEvent.bCheckWord) {
+ return FALSE;
+ }
+ CFWL_EvtEdtGetSuggestWords suggestWordsEvent;
+ suggestWordsEvent.m_pSrcTarget = m_pInterface;
+ suggestWordsEvent.bsWord = sLatinWord;
+ suggestWordsEvent.bsArraySuggestWords = sSuggest;
+ suggestWordsEvent.bSuggestWords = FALSE;
+ DispatchEvent(&checkWordEvent);
+ return suggestWordsEvent.bSuggestWords;
+}
+FX_BOOL CFWL_EditImp::ReplaceSpellCheckWord(CFX_PointF pointf,
+ const CFX_ByteStringC& bsReplace) {
+ int32_t nWordCount = 0;
+ int32_t nWordStart = GetWordAtPoint(pointf, nWordCount);
+ if (nWordCount < 1) {
+ return FALSE;
+ }
+ CFX_WideString wsSpell;
+ GetText(wsSpell, nWordStart, nWordCount);
+ for (int i = 0; i < nWordCount; i++) {
+ if (!FX_EDIT_ISLATINWORD(wsSpell[i])) {
+ nWordCount = i;
+ break;
+ }
+ }
+ int32_t nDestLen = bsReplace.GetLength();
+ CFX_WideString wsDest;
+ FX_WCHAR* pBuffer = wsDest.GetBuffer(nDestLen);
+ for (int32_t i = 0; i < nDestLen; i++) {
+ pBuffer[i] = bsReplace[i];
+ }
+ wsDest.ReleaseBuffer(nDestLen);
+ Replace(nWordStart, nWordCount, wsDest);
+ return TRUE;
+}
+void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ pGraphics->SaveGraphState();
+ if (pMatrix) {
+ pGraphics->ConcatMatrix((CFX_Matrix*)pMatrix);
+ }
+ FX_ARGB cr = 0xFFFF0000;
+ CFX_Color crLine(cr);
+ FX_FLOAT fWidth = 1.0f;
+ CFWL_EvtEdtCheckWord checkWordEvent;
+ checkWordEvent.m_pSrcTarget = m_pInterface;
+ CFX_ByteString sLatinWord;
+ CFX_Path pathSpell;
+ pathSpell.Create();
+ int32_t nStart = 0;
+ FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
+ FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
+ CFX_WideString wsSpell;
+ this->GetText(wsSpell);
+ int32_t nContentLen = wsSpell.GetLength();
+ for (int i = 0; i < nContentLen; i++) {
+ if (FX_EDIT_ISLATINWORD(wsSpell[i])) {
+ if (sLatinWord.IsEmpty()) {
+ nStart = i;
+ }
+ sLatinWord += (FX_CHAR)wsSpell[i];
+ } else {
+ checkWordEvent.bsWord = sLatinWord;
+ checkWordEvent.bCheckWord = TRUE;
+ DispatchEvent(&checkWordEvent);
+ if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) {
+ AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX,
+ fOffSetY);
+ }
+ sLatinWord.Empty();
+ }
+ }
+ checkWordEvent.bsWord = sLatinWord;
+ checkWordEvent.bCheckWord = TRUE;
+ DispatchEvent(&checkWordEvent);
+ if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) {
+ AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX,
+ fOffSetY);
+ }
+ if (!pathSpell.IsEmpty()) {
+ CFX_RectF rtClip = m_rtEngine;
+ CFX_Matrix mt;
+ mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY);
if (pMatrix) {
- pGraphics->ConcatMatrix((CFX_Matrix*)pMatrix);
- }
- FX_ARGB cr = 0xFFFF0000;
- CFX_Color crLine(cr);
- FX_FLOAT fWidth = 1.0f;
- CFWL_EvtEdtCheckWord checkWordEvent;
- checkWordEvent.m_pSrcTarget = m_pInterface;
- CFX_ByteString sLatinWord;
- CFX_Path pathSpell;
- pathSpell.Create();
- int32_t nStart = 0;
- FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
- FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
- CFX_WideString wsSpell;
- this->GetText(wsSpell);
- int32_t nContentLen = wsSpell.GetLength();
- for (int i = 0; i < nContentLen; i++) {
- if (FX_EDIT_ISLATINWORD(wsSpell[i])) {
- if (sLatinWord.IsEmpty()) {
- nStart = i;
- }
- sLatinWord += (FX_CHAR)wsSpell[i];
- } else {
- checkWordEvent.bsWord = sLatinWord;
- checkWordEvent.bCheckWord = TRUE;
- DispatchEvent(&checkWordEvent);
- if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) {
- AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, fOffSetY);
- }
- sLatinWord.Empty();
- }
- }
- checkWordEvent.bsWord = sLatinWord;
- checkWordEvent.bCheckWord = TRUE;
- DispatchEvent(&checkWordEvent);
- if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) {
- AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, fOffSetY);
- }
- if (!pathSpell.IsEmpty()) {
- CFX_RectF rtClip = m_rtEngine;
- CFX_Matrix mt;
- mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY);
- if (pMatrix) {
- pMatrix->TransformRect(rtClip);
- mt.Concat(*pMatrix);
- }
- pGraphics->SetClipRect(rtClip);
- pGraphics->SetStrokeColor(&crLine);
- pGraphics->SetLineWidth(0);
- pGraphics->StrokePath(&pathSpell, NULL);
- }
- pGraphics->RestoreGraphState();
-}
-FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- if (m_rtClient.IsEmpty()) {
- return FWL_ERR_Indefinite;
- }
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (!m_pWidgetMgr->IsFormDisabled()) {
- DrawTextBk(pGraphics, pTheme, pMatrix);
- }
- if (m_pEdtEngine) {
- DrawContent(pGraphics, pTheme, pMatrix);
- }
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) {
- DrawSpellCheck(pGraphics, pMatrix);
- }
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_EDT_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_EDT_Edge, pTheme, pMatrix);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider *pThemeProvider)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pThemeProvider, FWL_ERR_Indefinite);
- if (m_pHorzScrollBar) {
- m_pHorzScrollBar->SetThemeProvider(pThemeProvider);
- }
- if (m_pVertScrollBar) {
- m_pVertScrollBar->SetThemeProvider(pThemeProvider);
- }
- if (m_pCaret) {
- m_pCaret->SetThemeProvider(pThemeProvider);
- }
- m_pProperties->m_pThemeProvider = pThemeProvider;
+ pMatrix->TransformRect(rtClip);
+ mt.Concat(*pMatrix);
+ }
+ pGraphics->SetClipRect(rtClip);
+ pGraphics->SetStrokeColor(&crLine);
+ pGraphics->SetLineWidth(0);
+ pGraphics->StrokePath(&pathSpell, NULL);
+ }
+ pGraphics->RestoreGraphState();
+}
+FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ if (m_rtClient.IsEmpty()) {
+ return FWL_ERR_Indefinite;
+ }
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (!m_pWidgetMgr->IsFormDisabled()) {
+ DrawTextBk(pGraphics, pTheme, pMatrix);
+ }
+ if (m_pEdtEngine) {
+ DrawContent(pGraphics, pTheme, pMatrix);
+ }
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) &&
+ !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) {
+ DrawSpellCheck(pGraphics, pMatrix);
+ }
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_EDT_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_EDT_Edge, pTheme, pMatrix);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ _FWL_RETURN_VALUE_IF_FAIL(pThemeProvider, FWL_ERR_Indefinite);
+ if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->SetThemeProvider(pThemeProvider);
+ }
+ if (m_pVertScrollBar) {
+ m_pVertScrollBar->SetThemeProvider(pThemeProvider);
+ }
+ if (m_pCaret) {
+ m_pCaret->SetThemeProvider(pThemeProvider);
+ }
+ m_pProperties->m_pThemeProvider = pThemeProvider;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetText(const CFX_WideString& wsText) {
+ m_pEdtEngine->SetText(wsText);
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_EditImp::GetTextLength() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
+ return m_pEdtEngine->GetTextLength();
+}
+FWL_ERR CFWL_EditImp::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->GetText(wsText, nStart, nCount);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::ClearText() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->ClearText();
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_EditImp::GetCaretPos() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
+ return m_pEdtEngine->GetCaretPos();
+}
+int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
+ return m_pEdtEngine->SetCaretPos(nIndex, bBefore);
+}
+FWL_ERR CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->AddSelRange(nStart, nCount);
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_EditImp::CountSelRanges() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, 0);
+ return m_pEdtEngine->CountSelRanges();
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
+ return m_pEdtEngine->GetSelRange(nIndex, nStart);
+}
+FWL_ERR CFWL_EditImp::ClearSelections() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->ClearSelection();
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_EditImp::GetLimit() {
+ return m_nLimit;
+}
+FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit) {
+ m_nLimit = nLimit;
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->SetLimit(nLimit);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Indefinite);
+ m_pEdtEngine->SetAliasChar(wAlias);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetFormatString(const CFX_WideString& wsFormat) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->SetFormatBlock(0, wsFormat);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+ return FWL_ERR_Indefinite;
+ }
+ m_pEdtEngine->Insert(nStart, lpText, nLen);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::DeleteSelections() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ int32_t iCount = m_pEdtEngine->CountSelRanges();
+ if (iCount > 0) {
+ m_pEdtEngine->Delete(-1);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->DeleteRange(nStart, nCount);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::ReplaceSelections(const CFX_WideStringC& wsReplace) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ int32_t iCount = m_pEdtEngine->CountSelRanges();
+ for (int i = 0; i < iCount; i++) {
+ int32_t nStart;
+ int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart);
+ m_pEdtEngine->Replace(nStart, nCount, wsReplace);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ m_pEdtEngine->Replace(nStart, nLen, wsReplace);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetText(const CFX_WideString &wsText)
-{
- m_pEdtEngine->SetText(wsText);
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_EditImp::GetTextLength() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
- return m_pEdtEngine->GetTextLength();
-}
-FWL_ERR CFWL_EditImp::GetText(CFX_WideString &wsText, int32_t nStart , int32_t nCount ) const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->GetText(wsText, nStart, nCount);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::ClearText()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->ClearText();
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_EditImp::GetCaretPos() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
- return m_pEdtEngine->GetCaretPos();
-}
-int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
- return m_pEdtEngine->SetCaretPos(nIndex, bBefore);
-}
-FWL_ERR CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->AddSelRange(nStart, nCount);
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_EditImp::CountSelRanges()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, 0);
- return m_pEdtEngine->CountSelRanges();
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t &nStart)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, -1);
- return m_pEdtEngine->GetSelRange(nIndex, nStart);
-}
-FWL_ERR CFWL_EditImp::ClearSelections()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->ClearSelection();
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_EditImp::GetLimit()
-{
- return m_nLimit;
-}
-FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit)
-{
- m_nLimit = nLimit;
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->SetLimit(nLimit);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Indefinite);
- m_pEdtEngine->SetAliasChar(wAlias);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetFormatString(const CFX_WideString &wsFormat)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->SetFormatBlock(0, wsFormat);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- if ( (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)
- || (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- return FWL_ERR_Indefinite;
- }
- m_pEdtEngine->Insert(nStart, lpText, nLen);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::DeleteSelections()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- int32_t iCount = m_pEdtEngine->CountSelRanges();
- if (iCount > 0) {
- m_pEdtEngine->Delete(-1);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->DeleteRange(nStart, nCount);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::ReplaceSelections(const CFX_WideStringC &wsReplace)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- int32_t iCount = m_pEdtEngine->CountSelRanges();
- for (int i = 0; i < iCount; i ++) {
- int32_t nStart;
- int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart);
- m_pEdtEngine->Replace(nStart, nCount, wsReplace);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::Replace(int32_t nStart, int32_t nLen, const CFX_WideStringC &wsReplace)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- m_pEdtEngine->Replace(nStart, nLen, wsReplace);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- if ( (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)
- || (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- return FWL_ERR_Succeeded;
- }
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(pNative, FWL_ERR_Indefinite);
- IFWL_AdapterClipboardMgr *pClipBorder = pNative->GetClipboardMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pClipBorder, FWL_ERR_Indefinite);
- CFX_WideString wsText;
- switch(iCmd) {
- case 1: {
- int32_t nStart;
- int32_t nCount = m_pEdtEngine->GetSelRange(0, nStart);
- if (nCount < 1) {
- break;
- }
- m_pEdtEngine->GetText(wsText, nStart, nCount);
- pClipBorder->SetStringData(wsText);
- break;
- }
- case 2: {
- int32_t nStart;
- int32_t nCount = m_pEdtEngine->GetSelRange(0, nStart);
- if (nCount < 1) {
- break;
- }
- m_pEdtEngine->GetText(wsText, nStart, nCount);
- m_pEdtEngine->DeleteRange(nStart, nCount);
- m_pEdtEngine->ClearSelection();
- pClipBorder->SetStringData(wsText);
- break;
- }
- case 3: {
- pClipBorder->GetStringData(wsText);
- int32_t iLen = wsText.GetLength();
- if (iLen < 0) {
- break;
- }
- if (wsText[iLen] == L'\0') {
- if (iLen == 1) {
- break;
- }
- iLen --;
- wsText = wsText.Left(iLen);
- }
- int32_t nPos = m_pEdtEngine->GetCaretPos();
- m_pEdtEngine->Insert(nPos, wsText, iLen);
- break;
- }
- default: {
- }
- }
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_EditImp::Copy(CFX_WideString &wsCopy)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- int32_t nCount = m_pEdtEngine->CountSelRanges();
- if (nCount == 0) {
- return FALSE;
- }
- wsCopy.Empty();
- CFX_WideString wsTemp;
- int32_t nStart, nLength;
- for (int32_t i = 0; i < nCount; i ++) {
- nLength = m_pEdtEngine->GetSelRange(i, nStart);
- m_pEdtEngine->GetText(wsTemp, nStart, nLength);
- wsCopy += wsTemp;
- wsTemp.Empty();
- }
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::Cut(CFX_WideString &wsCut)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- int32_t nCount = m_pEdtEngine->CountSelRanges();
- if (nCount == 0) {
- return FALSE;
- }
- wsCut.Empty();
- CFX_WideString wsTemp;
- int32_t nStart, nLength;
- for (int32_t i = 0; i < nCount; i ++) {
- nLength = m_pEdtEngine->GetSelRange(i, nStart);
- m_pEdtEngine->GetText(wsTemp, nStart, nLength);
- wsCut += wsTemp;
- wsTemp.Empty();
- }
- m_pEdtEngine->Delete(0);
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::Paste(const CFX_WideString &wsPaste)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- int32_t nCaret = m_pEdtEngine->GetCaretPos();
- int32_t iError = m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength());
- if (iError < 0) {
- ProcessInsertError(iError);
- return FALSE;
- }
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::Delete()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- int32_t nCount = m_pEdtEngine->CountSelRanges();
- if (nCount < 1) {
- return FALSE;
- }
- m_pEdtEngine->Delete(0);
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) {
- return TRUE;
- }
- return m_pEdtEngine->Redo(bsRecord);
-}
-FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) {
- return TRUE;
- }
- return m_pEdtEngine->Undo(bsRecord);
-}
-FX_BOOL CFWL_EditImp::Undo()
-{
- if (!CanUndo()) {
- return FALSE;
- }
- CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--];
- return Undo(bsRecord);
-}
-FX_BOOL CFWL_EditImp::Redo()
-{
- if (!CanRedo()) {
- return FALSE;
- }
- CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord];
- return Redo(bsRecord);
-}
-FX_BOOL CFWL_EditImp::CanUndo()
-{
- return m_iCurRecord >= 0;
-}
-FX_BOOL CFWL_EditImp::CanRedo()
-{
- return m_iCurRecord < m_RecordArr.GetSize() - 1;
-}
-FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
- FDE_LPTXTEDTPARAMS pParams = (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams();
- pParams->fTabWidth = fTabWidth;
- pParams->bTabEquidistant = bEquidistant;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget *pOuter)
-{
- m_pOuter = pOuter;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax)
-{
- m_iMin = iMin;
- m_iMax = iMax;
- m_bSetRange = TRUE;
- return FWL_ERR_Succeeded;
-}
-void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine *pEdit, int32_t nPage, FX_BOOL bVisible )
-{
- if (m_rtEngine.IsEmpty()) {
- return;
- }
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- return;
- }
- FX_BOOL bRepaintContent = UpdateOffset();
- UpdateCaret();
- CFX_RectF rtInvalid;
- rtInvalid.Set(0, 0, 0, 0);
- FX_BOOL bRepaintScroll = FALSE;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
- IFWL_ScrollBar *pScroll = UpdateScroll();
- if (pScroll) {
- pScroll->GetWidgetRect(rtInvalid);
- bRepaintScroll = TRUE;
- }
- }
- if (bRepaintContent || bRepaintScroll) {
- if (bRepaintContent) {
- rtInvalid.Union(m_rtEngine);
+ }
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(pNative, FWL_ERR_Indefinite);
+ IFWL_AdapterClipboardMgr* pClipBorder = pNative->GetClipboardMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pClipBorder, FWL_ERR_Indefinite);
+ CFX_WideString wsText;
+ switch (iCmd) {
+ case 1: {
+ int32_t nStart;
+ int32_t nCount = m_pEdtEngine->GetSelRange(0, nStart);
+ if (nCount < 1) {
+ break;
+ }
+ m_pEdtEngine->GetText(wsText, nStart, nCount);
+ pClipBorder->SetStringData(wsText);
+ break;
+ }
+ case 2: {
+ int32_t nStart;
+ int32_t nCount = m_pEdtEngine->GetSelRange(0, nStart);
+ if (nCount < 1) {
+ break;
+ }
+ m_pEdtEngine->GetText(wsText, nStart, nCount);
+ m_pEdtEngine->DeleteRange(nStart, nCount);
+ m_pEdtEngine->ClearSelection();
+ pClipBorder->SetStringData(wsText);
+ break;
+ }
+ case 3: {
+ pClipBorder->GetStringData(wsText);
+ int32_t iLen = wsText.GetLength();
+ if (iLen < 0) {
+ break;
+ }
+ if (wsText[iLen] == L'\0') {
+ if (iLen == 1) {
+ break;
}
- Repaint(&rtInvalid);
- }
-}
-void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine *pEdit, FDE_TXTEDT_TEXTCHANGE_INFO &ChangeInfo)
-{
- FX_DWORD dwStyleEx = m_pProperties->m_dwStyleExes;
- if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) {
- UpdateVAlignment();
- }
- IFDE_TxtEdtPage *page = m_pEdtEngine->GetPage(0);
- FX_FLOAT fContentWidth = page->GetContentsBox().width;
- FX_FLOAT fContentHeight = page->GetContentsBox().height;
- CFX_RectF rtTemp;
- GetClientRect(rtTemp);
- FX_BOOL bHSelfAdaption = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption;
- FX_BOOL bVSelfAdaption = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption;
- FX_BOOL bNeedUpdate = FALSE;
- if (bHSelfAdaption || bVSelfAdaption) {
- CFWL_EvtEdtPreSelfAdaption evt;
- evt.m_pSrcTarget = m_pInterface;
- evt.bHSelfAdaption = TRUE;
- evt.bVSelfAdaption = TRUE;
- FX_FLOAT fWidth;
- FX_FLOAT fHight;
- fWidth = bHSelfAdaption ? fContentWidth : m_pProperties->m_rtWidget.width;
- fHight = bVSelfAdaption ? fContentHeight : m_pProperties->m_rtWidget.height;
- evt.rtAfterChange.Set(0, 0, fWidth, fHight);
- DispatchEvent(&evt);
- if (!evt.bHSelfAdaption) {
- ModifyStylesEx(0, FWL_STYLEEXT_EDT_HSelfAdaption | FWL_STYLEEXT_EDT_AutoHScroll);
- }
- if (!evt.bVSelfAdaption) {
- ModifyStylesEx(0, FWL_STYLEEXT_EDT_VSelfAdaption | FWL_STYLEEXT_EDT_AutoVScroll);
- }
- bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) || (bVSelfAdaption && !evt.bVSelfAdaption);
- }
- FX_FLOAT fContentWidth1 = fContentWidth;
- FX_FLOAT fContentHeight1 = fContentHeight;
- if (bNeedUpdate) {
- UpdateEditParams();
- UpdateEditLayout();
- IFDE_TxtEdtPage *page1 = m_pEdtEngine->GetPage(0);
- fContentWidth1 = page1->GetContentsBox().width;
- fContentHeight1 = page1->GetContentsBox().height;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) {
- rtTemp.width = FX_MAX(m_pProperties->m_rtWidget.width, fContentWidth1);
- m_pProperties->m_rtWidget.width = fContentWidth1;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) {
- rtTemp.height = FX_MAX(m_pProperties->m_rtWidget.height, fContentHeight1);
- m_pProperties->m_rtWidget.height = fContentHeight1;
- }
- CFWL_EvtEdtTextChanged event;
- event.m_pSrcTarget = m_pInterface;
- event.nChangeType = ChangeInfo.nChangeType;
- event.wsInsert = ChangeInfo.wsInsert;
- event.wsDelete = ChangeInfo.wsDelete;
- event.wsPrevText = ChangeInfo.wsPrevText;
- DispatchEvent(&event);
- LayoutScrollBar();
- Repaint(&rtTemp);
-}
-void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine *pEdit)
-{
- CFX_RectF rtTemp;
- GetClientRect(rtTemp);
- Repaint(&rtTemp);
-}
-FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine *pEdit, int32_t nPageIndex, int32_t nPurpose)
-{
- IFDE_TxtEdtEngine *pEdtEngine = m_pEdtEngine;
- IFDE_TxtEdtPage *pPage = pEdtEngine->GetPage(nPageIndex);
- _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
- pPage->LoadPage();
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine *pEdit, int32_t nPageIndex, int32_t nPurpose)
-{
- IFDE_TxtEdtEngine *pEdtEngine = m_pEdtEngine;
- IFDE_TxtEdtPage *pPage = pEdtEngine->GetPage(nPageIndex);
- _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
- pPage->UnloadPage();
- return TRUE;
+ iLen--;
+ wsText = wsText.Left(iLen);
+ }
+ int32_t nPos = m_pEdtEngine->GetCaretPos();
+ m_pEdtEngine->Insert(nPos, wsText, iLen);
+ break;
+ }
+ default: {}
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ int32_t nCount = m_pEdtEngine->CountSelRanges();
+ if (nCount == 0) {
+ return FALSE;
+ }
+ wsCopy.Empty();
+ CFX_WideString wsTemp;
+ int32_t nStart, nLength;
+ for (int32_t i = 0; i < nCount; i++) {
+ nLength = m_pEdtEngine->GetSelRange(i, nStart);
+ m_pEdtEngine->GetText(wsTemp, nStart, nLength);
+ wsCopy += wsTemp;
+ wsTemp.Empty();
+ }
+ return TRUE;
+}
+FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ int32_t nCount = m_pEdtEngine->CountSelRanges();
+ if (nCount == 0) {
+ return FALSE;
+ }
+ wsCut.Empty();
+ CFX_WideString wsTemp;
+ int32_t nStart, nLength;
+ for (int32_t i = 0; i < nCount; i++) {
+ nLength = m_pEdtEngine->GetSelRange(i, nStart);
+ m_pEdtEngine->GetText(wsTemp, nStart, nLength);
+ wsCut += wsTemp;
+ wsTemp.Empty();
+ }
+ m_pEdtEngine->Delete(0);
+ return TRUE;
+}
+FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ int32_t nCaret = m_pEdtEngine->GetCaretPos();
+ int32_t iError =
+ m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength());
+ if (iError < 0) {
+ ProcessInsertError(iError);
+ return FALSE;
+ }
+ return TRUE;
}
-void CFWL_EditImp::On_AddDoRecord(IFDE_TxtEdtEngine *pEdit, const CFX_ByteStringC& bsDoRecord)
-{
- AddDoRecord(bsDoRecord);
- CFWL_WidgetImp *pSrcTarget = GetRootOuter();
- if (!pSrcTarget) {
- pSrcTarget = this;
- }
- CFWL_EvtEdtAddDoRecord evt;
- evt.m_pSrcTarget = m_pInterface;
- evt.m_wsDoRecord = bsDoRecord;
- m_pDelegate->OnProcessEvent(&evt);
+FX_BOOL CFWL_EditImp::Delete() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ int32_t nCount = m_pEdtEngine->CountSelRanges();
+ if (nCount < 1) {
+ return FALSE;
+ }
+ m_pEdtEngine->Delete(0);
+ return TRUE;
}
-FX_BOOL CFWL_EditImp::On_ValidateField(IFDE_TxtEdtEngine *pEdit, int32_t nBlockIndex, int32_t nFieldIndex, \
- const CFX_WideString &wsFieldText, int32_t nCharIndex)
-{
+FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) {
return TRUE;
+ }
+ return m_pEdtEngine->Redo(bsRecord);
}
-FX_BOOL CFWL_EditImp::On_ValidateBlock(IFDE_TxtEdtEngine *pEdit, int32_t nBlockIndex)
-{
+FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) {
return TRUE;
+ }
+ return m_pEdtEngine->Undo(bsRecord);
}
-FX_BOOL CFWL_EditImp::On_GetBlockFormatText(IFDE_TxtEdtEngine *pEdit, int32_t nBlockIndex, CFX_WideString &wsBlockText)
-{
+FX_BOOL CFWL_EditImp::Undo() {
+ if (!CanUndo()) {
return FALSE;
+ }
+ CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--];
+ return Undo(bsRecord);
}
-FX_BOOL CFWL_EditImp::On_Validate(IFDE_TxtEdtEngine * pEdit, CFX_WideString &wsText)
-{
- IFWL_Widget *pDst = GetOuter();
- if (!pDst) {
- pDst = (IFWL_Widget*)this;
- }
- CFWL_EvtEdtValidate event;
- event.pDstWidget = pDst;
- event.m_pSrcTarget = m_pInterface;
- event.wsInsert = wsText;
- event.bValidate = TRUE;
- DispatchEvent(&event);
- return event.bValidate;
-}
-FWL_ERR CFWL_EditImp::SetBackgroundColor(FX_DWORD color)
-{
- m_backColor = color;
- m_updateBackColor = TRUE;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString &wsFont, FX_FLOAT fSize)
-{
- m_wsFont = wsFont;
- m_fFontSize = fSize;
- return FWL_ERR_Succeeded;
-}
-void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset)
-{
- m_fScrollOffsetY = fScrollOffset;
-}
-void CFWL_EditImp::DrawTextBk(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix )
-{
+FX_BOOL CFWL_EditImp::Redo() {
+ if (!CanRedo()) {
+ return FALSE;
+ }
+ CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord];
+ return Redo(bsRecord);
+}
+FX_BOOL CFWL_EditImp::CanUndo() {
+ return m_iCurRecord >= 0;
+}
+FX_BOOL CFWL_EditImp::CanRedo() {
+ return m_iCurRecord < m_RecordArr.GetSize() - 1;
+}
+FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FWL_ERR_Succeeded);
+ FDE_LPTXTEDTPARAMS pParams =
+ (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams();
+ pParams->fTabWidth = fTabWidth;
+ pParams->bTabEquidistant = bEquidistant;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) {
+ m_pOuter = pOuter;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) {
+ m_iMin = iMin;
+ m_iMax = iMax;
+ m_bSetRange = TRUE;
+ return FWL_ERR_Succeeded;
+}
+void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPage,
+ FX_BOOL bVisible) {
+ if (m_rtEngine.IsEmpty()) {
+ return;
+ }
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ return;
+ }
+ FX_BOOL bRepaintContent = UpdateOffset();
+ UpdateCaret();
+ CFX_RectF rtInvalid;
+ rtInvalid.Set(0, 0, 0, 0);
+ FX_BOOL bRepaintScroll = FALSE;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
+ IFWL_ScrollBar* pScroll = UpdateScroll();
+ if (pScroll) {
+ pScroll->GetWidgetRect(rtInvalid);
+ bRepaintScroll = TRUE;
+ }
+ }
+ if (bRepaintContent || bRepaintScroll) {
+ if (bRepaintContent) {
+ rtInvalid.Union(m_rtEngine);
+ }
+ Repaint(&rtInvalid);
+ }
+}
+void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit,
+ FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
+ FX_DWORD dwStyleEx = m_pProperties->m_dwStyleExes;
+ if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) {
+ UpdateVAlignment();
+ }
+ IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0);
+ FX_FLOAT fContentWidth = page->GetContentsBox().width;
+ FX_FLOAT fContentHeight = page->GetContentsBox().height;
+ CFX_RectF rtTemp;
+ GetClientRect(rtTemp);
+ FX_BOOL bHSelfAdaption =
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption;
+ FX_BOOL bVSelfAdaption =
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption;
+ FX_BOOL bNeedUpdate = FALSE;
+ if (bHSelfAdaption || bVSelfAdaption) {
+ CFWL_EvtEdtPreSelfAdaption evt;
+ evt.m_pSrcTarget = m_pInterface;
+ evt.bHSelfAdaption = TRUE;
+ evt.bVSelfAdaption = TRUE;
+ FX_FLOAT fWidth;
+ FX_FLOAT fHight;
+ fWidth = bHSelfAdaption ? fContentWidth : m_pProperties->m_rtWidget.width;
+ fHight = bVSelfAdaption ? fContentHeight : m_pProperties->m_rtWidget.height;
+ evt.rtAfterChange.Set(0, 0, fWidth, fHight);
+ DispatchEvent(&evt);
+ if (!evt.bHSelfAdaption) {
+ ModifyStylesEx(
+ 0, FWL_STYLEEXT_EDT_HSelfAdaption | FWL_STYLEEXT_EDT_AutoHScroll);
+ }
+ if (!evt.bVSelfAdaption) {
+ ModifyStylesEx(
+ 0, FWL_STYLEEXT_EDT_VSelfAdaption | FWL_STYLEEXT_EDT_AutoVScroll);
+ }
+ bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) ||
+ (bVSelfAdaption && !evt.bVSelfAdaption);
+ }
+ FX_FLOAT fContentWidth1 = fContentWidth;
+ FX_FLOAT fContentHeight1 = fContentHeight;
+ if (bNeedUpdate) {
+ UpdateEditParams();
+ UpdateEditLayout();
+ IFDE_TxtEdtPage* page1 = m_pEdtEngine->GetPage(0);
+ fContentWidth1 = page1->GetContentsBox().width;
+ fContentHeight1 = page1->GetContentsBox().height;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) {
+ rtTemp.width = FX_MAX(m_pProperties->m_rtWidget.width, fContentWidth1);
+ m_pProperties->m_rtWidget.width = fContentWidth1;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) {
+ rtTemp.height = FX_MAX(m_pProperties->m_rtWidget.height, fContentHeight1);
+ m_pProperties->m_rtWidget.height = fContentHeight1;
+ }
+ CFWL_EvtEdtTextChanged event;
+ event.m_pSrcTarget = m_pInterface;
+ event.nChangeType = ChangeInfo.nChangeType;
+ event.wsInsert = ChangeInfo.wsInsert;
+ event.wsDelete = ChangeInfo.wsDelete;
+ event.wsPrevText = ChangeInfo.wsPrevText;
+ DispatchEvent(&event);
+ LayoutScrollBar();
+ Repaint(&rtTemp);
+}
+void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine* pEdit) {
+ CFX_RectF rtTemp;
+ GetClientRect(rtTemp);
+ Repaint(&rtTemp);
+}
+FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPageIndex,
+ int32_t nPurpose) {
+ IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
+ IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
+ _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
+ pPage->LoadPage();
+ return TRUE;
+}
+FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPageIndex,
+ int32_t nPurpose) {
+ IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
+ IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
+ _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
+ pPage->UnloadPage();
+ return TRUE;
+}
+void CFWL_EditImp::On_AddDoRecord(IFDE_TxtEdtEngine* pEdit,
+ const CFX_ByteStringC& bsDoRecord) {
+ AddDoRecord(bsDoRecord);
+ CFWL_WidgetImp* pSrcTarget = GetRootOuter();
+ if (!pSrcTarget) {
+ pSrcTarget = this;
+ }
+ CFWL_EvtEdtAddDoRecord evt;
+ evt.m_pSrcTarget = m_pInterface;
+ evt.m_wsDoRecord = bsDoRecord;
+ m_pDelegate->OnProcessEvent(&evt);
+}
+FX_BOOL CFWL_EditImp::On_ValidateField(IFDE_TxtEdtEngine* pEdit,
+ int32_t nBlockIndex,
+ int32_t nFieldIndex,
+ const CFX_WideString& wsFieldText,
+ int32_t nCharIndex) {
+ return TRUE;
+}
+FX_BOOL CFWL_EditImp::On_ValidateBlock(IFDE_TxtEdtEngine* pEdit,
+ int32_t nBlockIndex) {
+ return TRUE;
+}
+FX_BOOL CFWL_EditImp::On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit,
+ int32_t nBlockIndex,
+ CFX_WideString& wsBlockText) {
+ return FALSE;
+}
+FX_BOOL CFWL_EditImp::On_Validate(IFDE_TxtEdtEngine* pEdit,
+ CFX_WideString& wsText) {
+ IFWL_Widget* pDst = GetOuter();
+ if (!pDst) {
+ pDst = (IFWL_Widget*)this;
+ }
+ CFWL_EvtEdtValidate event;
+ event.pDstWidget = pDst;
+ event.m_pSrcTarget = m_pInterface;
+ event.wsInsert = wsText;
+ event.bValidate = TRUE;
+ DispatchEvent(&event);
+ return event.bValidate;
+}
+FWL_ERR CFWL_EditImp::SetBackgroundColor(FX_DWORD color) {
+ m_backColor = color;
+ m_updateBackColor = TRUE;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+ m_wsFont = wsFont;
+ m_fFontSize = fSize;
+ return FWL_ERR_Succeeded;
+}
+void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) {
+ m_fScrollOffsetY = fScrollOffset;
+}
+void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_EDT_Background;
+ param.m_dwData = FWL_PARTDATA_EDT_Background;
+ param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly
+ ? FWL_PARTSTATE_EDT_ReadOnly
+ : FWL_PARTSTATE_EDT_Normal;
+ FX_DWORD dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled);
+ if (dwStates) {
+ param.m_dwStates = FWL_PARTSTATE_EDT_Disable;
+ }
+ param.m_pGraphics = pGraphics;
+ param.m_matrix = *pMatrix;
+ param.m_rtPart = m_rtClient;
+ pTheme->DrawBackground(¶m);
+ if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) {
+ return;
+ }
+ CFX_RectF rtScorll;
+ m_pHorzScrollBar->GetWidgetRect(rtScorll);
+ FX_FLOAT fStaticWidth = rtScorll.height;
+ CFX_RectF rtStatic;
+ rtStatic.Set(m_rtClient.right() - rtScorll.height,
+ m_rtClient.bottom() - rtScorll.height, rtScorll.height,
+ rtScorll.height);
+ param.m_dwData = FWL_PARTDATA_EDT_StaticBackground;
+ param.m_rtPart = rtStatic;
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(m_pEdtEngine);
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_IF_FAIL(pPage);
+ pGraphics->SaveGraphState();
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
+ pGraphics->SaveGraphState();
+ }
+ CFX_RectF rtClip = m_rtEngine;
+ FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
+ FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
+ CFX_Matrix mt;
+ mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY);
+ if (pMatrix) {
+ pMatrix->TransformRect(rtClip);
+ mt.Concat(*pMatrix);
+ }
+ FX_BOOL bShowSel =
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
+ if (bShowSel) {
+ IFWL_Widget* pForm =
+ m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
+ if (pForm) {
+ bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) !=
+ FWL_WGTSTATE_Deactivated;
+ }
+ }
+ int32_t nSelCount = m_pEdtEngine->CountSelRanges();
+ if (bShowSel && nSelCount > 0) {
+ int32_t nPageCharStart = pPage->GetCharStart();
+ int32_t nPageCharCount = pPage->GetCharCount();
+ int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1;
+ int32_t nCharCount;
+ int32_t nCharStart;
+ CFX_RectFArray rectArr;
+ int32_t i = 0;
+ for (i = 0; i < nSelCount; i++) {
+ nCharCount = m_pEdtEngine->GetSelRange(i, nCharStart);
+ int32_t nCharEnd = nCharStart + nCharCount - 1;
+ if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) {
+ continue;
+ }
+ int32_t nBgn = FX_MAX(nCharStart, nPageCharStart);
+ int32_t nEnd = FX_MIN(nCharEnd, nPageCharEnd);
+ pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1,
+ rectArr);
+ }
+ int32_t nCount = rectArr.GetSize();
+ CFX_Path path;
+ path.Create();
+ for (i = 0; i < nCount; i++) {
+ rectArr[i].left += fOffSetX;
+ rectArr[i].top += fOffSetY;
+ path.AddRectangle(rectArr[i].left, rectArr[i].top, rectArr[i].width,
+ rectArr[i].height);
+ }
+ pGraphics->SetClipRect(rtClip);
CFWL_ThemeBackground param;
+ param.m_pGraphics = pGraphics;
+ param.m_matrix = *pMatrix;
param.m_pWidget = m_pInterface;
param.m_iPart = FWL_PART_EDT_Background;
- param.m_dwData = FWL_PARTDATA_EDT_Background;
- param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly ?
- FWL_PARTSTATE_EDT_ReadOnly : FWL_PARTSTATE_EDT_Normal;
- FX_DWORD dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled);
- if ( dwStates) {
- param.m_dwStates = FWL_PARTSTATE_EDT_Disable;
+ param.m_pPath = &path;
+ pTheme->DrawBackground(¶m);
+ }
+ CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice();
+ _FWL_RETURN_IF_FAIL(pRenderDev);
+ IFDE_RenderDevice* pRenderDevice = IFDE_RenderDevice::Create(pRenderDev);
+ _FWL_RETURN_IF_FAIL(pRenderDevice);
+ IFDE_RenderContext* pRenderContext = IFDE_RenderContext::Create();
+ _FWL_RETURN_IF_FAIL(pRenderContext);
+ pRenderDevice->SetClipRect(rtClip);
+ pRenderContext->StartRender(pRenderDevice, (IFDE_CanvasSet*)pPage, mt);
+ pRenderContext->DoRender(NULL);
+ pRenderContext->Release();
+ pRenderDevice->Release();
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
+ pGraphics->RestoreGraphState();
+ CFX_Path path;
+ path.Create();
+ int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1;
+ FX_FLOAT fStep = m_rtEngine.width / iLimit;
+ FX_FLOAT fLeft = m_rtEngine.left + 1;
+ for (int32_t i = 1; i < iLimit; i++) {
+ fLeft += fStep;
+ path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom());
}
+ CFWL_ThemeBackground param;
param.m_pGraphics = pGraphics;
param.m_matrix = *pMatrix;
- param.m_rtPart = m_rtClient;
- pTheme->DrawBackground(¶m);
- if (!IsShowScrollBar(TRUE) || !IsShowScrollBar(FALSE)) {
- return;
- }
- CFX_RectF rtScorll;
- m_pHorzScrollBar->GetWidgetRect(rtScorll);
- FX_FLOAT fStaticWidth = rtScorll.height;
- CFX_RectF rtStatic;
- rtStatic.Set(m_rtClient.right() - rtScorll.height,
- m_rtClient.bottom() - rtScorll.height,
- rtScorll.height,
- rtScorll.height);
- param.m_dwData = FWL_PARTDATA_EDT_StaticBackground;
- param.m_rtPart = rtStatic;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_EDT_CombTextLine;
+ param.m_pPath = &path;
pTheme->DrawBackground(¶m);
-}
-void CFWL_EditImp::DrawContent(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(m_pEdtEngine);
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- _FWL_RETURN_IF_FAIL(pPage);
- pGraphics->SaveGraphState();
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
- pGraphics->SaveGraphState();
- }
- CFX_RectF rtClip = m_rtEngine;
- FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
- FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
- CFX_Matrix mt;
- mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY);
- if (pMatrix) {
- pMatrix->TransformRect(rtClip);
- mt.Concat(*pMatrix);
- }
- FX_BOOL bShowSel = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
- if (bShowSel) {
- IFWL_Widget *pForm = m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
- if (pForm) {
- bShowSel = (pForm->GetStates() & FWL_WGTSTATE_Deactivated) != FWL_WGTSTATE_Deactivated;
- }
- }
- int32_t nSelCount = m_pEdtEngine->CountSelRanges();
- if (bShowSel && nSelCount > 0) {
- int32_t nPageCharStart = pPage->GetCharStart();
- int32_t nPageCharCount = pPage->GetCharCount();
- int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1;
- int32_t nCharCount;
- int32_t nCharStart;
- CFX_RectFArray rectArr;
- int32_t i = 0;
- for (i = 0; i < nSelCount; i ++) {
- nCharCount = m_pEdtEngine->GetSelRange(i, nCharStart);
- int32_t nCharEnd = nCharStart + nCharCount - 1;
- if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) {
- continue;
- }
- int32_t nBgn = FX_MAX(nCharStart, nPageCharStart);
- int32_t nEnd = FX_MIN(nCharEnd, nPageCharEnd);
- pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, rectArr);
- }
- int32_t nCount = rectArr.GetSize();
- CFX_Path path;
- path.Create();
- for (i = 0; i < nCount; i ++) {
- rectArr[i].left += fOffSetX;
- rectArr[i].top += fOffSetY;
- path.AddRectangle(rectArr[i].left,
- rectArr[i].top,
- rectArr[i].width,
- rectArr[i].height);
- }
- pGraphics->SetClipRect(rtClip);
- CFWL_ThemeBackground param;
- param.m_pGraphics = pGraphics;
- param.m_matrix = *pMatrix;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_EDT_Background;
- param.m_pPath = &path;
- pTheme->DrawBackground(¶m);
- }
- CFX_RenderDevice *pRenderDev = pGraphics->GetRenderDevice();
- _FWL_RETURN_IF_FAIL(pRenderDev);
- IFDE_RenderDevice *pRenderDevice = IFDE_RenderDevice::Create(pRenderDev);
- _FWL_RETURN_IF_FAIL(pRenderDevice);
- IFDE_RenderContext *pRenderContext = IFDE_RenderContext::Create();
- _FWL_RETURN_IF_FAIL(pRenderContext);
- pRenderDevice->SetClipRect(rtClip);
- pRenderContext->StartRender(pRenderDevice, (IFDE_CanvasSet*)pPage, mt);
- pRenderContext->DoRender(NULL);
- pRenderContext->Release();
- pRenderDevice->Release();
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
- pGraphics->RestoreGraphState();
- CFX_Path path;
- path.Create();
- int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1;
- FX_FLOAT fStep = m_rtEngine.width / iLimit;
- FX_FLOAT fLeft = m_rtEngine.left + 1;
- for (int32_t i = 1; i < iLimit; i++) {
- fLeft += fStep;
- path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom());
- }
- CFWL_ThemeBackground param;
- param.m_pGraphics = pGraphics;
- param.m_matrix = *pMatrix;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_EDT_CombTextLine;
- param.m_pPath = &path;
- pTheme->DrawBackground(¶m);
- }
- pGraphics->RestoreGraphState();
-}
-void CFWL_EditImp::UpdateEditEngine()
-{
- UpdateEditParams();
- UpdateEditLayout();
- if (m_nLimit > -1) {
- m_pEdtEngine->SetLimit(m_nLimit);
- }
-}
-void CFWL_EditImp::UpdateEditParams()
-{
- FDE_TXTEDTPARAMS params;
- params.nHorzScale = 100;
- params.fPlateWidth = m_rtEngine.width;
- params.fPlateHeight = m_rtEngine.height;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CharVertial;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LineReserve;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ArabicShapes;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ExpandTab;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) {
- params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) {
- params.dwMode |= FDE_TEXTEDITMODE_Validate;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) {
- params.dwMode |= FDE_TEXTEDITMODE_Password;
- }
- switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) {
- case FWL_STYLEEXT_EDT_HNear: {
- params.dwAlignment |= FDE_TEXTEDITALIGN_Left;
- break;
- }
- case FWL_STYLEEXT_EDT_HCenter: {
- params.dwAlignment |= FDE_TEXTEDITALIGN_Center;
- break;
- }
- case FWL_STYLEEXT_EDT_HFar: {
- params.dwAlignment |= FDE_TEXTEDITALIGN_Right;
- break;
- }
- default: {
- }
- }
- switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) {
- case FWL_STYLEEXT_EDT_Justified: {
- params.dwAlignment |= FDE_TEXTEDITALIGN_Justified;
- break;
- }
- case FWL_STYLEEXT_EDT_Distributed: {
- params.dwAlignment |= FDE_TEXTEDITALIGN_Distributed;
- break;
- }
- default: {
- params.dwAlignment |= FDE_TEXTEDITALIGN_Normal;
- }
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
- params.dwMode |= FDE_TEXTEDITMODE_MultiLines;
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) == 0 && (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) {
- params.dwMode |= FDE_TEXTEDITMODE_AutoLineWrap | FDE_TEXTEDITMODE_LimitArea_Horz;
- }
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) == 0 && (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoVScroll) == 0) {
- params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Vert;
- } else {
- params.fPlateHeight = 0x00FFFFFF;
- }
+ }
+ pGraphics->RestoreGraphState();
+}
+void CFWL_EditImp::UpdateEditEngine() {
+ UpdateEditParams();
+ UpdateEditLayout();
+ if (m_nLimit > -1) {
+ m_pEdtEngine->SetLimit(m_nLimit);
+ }
+}
+void CFWL_EditImp::UpdateEditParams() {
+ FDE_TXTEDTPARAMS params;
+ params.nHorzScale = 100;
+ params.fPlateWidth = m_rtEngine.width;
+ params.fPlateHeight = m_rtEngine.height;
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CharVertial;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LineReserve;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ArabicShapes;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ExpandTab;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) {
+ params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) {
+ params.dwMode |= FDE_TEXTEDITMODE_Validate;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) {
+ params.dwMode |= FDE_TEXTEDITMODE_Password;
+ }
+ switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) {
+ case FWL_STYLEEXT_EDT_HNear: {
+ params.dwAlignment |= FDE_TEXTEDITALIGN_Left;
+ break;
+ }
+ case FWL_STYLEEXT_EDT_HCenter: {
+ params.dwAlignment |= FDE_TEXTEDITALIGN_Center;
+ break;
+ }
+ case FWL_STYLEEXT_EDT_HFar: {
+ params.dwAlignment |= FDE_TEXTEDITALIGN_Right;
+ break;
+ }
+ default: {}
+ }
+ switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) {
+ case FWL_STYLEEXT_EDT_Justified: {
+ params.dwAlignment |= FDE_TEXTEDITALIGN_Justified;
+ break;
+ }
+ case FWL_STYLEEXT_EDT_Distributed: {
+ params.dwAlignment |= FDE_TEXTEDITALIGN_Distributed;
+ break;
+ }
+ default: { params.dwAlignment |= FDE_TEXTEDITALIGN_Normal; }
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
+ params.dwMode |= FDE_TEXTEDITMODE_MultiLines;
+ if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) == 0 &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) {
+ params.dwMode |=
+ FDE_TEXTEDITMODE_AutoLineWrap | FDE_TEXTEDITMODE_LimitArea_Horz;
+ }
+ if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) == 0 &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoVScroll) == 0) {
+ params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Vert;
} else {
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) {
- params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Horz;
- }
- }
- if ( (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)
- || (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- params.dwMode |= FDE_TEXTEDITMODE_ReadOnly;
- }
- FX_FLOAT *pFontSize = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_FontSize);
- _FWL_RETURN_IF_FAIL(pFontSize);
- m_fFontSize = *pFontSize;
- FX_DWORD *pFontColor = (FX_DWORD*)GetThemeCapacity(FWL_WGTCAPACITY_TextColor);
- _FWL_RETURN_IF_FAIL(pFontColor);
- params.dwFontColor = *pFontColor;
- FX_FLOAT *pLineHeight = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_LineHeight);
- _FWL_RETURN_IF_FAIL(pLineHeight);
- params.fLineSpace = *pLineHeight;
- IFX_Font *pFont = (IFX_Font*)GetThemeCapacity(FWL_WGTCAPACITY_Font);
- _FWL_RETURN_IF_FAIL(pFont);
- params.pFont = pFont;
- params.fFontSize = m_fFontSize;
- params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace);
- if (params.nLineCount <= 0) {
- params.nLineCount = 1;
- }
- params.fTabWidth = params.fFontSize * 1;
- params.bTabEquidistant = TRUE;
- params.wLineBreakChar = L'\n';
- params.nCharRotation = 0;
- params.pEventSink = this;
- m_pEdtEngine->SetEditParams(params);
-}
-void CFWL_EditImp::UpdateEditLayout()
-{
- if (m_pEdtEngine->GetTextLength() <= 0) {
- m_pEdtEngine->SetTextByStream(NULL);
- }
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- if (pPage) {
- pPage->UnloadPage();
- pPage = NULL;
- }
- m_pEdtEngine->StartLayout();
- m_pEdtEngine->DoLayout(NULL);
- m_pEdtEngine->EndLayout();
- pPage = m_pEdtEngine->GetPage(0);
- if (pPage) {
- pPage->LoadPage();
- }
-}
-FX_BOOL CFWL_EditImp::UpdateOffset()
-{
- CFX_RectF rtCaret;
- m_pEdtEngine->GetCaretRect(rtCaret);
- FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
- FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
- rtCaret.Offset(fOffSetX, fOffSetY);
- const CFX_RectF& rtEidt = m_rtEngine;
- if (rtEidt.Contains(rtCaret)) {
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
- CFX_RectF rtFDE = pPage->GetContentsBox();
- rtFDE.Offset(fOffSetX, fOffSetY);
- if (rtFDE.right() < rtEidt.right() && m_fScrollOffsetX > 0) {
- m_fScrollOffsetX += rtFDE.right() - rtEidt.right();
- if (m_fScrollOffsetX < 0) {
- m_fScrollOffsetX = 0;
- }
- }
- if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) {
- m_fScrollOffsetY += rtFDE.bottom() - rtEidt.bottom();
- if (m_fScrollOffsetY < 0) {
- m_fScrollOffsetY = 0;
- }
- }
- return FALSE;
- } else {
- FX_FLOAT offsetX = 0.0;
- FX_FLOAT offsetY = 0.0;
- if (rtCaret.left < rtEidt.left) {
- offsetX = rtCaret.left - rtEidt.left;
- }
- if (rtCaret.right() > rtEidt.right()) {
- offsetX = rtCaret.right() - rtEidt.right();
- }
- if (rtCaret.top < rtEidt.top) {
- offsetY = rtCaret.top - rtEidt.top;
- }
- if (rtCaret.bottom() > rtEidt.bottom()) {
- offsetY = rtCaret.bottom() - rtEidt.bottom();
- }
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption)) {
- m_fScrollOffsetX += offsetX;
- }
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption)) {
- m_fScrollOffsetY += offsetY;
- }
- if (m_fFontSize > m_rtEngine.height) {
- m_fScrollOffsetY = 0;
- }
- return TRUE;
+ params.fPlateHeight = 0x00FFFFFF;
+ }
+ } else {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) {
+ params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Horz;
+ }
+ }
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+ params.dwMode |= FDE_TEXTEDITMODE_ReadOnly;
+ }
+ FX_FLOAT* pFontSize = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_FontSize);
+ _FWL_RETURN_IF_FAIL(pFontSize);
+ m_fFontSize = *pFontSize;
+ FX_DWORD* pFontColor = (FX_DWORD*)GetThemeCapacity(FWL_WGTCAPACITY_TextColor);
+ _FWL_RETURN_IF_FAIL(pFontColor);
+ params.dwFontColor = *pFontColor;
+ FX_FLOAT* pLineHeight =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_LineHeight);
+ _FWL_RETURN_IF_FAIL(pLineHeight);
+ params.fLineSpace = *pLineHeight;
+ IFX_Font* pFont = (IFX_Font*)GetThemeCapacity(FWL_WGTCAPACITY_Font);
+ _FWL_RETURN_IF_FAIL(pFont);
+ params.pFont = pFont;
+ params.fFontSize = m_fFontSize;
+ params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace);
+ if (params.nLineCount <= 0) {
+ params.nLineCount = 1;
+ }
+ params.fTabWidth = params.fFontSize * 1;
+ params.bTabEquidistant = TRUE;
+ params.wLineBreakChar = L'\n';
+ params.nCharRotation = 0;
+ params.pEventSink = this;
+ m_pEdtEngine->SetEditParams(params);
+}
+void CFWL_EditImp::UpdateEditLayout() {
+ if (m_pEdtEngine->GetTextLength() <= 0) {
+ m_pEdtEngine->SetTextByStream(NULL);
+ }
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ if (pPage) {
+ pPage->UnloadPage();
+ pPage = NULL;
+ }
+ m_pEdtEngine->StartLayout();
+ m_pEdtEngine->DoLayout(NULL);
+ m_pEdtEngine->EndLayout();
+ pPage = m_pEdtEngine->GetPage(0);
+ if (pPage) {
+ pPage->LoadPage();
+ }
+}
+FX_BOOL CFWL_EditImp::UpdateOffset() {
+ CFX_RectF rtCaret;
+ m_pEdtEngine->GetCaretRect(rtCaret);
+ FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX;
+ FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset;
+ rtCaret.Offset(fOffSetX, fOffSetY);
+ const CFX_RectF& rtEidt = m_rtEngine;
+ if (rtEidt.Contains(rtCaret)) {
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
+ CFX_RectF rtFDE = pPage->GetContentsBox();
+ rtFDE.Offset(fOffSetX, fOffSetY);
+ if (rtFDE.right() < rtEidt.right() && m_fScrollOffsetX > 0) {
+ m_fScrollOffsetX += rtFDE.right() - rtEidt.right();
+ if (m_fScrollOffsetX < 0) {
+ m_fScrollOffsetX = 0;
+ }
+ }
+ if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) {
+ m_fScrollOffsetY += rtFDE.bottom() - rtEidt.bottom();
+ if (m_fScrollOffsetY < 0) {
+ m_fScrollOffsetY = 0;
+ }
}
-}
-FX_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar *pScrollBar, FX_FLOAT fPosChanged)
-{
- if (pScrollBar == (IFWL_ScrollBar*)m_pHorzScrollBar) {
- m_fScrollOffsetX += fPosChanged;
- } else {
- m_fScrollOffsetY += fPosChanged;
+ return FALSE;
+ } else {
+ FX_FLOAT offsetX = 0.0;
+ FX_FLOAT offsetY = 0.0;
+ if (rtCaret.left < rtEidt.left) {
+ offsetX = rtCaret.left - rtEidt.left;
}
- return TRUE;
-}
-void CFWL_EditImp::UpdateVAlignment()
-{
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- _FWL_RETURN_IF_FAIL(pPage);
- const CFX_RectF& rtFDE = pPage->GetContentsBox();
- FX_FLOAT fOffsetY = 0.0f;
- FX_FLOAT fSpaceAbove = 0.0f;
- FX_FLOAT fSpaceBelow = 0.0f;
- CFX_SizeF* pSpace = (CFX_SizeF*)GetThemeCapacity(FWL_WGTCAPACITY_SpaceAboveBelow);
- if (pSpace) {
- fSpaceAbove = pSpace->x;
- fSpaceBelow = pSpace->y;
- }
- if (fSpaceAbove < 0.1f) {
- fSpaceAbove = 0;
- }
- if (fSpaceBelow < 0.1f) {
- fSpaceBelow = 0;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) {
- fOffsetY = (m_rtEngine.height - rtFDE.height) / 2;
- if (fOffsetY < (fSpaceAbove + fSpaceBelow) / 2 && fSpaceAbove < fSpaceBelow) {
- return;
- }
- fOffsetY += (fSpaceAbove - fSpaceBelow) / 2;
- } else if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VFar) {
- fOffsetY = (m_rtEngine.height - rtFDE.height);
- fOffsetY -= fSpaceBelow;
- } else {
- fOffsetY += fSpaceAbove;
- }
- m_fVAlignOffset = fOffsetY;
- if (m_fVAlignOffset < 0) {
- m_fVAlignOffset = 0;
- }
-}
-void CFWL_EditImp::UpdateCaret()
-{
- CFX_RectF rtFDE;
- m_pEdtEngine->GetCaretRect(rtFDE);
- rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset);
- CFX_RectF rtCaret;
- rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height);
- CFX_RectF temp = rtCaret;
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- rtCaret.Intersect(rtClient);
- if (rtCaret.left > rtClient.right()) {
- FX_FLOAT right = rtCaret.right();
- rtCaret.left = rtClient.right() - 1;
- rtCaret.width = right - rtCaret.left;
- }
- FX_BOOL bIntersect = !rtCaret.IsEmpty();
- FX_BOOL bShow = TRUE;
- FX_BOOL bShowWhole = FALSE;
- if (!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) || !bIntersect) {
- bShow = FALSE;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption && temp.right() > m_rtEngine.right()) {
- bShowWhole = TRUE;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption && temp.bottom() > m_rtEngine.bottom()) {
- bShowWhole = TRUE;
- } else {
- bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect);
- }
- if (bShowWhole) {
- rtCaret = temp;
- }
- ShowCaret(bShow, &rtCaret);
-}
-IFWL_ScrollBar* CFWL_EditImp::UpdateScroll()
-{
- FX_BOOL bShowHorz = m_pHorzScrollBar && ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
- FX_BOOL bShowVert = m_pVertScrollBar && ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
- if (!bShowHorz && !bShowVert) {
- return NULL;
- }
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- _FWL_RETURN_VALUE_IF_FAIL(pPage, NULL);
- const CFX_RectF &rtFDE = pPage->GetContentsBox();
- IFWL_ScrollBar *pRepaint = NULL;
- if (bShowHorz) {
- CFX_RectF rtScroll;
- m_pHorzScrollBar->GetWidgetRect(rtScroll);
- if (rtScroll.width < rtFDE.width) {
- m_pHorzScrollBar->LockUpdate();
- FX_FLOAT fRange = rtFDE.width - rtScroll.width;
- m_pHorzScrollBar->SetRange(0.0f, fRange);
- FX_FLOAT fPos = m_fScrollOffsetX;
- if (fPos < 0.0f) {
- fPos = 0.0f;
- }
- if (fPos > fRange) {
- fPos = fRange;
- }
- m_pHorzScrollBar->SetPos(fPos);
- m_pHorzScrollBar->SetTrackPos(fPos);
- m_pHorzScrollBar->SetPageSize(rtScroll.width);
- m_pHorzScrollBar->SetStepSize(rtScroll.width / 10);
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE);
- m_pHorzScrollBar->UnlockUpdate();
- m_pHorzScrollBar->Update();
- pRepaint = (IFWL_ScrollBar*)m_pHorzScrollBar;
- } else if ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) {
- m_pHorzScrollBar->LockUpdate();
- m_pHorzScrollBar->SetRange(0, -1);
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE);
- m_pHorzScrollBar->UnlockUpdate();
- m_pHorzScrollBar->Update();
- pRepaint = (IFWL_ScrollBar*)m_pHorzScrollBar;
- }
+ if (rtCaret.right() > rtEidt.right()) {
+ offsetX = rtCaret.right() - rtEidt.right();
}
- if (bShowVert) {
- CFX_RectF rtScroll;
- m_pVertScrollBar->GetWidgetRect(rtScroll);
- if (rtScroll.height < rtFDE.height) {
- m_pVertScrollBar->LockUpdate();
- FX_FLOAT fStep = m_pEdtEngine->GetEditParams()->fLineSpace;
- FX_FLOAT fRange = rtFDE.height - m_rtEngine.height;
- if (fRange < fStep) {
- fRange = fStep;
- }
- m_pVertScrollBar->SetRange(0.0f, fRange);
- FX_FLOAT fPos = m_fScrollOffsetY;
- if (fPos < 0.0f) {
- fPos = 0.0f;
- }
- if (fPos > fRange) {
- fPos = fRange;
- }
- m_pVertScrollBar->SetPos(fPos);
- m_pVertScrollBar->SetTrackPos(fPos);
- m_pVertScrollBar->SetPageSize(rtScroll.height);
- m_pVertScrollBar->SetStepSize(fStep);
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE);
- m_pVertScrollBar->UnlockUpdate();
- m_pVertScrollBar->Update();
- pRepaint = (IFWL_ScrollBar*)m_pVertScrollBar;
- } else if ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) {
- m_pVertScrollBar->LockUpdate();
- m_pVertScrollBar->SetRange(0, -1);
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE);
- m_pVertScrollBar->UnlockUpdate();
- m_pVertScrollBar->Update();
- pRepaint = (IFWL_ScrollBar*)m_pVertScrollBar;
- }
+ if (rtCaret.top < rtEidt.top) {
+ offsetY = rtCaret.top - rtEidt.top;
}
- return pRepaint;
-}
-FX_BOOL CFWL_EditImp::IsShowScrollBar(FX_BOOL bVert)
-{
- FX_BOOL bShow = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) ? (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == FWL_WGTSTATE_Focused : TRUE;
- if (bVert) {
- return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) &&
- (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) && IsContentHeightOverflow();
+ if (rtCaret.bottom() > rtEidt.bottom()) {
+ offsetY = rtCaret.bottom() - rtEidt.bottom();
}
- return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine);
-}
-FX_BOOL CFWL_EditImp::IsContentHeightOverflow()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
- IFDE_TxtEdtPage *pPage = m_pEdtEngine->GetPage(0);
- _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
- return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f;
-}
-int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord)
-{
- int32_t nCount = m_RecordArr.GetSize();
- if (m_iCurRecord == nCount - 1) {
- if (nCount == m_iMaxRecord) {
- m_RecordArr.RemoveAt(0);
- m_iCurRecord --;
- }
- } else {
- for (int32_t i = nCount - 1; i > m_iCurRecord; i --) {
- m_RecordArr.RemoveAt(i);
- }
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption)) {
+ m_fScrollOffsetX += offsetX;
}
- m_RecordArr.Add(bsDoRecord);
- return m_iCurRecord = m_RecordArr.GetSize() - 1;
-}
-void CFWL_EditImp::Layout()
-{
- GetClientRect(m_rtClient);
- m_rtEngine = m_rtClient;
- FX_FLOAT *pfWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_IF_FAIL(pfWidth);
- FX_FLOAT fWidth = *pfWidth;
- if (!m_pOuter) {
- CFX_RectF* pUIMargin = (CFX_RectF*)GetThemeCapacity(FWL_WGTCAPACITY_UIMargin);
- if (pUIMargin) {
- m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, pUIMargin->height);
- }
- } else if (m_pOuter->GetClassID() == FWL_CLASSHASH_DateTimePicker) {
- CFWL_ThemePart part;
- part.m_pWidget = m_pOuter;
- CFX_RectF* pUIMargin = (CFX_RectF*)m_pOuter->GetThemeProvider()->GetCapacity(&part, FWL_WGTCAPACITY_UIMargin);
- if (pUIMargin) {
- m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, pUIMargin->height);
- }
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption)) {
+ m_fScrollOffsetY += offsetY;
}
- FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE);
- FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE);
- if (bShowVertScrollbar) {
- InitScrollBar();
- CFX_RectF rtVertScr;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin,
- m_rtClient.top, fWidth, m_rtClient.height);
- } else {
- rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, m_rtClient.height);
- if (bShowHorzScrollbar) {
- rtVertScr.height -= fWidth;
- }
- m_rtEngine.width -= fWidth;
- }
- m_pVertScrollBar->SetWidgetRect(rtVertScr);
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- m_pVertScrollBar->Update();
- } else if (m_pVertScrollBar) {
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
- if (bShowHorzScrollbar) {
- InitScrollBar(FALSE);
- CFX_RectF rtHoriScr;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin, m_rtClient.width, fWidth);
- } else {
- rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, m_rtClient.width, fWidth);
- if (bShowVertScrollbar) {
- rtHoriScr.width -= fWidth;
- }
- m_rtEngine.height -= fWidth;
- }
- m_pHorzScrollBar->SetWidgetRect(rtHoriScr);
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- m_pHorzScrollBar->Update();
- } else if (m_pHorzScrollBar) {
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
-}
-void CFWL_EditImp::LayoutScrollBar()
-{
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == 0) {
- return;
- }
- FX_FLOAT* pfWidth = NULL;
- FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE);
- FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE);
- if (bShowVertScrollbar) {
- if (!m_pVertScrollBar) {
- pfWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
- InitScrollBar();
- CFX_RectF rtVertScr;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin,
- m_rtClient.top, fWidth, m_rtClient.height);
- } else {
- rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, m_rtClient.height);
- if (bShowHorzScrollbar) {
- rtVertScr.height -= fWidth;
- }
- }
- m_pVertScrollBar->SetWidgetRect(rtVertScr);
- m_pVertScrollBar->Update();
- }
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- } else if (m_pVertScrollBar) {
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
- if (bShowHorzScrollbar) {
- if (!m_pHorzScrollBar) {
- pfWidth = !pfWidth ? (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth) : pfWidth;
- FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
- InitScrollBar(FALSE);
- CFX_RectF rtHoriScr;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin, m_rtClient.width, fWidth);
- } else {
- rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, m_rtClient.width, fWidth);
- if (bShowVertScrollbar) {
- rtHoriScr.width -= (fWidth);
- }
- }
- m_pHorzScrollBar->SetWidgetRect(rtHoriScr);
- m_pHorzScrollBar->Update();
- }
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- } else if (m_pHorzScrollBar) {
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
- if (bShowVertScrollbar || bShowHorzScrollbar) {
- UpdateScroll();
- }
-}
-void CFWL_EditImp::DeviceToEngine(CFX_PointF &pt)
-{
- pt.x += -m_rtEngine.left + m_fScrollOffsetX;
- pt.y += -m_rtEngine.top - m_fVAlignOffset + m_fScrollOffsetY;
-}
-void CFWL_EditImp::InitScrollBar(FX_BOOL bVert )
-{
- if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
- return;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
- prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
- prop.m_pParent = m_pInterface;
- prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- IFWL_ScrollBar *pScrollBar = IFWL_ScrollBar::Create();
- pScrollBar->Initialize(prop, m_pInterface);
- bVert ? (m_pVertScrollBar = pScrollBar) : (m_pHorzScrollBar = pScrollBar);
-}
-void CFWL_EditImp::InitEngine()
-{
- if (m_pEdtEngine) {
- return;
+ if (m_fFontSize > m_rtEngine.height) {
+ m_fScrollOffsetY = 0;
}
- m_pEdtEngine = IFDE_TxtEdtEngine::Create();
-}
-extern FX_BOOL FWL_ShowCaret(IFWL_Widget *pWidget, FX_BOOL bVisible, const CFX_RectF *pRtAnchor);
-void CFWL_EditImp::ShowCaret(FX_BOOL bVisible, CFX_RectF *pRect )
-{
- if (m_pCaret) {
- m_pCaret->ShowCaret(bVisible);
- if (bVisible && !pRect->IsEmpty()) {
- m_pCaret->SetWidgetRect(*pRect);
- }
- Repaint(&m_rtEngine);
+ return TRUE;
+ }
+}
+FX_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar* pScrollBar,
+ FX_FLOAT fPosChanged) {
+ if (pScrollBar == (IFWL_ScrollBar*)m_pHorzScrollBar) {
+ m_fScrollOffsetX += fPosChanged;
+ } else {
+ m_fScrollOffsetY += fPosChanged;
+ }
+ return TRUE;
+}
+void CFWL_EditImp::UpdateVAlignment() {
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_IF_FAIL(pPage);
+ const CFX_RectF& rtFDE = pPage->GetContentsBox();
+ FX_FLOAT fOffsetY = 0.0f;
+ FX_FLOAT fSpaceAbove = 0.0f;
+ FX_FLOAT fSpaceBelow = 0.0f;
+ CFX_SizeF* pSpace =
+ (CFX_SizeF*)GetThemeCapacity(FWL_WGTCAPACITY_SpaceAboveBelow);
+ if (pSpace) {
+ fSpaceAbove = pSpace->x;
+ fSpaceBelow = pSpace->y;
+ }
+ if (fSpaceAbove < 0.1f) {
+ fSpaceAbove = 0;
+ }
+ if (fSpaceBelow < 0.1f) {
+ fSpaceBelow = 0;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) {
+ fOffsetY = (m_rtEngine.height - rtFDE.height) / 2;
+ if (fOffsetY < (fSpaceAbove + fSpaceBelow) / 2 &&
+ fSpaceAbove < fSpaceBelow) {
+ return;
+ }
+ fOffsetY += (fSpaceAbove - fSpaceBelow) / 2;
+ } else if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VFar) {
+ fOffsetY = (m_rtEngine.height - rtFDE.height);
+ fOffsetY -= fSpaceBelow;
+ } else {
+ fOffsetY += fSpaceAbove;
+ }
+ m_fVAlignOffset = fOffsetY;
+ if (m_fVAlignOffset < 0) {
+ m_fVAlignOffset = 0;
+ }
+}
+void CFWL_EditImp::UpdateCaret() {
+ CFX_RectF rtFDE;
+ m_pEdtEngine->GetCaretRect(rtFDE);
+ rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX,
+ m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset);
+ CFX_RectF rtCaret;
+ rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height);
+ CFX_RectF temp = rtCaret;
+ CFX_RectF rtClient;
+ GetClientRect(rtClient);
+ rtCaret.Intersect(rtClient);
+ if (rtCaret.left > rtClient.right()) {
+ FX_FLOAT right = rtCaret.right();
+ rtCaret.left = rtClient.right() - 1;
+ rtCaret.width = right - rtCaret.left;
+ }
+ FX_BOOL bIntersect = !rtCaret.IsEmpty();
+ FX_BOOL bShow = TRUE;
+ FX_BOOL bShowWhole = FALSE;
+ if (!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) || !bIntersect) {
+ bShow = FALSE;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption &&
+ temp.right() > m_rtEngine.right()) {
+ bShowWhole = TRUE;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption &&
+ temp.bottom() > m_rtEngine.bottom()) {
+ bShowWhole = TRUE;
+ } else {
+ bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect);
+ }
+ if (bShowWhole) {
+ rtCaret = temp;
+ }
+ ShowCaret(bShow, &rtCaret);
+}
+IFWL_ScrollBar* CFWL_EditImp::UpdateScroll() {
+ FX_BOOL bShowHorz =
+ m_pHorzScrollBar &&
+ ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
+ FX_BOOL bShowVert =
+ m_pVertScrollBar &&
+ ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0);
+ if (!bShowHorz && !bShowVert) {
+ return NULL;
+ }
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_VALUE_IF_FAIL(pPage, NULL);
+ const CFX_RectF& rtFDE = pPage->GetContentsBox();
+ IFWL_ScrollBar* pRepaint = NULL;
+ if (bShowHorz) {
+ CFX_RectF rtScroll;
+ m_pHorzScrollBar->GetWidgetRect(rtScroll);
+ if (rtScroll.width < rtFDE.width) {
+ m_pHorzScrollBar->LockUpdate();
+ FX_FLOAT fRange = rtFDE.width - rtScroll.width;
+ m_pHorzScrollBar->SetRange(0.0f, fRange);
+ FX_FLOAT fPos = m_fScrollOffsetX;
+ if (fPos < 0.0f) {
+ fPos = 0.0f;
+ }
+ if (fPos > fRange) {
+ fPos = fRange;
+ }
+ m_pHorzScrollBar->SetPos(fPos);
+ m_pHorzScrollBar->SetTrackPos(fPos);
+ m_pHorzScrollBar->SetPageSize(rtScroll.width);
+ m_pHorzScrollBar->SetStepSize(rtScroll.width / 10);
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE);
+ m_pHorzScrollBar->UnlockUpdate();
+ m_pHorzScrollBar->Update();
+ pRepaint = (IFWL_ScrollBar*)m_pHorzScrollBar;
+ } else if ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) {
+ m_pHorzScrollBar->LockUpdate();
+ m_pHorzScrollBar->SetRange(0, -1);
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE);
+ m_pHorzScrollBar->UnlockUpdate();
+ m_pHorzScrollBar->Update();
+ pRepaint = (IFWL_ScrollBar*)m_pHorzScrollBar;
+ }
+ }
+ if (bShowVert) {
+ CFX_RectF rtScroll;
+ m_pVertScrollBar->GetWidgetRect(rtScroll);
+ if (rtScroll.height < rtFDE.height) {
+ m_pVertScrollBar->LockUpdate();
+ FX_FLOAT fStep = m_pEdtEngine->GetEditParams()->fLineSpace;
+ FX_FLOAT fRange = rtFDE.height - m_rtEngine.height;
+ if (fRange < fStep) {
+ fRange = fStep;
+ }
+ m_pVertScrollBar->SetRange(0.0f, fRange);
+ FX_FLOAT fPos = m_fScrollOffsetY;
+ if (fPos < 0.0f) {
+ fPos = 0.0f;
+ }
+ if (fPos > fRange) {
+ fPos = fRange;
+ }
+ m_pVertScrollBar->SetPos(fPos);
+ m_pVertScrollBar->SetTrackPos(fPos);
+ m_pVertScrollBar->SetPageSize(rtScroll.height);
+ m_pVertScrollBar->SetStepSize(fStep);
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE);
+ m_pVertScrollBar->UnlockUpdate();
+ m_pVertScrollBar->Update();
+ pRepaint = (IFWL_ScrollBar*)m_pVertScrollBar;
+ } else if ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) {
+ m_pVertScrollBar->LockUpdate();
+ m_pVertScrollBar->SetRange(0, -1);
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE);
+ m_pVertScrollBar->UnlockUpdate();
+ m_pVertScrollBar->Update();
+ pRepaint = (IFWL_ScrollBar*)m_pVertScrollBar;
+ }
+ }
+ return pRepaint;
+}
+FX_BOOL CFWL_EditImp::IsShowScrollBar(FX_BOOL bVert) {
+ FX_BOOL bShow =
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus)
+ ? (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) ==
+ FWL_WGTSTATE_Focused
+ : TRUE;
+ if (bVert) {
+ return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll) &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) &&
+ IsContentHeightOverflow();
+ }
+ return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine);
+}
+FX_BOOL CFWL_EditImp::IsContentHeightOverflow() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pEdtEngine, FALSE);
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_VALUE_IF_FAIL(pPage, FALSE);
+ return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f;
+}
+int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord) {
+ int32_t nCount = m_RecordArr.GetSize();
+ if (m_iCurRecord == nCount - 1) {
+ if (nCount == m_iMaxRecord) {
+ m_RecordArr.RemoveAt(0);
+ m_iCurRecord--;
+ }
+ } else {
+ for (int32_t i = nCount - 1; i > m_iCurRecord; i--) {
+ m_RecordArr.RemoveAt(i);
+ }
+ }
+ m_RecordArr.Add(bsDoRecord);
+ return m_iCurRecord = m_RecordArr.GetSize() - 1;
+}
+void CFWL_EditImp::Layout() {
+ GetClientRect(m_rtClient);
+ m_rtEngine = m_rtClient;
+ FX_FLOAT* pfWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_IF_FAIL(pfWidth);
+ FX_FLOAT fWidth = *pfWidth;
+ if (!m_pOuter) {
+ CFX_RectF* pUIMargin =
+ (CFX_RectF*)GetThemeCapacity(FWL_WGTCAPACITY_UIMargin);
+ if (pUIMargin) {
+ m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
+ pUIMargin->height);
+ }
+ } else if (m_pOuter->GetClassID() == FWL_CLASSHASH_DateTimePicker) {
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pOuter;
+ CFX_RectF* pUIMargin =
+ (CFX_RectF*)m_pOuter->GetThemeProvider()->GetCapacity(
+ &part, FWL_WGTCAPACITY_UIMargin);
+ if (pUIMargin) {
+ m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
+ pUIMargin->height);
+ }
+ }
+ FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE);
+ FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE);
+ if (bShowVertScrollbar) {
+ InitScrollBar();
+ CFX_RectF rtVertScr;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
+ rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin, m_rtClient.top,
+ fWidth, m_rtClient.height);
+ } else {
+ rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
+ m_rtClient.height);
+ if (bShowHorzScrollbar) {
+ rtVertScr.height -= fWidth;
+ }
+ m_rtEngine.width -= fWidth;
+ }
+ m_pVertScrollBar->SetWidgetRect(rtVertScr);
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ m_pVertScrollBar->Update();
+ } else if (m_pVertScrollBar) {
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ if (bShowHorzScrollbar) {
+ InitScrollBar(FALSE);
+ CFX_RectF rtHoriScr;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
+ rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin,
+ m_rtClient.width, fWidth);
} else {
- IFWL_Widget *pOuter = (IFWL_Widget*)m_pInterface;
- if (bVisible) {
- pRect->Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top);
+ rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
+ m_rtClient.width, fWidth);
+ if (bShowVertScrollbar) {
+ rtHoriScr.width -= fWidth;
+ }
+ m_rtEngine.height -= fWidth;
+ }
+ m_pHorzScrollBar->SetWidgetRect(rtHoriScr);
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ m_pHorzScrollBar->Update();
+ } else if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+}
+void CFWL_EditImp::LayoutScrollBar() {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) ==
+ 0) {
+ return;
+ }
+ FX_FLOAT* pfWidth = NULL;
+ FX_BOOL bShowVertScrollbar = IsShowScrollBar(TRUE);
+ FX_BOOL bShowHorzScrollbar = IsShowScrollBar(FALSE);
+ if (bShowVertScrollbar) {
+ if (!m_pVertScrollBar) {
+ pfWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
+ InitScrollBar();
+ CFX_RectF rtVertScr;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
+ rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin, m_rtClient.top,
+ fWidth, m_rtClient.height);
+ } else {
+ rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
+ m_rtClient.height);
+ if (bShowHorzScrollbar) {
+ rtVertScr.height -= fWidth;
}
- while (pOuter->GetOuter()) {
- pOuter = pOuter->GetOuter();
- if (bVisible) {
- CFX_RectF rtOuter;
- pOuter->GetWidgetRect(rtOuter);
- pRect->Offset(rtOuter.left, rtOuter.top);
- }
+ }
+ m_pVertScrollBar->SetWidgetRect(rtVertScr);
+ m_pVertScrollBar->Update();
+ }
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ } else if (m_pVertScrollBar) {
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ if (bShowHorzScrollbar) {
+ if (!m_pHorzScrollBar) {
+ pfWidth =
+ !pfWidth ? (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth)
+ : pfWidth;
+ FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
+ InitScrollBar(FALSE);
+ CFX_RectF rtHoriScr;
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
+ rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin,
+ m_rtClient.width, fWidth);
+ } else {
+ rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
+ m_rtClient.width, fWidth);
+ if (bShowVertScrollbar) {
+ rtHoriScr.width -= (fWidth);
}
- FWL_ShowCaret(pOuter, bVisible, pRect);
- }
-}
-FX_BOOL CFWL_EditImp::ValidateNumberChar(FX_WCHAR cNum)
-{
- if (!m_pEdtEngine) {
- return FALSE;
- }
- if (!m_bSetRange) {
- return TRUE;
+ }
+ m_pHorzScrollBar->SetWidgetRect(rtHoriScr);
+ m_pHorzScrollBar->Update();
+ }
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ } else if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ if (bShowVertScrollbar || bShowHorzScrollbar) {
+ UpdateScroll();
+ }
+}
+void CFWL_EditImp::DeviceToEngine(CFX_PointF& pt) {
+ pt.x += -m_rtEngine.left + m_fScrollOffsetX;
+ pt.y += -m_rtEngine.top - m_fVAlignOffset + m_fScrollOffsetY;
+}
+void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) {
+ if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
+ return;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
+ prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
+ prop.m_pParent = m_pInterface;
+ prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
+ IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create();
+ pScrollBar->Initialize(prop, m_pInterface);
+ bVert ? (m_pVertScrollBar = pScrollBar) : (m_pHorzScrollBar = pScrollBar);
+}
+void CFWL_EditImp::InitEngine() {
+ if (m_pEdtEngine) {
+ return;
+ }
+ m_pEdtEngine = IFDE_TxtEdtEngine::Create();
+}
+extern FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
+ FX_BOOL bVisible,
+ const CFX_RectF* pRtAnchor);
+void CFWL_EditImp::ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect) {
+ if (m_pCaret) {
+ m_pCaret->ShowCaret(bVisible);
+ if (bVisible && !pRect->IsEmpty()) {
+ m_pCaret->SetWidgetRect(*pRect);
+ }
+ Repaint(&m_rtEngine);
+ } else {
+ IFWL_Widget* pOuter = (IFWL_Widget*)m_pInterface;
+ if (bVisible) {
+ pRect->Offset(m_pProperties->m_rtWidget.left,
+ m_pProperties->m_rtWidget.top);
+ }
+ while (pOuter->GetOuter()) {
+ pOuter = pOuter->GetOuter();
+ if (bVisible) {
+ CFX_RectF rtOuter;
+ pOuter->GetWidgetRect(rtOuter);
+ pRect->Offset(rtOuter.left, rtOuter.top);
+ }
+ }
+ FWL_ShowCaret(pOuter, bVisible, pRect);
+ }
+}
+FX_BOOL CFWL_EditImp::ValidateNumberChar(FX_WCHAR cNum) {
+ if (!m_pEdtEngine) {
+ return FALSE;
+ }
+ if (!m_bSetRange) {
+ return TRUE;
+ }
+ CFX_WideString wsOld, wsText;
+ m_pEdtEngine->GetText(wsText, 0);
+ if (wsText.IsEmpty()) {
+ if (cNum == L'0') {
+ return FALSE;
}
- CFX_WideString wsOld, wsText;
- m_pEdtEngine->GetText(wsText, 0);
- if (wsText.IsEmpty()) {
- if (cNum == L'0') {
- return FALSE;
+ return TRUE;
+ }
+ int32_t caretPos = m_pEdtEngine->GetCaretPos();
+ int32_t iSel = CountSelRanges();
+ if (iSel == 0) {
+ if (cNum == L'0' && caretPos == 0) {
+ return FALSE;
+ }
+ int32_t nLen = wsText.GetLength();
+ CFX_WideString l = wsText.Mid(0, caretPos);
+ CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos);
+ CFX_WideString wsNew = l + cNum + r;
+ if (wsNew.GetInteger() <= m_iMax) {
+ return TRUE;
+ }
+ } else {
+ if (wsText.GetInteger() <= m_iMax) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+void CFWL_EditImp::InitCaret() {
+ if (!m_pCaret) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) {
+ m_pCaret = IFWL_Caret::Create();
+ m_pCaret->Initialize(m_pInterface);
+ m_pCaret->SetParent(m_pInterface);
+ m_pCaret->SetStates(m_pProperties->m_dwStates);
+ }
+ } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) ==
+ 0) {
+ m_pCaret->Release();
+ m_pCaret = NULL;
+ }
+}
+void CFWL_EditImp::ClearRecord() {
+ m_iCurRecord = -1;
+ m_RecordArr.RemoveAll();
+}
+void CFWL_EditImp::ProcessInsertError(int32_t iError) {
+ switch (iError) {
+ case -2: {
+ CFWL_EvtEdtTextFull textFullEvent;
+ textFullEvent.m_pSrcTarget = m_pInterface;
+ DispatchEvent(&textFullEvent);
+ break;
+ }
+ default: {}
+ }
+}
+CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_Activate: {
+ DoActivate((CFWL_MsgActivate*)pMessage);
+ break;
+ }
+ case FWL_MSGHASH_Deactivate: {
+ DoDeactivate((CFWL_MsgDeactivate*)pMessage);
+ break;
+ }
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
}
- return TRUE;
- }
- int32_t caretPos = m_pEdtEngine->GetCaretPos();
- int32_t iSel = CountSelRanges();
- if (iSel == 0) {
- if (cNum == L'0' && caretPos == 0) {
- return FALSE;
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- int32_t nLen = wsText.GetLength();
- CFX_WideString l = wsText.Mid(0, caretPos);
- CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos);
- CFX_WideString wsNew = l + cNum + r;
- if (wsNew.GetInteger() <= m_iMax) {
- return TRUE;
+ case FWL_MSGMOUSECMD_LButtonDblClk: {
+ OnButtonDblClk(pMsg);
+ break;
}
- } else {
- if (wsText.GetInteger() <= m_iMax) {
- return TRUE;
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
}
- }
- return FALSE;
-}
-void CFWL_EditImp::InitCaret()
-{
- if (!m_pCaret) {
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) {
- m_pCaret = IFWL_Caret::Create();
- m_pCaret->Initialize(m_pInterface);
- m_pCaret->SetParent(m_pInterface);
- m_pCaret->SetStates(m_pProperties->m_dwStates);
+ case FWL_MSGMOUSECMD_RButtonDown: {
+ DoButtonDown(pMsg);
+ break;
}
- } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == 0) {
- m_pCaret->Release();
- m_pCaret = NULL;
- }
-}
-void CFWL_EditImp::ClearRecord()
-{
- m_iCurRecord = -1;
- m_RecordArr.RemoveAll();
-}
-void CFWL_EditImp::ProcessInsertError(int32_t iError)
-{
- switch (iError) {
- case -2: {
- CFWL_EvtEdtTextFull textFullEvent;
- textFullEvent.m_pSrcTarget = m_pInterface;
- DispatchEvent(&textFullEvent);
- break;
- }
- default: {
- }
- }
-}
-CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
- DoActivate((CFWL_MsgActivate*)pMessage);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- DoDeactivate((CFWL_MsgDeactivate*)pMessage);
- break;
- }
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch(dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonDblClk: {
- OnButtonDblClk(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_RButtonDown: {
- DoButtonDown(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_MsgKey *pKey = (CFWL_MsgKey*)pMessage;
- FX_DWORD dwCmd = pKey->m_dwCmd;
- if (dwCmd == FWL_MSGKEYCMD_KeyDown) {
- OnKeyDown(pKey);
- } else if (dwCmd == FWL_MSGKEYCMD_Char) {
- OnChar(pKey);
- }
- break;
- }
- default: {
- iRet = 0;
- }
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pEvent, FWL_ERR_Indefinite);
- FX_DWORD dwHashCode = pEvent->GetClassID();
- if (dwHashCode != FWL_EVTHASH_Scroll) {
- return FWL_ERR_Succeeded;
- }
- IFWL_Widget *pSrcTarget = pEvent->m_pSrcTarget;
- if ((pSrcTarget == (IFWL_Widget*)m_pOwner->m_pVertScrollBar && m_pOwner->m_pVertScrollBar) || (pSrcTarget == (IFWL_Widget*)m_pOwner->m_pHorzScrollBar && m_pOwner->m_pHorzScrollBar)) {
- FX_DWORD dwScrollCode = ((CFWL_EvtScroll*)pEvent)->m_iScrollCode;
- FX_FLOAT fPos = ((CFWL_EvtScroll*)pEvent)->m_fPos;
- OnScroll((IFWL_ScrollBar*)pSrcTarget, dwScrollCode, fPos);
- }
+ default: {}
+ }
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ CFWL_MsgKey* pKey = (CFWL_MsgKey*)pMessage;
+ FX_DWORD dwCmd = pKey->m_dwCmd;
+ if (dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ OnKeyDown(pKey);
+ } else if (dwCmd == FWL_MSGKEYCMD_Char) {
+ OnChar(pKey);
+ }
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
+}
+FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ _FWL_RETURN_VALUE_IF_FAIL(pEvent, FWL_ERR_Indefinite);
+ FX_DWORD dwHashCode = pEvent->GetClassID();
+ if (dwHashCode != FWL_EVTHASH_Scroll) {
return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate *pMsg)
-{
- m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate *pMsg)
-{
- m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse *pMsg)
-{
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
+ }
+ IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
+ if ((pSrcTarget == (IFWL_Widget*)m_pOwner->m_pVertScrollBar &&
+ m_pOwner->m_pVertScrollBar) ||
+ (pSrcTarget == (IFWL_Widget*)m_pOwner->m_pHorzScrollBar &&
+ m_pOwner->m_pHorzScrollBar)) {
+ FX_DWORD dwScrollCode = ((CFWL_EvtScroll*)pEvent)->m_iScrollCode;
+ FX_FLOAT fPos = ((CFWL_EvtScroll*)pEvent)->m_fPos;
+ OnScroll((IFWL_ScrollBar*)pSrcTarget, dwScrollCode, fPos);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) {
+ m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) {
+ m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) {
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ m_pOwner->SetFocus(TRUE);
+ }
+ if (!m_pOwner->m_pEdtEngine) {
+ m_pOwner->UpdateEditEngine();
+ }
+ IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_IF_FAIL(pPage);
+ CFX_PointF pt;
+ pt.Set(pMsg->m_fx, pMsg->m_fy);
+ m_pOwner->DeviceToEngine(pt);
+ FX_BOOL bBefore = TRUE;
+ int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
+ if (nIndex < 0) {
+ nIndex = 0;
+ }
+ m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore);
+}
+void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ FX_DWORD dwStyleEx = m_pOwner->GetStylesEx();
+ FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret;
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
if (!m_pOwner->m_pEdtEngine) {
- m_pOwner->UpdateEditEngine();
- }
- IFDE_TxtEdtPage *pPage = m_pOwner->m_pEdtEngine->GetPage(0);
- _FWL_RETURN_IF_FAIL(pPage);
- CFX_PointF pt;
- pt.Set(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->DeviceToEngine(pt);
- FX_BOOL bBefore = TRUE;
- int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
- if (nIndex < 0) {
- nIndex = 0;
- }
- m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore);
-}
-void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet)
-{
- FX_DWORD dwStyleEx = m_pOwner->GetStylesEx();
- FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret;
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if (!m_pOwner->m_pEdtEngine) {
- m_pOwner->UpdateEditEngine();
- }
- m_pOwner->UpdateVAlignment();
- m_pOwner->UpdateOffset();
- m_pOwner->UpdateCaret();
- } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_pOwner->ShowCaret(FALSE);
- if (m_pOwner->m_pEdtEngine && (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) {
- int32_t nSel = m_pOwner->CountSelRanges();
- if (nSel > 0) {
- m_pOwner->ClearSelections();
- bRepaint = TRUE;
- }
- m_pOwner->SetCaretPos(0);
- m_pOwner->UpdateOffset();
- }
- m_pOwner->ClearRecord();
- }
- m_pOwner->LayoutScrollBar();
- if (bRepaint) {
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0,
- 0,
- m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
- m_pOwner->Repaint(&rtInvalidate);
- }
-}
-void CFWL_EditImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- DoCursor(pMsg);
- if(m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- return;
- }
- m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->SetGrab(TRUE);
- DoButtonDown(pMsg);
- int32_t nIndex = m_pOwner->m_pEdtEngine->GetCaretPos();
- FX_BOOL bRepaint = FALSE;
- int32_t iCount = m_pOwner->m_pEdtEngine->CountSelRanges();
- if (iCount > 0) {
- m_pOwner->m_pEdtEngine->ClearSelection();
- bRepaint = TRUE;
- }
- FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
- if (bShift && m_pOwner->m_nSelStart != nIndex) {
- int32_t iStart = FX_MIN(m_pOwner->m_nSelStart, nIndex);
- int32_t iEnd = FX_MAX(m_pOwner->m_nSelStart, nIndex);
- m_pOwner->m_pEdtEngine->AddSelRange(iStart, iEnd - iStart);
+ m_pOwner->UpdateEditEngine();
+ }
+ m_pOwner->UpdateVAlignment();
+ m_pOwner->UpdateOffset();
+ m_pOwner->UpdateCaret();
+ } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ m_pOwner->ShowCaret(FALSE);
+ if (m_pOwner->m_pEdtEngine &&
+ (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) {
+ int32_t nSel = m_pOwner->CountSelRanges();
+ if (nSel > 0) {
+ m_pOwner->ClearSelections();
bRepaint = TRUE;
- } else {
- m_pOwner->m_nSelStart = nIndex;
- }
- if (bRepaint) {
- m_pOwner->Repaint(&m_pOwner->m_rtEngine);
- }
-}
-void CFWL_EditImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- DoCursor(pMsg);
- m_pOwner->m_bLButtonDown = FALSE;
- m_pOwner->SetGrab(FALSE);
-}
-void CFWL_EditImpDelegate::OnButtonDblClk(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
- DoCursor(pMsg);
- IFDE_TxtEdtPage *pPage = m_pOwner->m_pEdtEngine->GetPage(0);
- _FWL_RETURN_IF_FAIL(pPage);
- CFX_PointF pt;
- pt.Set(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->DeviceToEngine(pt);
- int32_t nCount = 0;
- int32_t nIndex = pPage->SelectWord(pt, nCount);
- if (nIndex < 0) {
- return;
- }
- m_pOwner->m_pEdtEngine->AddSelRange(nIndex, nCount);
- m_pOwner->m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, FALSE);
- m_pOwner->Repaint(&m_pOwner->m_rtEngine);
-}
-void CFWL_EditImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
- DoCursor(pMsg);
- if (m_pOwner->m_nSelStart == -1 || !m_pOwner->m_bLButtonDown) {
- return;
- }
- IFDE_TxtEdtPage *pPage = m_pOwner->m_pEdtEngine->GetPage(0);
- _FWL_RETURN_IF_FAIL(pPage);
- CFX_PointF pt;
- pt.Set(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->DeviceToEngine(pt);
- FX_BOOL bBefore = TRUE;
- int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
- m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore);
- nIndex = m_pOwner->m_pEdtEngine->GetCaretPos();
+ }
+ m_pOwner->SetCaretPos(0);
+ m_pOwner->UpdateOffset();
+ }
+ m_pOwner->ClearRecord();
+ }
+ m_pOwner->LayoutScrollBar();
+ if (bRepaint) {
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
+ m_pOwner->m_pProperties->m_rtWidget.height);
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+}
+void CFWL_EditImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ DoCursor(pMsg);
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ return;
+ }
+ m_pOwner->m_bLButtonDown = TRUE;
+ m_pOwner->SetGrab(TRUE);
+ DoButtonDown(pMsg);
+ int32_t nIndex = m_pOwner->m_pEdtEngine->GetCaretPos();
+ FX_BOOL bRepaint = FALSE;
+ int32_t iCount = m_pOwner->m_pEdtEngine->CountSelRanges();
+ if (iCount > 0) {
m_pOwner->m_pEdtEngine->ClearSelection();
- if (nIndex != m_pOwner->m_nSelStart) {
- int32_t nLen = m_pOwner->m_pEdtEngine->GetTextLength();
- if (m_pOwner->m_nSelStart >= nLen) {
- m_pOwner->m_nSelStart = nLen;
- }
- m_pOwner->m_pEdtEngine->AddSelRange(FX_MIN(m_pOwner->m_nSelStart, nIndex), FXSYS_abs(nIndex - m_pOwner->m_nSelStart));
- }
-}
-void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey *pMsg)
-{
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
- FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone;
- FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
- FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl;
- FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
- switch (dwKeyCode) {
- case FWL_VKEY_Left: {
- MoveCaret = MC_Left;
- break;
- }
- case FWL_VKEY_Right: {
- MoveCaret = MC_Right;
- break;
- }
- case FWL_VKEY_Up: {
- MoveCaret = MC_Up;
- break;
- }
- case FWL_VKEY_Down: {
- MoveCaret = MC_Down;
- break;
- }
- case FWL_VKEY_Home: {
- if (bCtrl) {
- MoveCaret = MC_Home;
- } else {
- MoveCaret = MC_LineStart;
- }
- break;
- }
- case FWL_VKEY_End: {
- if (bCtrl) {
- MoveCaret = MC_End;
- } else {
- MoveCaret = MC_LineEnd;
- }
- break;
- }
- case FWL_VKEY_Insert: {
- break;
- }
- case FWL_VKEY_Delete: {
- if ( (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)
- || (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- break;
- }
- int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos();
-#if (_FX_OS_==_FX_MACOSX_)
- m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE);
-#else
- m_pOwner->m_pEdtEngine->Delete(nCaret);
-#endif
- break;
- }
- case FWL_VKEY_F2: {
- break;
- }
- case FWL_VKEY_Tab: {
- m_pOwner->DispatchKeyEvent(pMsg);
- break;
- }
- default: {
-#if (_FX_OS_==_FX_MACOSX_)
- if (pMsg->m_dwFlags & FWL_KEYFLAG_Command)
+ bRepaint = TRUE;
+ }
+ FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
+ if (bShift && m_pOwner->m_nSelStart != nIndex) {
+ int32_t iStart = FX_MIN(m_pOwner->m_nSelStart, nIndex);
+ int32_t iEnd = FX_MAX(m_pOwner->m_nSelStart, nIndex);
+ m_pOwner->m_pEdtEngine->AddSelRange(iStart, iEnd - iStart);
+ bRepaint = TRUE;
+ } else {
+ m_pOwner->m_nSelStart = nIndex;
+ }
+ if (bRepaint) {
+ m_pOwner->Repaint(&m_pOwner->m_rtEngine);
+ }
+}
+void CFWL_EditImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ DoCursor(pMsg);
+ m_pOwner->m_bLButtonDown = FALSE;
+ m_pOwner->SetGrab(FALSE);
+}
+void CFWL_EditImpDelegate::OnButtonDblClk(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
+ DoCursor(pMsg);
+ IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_IF_FAIL(pPage);
+ CFX_PointF pt;
+ pt.Set(pMsg->m_fx, pMsg->m_fy);
+ m_pOwner->DeviceToEngine(pt);
+ int32_t nCount = 0;
+ int32_t nIndex = pPage->SelectWord(pt, nCount);
+ if (nIndex < 0) {
+ return;
+ }
+ m_pOwner->m_pEdtEngine->AddSelRange(nIndex, nCount);
+ m_pOwner->m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, FALSE);
+ m_pOwner->Repaint(&m_pOwner->m_rtEngine);
+}
+void CFWL_EditImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
+ DoCursor(pMsg);
+ if (m_pOwner->m_nSelStart == -1 || !m_pOwner->m_bLButtonDown) {
+ return;
+ }
+ IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0);
+ _FWL_RETURN_IF_FAIL(pPage);
+ CFX_PointF pt;
+ pt.Set(pMsg->m_fx, pMsg->m_fy);
+ m_pOwner->DeviceToEngine(pt);
+ FX_BOOL bBefore = TRUE;
+ int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
+ m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore);
+ nIndex = m_pOwner->m_pEdtEngine->GetCaretPos();
+ m_pOwner->m_pEdtEngine->ClearSelection();
+ if (nIndex != m_pOwner->m_nSelStart) {
+ int32_t nLen = m_pOwner->m_pEdtEngine->GetTextLength();
+ if (m_pOwner->m_nSelStart >= nLen) {
+ m_pOwner->m_nSelStart = nLen;
+ }
+ m_pOwner->m_pEdtEngine->AddSelRange(
+ FX_MIN(m_pOwner->m_nSelStart, nIndex),
+ FXSYS_abs(nIndex - m_pOwner->m_nSelStart));
+ }
+}
+void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
+ FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone;
+ FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
+ FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl;
+ FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
+ switch (dwKeyCode) {
+ case FWL_VKEY_Left: {
+ MoveCaret = MC_Left;
+ break;
+ }
+ case FWL_VKEY_Right: {
+ MoveCaret = MC_Right;
+ break;
+ }
+ case FWL_VKEY_Up: {
+ MoveCaret = MC_Up;
+ break;
+ }
+ case FWL_VKEY_Down: {
+ MoveCaret = MC_Down;
+ break;
+ }
+ case FWL_VKEY_Home: {
+ if (bCtrl) {
+ MoveCaret = MC_Home;
+ } else {
+ MoveCaret = MC_LineStart;
+ }
+ break;
+ }
+ case FWL_VKEY_End: {
+ if (bCtrl) {
+ MoveCaret = MC_End;
+ } else {
+ MoveCaret = MC_LineEnd;
+ }
+ break;
+ }
+ case FWL_VKEY_Insert: {
+ break;
+ }
+ case FWL_VKEY_Delete: {
+ if ((m_pOwner->m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+ break;
+ }
+ int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos();
+#if (_FX_OS_ == _FX_MACOSX_)
+ m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE);
#else
- if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl)
+ m_pOwner->m_pEdtEngine->Delete(nCaret);
#endif
- {
- if (dwKeyCode == 0x43 || dwKeyCode == 0x63) {
- m_pOwner->DoClipboard(1);
- return;
- }
- if (dwKeyCode == 0x58 || dwKeyCode == 0x78) {
- m_pOwner->DoClipboard(2);
- return;
- }
- if (dwKeyCode == 0x56 || dwKeyCode == 0x76) {
- m_pOwner->DoClipboard(3);
- return;
- }
- }
- }
- }
- if (MoveCaret != MC_MoveNone) {
- m_pOwner->m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl);
- }
-}
-void CFWL_EditImpDelegate::OnChar(CFWL_MsgKey *pMsg)
-{
- if ( (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)
- || ( m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- return;
- }
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
- int32_t iError = 0;
- FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode;
- int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos();
- switch (c) {
- case FWL_VKEY_Back: {
- m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE);
- break;
- }
- case 0x0A: {
- break;
- }
- case FWL_VKEY_Escape: {
- break;
- }
- case FWL_VKEY_Tab: {
- iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\t", 1);
- break;
- }
- case FWL_VKEY_Return: {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) {
- iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\n", 1);
- }
- break;
- }
- default: {
- if (!m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) {
- if (((pMsg->m_dwKeyCode < FWL_VKEY_0) && (pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) || pMsg->m_dwKeyCode > FWL_VKEY_9) {
- break;
- }
- if (!m_pOwner->ValidateNumberChar(c)) {
- break;
- }
- }
- }
-#if (_FX_OS_==_FX_MACOSX_)
- if (pMsg->m_dwFlags & FWL_KEYFLAG_Command)
+ break;
+ }
+ case FWL_VKEY_F2: {
+ break;
+ }
+ case FWL_VKEY_Tab: {
+ m_pOwner->DispatchKeyEvent(pMsg);
+ break;
+ }
+ default: {
+#if (_FX_OS_ == _FX_MACOSX_)
+ if (pMsg->m_dwFlags & FWL_KEYFLAG_Command)
#else
- if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl)
+ if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl)
#endif
- {
- break;
- }
- iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1);
- break;
- }
- }
- if (iError < 0) {
- m_pOwner->ProcessInsertError(iError);
- }
-}
-FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar *pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos)
-{
- CFX_SizeF fs;
- pScrollBar->GetRange(fs.x, fs.y);
- FX_FLOAT iCurPos = pScrollBar->GetPos();
- FX_FLOAT fStep = pScrollBar->GetStepSize();
- switch (dwCode) {
- case FWL_SCBCODE_Min: {
- fPos = fs.x;
- break;
- }
- case FWL_SCBCODE_Max: {
- fPos = fs.y;
- break;
- }
- case FWL_SCBCODE_StepBackward: {
- fPos -= fStep;
- if (fPos < fs.x + fStep / 2) {
- fPos = fs.x;
- }
- break;
- }
- case FWL_SCBCODE_StepForward: {
- fPos += fStep;
- if (fPos > fs.y - fStep / 2) {
- fPos = fs.y;
- }
- break;
- }
- case FWL_SCBCODE_PageBackward: {
- fPos -= pScrollBar->GetPageSize();
- if (fPos < fs.x) {
- fPos = fs.x;
- }
- break;
- }
- case FWL_SCBCODE_PageForward: {
- fPos += pScrollBar->GetPageSize();
- if (fPos > fs.y) {
- fPos = fs.y;
- }
- break;
- }
- case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos: {
- break;
- }
- case FWL_SCBCODE_EndScroll: {
- return FALSE;
- }
- default: {
- }
- }
- if (iCurPos != fPos) {
- pScrollBar->SetPos(fPos);
- pScrollBar->SetTrackPos(fPos);
- m_pOwner->UpdateOffset(pScrollBar, fPos - iCurPos);
- if (m_pOwner->m_pEdtEngine) {
- m_pOwner->UpdateCaret();
+ {
+ if (dwKeyCode == 0x43 || dwKeyCode == 0x63) {
+ m_pOwner->DoClipboard(1);
+ return;
}
- CFX_RectF rect;
- m_pOwner->GetWidgetRect(rect);
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
- m_pOwner->Repaint(&rtInvalidate);
- }
- return TRUE;
-}
-void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- IFWL_AdapterCursorMgr *pCursorMgr = pNative->GetCursorMgr();
- if (NULL != pCursorMgr) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_InputBeam);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
+ if (dwKeyCode == 0x58 || dwKeyCode == 0x78) {
+ m_pOwner->DoClipboard(2);
+ return;
}
- }
+ if (dwKeyCode == 0x56 || dwKeyCode == 0x76) {
+ m_pOwner->DoClipboard(3);
+ return;
+ }
+ }
+ }
+ }
+ if (MoveCaret != MC_MoveNone) {
+ m_pOwner->m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl);
+ }
+}
+void CFWL_EditImpDelegate::OnChar(CFWL_MsgKey* pMsg) {
+ if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+ return;
+ }
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pEdtEngine);
+ int32_t iError = 0;
+ FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode;
+ int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos();
+ switch (c) {
+ case FWL_VKEY_Back: {
+ m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE);
+ break;
+ }
+ case 0x0A: {
+ break;
+ }
+ case FWL_VKEY_Escape: {
+ break;
+ }
+ case FWL_VKEY_Tab: {
+ iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\t", 1);
+ break;
+ }
+ case FWL_VKEY_Return: {
+ if (m_pOwner->m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_EDT_WantReturn) {
+ iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\n", 1);
+ }
+ break;
+ }
+ default: {
+ if (!m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) {
+ if (((pMsg->m_dwKeyCode < FWL_VKEY_0) &&
+ (pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) ||
+ pMsg->m_dwKeyCode > FWL_VKEY_9) {
+ break;
+ }
+ if (!m_pOwner->ValidateNumberChar(c)) {
+ break;
+ }
+ }
+ }
+#if (_FX_OS_ == _FX_MACOSX_)
+ if (pMsg->m_dwFlags & FWL_KEYFLAG_Command)
+#else
+ if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl)
+#endif
+ {
+ break;
+ }
+ iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1);
+ break;
+ }
+ }
+ if (iError < 0) {
+ m_pOwner->ProcessInsertError(iError);
+ }
+}
+FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
+ FX_DWORD dwCode,
+ FX_FLOAT fPos) {
+ CFX_SizeF fs;
+ pScrollBar->GetRange(fs.x, fs.y);
+ FX_FLOAT iCurPos = pScrollBar->GetPos();
+ FX_FLOAT fStep = pScrollBar->GetStepSize();
+ switch (dwCode) {
+ case FWL_SCBCODE_Min: {
+ fPos = fs.x;
+ break;
+ }
+ case FWL_SCBCODE_Max: {
+ fPos = fs.y;
+ break;
+ }
+ case FWL_SCBCODE_StepBackward: {
+ fPos -= fStep;
+ if (fPos < fs.x + fStep / 2) {
+ fPos = fs.x;
+ }
+ break;
+ }
+ case FWL_SCBCODE_StepForward: {
+ fPos += fStep;
+ if (fPos > fs.y - fStep / 2) {
+ fPos = fs.y;
+ }
+ break;
+ }
+ case FWL_SCBCODE_PageBackward: {
+ fPos -= pScrollBar->GetPageSize();
+ if (fPos < fs.x) {
+ fPos = fs.x;
+ }
+ break;
+ }
+ case FWL_SCBCODE_PageForward: {
+ fPos += pScrollBar->GetPageSize();
+ if (fPos > fs.y) {
+ fPos = fs.y;
+ }
+ break;
+ }
+ case FWL_SCBCODE_Pos:
+ case FWL_SCBCODE_TrackPos: {
+ break;
+ }
+ case FWL_SCBCODE_EndScroll: {
+ return FALSE;
+ }
+ default: {}
+ }
+ if (iCurPos != fPos) {
+ pScrollBar->SetPos(fPos);
+ pScrollBar->SetTrackPos(fPos);
+ m_pOwner->UpdateOffset(pScrollBar, fPos - iCurPos);
+ if (m_pOwner->m_pEdtEngine) {
+ m_pOwner->UpdateCaret();
+ }
+ CFX_RectF rect;
+ m_pOwner->GetWidgetRect(rect);
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+ return TRUE;
+}
+void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr();
+ if (NULL != pCursorMgr) {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_InputBeam);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ }
+ }
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_formproxyimp.cpp b/xfa/src/fwl/src/basewidget/fwl_formproxyimp.cpp index 6ecfeeeb0f..5dcbb8af6f 100644 --- a/xfa/src/fwl/src/basewidget/fwl_formproxyimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_formproxyimp.cpp @@ -11,61 +11,48 @@ #include "../core/include/fwl_panelimp.h"
#include "../core/include/fwl_formimp.h"
#include "include/fwl_formproxyimp.h"
-CFWL_FormProxyImp::CFWL_FormProxyImp(IFWL_Widget *pOuter )
- : CFWL_FormImp(pOuter)
-{
-}
-CFWL_FormProxyImp::CFWL_FormProxyImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_FormImp(properties, pOuter)
-{
-}
-CFWL_FormProxyImp::~CFWL_FormProxyImp()
-{
-}
-FWL_ERR CFWL_FormProxyImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_FormProxy;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_FormProxyImp::GetClassID() const
-{
- return FWL_CLASSHASH_FormProxy;
-}
-FX_BOOL CFWL_FormProxyImp::IsInstance(const CFX_WideStringC& wsClass) const
-{
- if (wsClass == CFX_WideStringC(FWL_CLASS_FormProxy)) {
- return TRUE;
- }
- return CFWL_FormImp::IsInstance(wsClass);
-}
-FWL_ERR CFWL_FormProxyImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate *)FX_NEW CFWL_FormProxyImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormProxyImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_FormProxyImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_FormProxyImp::Update()
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormProxyImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return FWL_ERR_Succeeded;
-}
-CFWL_FormProxyImpDelegate::CFWL_FormProxyImpDelegate(CFWL_FormProxyImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pOuter->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMessage);
+CFWL_FormProxyImp::CFWL_FormProxyImp(IFWL_Widget* pOuter)
+ : CFWL_FormImp(pOuter) {}
+CFWL_FormProxyImp::CFWL_FormProxyImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_FormImp(properties, pOuter) {}
+CFWL_FormProxyImp::~CFWL_FormProxyImp() {}
+FWL_ERR CFWL_FormProxyImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_FormProxy;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_FormProxyImp::GetClassID() const {
+ return FWL_CLASSHASH_FormProxy;
+}
+FX_BOOL CFWL_FormProxyImp::IsInstance(const CFX_WideStringC& wsClass) const {
+ if (wsClass == CFX_WideStringC(FWL_CLASS_FormProxy)) {
+ return TRUE;
+ }
+ return CFWL_FormImp::IsInstance(wsClass);
+}
+FWL_ERR CFWL_FormProxyImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_FormProxyImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_FormProxyImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_FormProxyImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_FormProxyImp::Update() {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_FormProxyImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return FWL_ERR_Succeeded;
+}
+CFWL_FormProxyImpDelegate::CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pOuter->SetDelegate(NULL);
+ return pDelegate->OnProcessMessage(pMessage);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp index 8453f43f4b..e20afa32c5 100644 --- a/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp @@ -11,1245 +11,1215 @@ #include "include/fwl_scrollbarimp.h"
#include "include/fwl_listboximp.h"
#define FWL_LISTBOX_ItemTextMargin 2
-IFWL_ListBox* IFWL_ListBox::Create()
-{
- return new IFWL_ListBox;
+IFWL_ListBox* IFWL_ListBox::Create() {
+ return new IFWL_ListBox;
}
-IFWL_ListBox::IFWL_ListBox()
-{
- m_pData = NULL;
-}
-IFWL_ListBox::~IFWL_ListBox()
-{
- if (m_pData) {
- delete (CFWL_ListBoxImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_ListBox::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ListBoxImp(pOuter);
- ((CFWL_ListBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_ListBoxImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_ListBox::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ListBoxImp(properties, pOuter);
- ((CFWL_ListBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_ListBoxImp*)m_pData)->Initialize();
-}
-int32_t IFWL_ListBox::CountSelItems()
-{
- return ((CFWL_ListBoxImp*)m_pData)->CountSelItems();
-}
-FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel)
-{
- return ((CFWL_ListBoxImp*)m_pData)->GetSelItem(nIndexSel);
-}
-int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex)
-{
- return ((CFWL_ListBoxImp*)m_pData)->GetSelIndex(nIndex);
-}
-FWL_ERR IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect)
-{
- return ((CFWL_ListBoxImp*)m_pData)->SetSelItem(hItem, bSelect);
-}
-FWL_ERR IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString &wsText)
-{
- return ((CFWL_ListBoxImp*)m_pData)->GetItemText(hItem, wsText);
-}
-FWL_ERR IFWL_ListBox::GetScrollPos(FX_FLOAT &fPos, FX_BOOL bVert)
-{
- return ((CFWL_ListBoxImp*)m_pData)->GetScrollPos(fPos, bVert);
-}
-FWL_ERR* IFWL_ListBox::Sort(IFWL_ListBoxCompare *pCom)
-{
- return ((CFWL_ListBoxImp*)m_pData)->Sort(pCom);
-}
-CFWL_ListBoxImp::CFWL_ListBoxImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_pHorzScrollBar(NULL)
- , m_pVertScrollBar(NULL)
- , m_dwTTOStyles(0)
- , m_iTTOAligns(0)
- , m_hAnchor(NULL)
- , m_fScorllBarWidth(0)
- , m_bLButtonDown(FALSE)
- , m_pScrollBarTP(NULL)
-{
- m_rtClient.Reset();
- m_rtConent.Reset();
- m_rtStatic.Reset();
-}
-CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_pHorzScrollBar(NULL)
- , m_pVertScrollBar(NULL)
- , m_dwTTOStyles(0)
- , m_iTTOAligns(0)
- , m_hAnchor(NULL)
- , m_fScorllBarWidth(0)
- , m_bLButtonDown(FALSE)
- , m_pScrollBarTP(NULL)
-{
- m_rtClient.Reset();
- m_rtConent.Reset();
- m_rtStatic.Reset();
-}
-CFWL_ListBoxImp::~CFWL_ListBoxImp()
-{
- if (m_pVertScrollBar) {
- m_pVertScrollBar->Release();
- m_pVertScrollBar = NULL;
- }
- if (m_pHorzScrollBar) {
- m_pHorzScrollBar->Release();
- m_pHorzScrollBar = NULL;
- }
-}
-FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_ListBox;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ListBoxImp::GetClassID() const
-{
- return FWL_CLASSHASH_ListBox;
-}
-FWL_ERR CFWL_ListBoxImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ListBoxImpDelegate(this);
- return FWL_ERR_Succeeded;
+IFWL_ListBox::IFWL_ListBox() {
+ m_pData = NULL;
}
-FWL_ERR CFWL_ListBoxImp::Finalize()
-{
- if (m_pVertScrollBar) {
- m_pVertScrollBar->Finalize();
- }
- if (m_pHorzScrollBar) {
- m_pHorzScrollBar->Finalize();
- }
- if (m_pDelegate) {
- delete (CFWL_ListBoxImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- CFX_SizeF fs = CalcSize(TRUE);
- rect.Set(0, 0, fs.x, fs.y);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBoxImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
+IFWL_ListBox::~IFWL_ListBox() {
+ if (m_pData) {
+ delete (CFWL_ListBoxImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+FWL_ERR IFWL_ListBox::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ListBoxImp(pOuter);
+ ((CFWL_ListBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ListBoxImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_ListBox::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ListBoxImp(properties, pOuter);
+ ((CFWL_ListBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ListBoxImp*)m_pData)->Initialize();
+}
+int32_t IFWL_ListBox::CountSelItems() {
+ return ((CFWL_ListBoxImp*)m_pData)->CountSelItems();
+}
+FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
+ return ((CFWL_ListBoxImp*)m_pData)->GetSelItem(nIndexSel);
+}
+int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
+ return ((CFWL_ListBoxImp*)m_pData)->GetSelIndex(nIndex);
+}
+FWL_ERR IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+ return ((CFWL_ListBoxImp*)m_pData)->SetSelItem(hItem, bSelect);
+}
+FWL_ERR IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) {
+ return ((CFWL_ListBoxImp*)m_pData)->GetItemText(hItem, wsText);
+}
+FWL_ERR IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+ return ((CFWL_ListBoxImp*)m_pData)->GetScrollPos(fPos, bVert);
+}
+FWL_ERR* IFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) {
+ return ((CFWL_ListBoxImp*)m_pData)->Sort(pCom);
+}
+CFWL_ListBoxImp::CFWL_ListBoxImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_pHorzScrollBar(NULL),
+ m_pVertScrollBar(NULL),
+ m_dwTTOStyles(0),
+ m_iTTOAligns(0),
+ m_hAnchor(NULL),
+ m_fScorllBarWidth(0),
+ m_bLButtonDown(FALSE),
+ m_pScrollBarTP(NULL) {
+ m_rtClient.Reset();
+ m_rtConent.Reset();
+ m_rtStatic.Reset();
+}
+CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_pHorzScrollBar(NULL),
+ m_pVertScrollBar(NULL),
+ m_dwTTOStyles(0),
+ m_iTTOAligns(0),
+ m_hAnchor(NULL),
+ m_fScorllBarWidth(0),
+ m_bLButtonDown(FALSE),
+ m_pScrollBarTP(NULL) {
+ m_rtClient.Reset();
+ m_rtConent.Reset();
+ m_rtStatic.Reset();
+}
+CFWL_ListBoxImp::~CFWL_ListBoxImp() {
+ if (m_pVertScrollBar) {
+ m_pVertScrollBar->Release();
+ m_pVertScrollBar = NULL;
+ }
+ if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->Release();
+ m_pHorzScrollBar = NULL;
+ }
+}
+FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_ListBox;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ListBoxImp::GetClassID() const {
+ return FWL_CLASSHASH_ListBox;
+}
+FWL_ERR CFWL_ListBoxImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ListBoxImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBoxImp::Finalize() {
+ if (m_pVertScrollBar) {
+ m_pVertScrollBar->Finalize();
+ }
+ if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->Finalize();
+ }
+ if (m_pDelegate) {
+ delete (CFWL_ListBoxImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- m_iTTOAligns = FDE_TTOALIGNMENT_Center;
- switch(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) {
- case FWL_STYLEEXT_LTB_LeftAlign: {
- m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft;
- break;
- }
- case FWL_STYLEEXT_LTB_RightAlign: {
- m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight;
- break;
- }
- case FWL_STYLEEXT_LTB_CenterAlign:
- default: {
- m_iTTOAligns = FDE_TTOALIGNMENT_Center;
- }
- }
- if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
- m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
- }
- m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
- m_fScorllBarWidth = GetScrollWidth();
- SortItem();
- CalcSize();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- if (IsShowScrollBar(FALSE)) {
- CFX_RectF rect;
- m_pHorzScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_HScrollBar;
- }
- }
- if (IsShowScrollBar(TRUE)) {
- CFX_RectF rect;
- m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_VScrollBar;
- }
- }
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- pGraphics->SaveGraphState();
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_LTB_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_LTB_Edge, pTheme, pMatrix);
- }
- CFX_RectF rtClip(m_rtConent);
- if (IsShowScrollBar(FALSE)) {
- rtClip.height -= m_fScorllBarWidth;
- }
- if (IsShowScrollBar(TRUE)) {
- rtClip.width -= m_fScorllBarWidth;
- }
- if (pMatrix) {
- pMatrix->TransformRect(rtClip);
- }
- pGraphics->SetClipRect(rtClip);
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) {
- DrawBkground(pGraphics, pTheme, pMatrix);
- }
- DrawItems(pGraphics, pTheme, pMatrix);
- pGraphics->RestoreGraphState();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider *pThemeProvider)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pThemeProvider, FWL_ERR_Indefinite);
- if (!pThemeProvider->IsValidWidget(m_pInterface)) {
- m_pScrollBarTP = pThemeProvider;
- return FWL_ERR_Succeeded;
- }
- m_pProperties->m_pThemeProvider = pThemeProvider;
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ CFX_SizeF fs = CalcSize(TRUE);
+ rect.Set(0, 0, fs.x, fs.y);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBoxImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ m_iTTOAligns = FDE_TTOALIGNMENT_Center;
+ switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) {
+ case FWL_STYLEEXT_LTB_LeftAlign: {
+ m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft;
+ break;
+ }
+ case FWL_STYLEEXT_LTB_RightAlign: {
+ m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight;
+ break;
+ }
+ case FWL_STYLEEXT_LTB_CenterAlign:
+ default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; }
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
+ m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
+ }
+ m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
+ m_fScorllBarWidth = GetScrollWidth();
+ SortItem();
+ CalcSize();
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (IsShowScrollBar(FALSE)) {
+ CFX_RectF rect;
+ m_pHorzScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_HScrollBar;
+ }
+ }
+ if (IsShowScrollBar(TRUE)) {
+ CFX_RectF rect;
+ m_pVertScrollBar->GetWidgetRect(rect);
+ if (rect.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_VScrollBar;
+ }
+ }
+ if (m_rtClient.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ return FWL_WGTHITTEST_Unknown;
+}
+FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ pGraphics->SaveGraphState();
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_LTB_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_LTB_Edge, pTheme, pMatrix);
+ }
+ CFX_RectF rtClip(m_rtConent);
+ if (IsShowScrollBar(FALSE)) {
+ rtClip.height -= m_fScorllBarWidth;
+ }
+ if (IsShowScrollBar(TRUE)) {
+ rtClip.width -= m_fScorllBarWidth;
+ }
+ if (pMatrix) {
+ pMatrix->TransformRect(rtClip);
+ }
+ pGraphics->SetClipRect(rtClip);
+ if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) {
+ DrawBkground(pGraphics, pTheme, pMatrix);
+ }
+ DrawItems(pGraphics, pTheme, pMatrix);
+ pGraphics->RestoreGraphState();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ _FWL_RETURN_VALUE_IF_FAIL(pThemeProvider, FWL_ERR_Indefinite);
+ if (!pThemeProvider->IsValidWidget(m_pInterface)) {
+ m_pScrollBarTP = pThemeProvider;
return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ListBoxImp::CountSelItems()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, 0);
- int32_t iRet = 0;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- if (!hItem) {
- continue;
- }
- FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
- if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
- iRet ++;
- }
- }
- return iRet;
-}
-FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, NULL);
- int32_t index = 0;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- if (!hItem) {
- return NULL;
- }
- FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
- if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
- if (index == nIndexSel) {
- return hItem;
- } else {
- index ++;
- }
- }
- }
- return NULL;
-}
-int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, -1);
- int32_t index = 0;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- if (!hItem) {
- return -1;
- }
- FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
- if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
- if (index == nIndex) {
- return i;
- } else {
- index ++;
- }
- }
- }
- return -1;
-}
-FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
+ }
+ m_pProperties->m_pThemeProvider = pThemeProvider;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ListBoxImp::CountSelItems() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, 0);
+ int32_t iRet = 0;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
if (!hItem) {
- if (bSelect) {
- SelectAll();
- } else {
- ClearSelection();
- SetFocusItem(NULL);
- }
- return FWL_ERR_Indefinite;
- }
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
- SetSelectionDirect(hItem, bSelect);
+ continue;
+ }
+ FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
+ if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
+ iRet++;
+ }
+ }
+ return iRet;
+}
+FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, NULL);
+ int32_t index = 0;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ if (!hItem) {
+ return NULL;
+ }
+ FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
+ if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
+ if (index == nIndexSel) {
+ return hItem;
+ } else {
+ index++;
+ }
+ }
+ }
+ return NULL;
+}
+int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, -1);
+ int32_t index = 0;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ if (!hItem) {
+ return -1;
+ }
+ FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
+ if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
+ if (index == nIndex) {
+ return i;
+ } else {
+ index++;
+ }
+ }
+ }
+ return -1;
+}
+FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
+ if (!hItem) {
+ if (bSelect) {
+ SelectAll();
} else {
- SetSelection(hItem, hItem, bSelect);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- pData->GetItemText(m_pInterface, hItem, wsText);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT &fPos, FX_BOOL bVert )
-{
- if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) {
- IFWL_ScrollBar *pScrollBar = bVert ? m_pVertScrollBar : m_pHorzScrollBar;
- fPos = pScrollBar->GetPos();
- return FWL_ERR_Succeeded;
+ ClearSelection();
+ SetFocusItem(NULL);
}
return FWL_ERR_Indefinite;
-}
-FWL_ERR* CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare *pCom)
-{
- FWL_HLISTITEM hTemp;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t sz = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < sz - 1; i++) {
- for (int32_t j = i + 1; j < sz; j++) {
- if (pCom->Compare(pData->GetItem(m_pInterface, i), pData->GetItem(m_pInterface, j)) > 0) {
- hTemp = pData->GetItem(m_pInterface, i);
- pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i);
- pData->SetItemIndex(m_pInterface, hTemp, j);
- }
- }
- }
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
+ SetSelectionDirect(hItem, bSelect);
+ } else {
+ SetSelection(hItem, hItem, bSelect);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ pData->GetItemText(m_pInterface, hItem, wsText);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+ if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) {
+ IFWL_ScrollBar* pScrollBar = bVert ? m_pVertScrollBar : m_pHorzScrollBar;
+ fPos = pScrollBar->GetPos();
return FWL_ERR_Succeeded;
-}
-FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, FX_DWORD dwKeyCode)
-{
- FWL_HLISTITEM hRet = NULL;
- switch(dwKeyCode) {
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Home:
- case FWL_VKEY_End: {
- FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up;
- FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down;
- FX_BOOL bHome = dwKeyCode == FWL_VKEY_Home;
- FX_BOOL bEnd = dwKeyCode == FWL_VKEY_End;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iDstItem = -1;
- if (bUp || bDown) {
- int32_t index = pData->GetItemIndex(m_pInterface, hItem);
- iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1;
- } else if (bHome) {
- iDstItem = 0;
- } else {
- int32_t iCount = pData->CountItems(m_pInterface);
- iDstItem = iCount - 1;
- }
- hRet = pData->GetItem(m_pInterface, iDstItem);
- break;
- }
- default: {
- }
- }
- return hRet;
-}
-void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart, FWL_HLISTITEM hEnd, FX_BOOL bSelected)
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iStart = pData->GetItemIndex(m_pInterface, hStart);
- int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd);
- if (iStart > iEnd) {
- int32_t iTemp = iStart;
- iStart = iEnd;
- iEnd = iTemp;
- }
- if (bSelected) {
+ }
+ return FWL_ERR_Indefinite;
+}
+FWL_ERR* CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare* pCom) {
+ FWL_HLISTITEM hTemp;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t sz = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < sz - 1; i++) {
+ for (int32_t j = i + 1; j < sz; j++) {
+ if (pCom->Compare(pData->GetItem(m_pInterface, i),
+ pData->GetItem(m_pInterface, j)) > 0) {
+ hTemp = pData->GetItem(m_pInterface, i);
+ pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i);
+ pData->SetItemIndex(m_pInterface, hTemp, j);
+ }
+ }
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem,
+ FX_DWORD dwKeyCode) {
+ FWL_HLISTITEM hRet = NULL;
+ switch (dwKeyCode) {
+ case FWL_VKEY_Up:
+ case FWL_VKEY_Down:
+ case FWL_VKEY_Home:
+ case FWL_VKEY_End: {
+ FX_BOOL bUp = dwKeyCode == FWL_VKEY_Up;
+ FX_BOOL bDown = dwKeyCode == FWL_VKEY_Down;
+ FX_BOOL bHome = dwKeyCode == FWL_VKEY_Home;
+ FX_BOOL bEnd = dwKeyCode == FWL_VKEY_End;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iDstItem = -1;
+ if (bUp || bDown) {
+ int32_t index = pData->GetItemIndex(m_pInterface, hItem);
+ iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1;
+ } else if (bHome) {
+ iDstItem = 0;
+ } else {
int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i++ ) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- SetSelectionDirect(hItem, FALSE);
- }
- }
- for (; iStart <= iEnd; iStart++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iStart);
- SetSelectionDirect(hItem, bSelected);
- }
-}
-void CFWL_ListBoxImp::SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect)
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FX_DWORD dwOldStyle = pData->GetItemStyles(m_pInterface, hItem);
- bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected
- : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected;
- pData->SetItemStyles(m_pInterface, hItem, dwOldStyle);
-}
-FX_BOOL CFWL_ListBoxImp::IsItemSelected(FWL_HLISTITEM hItem)
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem);
- return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0;
-}
-void CFWL_ListBoxImp::ClearSelection()
-{
- FX_BOOL bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i++ ) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem);
- FX_BOOL bFindSel = dwState & FWL_ITEMSTATE_LTB_Selected;
- if (!bFindSel) {
- continue;
- }
- SetSelectionDirect(hItem, FALSE);
- if (!bMulti) {
- return;
- }
- }
-}
-void CFWL_ListBoxImp::SelectAll()
-{
- FX_BOOL bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
- if (!bMulti) {
- return;
- }
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- if (iCount > 0) {
- FWL_HLISTITEM hItemStart = pData->GetItem(m_pInterface, 0);
- FWL_HLISTITEM hItemEnd = pData->GetItem(m_pInterface, iCount - 1);
- SetSelection(hItemStart, hItemEnd, FALSE);
- }
-}
-FWL_HLISTITEM CFWL_ListBoxImp::GetFocusedItem()
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ iDstItem = iCount - 1;
+ }
+ hRet = pData->GetItem(m_pInterface, iDstItem);
+ break;
+ }
+ default: {}
+ }
+ return hRet;
+}
+void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart,
+ FWL_HLISTITEM hEnd,
+ FX_BOOL bSelected) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iStart = pData->GetItemIndex(m_pInterface, hStart);
+ int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd);
+ if (iStart > iEnd) {
+ int32_t iTemp = iStart;
+ iStart = iEnd;
+ iEnd = iTemp;
+ }
+ if (bSelected) {
int32_t iCount = pData->CountItems(m_pInterface);
for (int32_t i = 0; i < iCount; i++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
- if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) {
- return hItem;
- }
- }
- return NULL;
-}
-void CFWL_ListBoxImp::SetFocusItem(FWL_HLISTITEM hItem)
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FWL_HLISTITEM hFocus = GetFocusedItem();
- if (hItem != hFocus) {
- if (hFocus) {
- FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hFocus);
- dwStyle &= ~FWL_ITEMSTATE_LTB_Focused;
- pData->SetItemStyles(m_pInterface, hFocus, dwStyle);
- }
- if (hItem) {
- FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
- dwStyle |= FWL_ITEMSTATE_LTB_Focused;
- pData->SetItemStyles(m_pInterface, hItem, dwStyle);
- }
- }
-}
-FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy)
-{
- fx -= m_rtConent.left, fy -= m_rtConent.top;
- FX_FLOAT fPosX = 0.0f;
- if (m_pHorzScrollBar) {
- fPosX = m_pHorzScrollBar->GetPos();
- }
- FX_FLOAT fPosY = 0.0;
- if (m_pVertScrollBar) {
- fPosY = m_pVertScrollBar->GetPos();
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ SetSelectionDirect(hItem, FALSE);
+ }
+ }
+ for (; iStart <= iEnd; iStart++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iStart);
+ SetSelectionDirect(hItem, bSelected);
+ }
+}
+void CFWL_ListBoxImp::SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FX_DWORD dwOldStyle = pData->GetItemStyles(m_pInterface, hItem);
+ bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected
+ : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected;
+ pData->SetItemStyles(m_pInterface, hItem, dwOldStyle);
+}
+FX_BOOL CFWL_ListBoxImp::IsItemSelected(FWL_HLISTITEM hItem) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem);
+ return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0;
+}
+void CFWL_ListBoxImp::ClearSelection() {
+ FX_BOOL bMulti =
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ FX_DWORD dwState = pData->GetItemStyles(m_pInterface, hItem);
+ FX_BOOL bFindSel = dwState & FWL_ITEMSTATE_LTB_Selected;
+ if (!bFindSel) {
+ continue;
}
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t nCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < nCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- if (!hItem) {
- continue;
- }
- CFX_RectF rtItem;
- pData->GetItemRect(m_pInterface, hItem, rtItem);
- rtItem.Offset(-fPosX, -fPosY);
- if (rtItem.Contains(fx, fy)) {
- return hItem;
- }
+ SetSelectionDirect(hItem, FALSE);
+ if (!bMulti) {
+ return;
+ }
+ }
+}
+void CFWL_ListBoxImp::SelectAll() {
+ FX_BOOL bMulti =
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
+ if (!bMulti) {
+ return;
+ }
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ if (iCount > 0) {
+ FWL_HLISTITEM hItemStart = pData->GetItem(m_pInterface, 0);
+ FWL_HLISTITEM hItemEnd = pData->GetItem(m_pInterface, iCount - 1);
+ SetSelection(hItemStart, hItemEnd, FALSE);
+ }
+}
+FWL_HLISTITEM CFWL_ListBoxImp::GetFocusedItem() {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
+ if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) {
+ return hItem;
+ }
+ }
+ return NULL;
+}
+void CFWL_ListBoxImp::SetFocusItem(FWL_HLISTITEM hItem) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FWL_HLISTITEM hFocus = GetFocusedItem();
+ if (hItem != hFocus) {
+ if (hFocus) {
+ FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hFocus);
+ dwStyle &= ~FWL_ITEMSTATE_LTB_Focused;
+ pData->SetItemStyles(m_pInterface, hFocus, dwStyle);
+ }
+ if (hItem) {
+ FX_DWORD dwStyle = pData->GetItemStyles(m_pInterface, hItem);
+ dwStyle |= FWL_ITEMSTATE_LTB_Focused;
+ pData->SetItemStyles(m_pInterface, hItem, dwStyle);
+ }
+ }
+}
+FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
+ fx -= m_rtConent.left, fy -= m_rtConent.top;
+ FX_FLOAT fPosX = 0.0f;
+ if (m_pHorzScrollBar) {
+ fPosX = m_pHorzScrollBar->GetPos();
+ }
+ FX_FLOAT fPosY = 0.0;
+ if (m_pVertScrollBar) {
+ fPosY = m_pVertScrollBar->GetPos();
+ }
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t nCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < nCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ if (!hItem) {
+ continue;
}
- return NULL;
-}
-FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF &rtCheck)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FALSE);
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
- return FALSE;
- }
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- pData->GetItemCheckRect(m_pInterface, hItem, rtCheck);
- return TRUE;
-}
-FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FALSE);
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
- return FALSE;
- }
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- return (pData->GetItemCheckState(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Checked);
-}
-FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FALSE);
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
- return FALSE;
- }
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FX_DWORD dwCheckState = pData->GetItemCheckState(m_pInterface, hItem);
- if (bChecked) {
- pData->SetItemCheckState(m_pInterface, hItem, FWL_ITEMSTATE_LTB_Checked);
- } else {
- pData->SetItemCheckState(m_pInterface, hItem, 0);
+ CFX_RectF rtItem;
+ pData->GetItemRect(m_pInterface, hItem, rtItem);
+ rtItem.Offset(-fPosX, -fPosY);
+ if (rtItem.Contains(fx, fy)) {
+ return hItem;
+ }
+ }
+ return NULL;
+}
+FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FALSE);
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
+ return FALSE;
+ }
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ pData->GetItemCheckRect(m_pInterface, hItem, rtCheck);
+ return TRUE;
+}
+FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FALSE);
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
+ return FALSE;
+ }
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ return (pData->GetItemCheckState(m_pInterface, hItem) &
+ FWL_ITEMSTATE_LTB_Checked);
+}
+FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FALSE);
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
+ return FALSE;
+ }
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FX_DWORD dwCheckState = pData->GetItemCheckState(m_pInterface, hItem);
+ if (bChecked) {
+ pData->SetItemCheckState(m_pInterface, hItem, FWL_ITEMSTATE_LTB_Checked);
+ } else {
+ pData->SetItemCheckState(m_pInterface, hItem, 0);
+ }
+ return TRUE;
+}
+FX_BOOL CFWL_ListBoxImp::ScrollToVisible(FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pVertScrollBar, FALSE);
+ CFX_RectF rtItem;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ pData->GetItemRect(m_pInterface, hItem, rtItem);
+ FX_BOOL bScroll = FALSE;
+ FX_FLOAT fPosY = m_pVertScrollBar->GetPos();
+ rtItem.Offset(0, -fPosY + m_rtConent.top);
+ if (rtItem.top < m_rtConent.top) {
+ fPosY += rtItem.top - m_rtConent.top;
+ bScroll = TRUE;
+ } else if (rtItem.bottom() > m_rtConent.bottom()) {
+ fPosY += rtItem.bottom() - m_rtConent.bottom();
+ bScroll = TRUE;
+ }
+ if (!bScroll) {
+ return FALSE;
+ }
+ m_pVertScrollBar->SetPos(fPosY);
+ m_pVertScrollBar->SetTrackPos(fPosY);
+ Repaint(&m_rtClient);
+ return TRUE;
+}
+void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pTheme);
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_LTB_Background;
+ param.m_dwStates = 0;
+ param.m_pGraphics = pGraphics;
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = m_rtClient;
+ if (IsShowScrollBar(FALSE) && IsShowScrollBar(TRUE)) {
+ param.m_pData = &m_rtStatic;
+ }
+ if (!IsEnabled()) {
+ param.m_dwStates = FWL_PARTSTATE_LTB_Disabled;
+ }
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ FX_FLOAT fPosX = 0.0f;
+ if (m_pHorzScrollBar) {
+ fPosX = m_pHorzScrollBar->GetPos();
+ }
+ FX_FLOAT fPosY = 0.0f;
+ if (m_pVertScrollBar) {
+ fPosY = m_pVertScrollBar->GetPos();
+ }
+ CFX_RectF rtView(m_rtConent);
+ if (m_pHorzScrollBar) {
+ rtView.height -= m_fScorllBarWidth;
+ }
+ if (m_pVertScrollBar) {
+ rtView.width -= m_fScorllBarWidth;
+ }
+ FX_BOOL bMultiCol =
+ m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ if (!hItem) {
+ continue;
}
- return TRUE;
-}
-FX_BOOL CFWL_ListBoxImp::ScrollToVisible(FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pVertScrollBar, FALSE);
CFX_RectF rtItem;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
pData->GetItemRect(m_pInterface, hItem, rtItem);
- FX_BOOL bScroll = FALSE;
- FX_FLOAT fPosY = m_pVertScrollBar->GetPos();
- rtItem.Offset(0, - fPosY + m_rtConent.top);
- if (rtItem.top < m_rtConent.top) {
- fPosY += rtItem.top - m_rtConent.top;
- bScroll = TRUE;
- } else if (rtItem.bottom() > m_rtConent.bottom()) {
- fPosY += rtItem.bottom() - m_rtConent.bottom();
- bScroll = TRUE;
- }
- if (!bScroll) {
- return FALSE;
- }
- m_pVertScrollBar->SetPos(fPosY);
- m_pVertScrollBar->SetTrackPos(fPosY);
- Repaint(&m_rtClient);
- return TRUE;
-}
-void CFWL_ListBoxImp::DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pTheme);
+ rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY);
+ if (rtItem.bottom() < m_rtConent.top) {
+ continue;
+ }
+ if (rtItem.top >= m_rtConent.bottom()) {
+ break;
+ }
+ if (bMultiCol && rtItem.left > m_rtConent.right()) {
+ break;
+ }
+ if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) {
+ CFWL_EvtLtbDrawItem ev;
+ ev.m_pSrcTarget = m_pInterface;
+ ev.m_pGraphics = pGraphics;
+ ev.m_matrix = *pMatrix;
+ ev.m_index = i;
+ ev.m_rect = rtItem;
+ DispatchEvent(&ev);
+ } else {
+ DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix);
+ }
+ }
+}
+void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ FWL_HLISTITEM hItem,
+ int32_t Index,
+ const CFX_RectF& rtItem,
+ const CFX_Matrix* pMatrix) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ FX_DWORD dwItemStyles = pData->GetItemStyles(m_pInterface, hItem);
+ FX_DWORD dwPartStates = FWL_PARTSTATE_LTB_Normal;
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ dwPartStates = FWL_PARTSTATE_LTB_Disabled;
+ } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) {
+ dwPartStates = FWL_PARTSTATE_LTB_Selected;
+ }
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused &&
+ dwItemStyles & FWL_ITEMSTATE_LTB_Focused) {
+ dwPartStates |= FWL_PARTSTATE_LTB_Focused;
+ }
+ FWL_ListBoxItemData itemData;
+ itemData.pDataProvider = pData;
+ itemData.iIndex = Index;
+ {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_Background;
- param.m_dwStates = 0;
+ param.m_iPart = FWL_PART_LTB_ListItem;
+ param.m_dwStates = dwPartStates;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = m_rtClient;
- if (IsShowScrollBar(FALSE) && IsShowScrollBar(TRUE)) {
- param.m_pData = &m_rtStatic;
- }
- if (!IsEnabled()) {
- param.m_dwStates = FWL_PARTSTATE_LTB_Disabled;
+ param.m_rtPart = rtItem;
+ param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
+ CFX_RectF rtFocus(rtItem);
+ param.m_pData = &rtFocus;
+ if (m_pVertScrollBar && !m_pHorzScrollBar &&
+ (dwPartStates & FWL_PARTSTATE_LTB_Focused)) {
+ param.m_rtPart.left += 1;
+ param.m_rtPart.width -= (m_fScorllBarWidth + 1);
+ rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
}
pTheme->DrawBackground(¶m);
-}
-void CFWL_ListBoxImp::DrawItems(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix )
-{
- FX_FLOAT fPosX = 0.0f;
- if (m_pHorzScrollBar) {
- fPosX = m_pHorzScrollBar->GetPos();
- }
- FX_FLOAT fPosY = 0.0f;
- if (m_pVertScrollBar) {
- fPosY = m_pVertScrollBar->GetPos();
- }
- CFX_RectF rtView(m_rtConent);
- if (m_pHorzScrollBar) {
- rtView.height -= m_fScorllBarWidth;
- }
- if (m_pVertScrollBar) {
- rtView.width -= m_fScorllBarWidth;
- }
- FX_BOOL bMultiCol = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- if (!hItem) {
- continue;
- }
- CFX_RectF rtItem;
- pData->GetItemRect(m_pInterface, hItem, rtItem);
- rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY);
- if (rtItem.bottom() < m_rtConent.top) {
- continue;
- }
- if (rtItem.top >= m_rtConent.bottom()) {
- break;
- }
- if (bMultiCol && rtItem.left > m_rtConent.right()) {
- break;
- }
- if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) {
- CFWL_EvtLtbDrawItem ev;
- ev.m_pSrcTarget = m_pInterface;
- ev.m_pGraphics = pGraphics;
- ev.m_matrix = *pMatrix;
- ev.m_index = i;
- ev.m_rect = rtItem;
- DispatchEvent(&ev);
- } else {
- DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix);
- }
- }
-}
-void CFWL_ListBoxImp::DrawItem(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FWL_HLISTITEM hItem, int32_t Index, const CFX_RectF &rtItem, const CFX_Matrix *pMatrix )
-{
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- FX_DWORD dwItemStyles = pData->GetItemStyles(m_pInterface, hItem);
- FX_DWORD dwPartStates = FWL_PARTSTATE_LTB_Normal;
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- dwPartStates = FWL_PARTSTATE_LTB_Disabled;
- } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) {
- dwPartStates = FWL_PARTSTATE_LTB_Selected;
- }
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && dwItemStyles & FWL_ITEMSTATE_LTB_Focused) {
- dwPartStates |= FWL_PARTSTATE_LTB_Focused;
- }
- FWL_ListBoxItemData itemData;
- itemData.pDataProvider = pData;
- itemData.iIndex = Index;
- {
+ }
+ {
+ FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
+ if (bHasIcon) {
+ CFX_RectF rtDIB;
+ CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, hItem);
+ rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
+ if (pDib) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_ListItem;
- param.m_dwStates = dwPartStates;
+ param.m_iPart = FWL_PART_LTB_Icon;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = rtItem;
+ param.m_rtPart = rtDIB;
param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
- CFX_RectF rtFocus(rtItem);
- param.m_pData = &rtFocus;
- if (m_pVertScrollBar && !m_pHorzScrollBar && (dwPartStates & FWL_PARTSTATE_LTB_Focused)) {
- param.m_rtPart.left += 1;
- param.m_rtPart.width -= (m_fScorllBarWidth + 1);
- rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
- }
+ param.m_pImage = pDib;
pTheme->DrawBackground(¶m);
+ }
+ }
+ FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check;
+ if (bHasCheck) {
+ CFX_RectF rtCheck;
+ rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
+ rtCheck.Deflate(2, 2, 2, 2);
+ pData->SetItemCheckRect(m_pInterface, hItem, rtCheck);
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_LTB_Check;
+ param.m_pGraphics = pGraphics;
+ if (GetItemChecked(hItem)) {
+ param.m_dwStates = FWL_PARTSTATE_LTB_Checked;
+ } else {
+ param.m_dwStates = FWL_PARTSTATE_LTB_UnChecked;
+ }
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = rtCheck;
+ param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
+ pTheme->DrawBackground(¶m);
+ }
+ CFX_WideString wsText;
+ pData->GetItemText(m_pInterface, hItem, wsText);
+ if (wsText.GetLength() <= 0) {
+ return;
+ }
+ CFX_RectF rtText(rtItem);
+ rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin);
+ if (bHasIcon || bHasCheck) {
+ rtText.Deflate(rtItem.height, 0, 0, 0);
+ }
+ CFWL_ThemeText textParam;
+ textParam.m_pWidget = m_pInterface;
+ textParam.m_iPart = FWL_PART_LTB_ListItem;
+ textParam.m_dwStates = dwPartStates;
+ textParam.m_pGraphics = pGraphics;
+ textParam.m_matrix.Concat(*pMatrix);
+ textParam.m_rtPart = rtText;
+ textParam.m_wsText = wsText;
+ textParam.m_dwTTOStyles = m_dwTTOStyles;
+ textParam.m_iTTOAlign = m_iTTOAligns;
+ textParam.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
+ pTheme->DrawText(&textParam);
+ }
+}
+CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
+ CFX_SizeF fs;
+ fs.Set(0, 0);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, fs);
+ GetClientRect(m_rtClient);
+ m_rtConent = m_rtClient;
+ CFX_RectF rtUIMargin;
+ rtUIMargin.Set(0, 0, 0, 0);
+ if (!m_pOuter) {
+ CFX_RectF* pUIMargin =
+ (CFX_RectF*)GetThemeCapacity(FWL_WGTCAPACITY_UIMargin);
+ if (pUIMargin) {
+ m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
+ pUIMargin->height);
+ }
+ }
+ FX_FLOAT fWidth = 0;
+ if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) {
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ if (!bAutoSize) {
}
- {
- FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
- if (bHasIcon) {
- CFX_RectF rtDIB;
- CFX_DIBitmap *pDib = pData->GetItemIcon(m_pInterface, hItem);
- rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
- if (pDib) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_Icon;
- param.m_pGraphics = pGraphics;
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = rtDIB;
- param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
- param.m_pImage = pDib;
- pTheme->DrawBackground(¶m);
- }
- }
- FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check;
- if (bHasCheck) {
- CFX_RectF rtCheck;
- rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
- rtCheck.Deflate(2, 2, 2, 2);
- pData->SetItemCheckRect(m_pInterface, hItem, rtCheck);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_Check;
- param.m_pGraphics = pGraphics;
- if (GetItemChecked(hItem)) {
- param.m_dwStates = FWL_PARTSTATE_LTB_Checked;
- } else {
- param.m_dwStates = FWL_PARTSTATE_LTB_UnChecked;
- }
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = rtCheck;
- param.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
- pTheme->DrawBackground(¶m);
- }
- CFX_WideString wsText;
- pData->GetItemText(m_pInterface, hItem, wsText);
- if (wsText.GetLength() <= 0) {
- return;
- }
- CFX_RectF rtText(rtItem);
- rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin);
- if (bHasIcon || bHasCheck) {
- rtText.Deflate(rtItem.height, 0, 0, 0);
- }
- CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_LTB_ListItem;
- textParam.m_dwStates = dwPartStates;
- textParam.m_pGraphics = pGraphics;
- textParam.m_matrix.Concat(*pMatrix);
- textParam.m_rtPart = rtText;
- textParam.m_wsText = wsText;
- textParam.m_dwTTOStyles = m_dwTTOStyles;
- textParam.m_iTTOAlign = m_iTTOAligns;
- textParam.m_dwData = (FX_DWORD)(uintptr_t)(&itemData);
- pTheme->DrawText(&textParam);
- }
-}
-CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize )
-{
- CFX_SizeF fs;
- fs.Set(0, 0);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, fs);
- GetClientRect(m_rtClient);
- m_rtConent = m_rtClient;
- CFX_RectF rtUIMargin;
- rtUIMargin.Set(0, 0, 0, 0);
- if (!m_pOuter) {
- CFX_RectF* pUIMargin = (CFX_RectF*)GetThemeCapacity(FWL_WGTCAPACITY_UIMargin);
- if (pUIMargin) {
- m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, pUIMargin->height);
- }
- }
- FX_FLOAT fWidth = 0;
- if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) {
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- if (!bAutoSize) {
- }
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- CFWL_ThemePart itemPart;
- itemPart.m_pWidget = m_pInterface;
- itemPart.m_iPart = FWL_PART_LTB_ListItem;
- itemPart.m_pData = m_pProperties->m_pDataProvider;
- itemPart.m_dwData = i;
- CFX_RectF r;
- m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r);
- if (!bAutoSize) {
- CFX_RectF rtItem;
- rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- pData->SetItemRect(m_pInterface, hItem, rtItem);
- }
- fs.y += r.height;
- if (fs.x < r.width) {
- fs.x = r.width;
- fWidth = r.width;
- }
- }
- } else {
- fWidth = GetMaxTextWidth();
- fWidth += 2 * FWL_LISTBOX_ItemTextMargin;
- if (!bAutoSize) {
- FX_FLOAT fActualWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
- if (fWidth < fActualWidth) {
- fWidth = fActualWidth;
- }
- }
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- m_fItemHeight = GetItemHeigt();
- FX_BOOL bHasIcon;
- bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
- if (bHasIcon) {
- fWidth += m_fItemHeight;
- }
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM htem = pData->GetItem(m_pInterface, i);
- GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize);
- }
- }
- if (bAutoSize) {
- return fs;
- }
- FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
- FX_FLOAT iHeight = m_rtClient.height;
- FX_BOOL bShowVertScr = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
- (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll);
- FX_BOOL bShowHorzScr = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
- (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll);
- if (!bShowVertScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll &&
- (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) {
- bShowVertScr = (fs.y > iHeight);
- }
- if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) {
- bShowHorzScr = (fs.x > iWidth);
- }
- CFX_SizeF szRange;
- if (bShowVertScr) {
- if (!m_pVertScrollBar) {
- InitScrollBar();
- }
- CFX_RectF rtScrollBar;
- rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth,
- m_rtClient.top,
- m_fScorllBarWidth,
- m_rtClient.height - 1);
- if (bShowHorzScr) {
- rtScrollBar.height -= m_fScorllBarWidth;
- }
- m_pVertScrollBar->SetWidgetRect(rtScrollBar);
- szRange.x = 0, szRange.y = fs.y - m_rtConent.height;
- if (szRange.y < m_fItemHeight) {
- szRange.y = m_fItemHeight;
- }
- m_pVertScrollBar->SetRange(szRange.x, szRange.y);
- m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10);
- m_pVertScrollBar->SetStepSize(m_fItemHeight);
- FX_FLOAT fPos = m_pVertScrollBar->GetPos();
- if (fPos < 0) {
- fPos = 0;
- }
- if (fPos > szRange.y) {
- fPos = szRange.y;
- }
- m_pVertScrollBar->SetPos(fPos);
- m_pVertScrollBar->SetTrackPos(fPos);
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == 0 || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) {
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- }
- m_pVertScrollBar->Update();
- } else if (m_pVertScrollBar) {
- m_pVertScrollBar->SetPos(0);
- m_pVertScrollBar->SetTrackPos(0);
- m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ CFWL_ThemePart itemPart;
+ itemPart.m_pWidget = m_pInterface;
+ itemPart.m_iPart = FWL_PART_LTB_ListItem;
+ itemPart.m_pData = m_pProperties->m_pDataProvider;
+ itemPart.m_dwData = i;
+ CFX_RectF r;
+ m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r);
+ if (!bAutoSize) {
+ CFX_RectF rtItem;
+ rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height);
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ pData->SetItemRect(m_pInterface, hItem, rtItem);
+ }
+ fs.y += r.height;
+ if (fs.x < r.width) {
+ fs.x = r.width;
+ fWidth = r.width;
+ }
+ }
+ } else {
+ fWidth = GetMaxTextWidth();
+ fWidth += 2 * FWL_LISTBOX_ItemTextMargin;
+ if (!bAutoSize) {
+ FX_FLOAT fActualWidth =
+ m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
+ if (fWidth < fActualWidth) {
+ fWidth = fActualWidth;
+ }
+ }
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ m_fItemHeight = GetItemHeigt();
+ FX_BOOL bHasIcon;
+ bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
+ if (bHasIcon) {
+ fWidth += m_fItemHeight;
}
- if (bShowHorzScr) {
- if (!m_pHorzScrollBar) {
- InitScrollBar(FALSE);
- }
- CFX_RectF rtScrollBar;
- rtScrollBar.Set(m_rtClient.left,
- m_rtClient.bottom() - m_fScorllBarWidth,
- m_rtClient.width,
- m_fScorllBarWidth);
- if (bShowVertScr) {
- rtScrollBar.width -= m_fScorllBarWidth;
- }
- m_pHorzScrollBar->SetWidgetRect(rtScrollBar);
- szRange.x = 0, szRange.y = fs.x - rtScrollBar.width;
- m_pHorzScrollBar->SetRange(szRange.x, szRange.y);
- m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10);
- m_pHorzScrollBar->SetStepSize(fWidth / 10);
- FX_FLOAT fPos = m_pHorzScrollBar->GetPos();
- if (fPos < 0) {
- fPos = 0;
- }
- if (fPos > szRange.y) {
- fPos = szRange.y;
- }
- m_pHorzScrollBar->SetPos(fPos);
- m_pHorzScrollBar->SetTrackPos(fPos);
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == 0 || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) {
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- }
- m_pHorzScrollBar->Update();
- } else if (m_pHorzScrollBar) {
- m_pHorzScrollBar->SetPos(0);
- m_pHorzScrollBar->SetTrackPos(0);
- m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
- if (bShowVertScr && bShowHorzScr) {
- m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth,
- m_rtClient.bottom() - m_fScorllBarWidth,
- m_fScorllBarWidth,
- m_fScorllBarWidth);
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM htem = pData->GetItem(m_pInterface, i);
+ GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize);
}
+ }
+ if (bAutoSize) {
return fs;
-}
-void CFWL_ListBoxImp::GetItemSize(CFX_SizeF &size, FWL_HLISTITEM hItem, FX_FLOAT fWidth, FX_FLOAT m_fItemHeight, FX_BOOL bAutoSize)
-{
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) {
- } else {
- if (!bAutoSize) {
- CFX_RectF rtItem;
- rtItem.Set(0, size.y, fWidth, m_fItemHeight);
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- pData->SetItemRect(m_pInterface, hItem, rtItem);
- }
- size.x = fWidth;
- size.y += m_fItemHeight;
+ }
+ FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
+ FX_FLOAT iHeight = m_rtClient.height;
+ FX_BOOL bShowVertScr =
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
+ (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll);
+ FX_BOOL bShowHorzScr =
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
+ (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll);
+ if (!bShowVertScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) {
+ bShowVertScr = (fs.y > iHeight);
+ }
+ if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) {
+ bShowHorzScr = (fs.x > iWidth);
+ }
+ CFX_SizeF szRange;
+ if (bShowVertScr) {
+ if (!m_pVertScrollBar) {
+ InitScrollBar();
+ }
+ CFX_RectF rtScrollBar;
+ rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top,
+ m_fScorllBarWidth, m_rtClient.height - 1);
+ if (bShowHorzScr) {
+ rtScrollBar.height -= m_fScorllBarWidth;
+ }
+ m_pVertScrollBar->SetWidgetRect(rtScrollBar);
+ szRange.x = 0, szRange.y = fs.y - m_rtConent.height;
+ if (szRange.y < m_fItemHeight) {
+ szRange.y = m_fItemHeight;
+ }
+ m_pVertScrollBar->SetRange(szRange.x, szRange.y);
+ m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10);
+ m_pVertScrollBar->SetStepSize(m_fItemHeight);
+ FX_FLOAT fPos = m_pVertScrollBar->GetPos();
+ if (fPos < 0) {
+ fPos = 0;
+ }
+ if (fPos > szRange.y) {
+ fPos = szRange.y;
+ }
+ m_pVertScrollBar->SetPos(fPos);
+ m_pVertScrollBar->SetTrackPos(fPos);
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) ==
+ 0 ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) {
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ }
+ m_pVertScrollBar->Update();
+ } else if (m_pVertScrollBar) {
+ m_pVertScrollBar->SetPos(0);
+ m_pVertScrollBar->SetTrackPos(0);
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ if (bShowHorzScr) {
+ if (!m_pHorzScrollBar) {
+ InitScrollBar(FALSE);
+ }
+ CFX_RectF rtScrollBar;
+ rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth,
+ m_rtClient.width, m_fScorllBarWidth);
+ if (bShowVertScr) {
+ rtScrollBar.width -= m_fScorllBarWidth;
+ }
+ m_pHorzScrollBar->SetWidgetRect(rtScrollBar);
+ szRange.x = 0, szRange.y = fs.x - rtScrollBar.width;
+ m_pHorzScrollBar->SetRange(szRange.x, szRange.y);
+ m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10);
+ m_pHorzScrollBar->SetStepSize(fWidth / 10);
+ FX_FLOAT fPos = m_pHorzScrollBar->GetPos();
+ if (fPos < 0) {
+ fPos = 0;
+ }
+ if (fPos > szRange.y) {
+ fPos = szRange.y;
+ }
+ m_pHorzScrollBar->SetPos(fPos);
+ m_pHorzScrollBar->SetTrackPos(fPos);
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) ==
+ 0 ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) {
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ }
+ m_pHorzScrollBar->Update();
+ } else if (m_pHorzScrollBar) {
+ m_pHorzScrollBar->SetPos(0);
+ m_pHorzScrollBar->SetTrackPos(0);
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ if (bShowVertScr && bShowHorzScr) {
+ m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth,
+ m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth,
+ m_fScorllBarWidth);
+ }
+ return fs;
+}
+void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size,
+ FWL_HLISTITEM hItem,
+ FX_FLOAT fWidth,
+ FX_FLOAT m_fItemHeight,
+ FX_BOOL bAutoSize) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) {
+ } else {
+ if (!bAutoSize) {
+ CFX_RectF rtItem;
+ rtItem.Set(0, size.y, fWidth, m_fItemHeight);
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ pData->SetItemRect(m_pInterface, hItem, rtItem);
+ }
+ size.x = fWidth;
+ size.y += m_fItemHeight;
+ }
+}
+FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() {
+ FX_FLOAT fRet = 0.0f;
+ IFWL_ListBoxDP* pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
+ int32_t iCount = pData->CountItems(m_pInterface);
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
+ if (!hItem) {
+ continue;
}
-}
-FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth()
-{
- FX_FLOAT fRet = 0.0f;
- IFWL_ListBoxDP *pData = (IFWL_ListBoxDP*)m_pProperties->m_pDataProvider;
- int32_t iCount = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
- if (!hItem) {
- continue;
- }
- CFX_WideString wsText;
- pData->GetItemText(m_pInterface, hItem, wsText);
- CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
- if (sz.x > fRet) {
- fRet = sz.x;
+ CFX_WideString wsText;
+ pData->GetItemText(m_pInterface, hItem, wsText);
+ CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
+ if (sz.x > fRet) {
+ fRet = sz.x;
+ }
+ }
+ return fRet;
+}
+FX_FLOAT CFWL_ListBoxImp::GetScrollWidth() {
+ FX_FLOAT* pfWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_VALUE_IF_FAIL(pfWidth, 0);
+ return *pfWidth;
+}
+FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() {
+ FX_FLOAT* pfFont = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_FontSize);
+ _FWL_RETURN_VALUE_IF_FAIL(pfFont, 20);
+ return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin;
+}
+void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) {
+ if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
+ return;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
+ prop.m_dwStates = FWL_WGTSTATE_Invisible;
+ prop.m_pParent = m_pInterface;
+ prop.m_pThemeProvider = m_pScrollBarTP;
+ IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create();
+ pScrollBar->Initialize(prop, m_pInterface);
+ bVert ? (m_pVertScrollBar = pScrollBar) : (m_pHorzScrollBar = pScrollBar);
+}
+void CFWL_ListBoxImp::SortItem() {}
+FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) {
+ IFWL_ScrollBar* pScrollbar = bVert ? m_pVertScrollBar : m_pHorzScrollBar;
+ if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) {
+ return FALSE;
+ }
+ return !(m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
+}
+void CFWL_ListBoxImp::ProcessSelChanged() {
+ CFWL_EvtLtbSelChanged selEvent;
+ selEvent.m_pSrcTarget = m_pInterface;
+ CFX_Int32Array arrSels;
+ int32_t iCount = CountSelItems();
+ for (int32_t i = 0; i < iCount; i++) {
+ FWL_HLISTITEM item = GetSelItem(i);
+ if (item == NULL) {
+ continue;
+ }
+ selEvent.iarraySels.Add(i);
+ }
+ DispatchEvent(&selEvent);
+}
+CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ if (!m_pOwner->IsEnabled()) {
+ return 1;
+ }
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
}
- }
- return fRet;
-}
-FX_FLOAT CFWL_ListBoxImp::GetScrollWidth()
-{
- FX_FLOAT *pfWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_VALUE_IF_FAIL(pfWidth, 0);
- return *pfWidth;
-}
-FX_FLOAT CFWL_ListBoxImp::GetItemHeigt()
-{
- FX_FLOAT *pfFont = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_FontSize);
- _FWL_RETURN_VALUE_IF_FAIL(pfFont, 20);
- return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin;
-}
-void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert )
-{
- if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
- return;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
- prop.m_dwStates = FWL_WGTSTATE_Invisible;
- prop.m_pParent = m_pInterface;
- prop.m_pThemeProvider = m_pScrollBarTP;
- IFWL_ScrollBar *pScrollBar = IFWL_ScrollBar::Create();
- pScrollBar->Initialize(prop, m_pInterface);
- bVert ? (m_pVertScrollBar = pScrollBar) : (m_pHorzScrollBar = pScrollBar);
-}
-void CFWL_ListBoxImp::SortItem()
-{
-}
-FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert)
-{
- IFWL_ScrollBar* pScrollbar = bVert ? m_pVertScrollBar : m_pHorzScrollBar;
- if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) {
- return FALSE;
- }
- return !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
-}
-void CFWL_ListBoxImp::ProcessSelChanged()
-{
- CFWL_EvtLtbSelChanged selEvent;
- selEvent.m_pSrcTarget = m_pInterface;
- CFX_Int32Array arrSels;
- int32_t iCount = CountSelItems();
- for (int32_t i = 0; i < iCount; i ++) {
- FWL_HLISTITEM item = GetSelItem(i);
- if (item == NULL) {
- continue;
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- selEvent.iarraySels.Add(i);
- }
- DispatchEvent(&selEvent);
-}
-CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- if (!m_pOwner->IsEnabled()) {
- return 1;
- }
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_MouseWheel: {
- OnMouseWheel((CFWL_MsgMouseWheel*)pMessage);
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_MsgKey *pMsg = (CFWL_MsgKey*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- if (dwCmd == FWL_MSGKEYCMD_KeyDown) {
- OnKeyDown(pMsg);
- }
- break;
- }
- default: {
- iRet = 0;
- }
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pEvent, FWL_ERR_Indefinite);
- FX_DWORD dwHashCode = pEvent->GetClassID();
- if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) {
- return FWL_ERR_Succeeded;
- }
- IFWL_Widget *pSrcTarget = pEvent->m_pSrcTarget;
- if ((pSrcTarget == (IFWL_Widget*)m_pOwner->m_pVertScrollBar && m_pOwner->m_pVertScrollBar) || (pSrcTarget == (IFWL_Widget*)m_pOwner->m_pHorzScrollBar && m_pOwner->m_pHorzScrollBar)) {
- FX_DWORD dwScrollCode = ((CFWL_EvtScroll*)pEvent)->m_iScrollCode;
- FX_FLOAT fPos = ((CFWL_EvtScroll*)pEvent)->m_fPos;
- OnScroll((IFWL_ScrollBar*)pSrcTarget, dwScrollCode, fPos);
- }
+ default: {}
+ }
+ break;
+ }
+ case FWL_MSGHASH_MouseWheel: {
+ OnMouseWheel((CFWL_MsgMouseWheel*)pMessage);
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ CFWL_MsgKey* pMsg = (CFWL_MsgKey*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ if (dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ OnKeyDown(pMsg);
+ }
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
+}
+FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ _FWL_RETURN_VALUE_IF_FAIL(pEvent, FWL_ERR_Indefinite);
+ FX_DWORD dwHashCode = pEvent->GetClassID();
+ if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) {
return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet)
-{
- if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
- if (m_pOwner->m_pVertScrollBar) {
- m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
- }
- if (m_pOwner->m_pHorzScrollBar) {
- m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
- }
- }
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
+ }
+ IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
+ if ((pSrcTarget == (IFWL_Widget*)m_pOwner->m_pVertScrollBar &&
+ m_pOwner->m_pVertScrollBar) ||
+ (pSrcTarget == (IFWL_Widget*)m_pOwner->m_pHorzScrollBar &&
+ m_pOwner->m_pHorzScrollBar)) {
+ FX_DWORD dwScrollCode = ((CFWL_EvtScroll*)pEvent)->m_iScrollCode;
+ FX_FLOAT fPos = ((CFWL_EvtScroll*)pEvent)->m_fPos;
+ OnScroll((IFWL_ScrollBar*)pSrcTarget, dwScrollCode, fPos);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
+ if (m_pOwner->m_pVertScrollBar) {
+ m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
+ }
+ if (m_pOwner->m_pHorzScrollBar) {
+ m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
+ }
+ }
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ m_pOwner->m_bLButtonDown = TRUE;
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ m_pOwner->SetFocus(TRUE);
+ }
+ FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (!hItem) {
+ return;
+ }
+ if (m_pOwner->m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_LTB_MultiSelection) {
+ if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) {
+ FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem);
+ m_pOwner->SetSelectionDirect(hItem, !bSelected);
+ m_pOwner->m_hAnchor = hItem;
+ } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) {
+ if (m_pOwner->m_hAnchor) {
+ m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE);
+ } else {
+ m_pOwner->SetSelectionDirect(hItem, TRUE);
+ }
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->m_bLButtonDown = TRUE;
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (!hItem) {
- return;
- }
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
- if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) {
- FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem);
- m_pOwner->SetSelectionDirect(hItem, !bSelected);
- m_pOwner->m_hAnchor = hItem;
- } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) {
- if (m_pOwner->m_hAnchor) {
- m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE);
- } else {
- m_pOwner->SetSelectionDirect(hItem, TRUE);
- }
- } else {
- m_pOwner->SetSelection(hItem, hItem, TRUE);
- m_pOwner->m_hAnchor = hItem;
- }
+ m_pOwner->SetSelection(hItem, hItem, TRUE);
+ m_pOwner->m_hAnchor = hItem;
+ }
+ } else {
+ m_pOwner->SetSelection(hItem, hItem, TRUE);
+ }
+ if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) {
+ FWL_HLISTITEM hSelectedItem =
+ m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ CFX_RectF rtCheck;
+ m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck);
+ FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem);
+ if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (bChecked) {
+ m_pOwner->SetItemChecked(hItem, FALSE);
+ } else {
+ m_pOwner->SetItemChecked(hItem, TRUE);
+ }
+ m_pOwner->Update();
+ }
+ }
+ m_pOwner->SetFocusItem(hItem);
+ m_pOwner->ScrollToVisible(hItem);
+ m_pOwner->SetGrab(TRUE);
+ m_pOwner->ProcessSelChanged();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_bLButtonDown) {
+ m_pOwner->m_bLButtonDown = FALSE;
+ m_pOwner->SetGrab(FALSE);
+ DispatchSelChangedEv();
+ }
+}
+void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) {
+ if (!m_pOwner->IsShowScrollBar(TRUE)) {
+ return;
+ }
+ IFWL_WidgetDelegate* pDelegate =
+ m_pOwner->m_pVertScrollBar->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMsg);
+}
+void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+ FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
+ switch (dwKeyCode) {
+ case FWL_VKEY_Tab:
+ case FWL_VKEY_Up:
+ case FWL_VKEY_Down:
+ case FWL_VKEY_Home:
+ case FWL_VKEY_End: {
+ FWL_HLISTITEM hItem = m_pOwner->GetFocusedItem();
+ hItem = m_pOwner->GetItem(hItem, dwKeyCode);
+ FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
+ FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl;
+ OnVK(hItem, bShift, bCtrl);
+ DispatchSelChangedEv();
+ m_pOwner->ProcessSelChanged();
+ break;
+ }
+ default: {}
+ }
+}
+void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem,
+ FX_BOOL bShift,
+ FX_BOOL bCtrl) {
+ if (!hItem) {
+ return;
+ }
+ if (m_pOwner->m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_LTB_MultiSelection) {
+ if (bCtrl) {
+ } else if (bShift) {
+ if (m_pOwner->m_hAnchor) {
+ m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE);
+ } else {
+ m_pOwner->SetSelectionDirect(hItem, TRUE);
+ }
} else {
- m_pOwner->SetSelection(hItem, hItem, TRUE);
- }
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) {
- FWL_HLISTITEM hSelectedItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
- CFX_RectF rtCheck;
- m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck);
- FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem);
- if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (bChecked) {
- m_pOwner->SetItemChecked(hItem, FALSE);
- } else {
- m_pOwner->SetItemChecked(hItem, TRUE);
- }
- m_pOwner->Update();
- }
- }
- m_pOwner->SetFocusItem(hItem);
- m_pOwner->ScrollToVisible(hItem);
- m_pOwner->SetGrab(TRUE);
- m_pOwner->ProcessSelChanged();
+ m_pOwner->SetSelection(hItem, hItem, TRUE);
+ m_pOwner->m_hAnchor = hItem;
+ }
+ } else {
+ m_pOwner->SetSelection(hItem, hItem, TRUE);
+ }
+ m_pOwner->SetFocusItem(hItem);
+ m_pOwner->ScrollToVisible(hItem);
+ {
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
+ m_pOwner->m_pProperties->m_rtWidget.height);
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+}
+FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
+ FX_DWORD dwCode,
+ FX_FLOAT fPos) {
+ CFX_SizeF fs;
+ pScrollBar->GetRange(fs.x, fs.y);
+ FX_FLOAT iCurPos = pScrollBar->GetPos();
+ FX_FLOAT fStep = pScrollBar->GetStepSize();
+ switch (dwCode) {
+ case FWL_SCBCODE_Min: {
+ fPos = fs.x;
+ break;
+ }
+ case FWL_SCBCODE_Max: {
+ fPos = fs.y;
+ break;
+ }
+ case FWL_SCBCODE_StepBackward: {
+ fPos -= fStep;
+ if (fPos < fs.x + fStep / 2) {
+ fPos = fs.x;
+ }
+ break;
+ }
+ case FWL_SCBCODE_StepForward: {
+ fPos += fStep;
+ if (fPos > fs.y - fStep / 2) {
+ fPos = fs.y;
+ }
+ break;
+ }
+ case FWL_SCBCODE_PageBackward: {
+ fPos -= pScrollBar->GetPageSize();
+ if (fPos < fs.x) {
+ fPos = fs.x;
+ }
+ break;
+ }
+ case FWL_SCBCODE_PageForward: {
+ fPos += pScrollBar->GetPageSize();
+ if (fPos > fs.y) {
+ fPos = fs.y;
+ }
+ break;
+ }
+ case FWL_SCBCODE_Pos:
+ case FWL_SCBCODE_TrackPos:
+ break;
+ case FWL_SCBCODE_EndScroll:
+ return FALSE;
+ }
+ if (iCurPos != fPos) {
+ pScrollBar->SetPos(fPos);
+ pScrollBar->SetTrackPos(fPos);
m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
+ return TRUE;
}
-void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_bLButtonDown) {
- m_pOwner->m_bLButtonDown = FALSE;
- m_pOwner->SetGrab(FALSE);
- DispatchSelChangedEv();
- }
-}
-void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel *pMsg)
-{
- if (!m_pOwner->IsShowScrollBar(TRUE)) {
- return;
- }
- IFWL_WidgetDelegate *pDelegate = m_pOwner->m_pVertScrollBar->SetDelegate(NULL);
- pDelegate->OnProcessMessage(pMsg);
-}
-void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey *pMsg)
-{
- FX_DWORD dwKeyCode = pMsg->m_dwKeyCode;
- switch(dwKeyCode) {
- case FWL_VKEY_Tab:
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Home:
- case FWL_VKEY_End: {
- FWL_HLISTITEM hItem = m_pOwner->GetFocusedItem();
- hItem = m_pOwner->GetItem(hItem, dwKeyCode);
- FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
- FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl;
- OnVK(hItem, bShift, bCtrl);
- DispatchSelChangedEv();
- m_pOwner->ProcessSelChanged();
- break;
- }
- default: {
- }
- }
-}
-void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl)
-{
- if (!hItem) {
- return;
- }
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
- if (bCtrl) {
- } else if (bShift) {
- if (m_pOwner->m_hAnchor) {
- m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE);
- } else {
- m_pOwner->SetSelectionDirect(hItem, TRUE);
- }
- } else {
- m_pOwner->SetSelection(hItem, hItem, TRUE);
- m_pOwner->m_hAnchor = hItem;
- }
- } else {
- m_pOwner->SetSelection(hItem, hItem, TRUE);
- }
- m_pOwner->SetFocusItem(hItem);
- m_pOwner->ScrollToVisible(hItem);
- {
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0,
- 0,
- m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
- m_pOwner->Repaint(&rtInvalidate);
- }
-}
-FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar *pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos)
-{
- CFX_SizeF fs;
- pScrollBar->GetRange(fs.x, fs.y);
- FX_FLOAT iCurPos = pScrollBar->GetPos();
- FX_FLOAT fStep = pScrollBar->GetStepSize();
- switch (dwCode) {
- case FWL_SCBCODE_Min: {
- fPos = fs.x;
- break;
- }
- case FWL_SCBCODE_Max: {
- fPos = fs.y;
- break;
- }
- case FWL_SCBCODE_StepBackward: {
- fPos -= fStep;
- if (fPos < fs.x + fStep / 2) {
- fPos = fs.x;
- }
- break;
- }
- case FWL_SCBCODE_StepForward: {
- fPos += fStep;
- if (fPos > fs.y - fStep / 2) {
- fPos = fs.y;
- }
- break;
- }
- case FWL_SCBCODE_PageBackward: {
- fPos -= pScrollBar->GetPageSize();
- if (fPos < fs.x) {
- fPos = fs.x;
- }
- break;
- }
- case FWL_SCBCODE_PageForward: {
- fPos += pScrollBar->GetPageSize();
- if (fPos > fs.y) {
- fPos = fs.y;
- }
- break;
- }
- case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos:
- break;
- case FWL_SCBCODE_EndScroll:
- return FALSE;
- }
- if (iCurPos != fPos) {
- pScrollBar->SetPos(fPos);
- pScrollBar->SetTrackPos(fPos);
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- return TRUE;
-}
-void CFWL_ListBoxImpDelegate::DispatchSelChangedEv()
-{
- CFWL_EvtLtbSelChanged ev;
- ev.m_pSrcTarget = m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&ev);
+void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
+ CFWL_EvtLtbSelChanged ev;
+ ev.m_pSrcTarget = m_pOwner->m_pInterface;
+ m_pOwner->DispatchEvent(&ev);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp b/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp index c99b5c6002..822160f6b0 100644 --- a/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp @@ -9,1105 +9,1130 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "include/fwl_monthcalendarimp.h"
-#define MONTHCAL_HSEP_HEIGHT 1
-#define MONTHCAL_VSEP_WIDTH 1
-#define MONTHCAL_HMARGIN 3
-#define MONTHCAL_VMARGIN 2
-#define MONTHCAL_ROWS 9
-#define MONTHCAL_COLUMNS 7
-#define MONTHCAL_HEADER_BTN_VMARGIN 7
-#define MONTHCAL_HEADER_BTN_HMARGIN 5
-IFWL_MonthCalendar* IFWL_MonthCalendar::Create()
-{
- return new IFWL_MonthCalendar;
-}
-IFWL_MonthCalendar::IFWL_MonthCalendar()
-{
+#define MONTHCAL_HSEP_HEIGHT 1
+#define MONTHCAL_VSEP_WIDTH 1
+#define MONTHCAL_HMARGIN 3
+#define MONTHCAL_VMARGIN 2
+#define MONTHCAL_ROWS 9
+#define MONTHCAL_COLUMNS 7
+#define MONTHCAL_HEADER_BTN_VMARGIN 7
+#define MONTHCAL_HEADER_BTN_HMARGIN 5
+IFWL_MonthCalendar* IFWL_MonthCalendar::Create() {
+ return new IFWL_MonthCalendar;
+}
+IFWL_MonthCalendar::IFWL_MonthCalendar() {
+ m_pData = NULL;
+}
+IFWL_MonthCalendar::~IFWL_MonthCalendar() {
+ if (m_pData) {
+ delete (CFWL_MonthCalendarImp*)m_pData;
m_pData = NULL;
-}
-IFWL_MonthCalendar::~IFWL_MonthCalendar()
-{
- if (m_pData) {
- delete (CFWL_MonthCalendarImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_MonthCalendar::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_MonthCalendarImp(pOuter);
- ((CFWL_MonthCalendarImp*)m_pData)->SetInterface(this);
- return ((CFWL_MonthCalendarImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_MonthCalendar::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_MonthCalendarImp(properties, pOuter);
- ((CFWL_MonthCalendarImp*)m_pData)->SetInterface(this);
- return ((CFWL_MonthCalendarImp*)m_pData)->Initialize();
-}
-int32_t IFWL_MonthCalendar::CountSelect()
-{
- return ((CFWL_MonthCalendarImp*)m_pData)->CountSelect();
-}
-FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t &iYear, int32_t &iMonth, int32_t &iDay, int32_t nIndex)
-{
- return ((CFWL_MonthCalendarImp*)m_pData)->GetSelect(iYear, iMonth, iDay, nIndex);
-}
-FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- return ((CFWL_MonthCalendarImp*)m_pData)->SetSelect(iYear, iMonth, iDay);
-}
-CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal)
- , m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal)
- , m_iCurMonth(1)
- , m_iCurYear(2011)
- , m_iYear(2011)
- , m_iMonth(1)
- , m_iDay(1)
- , m_iHovered(-1)
-{
- m_rtHead.Reset();
- m_rtWeek.Reset();
- m_rtLBtn.Reset();
- m_rtRBtn.Reset();
- m_rtDates.Reset();
- m_rtHSep.Reset();
- m_rtHeadText.Reset();
- m_rtToday.Reset();
- m_rtTodayFlag.Reset();
- m_rtClient.Reset();
- m_rtWeekNum.Reset();
- m_rtWeekNumSep.Reset();
- m_szHead.Reset();
- m_szCell.Reset();
- m_szToday.Reset();
- m_pDateTime = new CFX_DateTime;
- m_bInit = FALSE;
- m_iMaxSel = 1;
-}
-CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_WidgetImp(properties, pOuter)
- , m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal)
- , m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal)
- , m_iCurMonth(1)
- , m_iCurYear(2011)
- , m_iYear(2011)
- , m_iMonth(1)
- , m_iDay(1)
- , m_iHovered(-1)
-{
- m_rtHead.Reset();
- m_rtWeek.Reset();
- m_rtLBtn.Reset();
- m_rtRBtn.Reset();
- m_rtDates.Reset();
- m_rtHSep.Reset();
- m_rtHeadText.Reset();
- m_rtToday.Reset();
- m_rtTodayFlag.Reset();
- m_rtClient.Reset();
- m_rtWeekNum.Reset();
- m_rtWeekNumSep.Reset();
- m_szHead.Reset();
- m_szCell.Reset();
- m_szToday.Reset();
- m_pDateTime = new CFX_DateTime;
- m_bInit = FALSE;
- m_iMaxSel = 1;
-}
-CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp()
-{
- ClearDateItem();
- delete m_pDateTime;
- m_arrSelDays.RemoveAll();
-}
-FWL_ERR CFWL_MonthCalendarImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_MonthCalendar;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_MonthCalendarImp::GetClassID() const
-{
- return FWL_CLASSHASH_MonthCalendar;
-}
-FWL_ERR CFWL_MonthCalendarImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_MonthCalendarImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_MonthCalendarImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_MonthCalendarImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- CFX_SizeF fs = CalcSize(TRUE);
- rect.Set(0, 0, fs.x, fs.y);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_MonthCalendarImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- GetCapValue();
- if (!m_bInit) {
- m_bInit = InitDate();
- }
- ClearDateItem();
- ReSetDateItem();
- LayOut();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- if (m_pProperties->m_pThemeProvider == NULL) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_MCD_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_MCD_Edge, pTheme, pMatrix);
- }
- DrawBkground(pGraphics, pTheme, pMatrix);
- DrawHeadBK(pGraphics, pTheme, pMatrix);
- DrawLButton(pGraphics, pTheme, pMatrix);
- DrawRButton(pGraphics, pTheme, pMatrix);
- DrawSeperator(pGraphics, pTheme, pMatrix);
- DrawDatesInBK(pGraphics, pTheme, pMatrix);
- DrawDatesInCircle(pGraphics, pTheme, pMatrix);
- DrawCaption(pGraphics, pTheme, pMatrix);
- DrawWeek(pGraphics, pTheme, pMatrix);
- DrawDatesIn(pGraphics, pTheme, pMatrix);
- DrawDatesOut(pGraphics, pTheme, pMatrix);
- DrawToday(pGraphics, pTheme, pMatrix);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
- DrawWeekNumberSep(pGraphics, pTheme, pMatrix);
- DrawWeekNumber(pGraphics, pTheme, pMatrix);
- }
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_MonthCalendarImp::CountSelect()
-{
- return m_arrSelDays.GetSize();
-}
-FX_BOOL CFWL_MonthCalendarImp::GetSelect(int32_t &iYear, int32_t &iMonth, int32_t &iDay, int32_t nIndex )
-{
- if (nIndex >= m_arrSelDays.GetSize()) {
- return FALSE;
- }
- iYear = m_iCurYear;
- iMonth = m_iCurMonth;
- iDay = m_arrSelDays[nIndex];
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- ChangeToMonth(iYear, iMonth);
- return AddSelDay(iDay);
-}
-void CFWL_MonthCalendarImp::DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Background;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_rtPart = m_rtClient;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawHeadBK(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Header;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_rtPart = m_rtHead;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawLButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_LBtn;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = m_iLBtnPartStates;
- params.m_rtPart = m_rtLBtn;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawRButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_RBtn;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = m_iRBtnPartStates;
- params.m_rtPart = m_rtRBtn;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawCaption(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_MCD_Caption;
- textParam.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- textParam.m_pGraphics = pGraphics;
- int32_t iYear;
- int32_t iMonth;
- iYear = m_iCurYear;
- iMonth = m_iCurMonth;
- CFX_WideString wsCation;
- GetHeadText(iYear, iMonth, wsCation);
- textParam.m_wsText = wsCation;
- m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider);
- CalcHeadSize();
- textParam.m_rtPart = m_rtHeadText;
- textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- if (pMatrix) {
- textParam.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawText(&textParam);
-}
-void CFWL_MonthCalendarImp::DrawSeperator(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_HSeparator;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_rtPart = m_rtHSep;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
+ }
+}
+FWL_ERR IFWL_MonthCalendar::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_MonthCalendarImp(pOuter);
+ ((CFWL_MonthCalendarImp*)m_pData)->SetInterface(this);
+ return ((CFWL_MonthCalendarImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_MonthCalendar::Initialize(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_MonthCalendarImp(properties, pOuter);
+ ((CFWL_MonthCalendarImp*)m_pData)->SetInterface(this);
+ return ((CFWL_MonthCalendarImp*)m_pData)->Initialize();
+}
+int32_t IFWL_MonthCalendar::CountSelect() {
+ return ((CFWL_MonthCalendarImp*)m_pData)->CountSelect();
+}
+FX_BOOL IFWL_MonthCalendar::GetSelect(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay,
+ int32_t nIndex) {
+ return ((CFWL_MonthCalendarImp*)m_pData)
+ ->GetSelect(iYear, iMonth, iDay, nIndex);
+}
+FX_BOOL IFWL_MonthCalendar::SetSelect(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ return ((CFWL_MonthCalendarImp*)m_pData)->SetSelect(iYear, iMonth, iDay);
+}
+CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal),
+ m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal),
+ m_iCurMonth(1),
+ m_iCurYear(2011),
+ m_iYear(2011),
+ m_iMonth(1),
+ m_iDay(1),
+ m_iHovered(-1) {
+ m_rtHead.Reset();
+ m_rtWeek.Reset();
+ m_rtLBtn.Reset();
+ m_rtRBtn.Reset();
+ m_rtDates.Reset();
+ m_rtHSep.Reset();
+ m_rtHeadText.Reset();
+ m_rtToday.Reset();
+ m_rtTodayFlag.Reset();
+ m_rtClient.Reset();
+ m_rtWeekNum.Reset();
+ m_rtWeekNumSep.Reset();
+ m_szHead.Reset();
+ m_szCell.Reset();
+ m_szToday.Reset();
+ m_pDateTime = new CFX_DateTime;
+ m_bInit = FALSE;
+ m_iMaxSel = 1;
+}
+CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal),
+ m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal),
+ m_iCurMonth(1),
+ m_iCurYear(2011),
+ m_iYear(2011),
+ m_iMonth(1),
+ m_iDay(1),
+ m_iHovered(-1) {
+ m_rtHead.Reset();
+ m_rtWeek.Reset();
+ m_rtLBtn.Reset();
+ m_rtRBtn.Reset();
+ m_rtDates.Reset();
+ m_rtHSep.Reset();
+ m_rtHeadText.Reset();
+ m_rtToday.Reset();
+ m_rtTodayFlag.Reset();
+ m_rtClient.Reset();
+ m_rtWeekNum.Reset();
+ m_rtWeekNumSep.Reset();
+ m_szHead.Reset();
+ m_szCell.Reset();
+ m_szToday.Reset();
+ m_pDateTime = new CFX_DateTime;
+ m_bInit = FALSE;
+ m_iMaxSel = 1;
+}
+CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() {
+ ClearDateItem();
+ delete m_pDateTime;
+ m_arrSelDays.RemoveAll();
+}
+FWL_ERR CFWL_MonthCalendarImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_MonthCalendar;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_MonthCalendarImp::GetClassID() const {
+ return FWL_CLASSHASH_MonthCalendar;
+}
+FWL_ERR CFWL_MonthCalendarImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate =
+ (IFWL_WidgetDelegate*)FX_NEW CFWL_MonthCalendarImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_MonthCalendarImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_MonthCalendarImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ CFX_SizeF fs = CalcSize(TRUE);
+ rect.Set(0, 0, fs.x, fs.y);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_MonthCalendarImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ GetCapValue();
+ if (!m_bInit) {
+ m_bInit = InitDate();
+ }
+ ClearDateItem();
+ ReSetDateItem();
+ LayOut();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ if (m_pProperties->m_pThemeProvider == NULL) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_MCD_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_MCD_Edge, pTheme, pMatrix);
+ }
+ DrawBkground(pGraphics, pTheme, pMatrix);
+ DrawHeadBK(pGraphics, pTheme, pMatrix);
+ DrawLButton(pGraphics, pTheme, pMatrix);
+ DrawRButton(pGraphics, pTheme, pMatrix);
+ DrawSeperator(pGraphics, pTheme, pMatrix);
+ DrawDatesInBK(pGraphics, pTheme, pMatrix);
+ DrawDatesInCircle(pGraphics, pTheme, pMatrix);
+ DrawCaption(pGraphics, pTheme, pMatrix);
+ DrawWeek(pGraphics, pTheme, pMatrix);
+ DrawDatesIn(pGraphics, pTheme, pMatrix);
+ DrawDatesOut(pGraphics, pTheme, pMatrix);
+ DrawToday(pGraphics, pTheme, pMatrix);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
+ DrawWeekNumberSep(pGraphics, pTheme, pMatrix);
+ DrawWeekNumber(pGraphics, pTheme, pMatrix);
+ }
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_MonthCalendarImp::CountSelect() {
+ return m_arrSelDays.GetSize();
+}
+FX_BOOL CFWL_MonthCalendarImp::GetSelect(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay,
+ int32_t nIndex) {
+ if (nIndex >= m_arrSelDays.GetSize()) {
+ return FALSE;
+ }
+ iYear = m_iCurYear;
+ iMonth = m_iCurMonth;
+ iDay = m_arrSelDays[nIndex];
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::SetSelect(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ ChangeToMonth(iYear, iMonth);
+ return AddSelDay(iDay);
+}
+void CFWL_MonthCalendarImp::DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_Background;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_rtPart = m_rtClient;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawHeadBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_Header;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_rtPart = m_rtHead;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawLButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_LBtn;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = m_iLBtnPartStates;
+ params.m_rtPart = m_rtLBtn;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawRButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_RBtn;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = m_iRBtnPartStates;
+ params.m_rtPart = m_rtRBtn;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawCaption(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeText textParam;
+ textParam.m_pWidget = m_pInterface;
+ textParam.m_iPart = FWL_PART_MCD_Caption;
+ textParam.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ textParam.m_pGraphics = pGraphics;
+ int32_t iYear;
+ int32_t iMonth;
+ iYear = m_iCurYear;
+ iMonth = m_iCurMonth;
+ CFX_WideString wsCation;
+ GetHeadText(iYear, iMonth, wsCation);
+ textParam.m_wsText = wsCation;
+ m_szHead = CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider);
+ CalcHeadSize();
+ textParam.m_rtPart = m_rtHeadText;
+ textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ if (pMatrix) {
+ textParam.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawText(&textParam);
+}
+void CFWL_MonthCalendarImp::DrawSeperator(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_HSeparator;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_rtPart = m_rtHSep;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_DateInBK;
+ params.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ int32_t iCount = m_arrDates.GetSize();
+ for (int32_t j = 0; j < iCount; j++) {
+ LPDATEINFO pDataInfo = (LPDATEINFO)m_arrDates.GetAt(j);
+ if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) {
+ params.m_dwStates |= FWL_PARTSTATE_MCD_Selected;
+ if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) ==
+ 0) &&
+ pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
+ params.m_dwStates |= FWL_PARTSTATE_MCD_Flagged;
+ }
+ if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) {
+ params.m_dwStates |= FWL_PARTSTATE_MCD_Focused;
+ }
+ } else if (j == m_iHovered - 1) {
+ params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered;
+ } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
+ params.m_dwStates = FWL_PARTSTATE_MCD_Flagged;
+ pTheme->DrawBackground(¶ms);
}
+ params.m_rtPart = pDataInfo->rect;
pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DateInBK;
- params.m_pGraphics = pGraphics;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t j = 0; j < iCount; j ++) {
- LPDATEINFO pDataInfo = (LPDATEINFO)m_arrDates.GetAt(j);
- if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Selected;
- if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) == 0) && pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Flagged;
- }
- if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Focused;
- }
- } else if (j == m_iHovered - 1) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered;
- } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
- params.m_dwStates = FWL_PARTSTATE_MCD_Flagged;
- pTheme->DrawBackground(¶ms);
- }
- params.m_rtPart = pDataInfo->rect;
- pTheme->DrawBackground(¶ms);
- params.m_dwStates = 0;
- }
-}
-void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeText params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Week;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- int32_t iWeek;
- iWeek = m_pDateTime->GetDayOfWeek();
- CFX_RectF rtDayOfWeek;
- const FX_WCHAR* pWeekDay[] = {
- (FX_WCHAR *)L"Sun", (FX_WCHAR *)L"Mon", (FX_WCHAR *)L"Tue",
- (FX_WCHAR *)L"Wed", (FX_WCHAR *)L"Thu", (FX_WCHAR *)L"Fri", (FX_WCHAR *)L"Sat"
- };
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- for (int32_t i = 0; i < 7; i++) {
- rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2),
- m_rtWeek.top,
- m_szCell.x,
- m_szCell.y);
- CFX_WideString *wsWeekDay = NULL;
- wsWeekDay = (CFX_WideString *)pTheme->GetCapacity(¶ms, i + FWL_MCCAPACITY_Sun);
- params.m_rtPart = rtDayOfWeek;
- params.m_wsText = *wsWeekDay;
- params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- pTheme->DrawText(¶ms);
- }
-}
-void CFWL_MonthCalendarImp::DrawWeekNumber(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeText params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_WeekNum;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
- CFX_WideString wsWeekNum;
+ params.m_dwStates = 0;
+ }
+}
+void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeText params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_Week;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ int32_t iWeek;
+ iWeek = m_pDateTime->GetDayOfWeek();
+ CFX_RectF rtDayOfWeek;
+ const FX_WCHAR* pWeekDay[] = {(FX_WCHAR*)L"Sun", (FX_WCHAR*)L"Mon",
+ (FX_WCHAR*)L"Tue", (FX_WCHAR*)L"Wed",
+ (FX_WCHAR*)L"Thu", (FX_WCHAR*)L"Fri",
+ (FX_WCHAR*)L"Sat"};
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ for (int32_t i = 0; i < 7; i++) {
+ rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2),
+ m_rtWeek.top, m_szCell.x, m_szCell.y);
+ CFX_WideString* wsWeekDay = NULL;
+ wsWeekDay =
+ (CFX_WideString*)pTheme->GetCapacity(¶ms, i + FWL_MCCAPACITY_Sun);
+ params.m_rtPart = rtDayOfWeek;
+ params.m_wsText = *wsWeekDay;
params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- int32_t iWeekNum = 0;
- int32_t iMonthNum = m_pDateTime->GetMonth();
- int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum);
- int32_t iTemp = 0;
- FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei;
- FX_FLOAT fHStartPos = m_rtClient.left;
- for (int32_t i = 1; i <= iDayNum; i += 7) {
- iTemp ++;
- iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i);
- m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp, m_fWeekNumWid, m_fDateCellHei);
- wsWeekNum.Format(L"%d", iWeekNum);
- params.m_wsText = wsWeekNum;
- params.m_rtPart = m_rtWeekNum;
- pTheme->DrawText(¶ms);
- }
-}
-void CFWL_MonthCalendarImp::DrawWeekNumberSep(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_WeekNumSep;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_rtPart = m_rtWeekNumSep;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawToday(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
- return;
+ pTheme->DrawText(¶ms);
+ }
+}
+void CFWL_MonthCalendarImp::DrawWeekNumber(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeText params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_WeekNum;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ CFX_WideString wsWeekNum;
+ params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ int32_t iWeekNum = 0;
+ int32_t iMonthNum = m_pDateTime->GetMonth();
+ int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum);
+ int32_t iTemp = 0;
+ FX_FLOAT fVStartPos = m_rtClient.top + m_fHeadHei + m_fHSepHei;
+ FX_FLOAT fHStartPos = m_rtClient.left;
+ for (int32_t i = 1; i <= iDayNum; i += 7) {
+ iTemp++;
+ iWeekNum = CalWeekNumber(m_iCurYear, iMonthNum, i);
+ m_rtWeekNum.Set(fHStartPos, fVStartPos + m_fDateCellHei * iTemp,
+ m_fWeekNumWid, m_fDateCellHei);
+ wsWeekNum.Format(L"%d", iWeekNum);
+ params.m_wsText = wsWeekNum;
+ params.m_rtPart = m_rtWeekNum;
+ pTheme->DrawText(¶ms);
+ }
+}
+void CFWL_MonthCalendarImp::DrawWeekNumberSep(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_WeekNumSep;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_rtPart = m_rtWeekNumSep;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawToday(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
+ return;
+ }
+ CFWL_ThemeText params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_Today;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ CFX_WideString* wsDay = NULL;
+ wsDay = (CFX_WideString*)pTheme->GetCapacity(¶ms, FWL_MCCAPACITY_Today);
+ CFX_WideString wsText;
+ GetTodayText(m_iYear, m_iMonth, m_iDay, wsText);
+ params.m_wsText = *wsDay + wsText;
+ m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider);
+ CalcTodaySize();
+ params.m_rtPart = m_rtToday;
+ params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawText(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeText params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_DatesIn;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ int32_t iCount = m_arrDates.GetSize();
+ for (int32_t j = 0; j < iCount; j++) {
+ LPDATEINFO pDataInfo = (LPDATEINFO)m_arrDates.GetAt(j);
+ params.m_wsText = pDataInfo->wsDay;
+ params.m_rtPart = pDataInfo->rect;
+ params.m_dwStates = pDataInfo->dwStates;
+ if (j + 1 == m_iHovered) {
+ params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered;
}
- CFWL_ThemeText params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Today;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
- CFX_WideString *wsDay = NULL;
- wsDay = (CFX_WideString *)pTheme->GetCapacity(¶ms, FWL_MCCAPACITY_Today);
- CFX_WideString wsText;
- GetTodayText(m_iYear, m_iMonth, m_iDay, wsText);
- params.m_wsText = *wsDay + wsText;
- m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider);
- CalcTodaySize();
- params.m_rtPart = m_rtToday;
params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
pTheme->DrawText(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeText params;
+ }
+}
+void CFWL_MonthCalendarImp::DrawDatesOut(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeText params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_DatesOut;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawText(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawDatesInCircle(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
+ return;
+ }
+ if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) {
+ return;
+ }
+ if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) {
+ return;
+ }
+ LPDATEINFO pDate = (LPDATEINFO)m_arrDates[m_iDay - 1];
+ _FWL_RETURN_IF_FAIL(pDate);
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_DateInCircle;
+ params.m_pGraphics = pGraphics;
+ params.m_rtPart = pDate->rect;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_MonthCalendarImp::DrawTodayCircle(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
+ return;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
+ return;
+ }
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_MCD_TodayCircle;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_rtPart = m_rtTodayFlag;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶ms);
+}
+CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) {
+ CFX_SizeF fs;
+ fs.Set(0, 0);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, fs);
+ if (bAutoSize) {
+ CFWL_ThemePart params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DatesIn;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ CFX_WideString* wsText = NULL;
+ FX_FLOAT fMaxWeekW = 0.0f;
+ FX_FLOAT fMaxWeekH = 0.0f;
+ for (FX_DWORD week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat;
+ week++) {
+ wsText = (CFX_WideString*)pTheme->GetCapacity(¶ms, week);
+ CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider);
+ fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x;
+ fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y;
}
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t j = 0; j < iCount; j ++) {
- LPDATEINFO pDataInfo = (LPDATEINFO)m_arrDates.GetAt(j);
- params.m_wsText = pDataInfo->wsDay;
- params.m_rtPart = pDataInfo->rect;
- params.m_dwStates = pDataInfo->dwStates;
- if (j + 1 == m_iHovered) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered;
- }
- params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- pTheme->DrawText(¶ms);
+ FX_FLOAT fDayMaxW = 0.0f;
+ FX_FLOAT fDayMaxH = 0.0f;
+ for (int day = 10; day <= 31; day++) {
+ CFX_WideString wsDay;
+ wsDay.Format(L"%d", day);
+ CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider);
+ fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x;
+ fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y;
}
-}
-void CFWL_MonthCalendarImp::DrawDatesOut(CFX_Graphics *pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeText params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DatesOut;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawText(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawDatesInCircle(CFX_Graphics *pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix *pMatrix)
-{
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
- return;
+ m_szCell.x = FX_FLOAT((fMaxWeekW >= fDayMaxW) ? (int)(fMaxWeekW + 0.5)
+ : (int)(fDayMaxW + 0.5));
+ m_szCell.y = (fMaxWeekH >= fDayMaxH) ? fMaxWeekH : fDayMaxH;
+ fs.x = m_szCell.x * MONTHCAL_COLUMNS +
+ MONTHCAL_HMARGIN * MONTHCAL_COLUMNS * 2 +
+ MONTHCAL_HEADER_BTN_HMARGIN * 2;
+ FX_FLOAT fMonthMaxW = 0.0f;
+ FX_FLOAT fMonthMaxH = 0.0f;
+ for (FX_DWORD month = FWL_MCCAPACITY_January;
+ month <= FWL_MCCAPACITY_December; month++) {
+ wsText = (CFX_WideString*)pTheme->GetCapacity(¶ms, month);
+ CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider);
+ fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x;
+ fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y;
}
- if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) {
- return;
+ CFX_WideString wsYear;
+ GetHeadText(m_iYear, m_iMonth, wsYear);
+ CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider);
+ fMonthMaxH = (fMonthMaxH >= szYear.y) ? fMonthMaxH : szYear.y;
+ m_szHead.Set(fMonthMaxW + szYear.x, fMonthMaxH);
+ fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2;
+ fs.x = (fs.x >= fMonthMaxW) ? fs.x : fMonthMaxW;
+ CFX_WideString wsToday;
+ GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday);
+ wsText =
+ (CFX_WideString*)pTheme->GetCapacity(¶ms, FWL_MCCAPACITY_Today);
+ m_wsToday = *wsText + wsToday;
+ m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider);
+ m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y;
+ fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y +
+ MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 +
+ MONTHCAL_HEADER_BTN_VMARGIN * 4;
+ } else {
+ GetClientRect(m_rtClient);
+ fs.Set(m_rtClient.width, m_rtClient.height);
+ }
+ return fs;
+}
+void CFWL_MonthCalendarImp::CalcHeadSize() {
+ FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2;
+ FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2;
+ m_rtHeadText.Set(m_rtClient.left + fHeadHMargin,
+ m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN +
+ MONTHCAL_VMARGIN + fHeadVMargin,
+ m_szHead.x, m_szHead.y);
+}
+void CFWL_MonthCalendarImp::CalcTodaySize() {
+ m_rtTodayFlag.Set(
+ m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
+ m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
+ m_szCell.x, m_szToday.y);
+ m_rtToday.Set(
+ m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x +
+ MONTHCAL_HMARGIN * 2,
+ m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
+ m_szToday.x, m_szToday.y);
+}
+void CFWL_MonthCalendarImp::LayOut() {
+ GetClientRect(m_rtClient);
+ {
+ m_rtHead.Set(
+ m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top,
+ m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
+ m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2);
+ m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
+ m_rtHead.bottom(),
+ m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
+ m_szCell.y + MONTHCAL_VMARGIN * 2);
+ m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
+ m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x,
+ m_szCell.x);
+ m_rtRBtn.Set(m_rtClient.left + m_rtClient.width -
+ MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x,
+ m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x,
+ m_szCell.x);
+ m_rtHSep.Set(
+ m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
+ m_rtWeek.bottom() - MONTHCAL_VMARGIN,
+ m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2,
+ MONTHCAL_HSEP_HEIGHT);
+ m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
+ m_rtWeek.bottom(),
+ m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
+ m_szCell.y * (MONTHCAL_ROWS - 3) +
+ MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2);
+ }
+ CalDateItem();
+}
+void CFWL_MonthCalendarImp::CalDateItem() {
+ FX_BOOL bNewWeek = FALSE;
+ int32_t iWeekOfMonth = 0;
+ FX_FLOAT fLeft = m_rtDates.left;
+ FX_FLOAT fTop = m_rtDates.top;
+ int32_t iCount = m_arrDates.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(i);
+ if (bNewWeek) {
+ iWeekOfMonth++;
+ bNewWeek = FALSE;
}
- if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) {
- return;
+ pDateInfo->rect.Set(
+ fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)),
+ fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)),
+ m_szCell.x + (MONTHCAL_HMARGIN * 2),
+ m_szCell.y + (MONTHCAL_VMARGIN * 2));
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
+ pDateInfo->rect.Offset(m_fWeekNumWid, 0);
}
- LPDATEINFO pDate = (LPDATEINFO)m_arrDates[m_iDay - 1];
- _FWL_RETURN_IF_FAIL(pDate);
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DateInCircle;
- params.m_pGraphics = pGraphics;
- params.m_rtPart = pDate->rect;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
+ if (pDateInfo->iDayOfWeek >= 6) {
+ bNewWeek = TRUE;
}
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_MonthCalendarImp::DrawTodayCircle(CFX_Graphics *pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix *pMatrix)
-{
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) {
- return;
+ }
+}
+void CFWL_MonthCalendarImp::GetCapValue() {
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ m_fHeadWid =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_WIDTH);
+ m_fHeadHei =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_Height);
+ m_fHeadBtnWid = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH);
+ m_fHeadBtnHei = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT);
+ m_fHeadBtnHMargin = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN);
+ m_fHeadBtnVMargin = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN);
+ m_fHeadTextWid = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT);
+ m_fHeadTextHei = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT);
+ m_fHeadTextHMargin = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN);
+ m_fHeadTextVMargin = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN);
+ m_fHSepWid =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_WIDTH);
+ m_fHSepHei =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_HEIGHT);
+ m_fWeekNumWid =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH);
+ m_fSepDOffset =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_DOFFSET);
+ m_fSepX = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_X);
+ m_fSepY = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_Y);
+ m_fWeekNumHeigh =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT);
+ m_fWeekWid =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_WIDTH);
+ m_fWeekHei =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_HEIGHT);
+ m_fDateCellWid = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH);
+ m_fDateCellHei = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT);
+ m_fTodayWid =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_WIDHT);
+ m_fTodayHei =
+ *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_HEIGHT);
+ m_fTodayFlagWid = *(FX_FLOAT*)pTheme->GetCapacity(
+ &part, FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT);
+ m_fMCWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WIDTH);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
+ m_fMCWid += m_fWeekNumWid;
+ }
+ m_fMCHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEIGHT);
+}
+int32_t CFWL_MonthCalendarImp::CalWeekNumber(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ return 0;
+}
+FX_BOOL CFWL_MonthCalendarImp::GetMinDate(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ iYear = m_dtMin.iYear;
+ iMonth = m_dtMin.iMonth;
+ iDay = m_dtMin.iDay;
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::SetMinDate(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ m_dtMin = DATE(iYear, iMonth, iDay);
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::GetMaxDate(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ iYear = m_dtMax.iYear;
+ iMonth = m_dtMax.iMonth;
+ iDay = m_dtMax.iDay;
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::SetMaxDate(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ m_dtMax = DATE(iYear, iMonth, iDay);
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::InitDate() {
+ if (m_pProperties->m_pDataProvider) {
+ IFWL_MonthCalendarDP* pDateProv =
+ (IFWL_MonthCalendarDP*)(m_pProperties->m_pDataProvider);
+ m_iYear = pDateProv->GetCurYear(m_pInterface);
+ m_iMonth = pDateProv->GetCurMonth(m_pInterface);
+ m_iDay = pDateProv->GetCurDay(m_pInterface);
+ m_iCurYear = m_iYear;
+ m_iCurMonth = m_iMonth;
+ } else {
+ m_iDay = 1;
+ m_iMonth = 1;
+ m_iYear = 1;
+ m_iCurYear = m_iYear;
+ m_iCurMonth = m_iMonth;
+ }
+ GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
+ GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
+ {
+ m_dtMin = DATE(1500, 12, 1);
+ m_dtMax = DATE(2200, 1, 1);
+ }
+ return TRUE;
+}
+void CFWL_MonthCalendarImp::ClearDateItem() {
+ int32_t iCount = m_arrDates.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ LPDATEINFO pData = (LPDATEINFO)m_arrDates.GetAt(i);
+ delete pData;
+ }
+ m_arrDates.RemoveAll();
+}
+void CFWL_MonthCalendarImp::ReSetDateItem() {
+ m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1);
+ int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth);
+ int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek();
+ for (int32_t i = 0; i < iDays; i++) {
+ if (iDayOfWeek >= 7) {
+ iDayOfWeek = 0;
}
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) {
- return;
+ CFX_WideString wsDay;
+ wsDay.Format(L"%d", i + 1);
+ FX_DWORD dwStates = 0;
+ if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) {
+ dwStates |= FWL_ITEMSTATE_MCD_Flag;
}
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_TodayCircle;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
- params.m_rtPart = m_rtTodayFlag;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
+ if (m_arrSelDays.Find(i + 1) != -1) {
+ dwStates |= FWL_ITEMSTATE_MCD_Selected;
}
- pTheme->DrawBackground(¶ms);
-}
-CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize)
-{
- CFX_SizeF fs;
- fs.Set(0, 0);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, fs);
- if (bAutoSize) {
- CFWL_ThemePart params;
- params.m_pWidget = m_pInterface;
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- CFX_WideString *wsText = NULL;
- FX_FLOAT fMaxWeekW = 0.0f;
- FX_FLOAT fMaxWeekH = 0.0f;
- for (FX_DWORD week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat; week++) {
- wsText = (CFX_WideString *)pTheme->GetCapacity(¶ms, week);
- CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider);
- fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x;
- fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y;
- }
- FX_FLOAT fDayMaxW = 0.0f;
- FX_FLOAT fDayMaxH = 0.0f;
- for (int day = 10; day <= 31; day++) {
- CFX_WideString wsDay;
- wsDay.Format(L"%d", day);
- CFX_SizeF sz = CalcTextSize(wsDay, m_pProperties->m_pThemeProvider);
- fDayMaxW = (fDayMaxW >= sz.x) ? fDayMaxW : sz.x;
- fDayMaxH = (fDayMaxH >= sz.y) ? fDayMaxH : sz.y;
- }
- m_szCell.x = FX_FLOAT((fMaxWeekW >= fDayMaxW) ? (int)(fMaxWeekW + 0.5) : (int)(fDayMaxW + 0.5));
- m_szCell.y = (fMaxWeekH >= fDayMaxH) ? fMaxWeekH : fDayMaxH;
- fs.x = m_szCell.x * MONTHCAL_COLUMNS + MONTHCAL_HMARGIN * MONTHCAL_COLUMNS * 2 + MONTHCAL_HEADER_BTN_HMARGIN * 2;
- FX_FLOAT fMonthMaxW = 0.0f;
- FX_FLOAT fMonthMaxH = 0.0f;
- for (FX_DWORD month = FWL_MCCAPACITY_January; month <= FWL_MCCAPACITY_December; month++) {
- wsText = (CFX_WideString *)pTheme->GetCapacity(¶ms, month);
- CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider);
- fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x;
- fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y;
- }
- CFX_WideString wsYear;
- GetHeadText(m_iYear, m_iMonth, wsYear);
- CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider);
- fMonthMaxH = (fMonthMaxH >= szYear.y) ? fMonthMaxH : szYear.y;
- m_szHead.Set(fMonthMaxW + szYear.x, fMonthMaxH);
- fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2;
- fs.x = (fs.x >= fMonthMaxW) ? fs.x : fMonthMaxW;
- CFX_WideString wsToday;
- GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday);
- wsText = (CFX_WideString *)pTheme->GetCapacity(¶ms, FWL_MCCAPACITY_Today);
- m_wsToday = *wsText + wsToday;
- m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider);
- m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y;
- fs.y = m_szCell.x + m_szCell.y * (MONTHCAL_ROWS - 2) + m_szToday.y + MONTHCAL_VMARGIN * MONTHCAL_ROWS * 2 + MONTHCAL_HEADER_BTN_VMARGIN * 4;
- } else {
- GetClientRect(m_rtClient);
- fs.Set(m_rtClient.width, m_rtClient.height);
+ CFX_RectF rtDate;
+ rtDate.Set(0, 0, 0, 0);
+ LPDATEINFO pData = new DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay);
+ m_arrDates.Add(pData);
+ iDayOfWeek++;
+ }
+}
+FX_BOOL CFWL_MonthCalendarImp::NextMonth() {
+ int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
+ if (iMonth >= 12) {
+ iMonth = 1;
+ iYear++;
+ } else {
+ iMonth++;
+ }
+ DATE dt(m_iCurYear, m_iCurMonth, 1);
+ if (!(dt < m_dtMax)) {
+ return FALSE;
+ }
+ m_iCurYear = iYear, m_iCurMonth = iMonth;
+ ChangeToMonth(m_iCurYear, m_iCurMonth);
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::PrevMonth() {
+ int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
+ if (iMonth <= 1) {
+ iMonth = 12;
+ iYear--;
+ } else {
+ iMonth--;
+ }
+ DATE dt(m_iCurYear, m_iCurMonth, 1);
+ if (!(dt > m_dtMin)) {
+ return FALSE;
+ }
+ m_iCurYear = iYear, m_iCurMonth = iMonth;
+ ChangeToMonth(m_iCurYear, m_iCurMonth);
+ return TRUE;
+}
+void CFWL_MonthCalendarImp::ChangeToMonth(int32_t iYear, int32_t iMonth) {
+ m_iCurYear = iYear;
+ m_iCurMonth = iMonth;
+ m_iHovered = -1;
+ ClearDateItem();
+ ReSetDateItem();
+ CalDateItem();
+ GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
+}
+FX_BOOL CFWL_MonthCalendarImp::RemoveSelDay(int32_t iDay, FX_BOOL bAll) {
+ if (iDay == -1 && !bAll) {
+ return FALSE;
+ }
+ if (bAll) {
+ int32_t iCount = m_arrSelDays.GetSize();
+ int32_t iDatesCount = m_arrDates.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ int32_t iSelDay = m_arrSelDays.GetAt(i);
+ if (iSelDay <= iDatesCount) {
+ LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(iSelDay - 1);
+ pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
+ }
}
- return fs;
-}
-void CFWL_MonthCalendarImp::CalcHeadSize()
-{
- FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2;
- FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2;
- m_rtHeadText.Set(m_rtClient.left + fHeadHMargin,
- m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN + fHeadVMargin,
- m_szHead.x,
- m_szHead.y);
-}
-void CFWL_MonthCalendarImp::CalcTodaySize()
-{
- m_rtTodayFlag.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
- m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
- m_szCell.x,
- m_szToday.y);
- m_rtToday.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + MONTHCAL_HMARGIN * 2 ,
- m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN,
- m_szToday.x,
- m_szToday.y);
-}
-void CFWL_MonthCalendarImp::LayOut()
-{
- GetClientRect(m_rtClient);
- {
- m_rtHead.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
- m_rtClient.top,
- m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
- m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2);
- m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
- m_rtHead.bottom(),
- m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
- m_szCell.y + MONTHCAL_VMARGIN * 2);
- m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
- m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN,
- m_szCell.x,
- m_szCell.x);
- m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x,
- m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN,
- m_szCell.x,
- m_szCell.x);
- m_rtHSep.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN,
- m_rtWeek.bottom() - MONTHCAL_VMARGIN,
- m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2,
- MONTHCAL_HSEP_HEIGHT);
- m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN,
- m_rtWeek.bottom(),
- m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2,
- m_szCell.y * (MONTHCAL_ROWS - 3) + MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2);
+ m_arrSelDays.RemoveAll();
+ } else {
+ int32_t index = m_arrSelDays.Find(iDay);
+ if (index == -1) {
+ return FALSE;
}
- CalDateItem();
-}
-void CFWL_MonthCalendarImp::CalDateItem()
-{
- FX_BOOL bNewWeek = FALSE;
- int32_t iWeekOfMonth = 0;
- FX_FLOAT fLeft = m_rtDates.left;
- FX_FLOAT fTop = m_rtDates.top;
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(i);
- if (bNewWeek) {
- iWeekOfMonth ++;
- bNewWeek = FALSE;
- }
- pDateInfo->rect.Set(fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)),
- fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)),
- m_szCell.x + (MONTHCAL_HMARGIN * 2),
- m_szCell.y + (MONTHCAL_VMARGIN * 2));
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
- pDateInfo->rect.Offset(m_fWeekNumWid, 0);
- }
- if (pDateInfo->iDayOfWeek >= 6) {
- bNewWeek = TRUE;
- }
+ int32_t iSelDay = m_arrSelDays.GetAt(iDay);
+ int32_t iDatesCount = m_arrDates.GetSize();
+ if (iSelDay <= iDatesCount) {
+ LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(iSelDay - 1);
+ pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
}
-}
-void CFWL_MonthCalendarImp::GetCapValue()
-{
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ m_arrSelDays.RemoveAt(index);
+ }
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::AddSelDay(int32_t iDay) {
+ FXSYS_assert(iDay > 0);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
+ } else {
+ if (m_arrSelDays.Find(iDay) == -1) {
+ RemoveSelDay(-1, TRUE);
+ if (iDay <= m_arrDates.GetSize()) {
+ LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(iDay - 1);
+ pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
+ }
+ m_arrSelDays.Add(iDay);
}
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- m_fHeadWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_WIDTH);
- m_fHeadHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_Height);
- m_fHeadBtnWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH);
- m_fHeadBtnHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT);
- m_fHeadBtnHMargin = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN);
- m_fHeadBtnVMargin = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN);
- m_fHeadTextWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT);
- m_fHeadTextHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT);
- m_fHeadTextHMargin = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN);
- m_fHeadTextVMargin = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN);
- m_fHSepWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_WIDTH);
- m_fHSepHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_HEIGHT);
- m_fWeekNumWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH);
- m_fSepDOffset = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_DOFFSET);
- m_fSepX = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_X);
- m_fSepY = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_Y);
- m_fWeekNumHeigh = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT);
- m_fWeekWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_WIDTH);
- m_fWeekHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_HEIGHT);
- m_fDateCellWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH);
- m_fDateCellHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT);
- m_fTodayWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_WIDHT);
- m_fTodayHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_HEIGHT);
- m_fTodayFlagWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT);
- m_fMCWid = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WIDTH);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
- m_fMCWid += m_fWeekNumWid;
+ }
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarImp::JumpToToday() {
+ if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) {
+ m_iCurYear = m_iYear;
+ m_iCurMonth = m_iMonth;
+ ChangeToMonth(m_iYear, m_iMonth);
+ AddSelDay(m_iDay);
+ } else {
+ if (m_arrSelDays.Find(m_iDay) == -1) {
+ AddSelDay(m_iDay);
}
- m_fMCHei = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEIGHT);
-}
-int32_t CFWL_MonthCalendarImp::CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- return 0;
-}
-FX_BOOL CFWL_MonthCalendarImp::GetMinDate(int32_t &iYear, int32_t &iMonth, int32_t &iDay)
-{
- iYear = m_dtMin.iYear;
- iMonth = m_dtMin.iMonth;
- iDay = m_dtMin.iDay;
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- m_dtMin = DATE(iYear, iMonth, iDay);
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::GetMaxDate(int32_t &iYear, int32_t &iMonth, int32_t &iDay)
-{
- iYear = m_dtMax.iYear;
- iMonth = m_dtMax.iMonth;
- iDay = m_dtMax.iDay;
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- m_dtMax = DATE(iYear, iMonth, iDay);
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::InitDate()
-{
- if (m_pProperties->m_pDataProvider) {
- IFWL_MonthCalendarDP *pDateProv = (IFWL_MonthCalendarDP*)(m_pProperties->m_pDataProvider);
- m_iYear = pDateProv->GetCurYear(m_pInterface);
- m_iMonth = pDateProv->GetCurMonth(m_pInterface);
- m_iDay = pDateProv->GetCurDay(m_pInterface);
- m_iCurYear = m_iYear;
- m_iCurMonth = m_iMonth;
- } else {
- m_iDay = 1;
- m_iMonth = 1;
- m_iYear = 1;
- m_iCurYear = m_iYear;
- m_iCurMonth = m_iMonth;
+ }
+ return TRUE;
+}
+void CFWL_MonthCalendarImp::GetHeadText(int32_t iYear,
+ int32_t iMonth,
+ CFX_WideString& wsHead) {
+ FXSYS_assert(iMonth > 0 && iMonth < 13);
+ static const FX_WCHAR* const pMonth[] = {
+ L"January", L"February", L"March", L"April",
+ L"May", L"June", L"July", L"August",
+ L"September", L"October", L"November", L"December"};
+ wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear);
+}
+void CFWL_MonthCalendarImp::GetTodayText(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay,
+ CFX_WideString& wsToday) {
+ wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear);
+}
+int32_t CFWL_MonthCalendarImp::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) {
+ int32_t iCount = m_arrDates.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(i);
+ if (pDateInfo->rect.Contains(x, y)) {
+ return ++i;
}
- GetTodayText(m_iYear, m_iMonth, m_iDay, m_wsToday);
- GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
- {
- m_dtMin = DATE(1500, 12, 1);
- m_dtMax = DATE(2200, 1, 1);
+ }
+ return -1;
+}
+FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
+ if (iDay <= 0 || iDay > m_arrDates.GetSize()) {
+ return FALSE;
+ }
+ LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates[iDay - 1];
+ _FWL_RETURN_VALUE_IF_FAIL(pDateInfo, FALSE);
+ rtDay = pDateInfo->rect;
+ return TRUE;
+}
+CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate(
+ CFWL_MonthCalendarImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage(
+ CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
}
- return TRUE;
-}
-void CFWL_MonthCalendarImp::ClearDateItem()
-{
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- LPDATEINFO pData = (LPDATEINFO)m_arrDates.GetAt(i);
- delete pData;
+ case FWL_MSGHASH_Key: {
+ break;
}
- m_arrDates.RemoveAll();
-}
-void CFWL_MonthCalendarImp::ReSetDateItem()
-{
- m_pDateTime->Set(m_iCurYear, m_iCurMonth, 1);
- int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth);
- int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek();
- for (int32_t i = 0; i < iDays; i ++) {
- if (iDayOfWeek >= 7) {
- iDayOfWeek = 0;
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMouse = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMouse->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMouse);
+ break;
}
- CFX_WideString wsDay;
- wsDay.Format(L"%d", i + 1);
- FX_DWORD dwStates = 0;
- if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) {
- dwStates |= FWL_ITEMSTATE_MCD_Flag;
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMouse);
+ break;
}
- if (m_arrSelDays.Find(i + 1) != -1) {
- dwStates |= FWL_ITEMSTATE_MCD_Selected;
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove((CFWL_MsgMouse*)pMouse);
+ break;
}
- CFX_RectF rtDate;
- rtDate.Set(0, 0, 0, 0);
- LPDATEINFO pData = new DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay);
- m_arrDates.Add(pData);
- iDayOfWeek++;
- }
-}
-FX_BOOL CFWL_MonthCalendarImp::NextMonth()
-{
- int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
- if (iMonth >= 12) {
- iMonth = 1;
- iYear++;
- } else {
- iMonth ++;
- }
- DATE dt(m_iCurYear, m_iCurMonth, 1);
- if (!(dt < m_dtMax)) {
- return FALSE;
- }
- m_iCurYear = iYear, m_iCurMonth = iMonth;
- ChangeToMonth(m_iCurYear, m_iCurMonth);
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::PrevMonth()
-{
- int32_t iYear = m_iCurYear, iMonth = m_iCurMonth;
- if (iMonth <= 1) {
- iMonth = 12;
- iYear --;
- } else {
- iMonth --;
- }
- DATE dt(m_iCurYear, m_iCurMonth, 1);
- if (!(dt > m_dtMin)) {
- return FALSE;
- }
- m_iCurYear = iYear, m_iCurMonth = iMonth;
- ChangeToMonth(m_iCurYear, m_iCurMonth);
- return TRUE;
-}
-void CFWL_MonthCalendarImp::ChangeToMonth(int32_t iYear, int32_t iMonth)
-{
- m_iCurYear = iYear;
- m_iCurMonth = iMonth;
- m_iHovered = -1;
- ClearDateItem();
- ReSetDateItem();
- CalDateItem();
- GetHeadText(m_iCurYear, m_iCurMonth, m_wsHead);
-}
-FX_BOOL CFWL_MonthCalendarImp::RemoveSelDay(int32_t iDay, FX_BOOL bAll)
-{
- if (iDay == -1 && !bAll) {
- return FALSE;
- }
- if (bAll) {
- int32_t iCount = m_arrSelDays.GetSize();
- int32_t iDatesCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- int32_t iSelDay = m_arrSelDays.GetAt(i);
- if (iSelDay <= iDatesCount) {
- LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(iSelDay - 1);
- pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
- }
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave((CFWL_MsgMouse*)pMouse);
+ break;
}
- m_arrSelDays.RemoveAll();
- } else {
- int32_t index = m_arrSelDays.Find(iDay);
- if (index == -1) {
- return FALSE;
- }
- int32_t iSelDay = m_arrSelDays.GetAt(iDay);
- int32_t iDatesCount = m_arrDates.GetSize();
- if (iSelDay <= iDatesCount) {
- LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(iSelDay - 1);
- pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected;
- }
- m_arrSelDays.RemoveAt(index);
+ default: { break; }
+ }
+ break;
}
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::AddSelDay(int32_t iDay)
-{
- FXSYS_assert(iDay > 0);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
- } else {
- if (m_arrSelDays.Find(iDay) == -1) {
- RemoveSelDay(-1, TRUE);
- if (iDay <= m_arrDates.GetSize()) {
- LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(iDay - 1);
- pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected;
- }
- m_arrSelDays.Add(iDay);
- }
+ default: {
+ iRet = 0;
+ break;
}
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarImp::JumpToToday()
-{
- if (m_iYear != m_iCurYear || m_iMonth != m_iCurMonth) {
- m_iCurYear = m_iYear;
- m_iCurMonth = m_iMonth;
- ChangeToMonth(m_iYear, m_iMonth);
- AddSelDay(m_iDay);
- } else {
- if (m_arrSelDays.Find(m_iDay) == -1) {
- AddSelDay(m_iDay);
- }
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
+}
+FWL_ERR CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message* pMsg) {
+ return;
+}
+void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iLBtnPartStates = FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->PrevMonth();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iRBtnPartStates |= FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->NextMonth();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) ==
+ 0) {
+ m_pOwner->JumpToToday();
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
- return TRUE;
-}
-void CFWL_MonthCalendarImp::GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString &wsHead)
-{
- FXSYS_assert(iMonth > 0 && iMonth < 13);
- static const FX_WCHAR* const pMonth[] = {
- L"January",
- L"February",
- L"March",
- L"April",
- L"May",
- L"June",
- L"July",
- L"August",
- L"September",
- L"October",
- L"November",
- L"December"
- };
- wsHead.Format(L"%s, %d", pMonth[iMonth - 1], iYear);
-}
-void CFWL_MonthCalendarImp::GetTodayText(int32_t iYear, int32_t iMonth, int32_t iDay, CFX_WideString &wsToday)
-{
- wsToday.Format(L", %d/%d/%d", iDay, iMonth, iYear);
-}
-int32_t CFWL_MonthCalendarImp::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y)
-{
- int32_t iCount = m_arrDates.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates.GetAt(i);
- if (pDateInfo->rect.Contains(x, y)) {
- return ++i;
+ } else {
+ if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
+ } else {
+ int32_t iOldSel = 0;
+ if (m_pOwner->m_arrSelDays.GetSize() > 0) {
+ iOldSel = m_pOwner->m_arrSelDays[0];
+ } else {
+ return;
+ }
+ int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel;
+ if (bSelChanged) {
+ LPDATEINFO lpDatesInfo =
+ (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ CFX_RectF rtInvalidate(lpDatesInfo->rect);
+ if (iOldSel > 0) {
+ lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ rtInvalidate.Union(lpDatesInfo->rect);
}
+ m_pOwner->AddSelDay(iCurSel);
+ CFWL_EvtClick wmClick;
+ wmClick.m_pSrcTarget = m_pOwner->m_pInterface;
+ m_pOwner->DispatchEvent(&wmClick);
+ CFWL_EventMcdDateChanged wmDateSelected;
+ wmDateSelected.m_iStartDay = iCurSel;
+ wmDateSelected.m_iEndDay = iCurSel;
+ wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth;
+ wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear;
+ wmDateSelected.m_pSrcTarget =
+ (IFWL_MonthCalendar*)m_pOwner->m_pInterface;
+ m_pOwner->DispatchEvent(&wmDateSelected);
+ m_pOwner->Repaint(&rtInvalidate);
+ }
}
- return -1;
-}
-FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF &rtDay)
-{
- if (iDay <= 0 || iDay > m_arrDates.GetSize()) {
- return FALSE;
- }
- LPDATEINFO pDateInfo = (LPDATEINFO)m_arrDates[iDay - 1];
- _FWL_RETURN_VALUE_IF_FAIL(pDateInfo, FALSE);
- rtDay = pDateInfo->rect;
- return TRUE;
-}
-CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate(CFWL_MonthCalendarImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Key: {
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse* pMouse = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMouse->m_dwCmd;
- switch(dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMouse);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMouse);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove((CFWL_MsgMouse*)pMouse);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave((CFWL_MsgMouse*)pMouse);
- break;
- }
- default: {
- break;
- }
- }
- break;
- }
- default: {
- iRet = 0;
- break;
- }
+ }
+}
+void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iLBtnPartStates = 0;
+ m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
+ } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_iRBtnPartStates = 0;
+ m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
+ } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (iDay != -1) {
+ m_pOwner->AddSelDay(iDay);
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
+ }
}
-FWL_ERR CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message *pMsg)
-{
+void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
return;
-}
-void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet)
-{
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = FWL_PARTSTATE_MCD_Pressed;
- m_pOwner->PrevMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates |= FWL_PARTSTATE_MCD_Pressed;
- m_pOwner->NextMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday ) == 0) {
- m_pOwner->JumpToToday();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
- } else {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
+ }
+ FX_BOOL bRepaint = FALSE;
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, 0, 0);
+ if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ bRepaint = m_pOwner->m_iHovered != iHover;
+ if (bRepaint) {
+ if (m_pOwner->m_iHovered > 0) {
+ m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
+ }
+ if (iHover > 0) {
+ CFX_RectF rtDay;
+ m_pOwner->GetDayRect(iHover, rtDay);
+ if (rtInvalidate.IsEmpty()) {
+ rtInvalidate = rtDay;
} else {
- int32_t iOldSel = 0;
- if (m_pOwner->m_arrSelDays.GetSize() > 0) {
- iOldSel = m_pOwner->m_arrSelDays[0];
- } else {
- return;
- }
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel;
- if (bSelChanged) {
- LPDATEINFO lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
- CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0) {
- lpDatesInfo = (LPDATEINFO)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
- rtInvalidate.Union(lpDatesInfo->rect);
- }
- m_pOwner->AddSelDay(iCurSel);
- CFWL_EvtClick wmClick;
- wmClick.m_pSrcTarget = m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&wmClick);
- CFWL_EventMcdDateChanged wmDateSelected;
- wmDateSelected.m_iStartDay = iCurSel;
- wmDateSelected.m_iEndDay = iCurSel;
- wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth;
- wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear;
- wmDateSelected.m_pSrcTarget = (IFWL_MonthCalendar *)m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&wmDateSelected);
- m_pOwner->Repaint(&rtInvalidate);
- }
+ rtInvalidate.Union(rtDay);
}
+ }
}
-}
-void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
- } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
- int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (iDay != -1) {
- m_pOwner->AddSelDay(iDay);
- }
- }
-}
-void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
- return;
+ m_pOwner->m_iHovered = iHover;
+ } else {
+ bRepaint = m_pOwner->m_iHovered > 0;
+ if (bRepaint) {
+ m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
}
- FX_BOOL bRepaint = FALSE;
+ m_pOwner->m_iHovered = -1;
+ }
+ if (bRepaint && !rtInvalidate.IsEmpty()) {
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+}
+void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_iHovered > 0) {
CFX_RectF rtInvalidate;
rtInvalidate.Set(0, 0, 0, 0);
- if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
- int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- bRepaint = m_pOwner->m_iHovered != iHover;
- if (bRepaint) {
- if (m_pOwner->m_iHovered > 0) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
- if (iHover > 0) {
- CFX_RectF rtDay;
- m_pOwner->GetDayRect(iHover, rtDay);
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = rtDay;
- } else {
- rtInvalidate.Union(rtDay);
- }
- }
- }
- m_pOwner->m_iHovered = iHover;
- } else {
- bRepaint = m_pOwner->m_iHovered > 0;
- if (bRepaint) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
- m_pOwner->m_iHovered = -1;
- }
- if (bRepaint && !rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
-}
-void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_iHovered > 0) {
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, 0, 0);
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- m_pOwner->m_iHovered = -1;
- if (!rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
+ m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
+ m_pOwner->m_iHovered = -1;
+ if (!rtInvalidate.IsEmpty()) {
+ m_pOwner->Repaint(&rtInvalidate);
}
+ }
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp index 03f821518d..4818945f8a 100644 --- a/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp @@ -9,164 +9,158 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "include/fwl_pictureboximp.h"
-IFWL_PictureBox* IFWL_PictureBox::Create()
-{
- return new IFWL_PictureBox;
+IFWL_PictureBox* IFWL_PictureBox::Create() {
+ return new IFWL_PictureBox;
}
-IFWL_PictureBox::IFWL_PictureBox()
-{
- m_pData = NULL;
-}
-IFWL_PictureBox::~IFWL_PictureBox()
-{
- if (m_pData) {
- delete (CFWL_PictureBoxImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_PictureBox::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_PictureBoxImp(pOuter);
- ((CFWL_PictureBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_PictureBoxImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_PictureBox::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_PictureBoxImp(properties, pOuter);
- ((CFWL_PictureBoxImp*)m_pData)->SetInterface(this);
- return ((CFWL_PictureBoxImp*)m_pData)->Initialize();
-}
-CFWL_PictureBoxImp::CFWL_PictureBoxImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_bTop(FALSE)
- , m_bVCenter(FALSE)
- , m_bButton(FALSE)
-{
- m_rtClient.Reset();
- m_rtImage.Reset();
- m_matrix.Reset();
-}
-CFWL_PictureBoxImp::CFWL_PictureBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_bTop(FALSE)
- , m_bVCenter(FALSE)
- , m_bButton(FALSE)
-{
- m_rtClient.Reset();
- m_rtImage.Reset();
- m_matrix.Reset();
-}
-CFWL_PictureBoxImp::~CFWL_PictureBoxImp()
-{
-}
-FWL_ERR CFWL_PictureBoxImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_PictureBox;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_PictureBoxImp::GetClassID() const
-{
- return FWL_CLASSHASH_PictureBox;
-}
-FWL_ERR CFWL_PictureBoxImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_PictureBoxImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PictureBoxImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_PictureBoxImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider, FWL_ERR_Indefinite);
- CFX_DIBitmap *pBitmap = ((IFWL_PictureBoxDP*)m_pProperties->m_pDataProvider)->GetPicture(m_pInterface);
- if (pBitmap) {
- rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)pBitmap->GetHeight());
- }
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PictureBoxImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Succeeded;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- GetClientRect(m_rtClient);
- return FWL_ERR_Succeeded;
+IFWL_PictureBox::IFWL_PictureBox() {
+ m_pData = NULL;
}
-FWL_ERR CFWL_PictureBoxImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = GetAvailableTheme();
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_PTB_Border, pTheme, pMatrix );
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_PTB_Edge, pTheme, pMatrix);
+IFWL_PictureBox::~IFWL_PictureBox() {
+ if (m_pData) {
+ delete (CFWL_PictureBoxImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+FWL_ERR IFWL_PictureBox::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_PictureBoxImp(pOuter);
+ ((CFWL_PictureBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_PictureBoxImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_PictureBox::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_PictureBoxImp(properties, pOuter);
+ ((CFWL_PictureBoxImp*)m_pData)->SetInterface(this);
+ return ((CFWL_PictureBoxImp*)m_pData)->Initialize();
+}
+CFWL_PictureBoxImp::CFWL_PictureBoxImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_bTop(FALSE),
+ m_bVCenter(FALSE),
+ m_bButton(FALSE) {
+ m_rtClient.Reset();
+ m_rtImage.Reset();
+ m_matrix.Reset();
+}
+CFWL_PictureBoxImp::CFWL_PictureBoxImp(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_bTop(FALSE),
+ m_bVCenter(FALSE),
+ m_bButton(FALSE) {
+ m_rtClient.Reset();
+ m_rtImage.Reset();
+ m_matrix.Reset();
+}
+CFWL_PictureBoxImp::~CFWL_PictureBoxImp() {}
+FWL_ERR CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_PictureBox;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_PictureBoxImp::GetClassID() const {
+ return FWL_CLASSHASH_PictureBox;
+}
+FWL_ERR CFWL_PictureBoxImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_PictureBoxImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBoxImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_PictureBoxImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pDataProvider,
+ FWL_ERR_Indefinite);
+ CFX_DIBitmap* pBitmap = ((IFWL_PictureBoxDP*)m_pProperties->m_pDataProvider)
+ ->GetPicture(m_pInterface);
+ if (pBitmap) {
+ rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(),
+ (FX_FLOAT)pBitmap->GetHeight());
}
- DrawBkground(pGraphics, pTheme, pMatrix);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBoxImp::Update() {
+ if (IsLocked()) {
return FWL_ERR_Succeeded;
-}
-void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
- CFX_DIBitmap *pPicture = ((IFWL_PictureBoxDP*)m_pProperties->m_pDataProvider)->GetPicture(m_pInterface);
- CFX_Matrix matrix;
- ((IFWL_PictureBoxDP*)m_pProperties->m_pDataProvider)->GetMatrix(m_pInterface, matrix);
- if (!pPicture) {
- return;
- }
- matrix.Concat(*pMatrix);
- FX_FLOAT fx = (FX_FLOAT)pPicture->GetWidth();
- FX_FLOAT fy = (FX_FLOAT)pPicture->GetHeight();
- if (fx > m_rtClient.width) {
- fx = m_rtClient.width;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ GetClientRect(m_rtClient);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = GetAvailableTheme();
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_PTB_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_PTB_Edge, pTheme, pMatrix);
+ }
+ DrawBkground(pGraphics, pTheme, pMatrix);
+ return FWL_ERR_Succeeded;
+}
+void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
+ CFX_DIBitmap* pPicture = ((IFWL_PictureBoxDP*)m_pProperties->m_pDataProvider)
+ ->GetPicture(m_pInterface);
+ CFX_Matrix matrix;
+ ((IFWL_PictureBoxDP*)m_pProperties->m_pDataProvider)
+ ->GetMatrix(m_pInterface, matrix);
+ if (!pPicture) {
+ return;
+ }
+ matrix.Concat(*pMatrix);
+ FX_FLOAT fx = (FX_FLOAT)pPicture->GetWidth();
+ FX_FLOAT fy = (FX_FLOAT)pPicture->GetHeight();
+ if (fx > m_rtClient.width) {
+ fx = m_rtClient.width;
+ }
+ if (fy > m_rtClient.height) {
+ fy = m_rtClient.height;
+ }
+ CFX_PointF pt;
+ pt.Set((m_rtClient.width - fx) / 2, (m_rtClient.height - fy) / 2);
+ pGraphics->DrawImage(pPicture, pt, &matrix);
+}
+FX_BOOL CFWL_PictureBoxImp::VStyle(FX_BOOL dwStyle) {
+ switch (dwStyle & FWL_STYLEEXT_PTB_VAlignMask) {
+ case FWL_STYLEEXT_PTB_Top: {
+ return m_bTop = TRUE;
+ break;
}
- if (fy > m_rtClient.height) {
- fy = m_rtClient.height;
+ case FWL_STYLEEXT_PTB_Vcenter: {
+ return m_bVCenter = TRUE;
+ break;
}
- CFX_PointF pt;
- pt.Set((m_rtClient.width - fx) / 2, (m_rtClient.height - fy) / 2);
- pGraphics->DrawImage(pPicture, pt, &matrix);
-}
-FX_BOOL CFWL_PictureBoxImp::VStyle(FX_BOOL dwStyle)
-{
- switch(dwStyle & FWL_STYLEEXT_PTB_VAlignMask) {
- case FWL_STYLEEXT_PTB_Top: {
- return m_bTop = TRUE;
- break;
- }
- case FWL_STYLEEXT_PTB_Vcenter: {
- return m_bVCenter = TRUE;
- break;
- }
- case FWL_STYLEEXT_PTB_Bottom: {
- return m_bButton = TRUE;
- break;
- }
+ case FWL_STYLEEXT_PTB_Bottom: {
+ return m_bButton = TRUE;
+ break;
}
- return FALSE;
-}
-CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate(CFWL_PictureBoxImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-FWL_ERR CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+ }
+ return FALSE;
+}
+CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate(
+ CFWL_PictureBoxImp* pOwner)
+ : m_pOwner(pOwner) {}
+FWL_ERR CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp b/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp index 364e497123..3329a76ee7 100644 --- a/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp @@ -9,534 +9,554 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "include/fwl_pushbuttonimp.h"
-IFWL_PushButton *IFWL_PushButton::Create()
-{
- return new IFWL_PushButton;
+IFWL_PushButton* IFWL_PushButton::Create() {
+ return new IFWL_PushButton;
}
-FWL_ERR IFWL_PushButton::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_PushButtonImp(pOuter);
- ((CFWL_PushButtonImp*)m_pData)->SetInterface(this);
- return ((CFWL_PushButtonImp*)m_pData)->Initialize();
+FWL_ERR IFWL_PushButton::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_PushButtonImp(pOuter);
+ ((CFWL_PushButtonImp*)m_pData)->SetInterface(this);
+ return ((CFWL_PushButtonImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_PushButton::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_PushButtonImp(properties, pOuter);
- ((CFWL_PushButtonImp*)m_pData)->SetInterface(this);
- return ((CFWL_PushButtonImp*)m_pData)->Initialize();
+FWL_ERR IFWL_PushButton::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_PushButtonImp(properties, pOuter);
+ ((CFWL_PushButtonImp*)m_pData)->SetInterface(this);
+ return ((CFWL_PushButtonImp*)m_pData)->Initialize();
}
-IFWL_PushButton::IFWL_PushButton()
-{
+IFWL_PushButton::IFWL_PushButton() {
+ m_pData = NULL;
+}
+IFWL_PushButton::~IFWL_PushButton() {
+ if (m_pData) {
+ delete (CFWL_PushButtonImp*)m_pData;
m_pData = NULL;
+ }
}
-IFWL_PushButton::~IFWL_PushButton()
-{
- if (m_pData) {
- delete (CFWL_PushButtonImp*)m_pData;
- m_pData = NULL;
- }
+CFWL_PushButtonImp::CFWL_PushButtonImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_bBtnDown(FALSE),
+ m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
+ m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
+ m_rtClient.Set(0, 0, 0, 0);
+ m_rtCaption.Set(0, 0, 0, 0);
}
-CFWL_PushButtonImp::CFWL_PushButtonImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_bBtnDown(FALSE)
- , m_dwTTOStyles(FDE_TTOSTYLE_SingleLine)
- , m_iTTOAlign(FDE_TTOALIGNMENT_Center)
-{
- m_rtClient.Set(0, 0, 0, 0);
- m_rtCaption.Set(0, 0, 0, 0);
+CFWL_PushButtonImp::CFWL_PushButtonImp(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_bBtnDown(FALSE),
+ m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
+ m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
+ m_rtClient.Set(0, 0, 0, 0);
+ m_rtCaption.Set(0, 0, 0, 0);
}
-CFWL_PushButtonImp::CFWL_PushButtonImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_bBtnDown(FALSE)
- , m_dwTTOStyles(FDE_TTOSTYLE_SingleLine)
- , m_iTTOAlign(FDE_TTOALIGNMENT_Center)
-{
- m_rtClient.Set(0, 0, 0, 0);
- m_rtCaption.Set(0, 0, 0, 0);
+CFWL_PushButtonImp::~CFWL_PushButtonImp() {}
+FWL_ERR CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_PushButton;
+ return FWL_ERR_Succeeded;
}
-CFWL_PushButtonImp::~CFWL_PushButtonImp()
-{
+FX_DWORD CFWL_PushButtonImp::GetClassID() const {
+ return FWL_CLASSHASH_PushButton;
}
-FWL_ERR CFWL_PushButtonImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_PushButton;
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_PushButtonImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_PushButtonImpDelegate(this);
+ return FWL_ERR_Succeeded;
}
-FX_DWORD CFWL_PushButtonImp::GetClassID() const
-{
- return FWL_CLASSHASH_PushButton;
+FWL_ERR CFWL_PushButtonImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_PushButtonImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_PushButtonImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_PushButtonImpDelegate(this);
+FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
+ if (m_pProperties->m_pThemeProvider == NULL) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ CFX_WideString wsCaption;
+ IFWL_PushButtonDP* pData =
+ (IFWL_PushButtonDP*)m_pProperties->m_pDataProvider;
+ if (pData) {
+ pData->GetCaption(m_pInterface, wsCaption);
+ }
+ int32_t iLen = wsCaption.GetLength();
+ if (iLen > 0) {
+ CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
+ rect.Set(0, 0, sz.x, sz.y);
+ }
+ FX_FLOAT* fcaption =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin);
+ rect.Inflate(*fcaption, *fcaption);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PushButtonImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
+ m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
return FWL_ERR_Succeeded;
+ }
+ return CFWL_WidgetImp::SetStates(dwStates, bSet);
}
-FWL_ERR CFWL_PushButtonImp::Finalize()
-{
- if( m_pDelegate) {
- delete (CFWL_PushButtonImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
+FWL_ERR CFWL_PushButtonImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ UpdateTextOutStyles();
+ GetClientRect(m_rtClient);
+ m_rtCaption = m_rtClient;
+ FX_FLOAT* fcaption = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin);
+ m_rtCaption.Inflate(-*fcaption, -*fcaption);
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- if (m_pProperties->m_pThemeProvider == NULL) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- CFX_WideString wsCaption;
- IFWL_PushButtonDP *pData = (IFWL_PushButtonDP*)m_pProperties->m_pDataProvider;
- if (pData) {
- pData->GetCaption(m_pInterface, wsCaption);
+FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_PushButtonDP* pData = (IFWL_PushButtonDP*)m_pProperties->m_pDataProvider;
+ CFX_DIBitmap* pPicture = NULL;
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_PSB_Border, m_pProperties->m_pThemeProvider,
+ pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider,
+ pMatrix);
+ }
+ DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
+ CFX_Matrix matrix;
+ matrix.Concat(*pMatrix);
+ FX_FLOAT iPicwidth = 0;
+ FX_FLOAT ipicheight = 0;
+ CFX_WideString wsCaption;
+ if (pData) {
+ pData->GetCaption(m_pInterface, wsCaption);
+ }
+ CFX_RectF rtText;
+ rtText.Set(0, 0, 0, 0);
+ if (!wsCaption.IsEmpty()) {
+ CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText);
+ }
+ switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) {
+ case FWL_STYLEEXT_PSB_TextOnly:
+ DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
+ break;
+ case FWL_STYLEEXT_PSB_IconOnly:
+ if (pData) {
+ pPicture = pData->GetPicture(m_pInterface);
+ }
+ if (pPicture) {
+ CFX_PointF point;
+ switch (m_iTTOAlign) {
+ case 0: {
+ point.x = m_rtClient.left;
+ point.y = m_rtClient.top;
+ break;
+ }
+ case 1: {
+ point.x = m_rtClient.left +
+ (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
+ point.y = m_rtClient.top;
+ break;
+ }
+ case 2:
+ point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
+ point.y = m_rtClient.top;
+ break;
+ case 4:
+ point.x = m_rtClient.left;
+ point.y = m_rtClient.top + m_rtClient.height / 2 -
+ pPicture->GetHeight() / 2;
+ break;
+ case 5:
+ point.x = m_rtClient.left +
+ (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
+ point.y = m_rtClient.top + m_rtClient.height / 2 -
+ pPicture->GetHeight() / 2;
+ break;
+ case 6:
+ point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
+ point.y = m_rtClient.top + m_rtClient.height / 2 -
+ pPicture->GetHeight() / 2;
+ break;
+ case 8:
+ point.x = m_rtClient.left;
+ point.y =
+ m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
+ break;
+ case 9:
+ point.x = m_rtClient.left +
+ (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
+ point.y =
+ m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
+ break;
+ case 10:
+ point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
+ point.y =
+ m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
+ break;
}
- int32_t iLen = wsCaption.GetLength();
- if (iLen > 0) {
- CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
- rect.Set(0, 0, sz.x, sz.y);
+ pGraphics->DrawImage(pPicture, point, &matrix);
+ }
+ break;
+ case FWL_STYLEEXT_PSB_TextIcon:
+ if (pPicture) {
+ CFX_PointF point;
+ switch (m_iTTOAlign) {
+ case 0: {
+ point.x = m_rtClient.left;
+ point.y = m_rtClient.top;
+ iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7);
+ ipicheight =
+ pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
+ break;
+ }
+ case 1: {
+ point.x =
+ m_rtClient.left + (m_rtClient.width / 2 -
+ (pPicture->GetWidth() + rtText.width) / 2);
+ point.y = m_rtClient.top;
+ iPicwidth = pPicture->GetWidth() -
+ ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) +
+ rtText.width / 2 - 7;
+ ipicheight =
+ pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
+ break;
+ }
+ case 2:
+ point.x = m_rtClient.left + m_rtClient.width -
+ pPicture->GetWidth() - rtText.width;
+ point.y = m_rtClient.top;
+ iPicwidth = m_rtClient.left + m_rtClient.width - point.x -
+ pPicture->GetWidth() - rtText.width + 7;
+ ipicheight =
+ pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
+ break;
+ case 4:
+ point.x = m_rtClient.left;
+ point.y = m_rtClient.top + m_rtClient.height / 2 -
+ pPicture->GetHeight() / 2;
+ iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7;
+ break;
+ case 5:
+ point.x =
+ m_rtClient.left + (m_rtClient.width / 2 -
+ (pPicture->GetWidth() + rtText.width) / 2);
+ point.y = m_rtClient.top + m_rtClient.height / 2 -
+ pPicture->GetHeight() / 2;
+ iPicwidth = pPicture->GetWidth() -
+ ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) +
+ rtText.width / 2 - 7;
+ break;
+ case 6:
+ point.x = m_rtClient.left + m_rtClient.width -
+ pPicture->GetWidth() - rtText.width;
+ point.y = m_rtClient.top + m_rtClient.height / 2 -
+ pPicture->GetHeight() / 2;
+ iPicwidth = m_rtClient.left + m_rtClient.width - point.x -
+ pPicture->GetWidth() - rtText.width + 7;
+ break;
+ case 8:
+ point.x = m_rtClient.left;
+ point.y =
+ m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
+ iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7);
+ ipicheight -= rtText.height / 2;
+ break;
+ case 9:
+ point.x =
+ m_rtClient.left + (m_rtClient.width / 2 -
+ (pPicture->GetWidth() + rtText.width) / 2);
+ point.y =
+ m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
+ iPicwidth = pPicture->GetWidth() -
+ ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) +
+ rtText.width / 2 - 7;
+ ipicheight -= rtText.height / 2;
+ break;
+ case 10:
+ point.x = m_rtClient.left + m_rtClient.width -
+ pPicture->GetWidth() - rtText.width;
+ point.y =
+ m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
+ iPicwidth = m_rtClient.left + m_rtClient.width - point.x -
+ pPicture->GetWidth() - rtText.width + 7;
+ ipicheight -= rtText.height / 2;
+ break;
}
- FX_FLOAT *fcaption = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin);
- rect.Inflate(*fcaption, *fcaption);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
+ pGraphics->DrawImage(pPicture, point, &matrix);
+ }
+ matrix.e += m_rtClient.left + iPicwidth;
+ matrix.f += m_rtClient.top + ipicheight;
+ DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
+ break;
+ }
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_PushButtonImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
- if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
- m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
+void CFWL_PushButtonImp::DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_PSB_Background;
+ param.m_dwStates = GetPartStates();
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = m_rtClient;
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ param.m_pData = &m_rtCaption;
+ }
+ pTheme->DrawBackground(¶m);
}
-FWL_ERR CFWL_PushButtonImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- UpdateTextOutStyles();
- GetClientRect(m_rtClient);
- m_rtCaption = m_rtClient;
- FX_FLOAT *fcaption = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin);
- m_rtCaption.Inflate(-*fcaption, -*fcaption);
- return FWL_ERR_Succeeded;
+void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
+ CFX_WideString wsCaption;
+ m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ if (wsCaption.IsEmpty()) {
+ return;
+ }
+ CFWL_ThemeText param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_PSB_Caption;
+ param.m_dwStates = GetPartStates();
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = m_rtCaption;
+ param.m_wsText = wsCaption;
+ param.m_dwTTOStyles = m_dwTTOStyles;
+ param.m_iTTOAlign = m_iTTOAlign;
+ pTheme->DrawText(¶m);
}
-FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_PushButtonDP *pData = (IFWL_PushButtonDP*)m_pProperties->m_pDataProvider;
- CFX_DIBitmap *pPicture = NULL;
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_PSB_Border, m_pProperties->m_pThemeProvider, pMatrix);
+FX_DWORD CFWL_PushButtonImp::GetPartStates() {
+ FX_DWORD dwStates = FWL_PARTSTATE_PSB_Normal;
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ dwStates |= FWL_PARTSTATE_PSB_Focused;
+ }
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+ dwStates = FWL_PARTSTATE_PSB_Disabled;
+ } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
+ dwStates |= FWL_PARTSTATE_PSB_Pressed;
+ } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
+ dwStates |= FWL_PARTSTATE_PSB_Hovered;
+ } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) {
+ dwStates |= FWL_PARTSTATE_PSB_Default;
+ }
+ return dwStates;
+}
+void CFWL_PushButtonImp::UpdateTextOutStyles() {
+ m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ switch (m_pProperties->m_dwStyleExes &
+ (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) {
+ case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
+ break;
}
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider, pMatrix);
+ case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
+ break;
}
- DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
- CFX_Matrix matrix;
- matrix.Concat(*pMatrix);
- FX_FLOAT iPicwidth = 0;
- FX_FLOAT ipicheight = 0;
- CFX_WideString wsCaption;
- if (pData) {
- pData->GetCaption(m_pInterface, wsCaption);
+ case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Top: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_TopRight;
+ break;
}
- CFX_RectF rtText;
- rtText.Set(0, 0, 0 , 0);
- if (!wsCaption.IsEmpty()) {
- CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText);
+ case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_VCenter: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ break;
}
- switch(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) {
- case FWL_STYLEEXT_PSB_TextOnly:
- DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
- break;
- case FWL_STYLEEXT_PSB_IconOnly:
- if (pData) {
- pPicture = pData->GetPicture(m_pInterface);
- }
- if (pPicture) {
- CFX_PointF point;
- switch(m_iTTOAlign) {
- case 0: {
- point.x = m_rtClient.left;
- point.y = m_rtClient.top;
- break;
- }
- case 1: {
- point.x = m_rtClient.left + (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
- point.y = m_rtClient.top;
- break;
- }
- case 2:
- point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
- point.y = m_rtClient.top;
- break;
- case 4:
- point.x = m_rtClient.left;
- point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2;
- break;
- case 5:
- point.x = m_rtClient.left + (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
- point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2;
- break;
- case 6:
- point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
- point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2;
- break;
- case 8:
- point.x = m_rtClient.left;
- point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
- break;
- case 9:
- point.x = m_rtClient.left + (m_rtClient.width / 2 - pPicture->GetWidth() / 2);
- point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
- break;
- case 10:
- point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth();
- point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
- break;
- }
- pGraphics->DrawImage(pPicture, point, &matrix);
- }
- break;
- case FWL_STYLEEXT_PSB_TextIcon:
- if (pPicture) {
- CFX_PointF point;
- switch(m_iTTOAlign) {
- case 0: {
- point.x = m_rtClient.left;
- point.y = m_rtClient.top;
- iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7);
- ipicheight = pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
- break;
- }
- case 1: {
- point.x = m_rtClient.left + (m_rtClient.width / 2 - (pPicture->GetWidth() + rtText.width) / 2);
- point.y = m_rtClient.top;
- iPicwidth = pPicture->GetWidth() - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + rtText.width / 2 - 7;
- ipicheight = pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
- break;
- }
- case 2:
- point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth() - rtText.width;
- point.y = m_rtClient.top;
- iPicwidth = m_rtClient.left + m_rtClient.width - point.x - pPicture->GetWidth() - rtText.width + 7;
- ipicheight = pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2;
- break;
- case 4:
- point.x = m_rtClient.left;
- point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2;
- iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7;
- break;
- case 5:
- point.x = m_rtClient.left + (m_rtClient.width / 2 - (pPicture->GetWidth() + rtText.width) / 2);
- point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2;
- iPicwidth = pPicture->GetWidth() - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + rtText.width / 2 - 7;
- break;
- case 6:
- point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth() - rtText.width;
- point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2;
- iPicwidth = m_rtClient.left + m_rtClient.width - point.x - pPicture->GetWidth() - rtText.width + 7;
- break;
- case 8:
- point.x = m_rtClient.left;
- point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
- iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7);
- ipicheight -= rtText.height / 2;
- break;
- case 9:
- point.x = m_rtClient.left + (m_rtClient.width / 2 - (pPicture->GetWidth() + rtText.width) / 2);
- point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
- iPicwidth = pPicture->GetWidth() - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + rtText.width / 2 - 7;
- ipicheight -= rtText.height / 2;
- break;
- case 10:
- point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth() - rtText.width;
- point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight();
- iPicwidth = m_rtClient.left + m_rtClient.width - point.x - pPicture->GetWidth() - rtText.width + 7;
- ipicheight -= rtText.height / 2;
- break;
- }
- pGraphics->DrawImage(pPicture, point, &matrix);
- }
- matrix.e += m_rtClient.left + iPicwidth;
- matrix.f += m_rtClient.top + ipicheight;
- DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
- break;
+ case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ break;
}
- return FWL_ERR_Succeeded;
-}
-void CFWL_PushButtonImp::DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_PSB_Background;
- param.m_dwStates = GetPartStates();
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
+ case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight;
+ break;
}
- param.m_rtPart = m_rtClient;
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- param.m_pData = &m_rtCaption;
+ case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Bottom: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft;
+ break;
}
- pTheme->DrawBackground(¶m);
-}
-void CFWL_PushButtonImp::DrawText(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
- CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
- if (wsCaption.IsEmpty()) {
- return;
+ case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Bottom: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter;
+ break;
}
- CFWL_ThemeText param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_PSB_Caption;
- param.m_dwStates = GetPartStates();
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
+ case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Bottom: {
+ m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight;
+ break;
}
- param.m_rtPart = m_rtCaption;
- param.m_wsText = wsCaption;
- param.m_dwTTOStyles = m_dwTTOStyles;
- param.m_iTTOAlign = m_iTTOAlign;
- pTheme->DrawText(¶m);
+ default: {}
+ }
+ m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
+ m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
+ }
}
-FX_DWORD CFWL_PushButtonImp::GetPartStates()
-{
- FX_DWORD dwStates = FWL_PARTSTATE_PSB_Normal;
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- dwStates |= FWL_PARTSTATE_PSB_Focused;
+CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(
+ CFWL_PushButtonImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ if (!m_pOwner->IsEnabled()) {
+ return 1;
+ }
+ int32_t iRet = 1;
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
}
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- dwStates = FWL_PARTSTATE_PSB_Disabled;
- } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
- dwStates |= FWL_PARTSTATE_PSB_Pressed;
- } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
- dwStates |= FWL_PARTSTATE_PSB_Hovered;
- } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) {
- dwStates |= FWL_PARTSTATE_PSB_Default;
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
+ }
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave(pMsg);
+ break;
+ }
+ default: {}
+ }
+ break;
}
- return dwStates;
-}
-void CFWL_PushButtonImp::UpdateTextOutStyles()
-{
- m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- switch(m_pProperties->m_dwStyleExes & (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) {
- case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
- break;
- }
- case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter;
- break;
- }
- case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Top: {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopRight;
- break;
- }
- case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_VCenter: {
- m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
- break;
- }
- case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: {
- m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- break;
- }
- case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: {
- m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight;
- break;
- }
- case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Bottom: {
- m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft;
- break;
- }
- case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Bottom: {
- m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter;
- break;
- }
- case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Bottom: {
- m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight;
- break;
- }
- default: {
- }
+ case FWL_MSGHASH_Key: {
+ CFWL_MsgKey* pKey = (CFWL_MsgKey*)pMessage;
+ if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ OnKeyDown((CFWL_MsgKey*)pKey);
+ }
+ break;
}
- m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
- m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
+ default: {
+ iRet = 0;
+ break;
}
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
}
-CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(CFWL_PushButtonImp *pOwner)
- : m_pOwner(pOwner)
-{
+FWL_ERR CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ return FWL_ERR_Succeeded;
}
-int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- if (!m_pOwner->IsEnabled()) {
- return 1;
- }
- int32_t iRet = 1;
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_MsgKey *pKey = (CFWL_MsgKey*)pMessage;
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
- OnKeyDown((CFWL_MsgKey*)pKey);
- }
- break;
- }
- default: {
- iRet = 0;
- break;
- }
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
}
-FWL_ERR CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet )
-{
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ m_pOwner->SetFocus(TRUE);
+ }
+ m_pOwner->m_bBtnDown = TRUE;
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- m_pOwner->m_bBtnDown = TRUE;
+void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_pOwner->m_bBtnDown = FALSE;
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ }
+ if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ CFWL_EvtClick wmClick;
+ wmClick.m_pSrcTarget = (IFWL_PushButton*)m_pOwner->m_pInterface;
+ m_pOwner->DispatchEvent(&wmClick);
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->m_bBtnDown = FALSE;
+void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ FX_BOOL bRepaint = FALSE;
+ if (m_pOwner->m_bBtnDown) {
if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
- } else {
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
+ bRepaint = TRUE;
+ }
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
+ bRepaint = TRUE;
+ }
+ } else {
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ bRepaint = TRUE;
+ }
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+ bRepaint = TRUE;
+ }
}
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- CFWL_EvtClick wmClick;
- wmClick.m_pSrcTarget = (IFWL_PushButton*)m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&wmClick);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- FX_BOOL bRepaint = FALSE;
- if (m_pOwner->m_bBtnDown) {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
- bRepaint = TRUE;
- }
- if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
- bRepaint = TRUE;
- }
- } else {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
- bRepaint = TRUE;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
- bRepaint = TRUE;
- }
- }
- } else {
- if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- return;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
- bRepaint = TRUE;
- }
+ } else {
+ if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ return;
}
- if (bRepaint) {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+ bRepaint = TRUE;
}
-}
-void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->m_bBtnDown = FALSE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ }
+ if (bRepaint) {
m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ }
}
-void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey *pMsg)
-{
- if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
- CFWL_EvtMouse wmMouse;
- wmMouse.m_pSrcTarget = m_pOwner->m_pInterface;
- wmMouse.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp;
- m_pOwner->DispatchEvent(&wmMouse);
- CFWL_EvtClick wmClick;
- wmClick.m_pSrcTarget = (IFWL_PushButton*)m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&wmClick);
- return;
- }
- if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) {
- return;
- }
- m_pOwner->DispatchKeyEvent(pMsg);
+void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ m_pOwner->m_bBtnDown = FALSE;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+ if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
+ CFWL_EvtMouse wmMouse;
+ wmMouse.m_pSrcTarget = m_pOwner->m_pInterface;
+ wmMouse.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp;
+ m_pOwner->DispatchEvent(&wmMouse);
+ CFWL_EvtClick wmClick;
+ wmClick.m_pSrcTarget = (IFWL_PushButton*)m_pOwner->m_pInterface;
+ m_pOwner->DispatchEvent(&wmClick);
+ return;
+ }
+ if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) {
+ return;
+ }
+ m_pOwner->DispatchKeyEvent(pMsg);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp b/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp index 7b3e43f6e5..a692d50448 100644 --- a/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp @@ -9,844 +9,835 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "include/fwl_scrollbarimp.h"
-#define FWL_SCROLLBAR_Elapse 500
-#define FWL_SCROLLBAR_MinThumb 5
-IFWL_ScrollBar* IFWL_ScrollBar::Create()
-{
- return new IFWL_ScrollBar;
-}
-IFWL_ScrollBar::IFWL_ScrollBar()
-{
- m_pData = NULL;
+#define FWL_SCROLLBAR_Elapse 500
+#define FWL_SCROLLBAR_MinThumb 5
+IFWL_ScrollBar* IFWL_ScrollBar::Create() {
+ return new IFWL_ScrollBar;
}
-IFWL_ScrollBar::~IFWL_ScrollBar()
-{
- if (m_pData) {
- delete (CFWL_ScrollBarImp*)m_pData;
- m_pData = NULL;
- }
+IFWL_ScrollBar::IFWL_ScrollBar() {
+ m_pData = NULL;
}
-FWL_ERR IFWL_ScrollBar::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ScrollBarImp(pOuter);
- ((CFWL_ScrollBarImp*)m_pData)->SetInterface(this);
- return ((CFWL_ScrollBarImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_ScrollBar::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ScrollBarImp(properties, pOuter);
- ((CFWL_ScrollBarImp*)m_pData)->SetInterface(this);
- return ((CFWL_ScrollBarImp*)m_pData)->Initialize();
-}
-FX_BOOL IFWL_ScrollBar::IsVertical()
-{
- return ((CFWL_ScrollBarImp*)m_pData)->IsVertical();
-}
-FWL_ERR IFWL_ScrollBar::GetRange(FX_FLOAT &fMin, FX_FLOAT &fMax)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->GetRange(fMin, fMax);
-}
-FWL_ERR IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->SetRange(fMin, fMax);
-}
-FX_FLOAT IFWL_ScrollBar::GetPageSize()
-{
- return ((CFWL_ScrollBarImp*)m_pData)->GetPageSize();
-}
-FWL_ERR IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->SetPageSize(fPageSize);
-}
-FX_FLOAT IFWL_ScrollBar::GetStepSize()
-{
- return ((CFWL_ScrollBarImp*)m_pData)->GetStepSize();
-}
-FWL_ERR IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->SetStepSize(fStepSize);
-}
-FX_FLOAT IFWL_ScrollBar::GetPos()
-{
- return ((CFWL_ScrollBarImp*)m_pData)->GetPos();
-}
-FWL_ERR IFWL_ScrollBar::SetPos(FX_FLOAT fPos)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->SetPos(fPos);
-}
-FX_FLOAT IFWL_ScrollBar::GetTrackPos()
-{
- return ((CFWL_ScrollBarImp*)m_pData)->GetTrackPos();
-}
-FWL_ERR IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->SetTrackPos(fTrackPos);
-}
-FX_BOOL IFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos)
-{
- return ((CFWL_ScrollBarImp*)m_pData)->DoScroll(dwCode, fPos);
-}
-CFWL_ScrollBarImp::CFWL_ScrollBarImp(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_hTimer(NULL)
- , m_fRangeMin(0)
- , m_fRangeMax(-1)
- , m_fPageSize(0)
- , m_fStepSize(0)
- , m_fPos(0)
- , m_fTrackPos(0)
- , m_iMinButtonState(FWL_PARTSTATE_SCB_Normal)
- , m_iMaxButtonState(FWL_PARTSTATE_SCB_Normal)
- , m_iThumbButtonState(FWL_PARTSTATE_SCB_Normal)
- , m_fLastTrackPos(0)
- , m_cpTrackPointX(0)
- , m_cpTrackPointY(0)
- , m_iMinTrackState(FWL_PARTSTATE_SCB_Normal)
- , m_iMaxTrackState(FWL_PARTSTATE_SCB_Normal)
- , m_iMouseWheel(0)
- , m_bTrackMouseLeave(FALSE)
- , m_bMouseHover(FALSE)
- , m_bRepaintThumb(FALSE)
- , m_bMouseDown(FALSE)
- , m_fButtonLen(0)
- , m_bMinSize(FALSE)
- , m_bCustomLayout(FALSE)
- , m_fMinThumb(FWL_SCROLLBAR_MinThumb)
-{
- m_rtClient.Reset();
- m_rtThumb.Reset();
- m_rtMinBtn.Reset();
- m_rtMaxBtn.Reset();
- m_rtMinTrack.Reset();
- m_rtMaxTrack.Reset();
-}
-CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget* pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_hTimer(NULL)
- , m_fRangeMin(0)
- , m_fRangeMax(-1)
- , m_fPageSize(0)
- , m_fStepSize(0)
- , m_fPos(0)
- , m_fTrackPos(0)
- , m_iMinButtonState(FWL_PARTSTATE_SCB_Normal)
- , m_iMaxButtonState(FWL_PARTSTATE_SCB_Normal)
- , m_iThumbButtonState(FWL_PARTSTATE_SCB_Normal)
- , m_fLastTrackPos(0)
- , m_cpTrackPointX(0)
- , m_cpTrackPointY(0)
- , m_iMinTrackState(FWL_PARTSTATE_SCB_Normal)
- , m_iMaxTrackState(FWL_PARTSTATE_SCB_Normal)
- , m_iMouseWheel(0)
- , m_bTrackMouseLeave(FALSE)
- , m_bMouseHover(FALSE)
- , m_bRepaintThumb(FALSE)
- , m_bMouseDown(FALSE)
- , m_fButtonLen(0)
- , m_bMinSize(FALSE)
- , m_bCustomLayout(FALSE)
- , m_fMinThumb(FWL_SCROLLBAR_MinThumb)
-{
- m_rtClient.Reset();
- m_rtThumb.Reset();
- m_rtMinBtn.Reset();
- m_rtMaxBtn.Reset();
- m_rtMinTrack.Reset();
- m_rtMaxTrack.Reset();
-}
-CFWL_ScrollBarImp::~CFWL_ScrollBarImp()
-{
-}
-FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_ScrollBar;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ScrollBarImp::GetClassID() const
-{
- return FWL_CLASSHASH_ScrollBar;
-}
-FWL_ERR CFWL_ScrollBarImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ScrollBarImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ScrollBarImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_ScrollBarImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_ScrollBarImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- FX_FLOAT *pfMinWidth = (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
- _FWL_RETURN_VALUE_IF_FAIL(pfMinWidth, FWL_ERR_Indefinite);
- if (IsVertical()) {
- rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3);
- } else {
- rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth));
- }
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+IFWL_ScrollBar::~IFWL_ScrollBar() {
+ if (m_pData) {
+ delete (CFWL_ScrollBarImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+FWL_ERR IFWL_ScrollBar::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ScrollBarImp(pOuter);
+ ((CFWL_ScrollBarImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ScrollBarImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_ScrollBar::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ScrollBarImp(properties, pOuter);
+ ((CFWL_ScrollBarImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ScrollBarImp*)m_pData)->Initialize();
+}
+FX_BOOL IFWL_ScrollBar::IsVertical() {
+ return ((CFWL_ScrollBarImp*)m_pData)->IsVertical();
+}
+FWL_ERR IFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
+ return ((CFWL_ScrollBarImp*)m_pData)->GetRange(fMin, fMax);
+}
+FWL_ERR IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
+ return ((CFWL_ScrollBarImp*)m_pData)->SetRange(fMin, fMax);
+}
+FX_FLOAT IFWL_ScrollBar::GetPageSize() {
+ return ((CFWL_ScrollBarImp*)m_pData)->GetPageSize();
+}
+FWL_ERR IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) {
+ return ((CFWL_ScrollBarImp*)m_pData)->SetPageSize(fPageSize);
+}
+FX_FLOAT IFWL_ScrollBar::GetStepSize() {
+ return ((CFWL_ScrollBarImp*)m_pData)->GetStepSize();
+}
+FWL_ERR IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) {
+ return ((CFWL_ScrollBarImp*)m_pData)->SetStepSize(fStepSize);
+}
+FX_FLOAT IFWL_ScrollBar::GetPos() {
+ return ((CFWL_ScrollBarImp*)m_pData)->GetPos();
+}
+FWL_ERR IFWL_ScrollBar::SetPos(FX_FLOAT fPos) {
+ return ((CFWL_ScrollBarImp*)m_pData)->SetPos(fPos);
+}
+FX_FLOAT IFWL_ScrollBar::GetTrackPos() {
+ return ((CFWL_ScrollBarImp*)m_pData)->GetTrackPos();
+}
+FWL_ERR IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
+ return ((CFWL_ScrollBarImp*)m_pData)->SetTrackPos(fTrackPos);
+}
+FX_BOOL IFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) {
+ return ((CFWL_ScrollBarImp*)m_pData)->DoScroll(dwCode, fPos);
+}
+CFWL_ScrollBarImp::CFWL_ScrollBarImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_hTimer(NULL),
+ m_fRangeMin(0),
+ m_fRangeMax(-1),
+ m_fPageSize(0),
+ m_fStepSize(0),
+ m_fPos(0),
+ m_fTrackPos(0),
+ m_iMinButtonState(FWL_PARTSTATE_SCB_Normal),
+ m_iMaxButtonState(FWL_PARTSTATE_SCB_Normal),
+ m_iThumbButtonState(FWL_PARTSTATE_SCB_Normal),
+ m_fLastTrackPos(0),
+ m_cpTrackPointX(0),
+ m_cpTrackPointY(0),
+ m_iMinTrackState(FWL_PARTSTATE_SCB_Normal),
+ m_iMaxTrackState(FWL_PARTSTATE_SCB_Normal),
+ m_iMouseWheel(0),
+ m_bTrackMouseLeave(FALSE),
+ m_bMouseHover(FALSE),
+ m_bRepaintThumb(FALSE),
+ m_bMouseDown(FALSE),
+ m_fButtonLen(0),
+ m_bMinSize(FALSE),
+ m_bCustomLayout(FALSE),
+ m_fMinThumb(FWL_SCROLLBAR_MinThumb) {
+ m_rtClient.Reset();
+ m_rtThumb.Reset();
+ m_rtMinBtn.Reset();
+ m_rtMaxBtn.Reset();
+ m_rtMinTrack.Reset();
+ m_rtMaxTrack.Reset();
+}
+CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_hTimer(NULL),
+ m_fRangeMin(0),
+ m_fRangeMax(-1),
+ m_fPageSize(0),
+ m_fStepSize(0),
+ m_fPos(0),
+ m_fTrackPos(0),
+ m_iMinButtonState(FWL_PARTSTATE_SCB_Normal),
+ m_iMaxButtonState(FWL_PARTSTATE_SCB_Normal),
+ m_iThumbButtonState(FWL_PARTSTATE_SCB_Normal),
+ m_fLastTrackPos(0),
+ m_cpTrackPointX(0),
+ m_cpTrackPointY(0),
+ m_iMinTrackState(FWL_PARTSTATE_SCB_Normal),
+ m_iMaxTrackState(FWL_PARTSTATE_SCB_Normal),
+ m_iMouseWheel(0),
+ m_bTrackMouseLeave(FALSE),
+ m_bMouseHover(FALSE),
+ m_bRepaintThumb(FALSE),
+ m_bMouseDown(FALSE),
+ m_fButtonLen(0),
+ m_bMinSize(FALSE),
+ m_bCustomLayout(FALSE),
+ m_fMinThumb(FWL_SCROLLBAR_MinThumb) {
+ m_rtClient.Reset();
+ m_rtThumb.Reset();
+ m_rtMinBtn.Reset();
+ m_rtMaxBtn.Reset();
+ m_rtMinTrack.Reset();
+ m_rtMaxTrack.Reset();
+}
+CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {}
+FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_ScrollBar;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ScrollBarImp::GetClassID() const {
+ return FWL_CLASSHASH_ScrollBar;
+}
+FWL_ERR CFWL_ScrollBarImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ScrollBarImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ScrollBarImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_ScrollBarImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_ScrollBarImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
+ FX_FLOAT* pfMinWidth =
+ (FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth);
+ _FWL_RETURN_VALUE_IF_FAIL(pfMinWidth, FWL_ERR_Indefinite);
+ if (IsVertical()) {
+ rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3);
} else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ScrollBarImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- Layout();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_SCB_Edge, pTheme, pMatrix);
- }
- DrawTrack(pGraphics, pTheme, TRUE, pMatrix);
- DrawTrack(pGraphics, pTheme, FALSE, pMatrix);
- DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix);
- DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix);
- DrawThumb(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
-}
-inline FX_BOOL CFWL_ScrollBarImp::IsVertical()
-{
- return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert;
-}
-FWL_ERR CFWL_ScrollBarImp::GetRange(FX_FLOAT &fMin, FX_FLOAT &fMax)
-{
- fMin = m_fRangeMin;
- fMax = m_fRangeMax;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax)
-{
- m_fRangeMin = fMin;
- m_fRangeMax = fMax;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ScrollBarImp::GetPageSize()
-{
- return m_fPageSize;
-}
-FWL_ERR CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize)
-{
- m_fPageSize = fPageSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ScrollBarImp::GetStepSize()
-{
- return m_fStepSize;
-}
-FWL_ERR CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize)
-{
- m_fStepSize = fStepSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ScrollBarImp::GetPos()
-{
- return m_fPos;
-}
-FWL_ERR CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos)
-{
- m_fPos = fPos;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ScrollBarImp::GetTrackPos()
-{
- return m_fTrackPos;
-}
-FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos)
-{
- m_fTrackPos = fTrackPos;
- CalcThumbButtonRect(m_rtThumb);
- CalcMinTrackRect(m_rtMinTrack);
- CalcMaxTrackRect(m_rtMaxTrack);
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_ScrollBarImp::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos )
-{
- switch (dwCode) {
- case FWL_SCBCODE_Min:
- case FWL_SCBCODE_Max:
- case FWL_SCBCODE_PageBackward:
- case FWL_SCBCODE_PageForward:
- case FWL_SCBCODE_StepBackward:
- break;
- case FWL_SCBCODE_StepForward:
- break;
- case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos:
- case FWL_SCBCODE_EndScroll:
- break;
- default: {
- return FALSE;
- }
- }
- return OnScroll(dwCode, fPos);
-}
-int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer)
-{
- if (m_hTimer) {
- FWL_StopTimer(m_hTimer);
- }
- if (!SendEvent()) {
- m_hTimer = FWL_StartTimer(this, 0);
- }
- return 1;
-}
-FWL_ERR CFWL_ScrollBarImp::SetOuter(IFWL_Widget *pOuter)
-{
- m_pOuter = pOuter;
- return FWL_ERR_Succeeded;
-}
-void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FX_BOOL bLower , const CFX_Matrix *pMatrix )
-{
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = bLower ? FWL_PART_SCB_LowerTrack : FWL_PART_SCB_UpperTrack;
- param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ?
- FWL_PARTSTATE_SCB_Disabled : (bLower ? m_iMinTrackState : m_iMaxTrackState);
- param.m_pGraphics = pGraphics;
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = bLower ? m_rtMinTrack : m_rtMaxTrack;
+ rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth));
+ }
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ScrollBarImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ Layout();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_SCB_Edge, pTheme, pMatrix);
+ }
+ DrawTrack(pGraphics, pTheme, TRUE, pMatrix);
+ DrawTrack(pGraphics, pTheme, FALSE, pMatrix);
+ DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix);
+ DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix);
+ DrawThumb(pGraphics, pTheme, pMatrix);
+ return FWL_ERR_Succeeded;
+}
+inline FX_BOOL CFWL_ScrollBarImp::IsVertical() {
+ return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert;
+}
+FWL_ERR CFWL_ScrollBarImp::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
+ fMin = m_fRangeMin;
+ fMax = m_fRangeMax;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
+ m_fRangeMin = fMin;
+ m_fRangeMax = fMax;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ScrollBarImp::GetPageSize() {
+ return m_fPageSize;
+}
+FWL_ERR CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize) {
+ m_fPageSize = fPageSize;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ScrollBarImp::GetStepSize() {
+ return m_fStepSize;
+}
+FWL_ERR CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize) {
+ m_fStepSize = fStepSize;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ScrollBarImp::GetPos() {
+ return m_fPos;
+}
+FWL_ERR CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos) {
+ m_fPos = fPos;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() {
+ return m_fTrackPos;
+}
+FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) {
+ m_fTrackPos = fTrackPos;
+ CalcThumbButtonRect(m_rtThumb);
+ CalcMinTrackRect(m_rtMinTrack);
+ CalcMaxTrackRect(m_rtMaxTrack);
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_ScrollBarImp::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) {
+ switch (dwCode) {
+ case FWL_SCBCODE_Min:
+ case FWL_SCBCODE_Max:
+ case FWL_SCBCODE_PageBackward:
+ case FWL_SCBCODE_PageForward:
+ case FWL_SCBCODE_StepBackward:
+ break;
+ case FWL_SCBCODE_StepForward:
+ break;
+ case FWL_SCBCODE_Pos:
+ case FWL_SCBCODE_TrackPos:
+ case FWL_SCBCODE_EndScroll:
+ break;
+ default: { return FALSE; }
+ }
+ return OnScroll(dwCode, fPos);
+}
+int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer) {
+ if (m_hTimer) {
+ FWL_StopTimer(m_hTimer);
+ }
+ if (!SendEvent()) {
+ m_hTimer = FWL_StartTimer(this, 0);
+ }
+ return 1;
+}
+FWL_ERR CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) {
+ m_pOuter = pOuter;
+ return FWL_ERR_Succeeded;
+}
+void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ FX_BOOL bLower,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = bLower ? FWL_PART_SCB_LowerTrack : FWL_PART_SCB_UpperTrack;
+ param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+ ? FWL_PARTSTATE_SCB_Disabled
+ : (bLower ? m_iMinTrackState : m_iMaxTrackState);
+ param.m_pGraphics = pGraphics;
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = bLower ? m_rtMinTrack : m_rtMaxTrack;
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ FX_BOOL bMinBtn,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = bMinBtn ? FWL_PART_SCB_ForeArrow : FWL_PART_SCB_BackArrow;
+ param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+ ? FWL_PARTSTATE_SCB_Disabled
+ : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState);
+ param.m_pGraphics = pGraphics;
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn;
+ if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) {
pTheme->DrawBackground(¶m);
-}
-void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FX_BOOL bMinBtn , const CFX_Matrix *pMatrix )
-{
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = bMinBtn ? FWL_PART_SCB_ForeArrow : FWL_PART_SCB_BackArrow;
- param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ?
- FWL_PARTSTATE_SCB_Disabled : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState);
- param.m_pGraphics = pGraphics;
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn;
- if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) {
- pTheme->DrawBackground(¶m);
- }
-}
-void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix )
-{
- if (!IsEnabled()) {
- }
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_SCB_Thumb;
- param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ?
- FWL_PARTSTATE_SCB_Disabled : m_iThumbButtonState;
- param.m_pGraphics = pGraphics;
- param.m_matrix.Concat(*pMatrix);
- param.m_rtPart = m_rtThumb;
- pTheme->DrawBackground(¶m);
-}
-void CFWL_ScrollBarImp::Layout()
-{
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- m_fMinThumb = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_CAPACITY_SCB_Size);
- m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface);
- GetClientRect(m_rtClient);
- CalcButtonLen();
- CalcMinButtonRect(m_rtMinBtn);
- CalcMaxButtonRect(m_rtMaxBtn);
- CalcThumbButtonRect(m_rtThumb);
- CalcMinTrackRect(m_rtMinTrack);
- CalcMaxTrackRect(m_rtMaxTrack);
-}
-void CFWL_ScrollBarImp::CalcButtonLen()
-{
- m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height;
- FX_FLOAT fLength = IsVertical() ? m_rtClient.height : m_rtClient.width;
- if (fLength < m_fButtonLen * 2) {
- m_fButtonLen = fLength / 2;
- m_bMinSize = TRUE;
+ }
+}
+void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ if (!IsEnabled()) {
+ }
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_SCB_Thumb;
+ param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+ ? FWL_PARTSTATE_SCB_Disabled
+ : m_iThumbButtonState;
+ param.m_pGraphics = pGraphics;
+ param.m_matrix.Concat(*pMatrix);
+ param.m_rtPart = m_rtThumb;
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_ScrollBarImp::Layout() {
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ m_fMinThumb = *(FX_FLOAT*)pTheme->GetCapacity(&part, FWL_CAPACITY_SCB_Size);
+ m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface);
+ GetClientRect(m_rtClient);
+ CalcButtonLen();
+ CalcMinButtonRect(m_rtMinBtn);
+ CalcMaxButtonRect(m_rtMaxBtn);
+ CalcThumbButtonRect(m_rtThumb);
+ CalcMinTrackRect(m_rtMinTrack);
+ CalcMaxTrackRect(m_rtMaxTrack);
+}
+void CFWL_ScrollBarImp::CalcButtonLen() {
+ m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height;
+ FX_FLOAT fLength = IsVertical() ? m_rtClient.height : m_rtClient.width;
+ if (fLength < m_fButtonLen * 2) {
+ m_fButtonLen = fLength / 2;
+ m_bMinSize = TRUE;
+ } else {
+ m_bMinSize = FALSE;
+ }
+}
+void CFWL_ScrollBarImp::CalcMinButtonRect(CFX_RectF& rect) {
+ if (m_bCustomLayout) {
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ CFWL_ThemePart pPart;
+ pPart.m_rtPart = m_rtMinBtn;
+ pPart.m_pWidget = m_pInterface;
+ pPart.m_iPart = FWL_PART_SCB_ForeArrow;
+ pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+ ? FWL_PARTSTATE_SCB_Disabled
+ : m_iMinButtonState;
+ pTheme->GetPartRect(&pPart, rect);
+ } else {
+ rect.left = m_rtClient.left;
+ rect.top = m_rtClient.top;
+ rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen;
+ rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height;
+ }
+}
+void CFWL_ScrollBarImp::CalcMaxButtonRect(CFX_RectF& rect) {
+ if (m_bCustomLayout) {
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ CFWL_ThemePart pPart;
+ pPart.m_rtPart = m_rtMaxBtn;
+ pPart.m_pWidget = m_pInterface;
+ pPart.m_iPart = FWL_PART_SCB_BackArrow;
+ pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
+ ? FWL_PARTSTATE_SCB_Disabled
+ : m_iMaxButtonState;
+ pTheme->GetPartRect(&pPart, rect);
+ } else {
+ rect.left =
+ IsVertical() ? m_rtClient.left : m_rtClient.right() - m_fButtonLen;
+ rect.top =
+ IsVertical() ? m_rtClient.bottom() - m_fButtonLen : m_rtClient.top;
+ rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen;
+ rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height;
+ }
+}
+void CFWL_ScrollBarImp::CalcThumbButtonRect(CFX_RectF& rect) {
+ if (!IsEnabled()) {
+ m_rtThumb.Reset();
+ return;
+ }
+ if (m_bMinSize) {
+ m_rtThumb.Empty();
+ return;
+ }
+ FX_FLOAT fRange = m_fRangeMax - m_fRangeMin;
+ memset(&rect, 0, sizeof(CFX_Rect));
+ if (fRange < 0) {
+ if (IsVertical()) {
+ rect.Set(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, 0);
} else {
- m_bMinSize = FALSE;
- }
-}
-void CFWL_ScrollBarImp::CalcMinButtonRect(CFX_RectF &rect)
-{
- if (m_bCustomLayout) {
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- CFWL_ThemePart pPart;
- pPart.m_rtPart = m_rtMinBtn;
- pPart.m_pWidget = m_pInterface;
- pPart.m_iPart = FWL_PART_SCB_ForeArrow;
- pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ? FWL_PARTSTATE_SCB_Disabled : m_iMinButtonState;
- pTheme->GetPartRect(&pPart, rect);
+ rect.Set(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height);
+ }
+ return;
+ }
+ CFX_RectF rtClient = m_rtClient;
+ FX_FLOAT fLength = IsVertical() ? rtClient.height : rtClient.width;
+ FX_FLOAT fSize = m_fButtonLen;
+ if (m_bCustomLayout) {
+ if (IsVertical()) {
+ fLength = fLength - m_rtMinBtn.height - m_rtMaxBtn.height;
+ if (fLength < m_rtMinBtn.height || fLength < m_rtMaxBtn.height) {
+ fLength = 0.0f;
+ }
} else {
- rect.left = m_rtClient.left;
+ fLength = fLength - m_rtMinBtn.width - m_rtMaxBtn.width;
+ if (fLength < m_rtMinBtn.width || fLength < m_rtMaxBtn.width) {
+ fLength = 0.0f;
+ }
+ }
+ } else {
+ fLength -= fSize * 2.0f;
+ if (fLength < fSize) {
+ fLength = 0.0f;
+ }
+ }
+ FX_FLOAT fThumbSize = fLength * fLength / (fRange + fLength);
+ if (fThumbSize < m_fMinThumb) {
+ fThumbSize = m_fMinThumb;
+ }
+ FX_FLOAT fDiff = fLength - fThumbSize;
+ if (fDiff < 0.0f) {
+ fDiff = 0.0f;
+ }
+ FX_FLOAT fTrackPos = m_fTrackPos;
+ if (fTrackPos > m_fRangeMax) {
+ fTrackPos = m_fRangeMax;
+ }
+ if (fTrackPos < m_fRangeMin) {
+ fTrackPos = m_fRangeMin;
+ }
+ _FWL_RETURN_IF_FAIL(fRange);
+ if (m_bCustomLayout) {
+ FX_FLOAT iPos = fDiff * (fTrackPos - m_fRangeMin) / fRange;
+ rect.left = rtClient.left;
+ if (!IsVertical()) {
+ if ((m_rtMinBtn.right() == m_rtMaxBtn.left && m_rtMinBtn.width > 0 &&
+ m_rtMaxBtn.width > 0) ||
+ (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width)) {
+ rect.left += iPos;
+ } else {
+ rect.left += m_rtMinBtn.right() + iPos;
+ }
+ }
+ rect.top = rtClient.top;
+ if (IsVertical()) {
+ if ((m_rtMinBtn.bottom() == m_rtMaxBtn.top && m_rtMinBtn.height > 0 &&
+ m_rtMaxBtn.height > 0) ||
+ (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height)) {
+ rect.top += iPos;
+ } else {
+ rect.top += m_rtMinBtn.bottom() + iPos;
+ }
+ }
+ rect.width = IsVertical() ? rtClient.width : fThumbSize;
+ rect.height = IsVertical() ? fThumbSize : rtClient.height;
+ } else {
+ FX_FLOAT iPos = fSize + fDiff * (fTrackPos - m_fRangeMin) / fRange;
+ rect.left = rtClient.left;
+ if (!IsVertical()) {
+ rect.left += iPos;
+ }
+ rect.top = rtClient.top;
+ if (IsVertical()) {
+ rect.top += iPos;
+ }
+ rect.width = IsVertical() ? rtClient.width : fThumbSize;
+ rect.height = IsVertical() ? fThumbSize : rtClient.height;
+ }
+}
+void CFWL_ScrollBarImp::CalcMinTrackRect(CFX_RectF& rect) {
+ if (m_bMinSize) {
+ rect.Empty();
+ return;
+ }
+ FX_FLOAT fBottom = m_rtThumb.bottom();
+ FX_FLOAT fRight = m_rtThumb.right();
+ FX_FLOAT ix = (m_rtThumb.left + fRight) / 2;
+ FX_FLOAT iy = (m_rtThumb.top + fBottom) / 2;
+ rect.left = m_rtClient.left;
+ rect.top = m_rtClient.top;
+ FX_BOOL bVertical = IsVertical();
+ rect.width = bVertical ? m_rtClient.width : ix;
+ rect.height = bVertical ? iy : m_rtClient.height;
+ if (m_bCustomLayout) {
+ if (bVertical) {
+ if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) {
rect.top = m_rtClient.top;
- rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen;
- rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height;
- }
-}
-void CFWL_ScrollBarImp::CalcMaxButtonRect(CFX_RectF &rect)
-{
- if (m_bCustomLayout) {
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- CFWL_ThemePart pPart;
- pPart.m_rtPart = m_rtMaxBtn;
- pPart.m_pWidget = m_pInterface;
- pPart.m_iPart = FWL_PART_SCB_BackArrow;
- pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ? FWL_PARTSTATE_SCB_Disabled : m_iMaxButtonState;
- pTheme->GetPartRect(&pPart, rect);
- } else {
- rect.left = IsVertical() ? m_rtClient.left : m_rtClient.right() - m_fButtonLen;
- rect.top = IsVertical() ? m_rtClient.bottom() - m_fButtonLen : m_rtClient.top;
- rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen;
- rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height;
- }
-}
-void CFWL_ScrollBarImp::CalcThumbButtonRect(CFX_RectF &rect)
-{
- if (!IsEnabled()) {
- m_rtThumb.Reset();
- return;
- }
- if (m_bMinSize) {
- m_rtThumb.Empty();
- return;
- }
- FX_FLOAT fRange = m_fRangeMax - m_fRangeMin;
- memset(&rect, 0, sizeof(CFX_Rect));
- if (fRange < 0) {
- if (IsVertical()) {
- rect.Set(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, 0);
- } else {
- rect.Set(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height);
- }
- return;
- }
- CFX_RectF rtClient = m_rtClient;
- FX_FLOAT fLength = IsVertical() ? rtClient.height : rtClient.width;
- FX_FLOAT fSize = m_fButtonLen;
- if (m_bCustomLayout) {
- if (IsVertical()) {
- fLength = fLength - m_rtMinBtn.height - m_rtMaxBtn.height;
- if (fLength < m_rtMinBtn.height || fLength < m_rtMaxBtn.height) {
- fLength = 0.0f;
- }
- } else {
- fLength = fLength - m_rtMinBtn.width - m_rtMaxBtn.width;
- if (fLength < m_rtMinBtn.width || fLength < m_rtMaxBtn.width) {
- fLength = 0.0f;
- }
- }
+ } else if (m_rtMinBtn.top < m_rtThumb.top) {
+ rect.top = m_rtMinBtn.bottom();
+ rect.height -= (m_rtMinBtn.bottom() - m_rtClient.top);
+ }
} else {
- fLength -= fSize * 2.0f;
- if (fLength < fSize) {
- fLength = 0.0f;
- }
- }
- FX_FLOAT fThumbSize = fLength * fLength / (fRange + fLength);
- if (fThumbSize < m_fMinThumb) {
- fThumbSize = m_fMinThumb;
- }
- FX_FLOAT fDiff = fLength - fThumbSize;
- if (fDiff < 0.0f) {
- fDiff = 0.0f;
- }
- FX_FLOAT fTrackPos = m_fTrackPos;
- if (fTrackPos > m_fRangeMax) {
- fTrackPos = m_fRangeMax;
- }
- if (fTrackPos < m_fRangeMin) {
- fTrackPos = m_fRangeMin;
- }
- _FWL_RETURN_IF_FAIL(fRange);
- if (m_bCustomLayout) {
- FX_FLOAT iPos = fDiff * (fTrackPos - m_fRangeMin) / fRange;
- rect.left = rtClient.left;
- if (!IsVertical()) {
- if ((m_rtMinBtn.right() == m_rtMaxBtn.left && m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) || (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width)) {
- rect.left += iPos;
- } else {
- rect.left += m_rtMinBtn.right() + iPos;
- }
- }
- rect.top = rtClient.top;
- if (IsVertical()) {
- if ((m_rtMinBtn.bottom() == m_rtMaxBtn.top && m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) || (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height)) {
- rect.top += iPos;
- } else {
- rect.top += m_rtMinBtn.bottom() + iPos;
- }
- }
- rect.width = IsVertical() ? rtClient.width : fThumbSize;
- rect.height = IsVertical() ? fThumbSize : rtClient.height;
+ if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) {
+ rect.left = m_rtClient.left;
+ } else if (m_rtMinBtn.left < m_rtThumb.left) {
+ rect.left = m_rtMinBtn.right();
+ rect.width -= (m_rtMinBtn.right() - m_rtClient.left);
+ }
+ }
+ }
+}
+void CFWL_ScrollBarImp::CalcMaxTrackRect(CFX_RectF& rect) {
+ if (m_bMinSize) {
+ rect.Empty();
+ return;
+ }
+ FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2;
+ FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2;
+ FX_BOOL bVertical = IsVertical();
+ rect.left = bVertical ? m_rtClient.left : ix;
+ rect.top = bVertical ? iy : m_rtClient.top;
+ rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix;
+ rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height;
+ if (m_bCustomLayout) {
+ if (bVertical) {
+ if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 &&
+ m_rtMaxBtn.height > 0) {
+ rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top);
+ } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) {
+ rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top);
+ }
} else {
- FX_FLOAT iPos = fSize + fDiff * (fTrackPos - m_fRangeMin) / fRange;
- rect.left = rtClient.left;
- if (!IsVertical()) {
- rect.left += iPos;
- }
- rect.top = rtClient.top;
- if (IsVertical()) {
- rect.top += iPos;
- }
- rect.width = IsVertical() ? rtClient.width : fThumbSize;
- rect.height = IsVertical() ? fThumbSize : rtClient.height;
- }
-}
-void CFWL_ScrollBarImp::CalcMinTrackRect(CFX_RectF &rect)
-{
- if (m_bMinSize) {
- rect.Empty();
- return;
- }
- FX_FLOAT fBottom = m_rtThumb.bottom();
- FX_FLOAT fRight = m_rtThumb.right();
- FX_FLOAT ix = (m_rtThumb.left + fRight) / 2;
- FX_FLOAT iy = (m_rtThumb.top + fBottom) / 2;
- rect.left = m_rtClient.left;
- rect.top = m_rtClient.top;
- FX_BOOL bVertical = IsVertical();
- rect.width = bVertical ? m_rtClient.width : ix;
- rect.height = bVertical ? iy : m_rtClient.height;
- if (m_bCustomLayout) {
- if (bVertical) {
- if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) {
- rect.top = m_rtClient.top;
- } else if (m_rtMinBtn.top < m_rtThumb.top) {
- rect.top = m_rtMinBtn.bottom();
- rect.height -= (m_rtMinBtn.bottom() - m_rtClient.top);
- }
- } else {
- if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) {
- rect.left = m_rtClient.left;
- } else if (m_rtMinBtn.left < m_rtThumb.left) {
- rect.left = m_rtMinBtn.right();
- rect.width -= (m_rtMinBtn.right() - m_rtClient.left);
- }
- }
- }
-}
-void CFWL_ScrollBarImp::CalcMaxTrackRect(CFX_RectF &rect)
-{
- if (m_bMinSize) {
- rect.Empty();
- return;
- }
- FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2;
- FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2;
- FX_BOOL bVertical = IsVertical();
- rect.left = bVertical ? m_rtClient.left : ix;
- rect.top = bVertical ? iy : m_rtClient.top;
- rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix;
- rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height;
- if (m_bCustomLayout) {
- if (bVertical) {
- if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) {
- rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top);
- } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) {
- rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top);
- }
- } else {
- if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) {
- rect.width -= (m_rtClient.right() - m_rtMinBtn.left);
- } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) {
- rect.width -= (m_rtClient.right() - m_rtMaxBtn.left);
- }
- }
- }
-}
-FX_FLOAT CFWL_ScrollBarImp::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy)
-{
- FX_FLOAT fDiffX = fx - m_cpTrackPointX;
- FX_FLOAT fDiffY = fy - m_cpTrackPointY;
- FX_FLOAT fRange = m_fRangeMax - m_fRangeMin;
- FX_FLOAT fPos;
- if (m_bCustomLayout) {
- if (IsVertical()) {
- if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) {
- fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height);
- } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) {
- fPos = fRange * fDiffY / (m_rtMinBtn.top - m_rtClient.top - m_rtThumb.height);
- } else {
- fPos = fRange * fDiffY / (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height);
- }
- } else {
- if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) {
- fPos = fRange * fDiffX / (m_rtClient.width - m_rtThumb.width);
- } else if (m_rtMinBtn.right() == m_rtMaxBtn.left) {
- fPos = fRange * fDiffX / (m_rtMinBtn.left - m_rtClient.left - m_rtThumb.width);
- } else {
- fPos = fRange * fDiffX / (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width);
- }
- }
+ if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 &&
+ m_rtMaxBtn.width > 0) {
+ rect.width -= (m_rtClient.right() - m_rtMinBtn.left);
+ } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) {
+ rect.width -= (m_rtClient.right() - m_rtMaxBtn.left);
+ }
+ }
+ }
+}
+FX_FLOAT CFWL_ScrollBarImp::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) {
+ FX_FLOAT fDiffX = fx - m_cpTrackPointX;
+ FX_FLOAT fDiffY = fy - m_cpTrackPointY;
+ FX_FLOAT fRange = m_fRangeMax - m_fRangeMin;
+ FX_FLOAT fPos;
+ if (m_bCustomLayout) {
+ if (IsVertical()) {
+ if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) {
+ fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height);
+ } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) {
+ fPos = fRange * fDiffY /
+ (m_rtMinBtn.top - m_rtClient.top - m_rtThumb.height);
+ } else {
+ fPos = fRange * fDiffY /
+ (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height);
+ }
} else {
- if (IsVertical()) {
- fPos = fRange * fDiffY / (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height);
- } else {
- fPos = fRange * fDiffX / (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width);
- }
- }
- fPos += m_fLastTrackPos;
- if (fPos < m_fRangeMin) {
- fPos = m_fRangeMin;
- }
- if (fPos > m_fRangeMax) {
- fPos = m_fRangeMax;
- }
- return fPos;
-}
-void CFWL_ScrollBarImp::GetTrackRect(CFX_RectF &rect, FX_BOOL bLower )
-{
- FX_BOOL bDisabled = m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled;
- if (bDisabled || m_bCustomLayout) {
- rect = bLower ? m_rtMinTrack : m_rtMaxTrack;
+ if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) {
+ fPos = fRange * fDiffX / (m_rtClient.width - m_rtThumb.width);
+ } else if (m_rtMinBtn.right() == m_rtMaxBtn.left) {
+ fPos = fRange * fDiffX /
+ (m_rtMinBtn.left - m_rtClient.left - m_rtThumb.width);
+ } else {
+ fPos = fRange * fDiffX /
+ (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width);
+ }
+ }
+ } else {
+ if (IsVertical()) {
+ fPos = fRange * fDiffY /
+ (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height);
} else {
- FX_FLOAT fW = m_rtThumb.width / 2;
- FX_FLOAT fH = m_rtThumb.height / 2;
- FX_BOOL bVert = IsVertical();
- if (bLower) {
- if (bVert) {
- FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height;
- fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f;
- rect.Set(m_rtMinTrack.left,
- m_rtMinTrack.top + m_rtMinBtn.height,
- m_rtMinTrack.width,
- fMinTrackHeight);
- } else {
- FX_FLOAT fMinTrackWidth = m_rtMinTrack.width - fW - m_rtMinBtn.width + 2;
- fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f;
- rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1,
- m_rtMinTrack.top,
- fMinTrackWidth,
- m_rtMinTrack.height);
- }
- } else {
- if (bVert) {
- FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height;
- fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f;
- rect.Set(m_rtMaxTrack.left,
- m_rtMaxTrack.top + fH,
- m_rtMaxTrack.width,
- fMaxTrackHeight);
- } else {
- FX_FLOAT fMaxTrackWidth = m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2;
- fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f;
- rect.Set(m_rtMaxTrack.left + fW,
- m_rtMaxTrack.top,
- fMaxTrackWidth,
- m_rtMaxTrack.height);
- }
- }
- }
-}
-FX_BOOL CFWL_ScrollBarImp::SendEvent()
-{
- if (m_iMinButtonState == FWL_PARTSTATE_SCB_Pressed) {
- DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos);
- return FALSE;
- }
- if (m_iMaxButtonState == FWL_PARTSTATE_SCB_Pressed) {
- DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos);
- return FALSE;
- }
- if (m_iMinTrackState == FWL_PARTSTATE_SCB_Pressed) {
- DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos);
- return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
- }
- if (m_iMaxTrackState == FWL_PARTSTATE_SCB_Pressed) {
- DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos);
- return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
- }
- if (m_iMouseWheel) {
- FX_WORD dwCode = m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward;
- DoScroll(dwCode, m_fTrackPos);
- }
- return TRUE;
-}
-FX_BOOL CFWL_ScrollBarImp::OnScroll(FX_DWORD dwCode, FX_FLOAT fPos)
-{
- FX_BOOL bRet = TRUE;
- CFWL_EvtScroll ev;
- ev.m_iScrollCode = dwCode;
- ev.m_pSrcTarget = m_pInterface;
- ev.m_fPos = fPos;
- ev.m_pRet = &bRet;
- DispatchEvent(&ev);
- return bRet;
-}
-CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- int32_t iRet = 1;
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- if (dwMsgCode == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave();
- break;
- }
- default: {
- iRet = 0;
- }
- }
- } else if (dwMsgCode == FWL_MSGHASH_MouseWheel) {
- CFWL_MsgMouseWheel *pMsg = (CFWL_MsgMouseWheel*)pMessage;
- OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX, pMsg->m_fDeltaY);
+ fPos = fRange * fDiffX /
+ (m_rtMaxBtn.left - m_rtMinBtn.right() - m_rtThumb.width);
+ }
+ }
+ fPos += m_fLastTrackPos;
+ if (fPos < m_fRangeMin) {
+ fPos = m_fRangeMin;
+ }
+ if (fPos > m_fRangeMax) {
+ fPos = m_fRangeMax;
+ }
+ return fPos;
+}
+void CFWL_ScrollBarImp::GetTrackRect(CFX_RectF& rect, FX_BOOL bLower) {
+ FX_BOOL bDisabled = m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled;
+ if (bDisabled || m_bCustomLayout) {
+ rect = bLower ? m_rtMinTrack : m_rtMaxTrack;
+ } else {
+ FX_FLOAT fW = m_rtThumb.width / 2;
+ FX_FLOAT fH = m_rtThumb.height / 2;
+ FX_BOOL bVert = IsVertical();
+ if (bLower) {
+ if (bVert) {
+ FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height;
+ fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f;
+ rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height,
+ m_rtMinTrack.width, fMinTrackHeight);
+ } else {
+ FX_FLOAT fMinTrackWidth =
+ m_rtMinTrack.width - fW - m_rtMinBtn.width + 2;
+ fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f;
+ rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top,
+ fMinTrackWidth, m_rtMinTrack.height);
+ }
} else {
- iRet = 0;
- }
- return iRet;
-}
-FWL_ERR CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_ScrollBarImpDelegate::OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy)
-{
- if (!m_pOwner->IsEnabled()) {
- return;
- }
- m_pOwner->m_bMouseDown = TRUE;
- m_pOwner->SetGrab(TRUE);
- m_pOwner->m_cpTrackPointX = fx;
- m_pOwner->m_cpTrackPointY = fy;
- m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos;
- if (m_pOwner->m_rtMinBtn.Contains(fx, fy)) {
- DoMouseDown(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
+ if (bVert) {
+ FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height;
+ fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f;
+ rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width,
+ fMaxTrackHeight);
+ } else {
+ FX_FLOAT fMaxTrackWidth =
+ m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2;
+ fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f;
+ rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth,
+ m_rtMaxTrack.height);
+ }
+ }
+ }
+}
+FX_BOOL CFWL_ScrollBarImp::SendEvent() {
+ if (m_iMinButtonState == FWL_PARTSTATE_SCB_Pressed) {
+ DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos);
+ return FALSE;
+ }
+ if (m_iMaxButtonState == FWL_PARTSTATE_SCB_Pressed) {
+ DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos);
+ return FALSE;
+ }
+ if (m_iMinTrackState == FWL_PARTSTATE_SCB_Pressed) {
+ DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos);
+ return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
+ }
+ if (m_iMaxTrackState == FWL_PARTSTATE_SCB_Pressed) {
+ DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos);
+ return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
+ }
+ if (m_iMouseWheel) {
+ FX_WORD dwCode =
+ m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward;
+ DoScroll(dwCode, m_fTrackPos);
+ }
+ return TRUE;
+}
+FX_BOOL CFWL_ScrollBarImp::OnScroll(FX_DWORD dwCode, FX_FLOAT fPos) {
+ FX_BOOL bRet = TRUE;
+ CFWL_EvtScroll ev;
+ ev.m_iScrollCode = dwCode;
+ ev.m_pSrcTarget = m_pInterface;
+ ev.m_fPos = fPos;
+ ev.m_pRet = &bRet;
+ DispatchEvent(&ev);
+ return bRet;
+}
+CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ int32_t iRet = 1;
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ if (dwMsgCode == FWL_MSGHASH_Mouse) {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
+ break;
+ }
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
+ break;
+ }
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
+ break;
+ }
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave();
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ } else if (dwMsgCode == FWL_MSGHASH_MouseWheel) {
+ CFWL_MsgMouseWheel* pMsg = (CFWL_MsgMouseWheel*)pMessage;
+ OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX,
+ pMsg->m_fDeltaY);
+ } else {
+ iRet = 0;
+ }
+ return iRet;
+}
+FWL_ERR CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_ScrollBarImpDelegate::OnLButtonDown(FX_DWORD dwFlags,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!m_pOwner->IsEnabled()) {
+ return;
+ }
+ m_pOwner->m_bMouseDown = TRUE;
+ m_pOwner->SetGrab(TRUE);
+ m_pOwner->m_cpTrackPointX = fx;
+ m_pOwner->m_cpTrackPointY = fy;
+ m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos;
+ if (m_pOwner->m_rtMinBtn.Contains(fx, fy)) {
+ DoMouseDown(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
+ } else {
+ if (m_pOwner->m_rtThumb.Contains(fx, fy)) {
+ DoMouseDown(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx,
+ fy);
} else {
- if (m_pOwner->m_rtThumb.Contains(fx, fy)) {
- DoMouseDown(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
+ if (m_pOwner->m_rtMaxBtn.Contains(fx, fy)) {
+ DoMouseDown(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx,
+ fy);
+ } else {
+ if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) {
+ DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx,
+ fy);
} else {
- if (m_pOwner->m_rtMaxBtn.Contains(fx, fy)) {
- DoMouseDown(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
- } else {
- if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) {
- DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
- } else {
- DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
- }
- }
+ DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx,
+ fy);
}
- }
- if (!m_pOwner->SendEvent()) {
- m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse);
- }
-}
-void CFWL_ScrollBarImpDelegate::OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy)
-{
- FWL_StopTimer(m_pOwner->m_hTimer);
- m_pOwner->m_bMouseDown = FALSE;
- DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
- DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
- DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
- DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
- DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
- m_pOwner->SetGrab(FALSE);
-}
-void CFWL_ScrollBarImpDelegate::OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy)
-{
- DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
- DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
- DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
- DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
- DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
-}
-void CFWL_ScrollBarImpDelegate::OnMouseLeave()
-{
- DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState);
- DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState);
- DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState);
- DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState);
- DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState);
-}
-void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, FX_FLOAT fy, FX_DWORD dwFlags, FX_FLOAT fDeltaX, FX_FLOAT fDeltaY)
-{
- m_pOwner->m_iMouseWheel = (int32_t)fDeltaX;
- m_pOwner->SendEvent();
- m_pOwner->m_iMouseWheel = 0;
-}
-void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState, FX_FLOAT fx, FX_FLOAT fy)
-{
- if (!rtItem.Contains(fx, fy)) {
- return;
- }
- if (iState == FWL_PARTSTATE_SCB_Pressed) {
- return;
- }
- iState = FWL_PARTSTATE_SCB_Pressed;
- m_pOwner->Repaint(&rtItem);
-}
-void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState, FX_FLOAT fx, FX_FLOAT fy)
-{
- int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered : FWL_PARTSTATE_SCB_Normal;
+ }
+ }
+ }
+ if (!m_pOwner->SendEvent()) {
+ m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse);
+ }
+}
+void CFWL_ScrollBarImpDelegate::OnLButtonUp(FX_DWORD dwFlags,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ FWL_StopTimer(m_pOwner->m_hTimer);
+ m_pOwner->m_bMouseDown = FALSE;
+ DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
+ DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
+ DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
+ DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
+ DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
+ m_pOwner->SetGrab(FALSE);
+}
+void CFWL_ScrollBarImpDelegate::OnMouseMove(FX_DWORD dwFlags,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
+ DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
+ DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
+ DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
+ DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
+}
+void CFWL_ScrollBarImpDelegate::OnMouseLeave() {
+ DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState);
+ DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState);
+ DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState);
+ DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState);
+ DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState);
+}
+void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx,
+ FX_FLOAT fy,
+ FX_DWORD dwFlags,
+ FX_FLOAT fDeltaX,
+ FX_FLOAT fDeltaY) {
+ m_pOwner->m_iMouseWheel = (int32_t)fDeltaX;
+ m_pOwner->SendEvent();
+ m_pOwner->m_iMouseWheel = 0;
+}
+void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!rtItem.Contains(fx, fy)) {
+ return;
+ }
+ if (iState == FWL_PARTSTATE_SCB_Pressed) {
+ return;
+ }
+ iState = FWL_PARTSTATE_SCB_Pressed;
+ m_pOwner->Repaint(&rtItem);
+}
+void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered
+ : FWL_PARTSTATE_SCB_Normal;
+ if (iState == iNewState) {
+ return;
+ }
+ iState = iNewState;
+ m_pOwner->Repaint(&rtItem);
+ m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos);
+}
+void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!m_pOwner->m_bMouseDown) {
+ int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered
+ : FWL_PARTSTATE_SCB_Normal;
if (iState == iNewState) {
- return;
+ return;
}
iState = iNewState;
m_pOwner->Repaint(&rtItem);
- m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos);
-}
-void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState, FX_FLOAT fx, FX_FLOAT fy)
-{
- if (!m_pOwner->m_bMouseDown) {
- int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered : FWL_PARTSTATE_SCB_Normal;
- if (iState == iNewState) {
- return;
- }
- iState = iNewState;
- m_pOwner->Repaint(&rtItem);
- } else if ((2 == iItem) && (m_pOwner->m_iThumbButtonState == FWL_PARTSTATE_SCB_Pressed)) {
- FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy);
- m_pOwner->m_fTrackPos = fPos;
- m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos);
- }
-}
-void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState)
-{
- if (iState == FWL_PARTSTATE_SCB_Normal) {
- return;
- }
- iState = FWL_PARTSTATE_SCB_Normal;
- m_pOwner->Repaint(&rtItem);
-}
-void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState)
-{
- if (iState == FWL_PARTSTATE_SCB_Hovered) {
- return;
- }
- iState = FWL_PARTSTATE_SCB_Hovered;
- m_pOwner->Repaint(&rtItem);
+ } else if ((2 == iItem) &&
+ (m_pOwner->m_iThumbButtonState == FWL_PARTSTATE_SCB_Pressed)) {
+ FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy);
+ m_pOwner->m_fTrackPos = fPos;
+ m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos);
+ }
+}
+void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState) {
+ if (iState == FWL_PARTSTATE_SCB_Normal) {
+ return;
+ }
+ iState = FWL_PARTSTATE_SCB_Normal;
+ m_pOwner->Repaint(&rtItem);
+}
+void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState) {
+ if (iState == FWL_PARTSTATE_SCB_Hovered) {
+ return;
+ }
+ iState = FWL_PARTSTATE_SCB_Hovered;
+ m_pOwner->Repaint(&rtItem);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp b/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp index c8be73228b..28d3be46ca 100644 --- a/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp @@ -9,442 +9,433 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "include/fwl_spinbuttonimp.h"
-#define FWL_SPN_MinWidth 18
-#define FWL_SPN_MinHeight 32
-#define FWL_SPIN_Elapse 200
-IFWL_SpinButton* IFWL_SpinButton::Create()
-{
- return new IFWL_SpinButton;
-}
-IFWL_SpinButton::IFWL_SpinButton()
-{
+#define FWL_SPN_MinWidth 18
+#define FWL_SPN_MinHeight 32
+#define FWL_SPIN_Elapse 200
+IFWL_SpinButton* IFWL_SpinButton::Create() {
+ return new IFWL_SpinButton;
+}
+IFWL_SpinButton::IFWL_SpinButton() {
+ m_pData = NULL;
+}
+IFWL_SpinButton::~IFWL_SpinButton() {
+ if (m_pData) {
+ delete (CFWL_SpinButtonImp*)m_pData;
m_pData = NULL;
-}
-IFWL_SpinButton::~IFWL_SpinButton()
-{
- if (m_pData) {
- delete (CFWL_SpinButtonImp*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_SpinButton::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_SpinButtonImp;
- ((CFWL_SpinButtonImp*)m_pData)->SetInterface(this);
- return ((CFWL_SpinButtonImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_SpinButton::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_SpinButtonImp(properties);
- ((CFWL_SpinButtonImp*)m_pData)->SetInterface(this);
- return ((CFWL_SpinButtonImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp)
-{
- return ((CFWL_SpinButtonImp*)m_pData)->EnableButton(bEnable, bUp);
-}
-FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp)
-{
- return ((CFWL_SpinButtonImp*)m_pData)->IsButtonEnable(bUp);
-}
-CFWL_SpinButtonImp::CFWL_SpinButtonImp(IFWL_Widget* pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_dwUpState(FWL_PARTSTATE_SPB_Normal)
- , m_dwDnState(FWL_PARTSTATE_SPB_Normal)
- , m_bLButtonDwn(FALSE)
- , m_iButtonIndex(0)
- , m_hTimer(NULL)
-{
- m_rtClient.Reset();
- m_rtUpButton.Reset();
- m_rtDnButton.Reset();
- m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
-}
-CFWL_SpinButtonImp::CFWL_SpinButtonImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
- : CFWL_WidgetImp(properties, pOuter)
- , m_dwUpState(FWL_PARTSTATE_SPB_Normal)
- , m_dwDnState(FWL_PARTSTATE_SPB_Normal)
- , m_bLButtonDwn(FALSE)
- , m_iButtonIndex(0)
- , m_hTimer(NULL)
-{
- m_rtClient.Reset();
- m_rtUpButton.Reset();
- m_rtDnButton.Reset();
- m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
-}
-CFWL_SpinButtonImp::~CFWL_SpinButtonImp()
-{
-}
-FWL_ERR CFWL_SpinButtonImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_SpinButton;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_SpinButtonImp::GetClassID() const
-{
- return FWL_CLASSHASH_SpinButton;
-}
-FWL_ERR CFWL_SpinButtonImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_SpinButtonImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SpinButtonImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_SpinButtonImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize)
-{
- if (bAutoSize) {
- rect.Set(0, 0, FWL_SPN_MinWidth, FWL_SPN_MinHeight);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ }
+}
+FWL_ERR IFWL_SpinButton::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_SpinButtonImp;
+ ((CFWL_SpinButtonImp*)m_pData)->SetInterface(this);
+ return ((CFWL_SpinButtonImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_SpinButton::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_SpinButtonImp(properties);
+ ((CFWL_SpinButtonImp*)m_pData)->SetInterface(this);
+ return ((CFWL_SpinButtonImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
+ return ((CFWL_SpinButtonImp*)m_pData)->EnableButton(bEnable, bUp);
+}
+FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) {
+ return ((CFWL_SpinButtonImp*)m_pData)->IsButtonEnable(bUp);
+}
+CFWL_SpinButtonImp::CFWL_SpinButtonImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter),
+ m_dwUpState(FWL_PARTSTATE_SPB_Normal),
+ m_dwDnState(FWL_PARTSTATE_SPB_Normal),
+ m_bLButtonDwn(FALSE),
+ m_iButtonIndex(0),
+ m_hTimer(NULL) {
+ m_rtClient.Reset();
+ m_rtUpButton.Reset();
+ m_rtDnButton.Reset();
+ m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
+}
+CFWL_SpinButtonImp::CFWL_SpinButtonImp(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter),
+ m_dwUpState(FWL_PARTSTATE_SPB_Normal),
+ m_dwDnState(FWL_PARTSTATE_SPB_Normal),
+ m_bLButtonDwn(FALSE),
+ m_iButtonIndex(0),
+ m_hTimer(NULL) {
+ m_rtClient.Reset();
+ m_rtUpButton.Reset();
+ m_rtDnButton.Reset();
+ m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
+}
+CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {}
+FWL_ERR CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_SpinButton;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_SpinButtonImp::GetClassID() const {
+ return FWL_CLASSHASH_SpinButton;
+}
+FWL_ERR CFWL_SpinButtonImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_SpinButtonImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_SpinButtonImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_SpinButtonImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, FWL_SPN_MinWidth, FWL_SPN_MinHeight);
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_SpinButtonImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ GetClientRect(m_rtClient);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) {
+ m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width,
+ m_rtClient.height / 2);
+ m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2,
+ m_rtClient.width, m_rtClient.height / 2);
+ } else {
+ m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2,
+ m_rtClient.height);
+ m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top,
+ m_rtClient.width / 2, m_rtClient.height);
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_SpinButtonImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_rtClient.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ if (HasBorder() && (m_rtClient.Contains(fx, fy))) {
+ return FWL_WGTHITTEST_Border;
+ }
+ if (HasEdge()) {
+ CFX_RectF rtEdge;
+ GetEdgeRect(rtEdge);
+ if (rtEdge.Contains(fx, fy)) {
+ return FWL_PART_SPB_Edge;
+ }
+ }
+ if (m_rtUpButton.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_SPB_UpButton;
+ }
+ if (m_rtDnButton.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_SPB_DownButton;
+ }
+ return FWL_WGTHITTEST_Unknown;
+}
+FWL_ERR CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ CFX_RectF rtClip(m_rtClient);
+ if (pMatrix != NULL) {
+ pMatrix->TransformRect(rtClip);
+ }
+ IFWL_ThemeProvider* pTheme = GetAvailableTheme();
+ if (HasBorder()) {
+ DrawBorder(pGraphics, FWL_PART_SPB_Border, pTheme, pMatrix);
+ }
+ if (HasEdge()) {
+ DrawEdge(pGraphics, FWL_PART_SPB_Edge, pTheme, pMatrix);
+ }
+ DrawUpButton(pGraphics, pTheme, pMatrix);
+ DrawDownButton(pGraphics, pTheme, pMatrix);
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) {
+ if (m_hTimer) {
+ CFWL_EvtSpbClick wmPosChanged;
+ wmPosChanged.m_pSrcTarget = m_pInterface;
+ wmPosChanged.m_bUp = m_iButtonIndex == 0;
+ DispatchEvent(&wmPosChanged);
+ }
+ return 1;
+}
+FWL_ERR CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
+ if (bUp) {
+ if (bEnable) {
+ m_dwUpState = FWL_PARTSTATE_SPB_Normal;
} else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SpinButtonImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ m_dwUpState = FWL_PARTSTATE_SPB_Disabled;
}
- GetClientRect(m_rtClient);
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) {
- m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, m_rtClient.height / 2);
- m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, m_rtClient.width, m_rtClient.height / 2);
+ } else {
+ if (bEnable) {
+ m_dwDnState = FWL_PARTSTATE_SPB_Normal;
} else {
- m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, m_rtClient.height);
- m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, m_rtClient.width / 2, m_rtClient.height);
- }
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_SpinButtonImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- if (HasBorder() && (m_rtClient.Contains(fx, fy))) {
- return FWL_WGTHITTEST_Border;
- }
- if (HasEdge()) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy)) {
- return FWL_PART_SPB_Edge;
+ m_dwDnState = FWL_PARTSTATE_SPB_Disabled;
+ }
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_SpinButtonImp::IsButtonEnable(FX_BOOL bUp) {
+ if (bUp) {
+ return (m_dwUpState != FWL_PARTSTATE_SPB_Disabled);
+ }
+ return (m_dwDnState != FWL_PARTSTATE_SPB_Disabled);
+}
+void CFWL_SpinButtonImp::DrawUpButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_SPB_UpButton;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = m_dwUpState + 1;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ params.m_rtPart = m_rtUpButton;
+ pTheme->DrawBackground(¶ms);
+}
+void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground params;
+ params.m_pWidget = m_pInterface;
+ params.m_iPart = FWL_PART_SPB_DownButton;
+ params.m_pGraphics = pGraphics;
+ params.m_dwStates = m_dwDnState + 1;
+ if (pMatrix) {
+ params.m_matrix.Concat(*pMatrix);
+ }
+ params.m_rtPart = m_rtDnButton;
+ pTheme->DrawBackground(¶ms);
+}
+CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate(
+ CFWL_SpinButtonImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ int32_t iRet = 1;
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_SetFocus:
+ case FWL_MSGHASH_KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ FX_DWORD dwCmd = pMsg->m_dwCmd;
+ switch (dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
}
- }
- if (m_rtUpButton.Contains(fx, fy)) {
- return FWL_WGTHITTEST_SPB_UpButton;
- }
- if (m_rtDnButton.Contains(fx, fy)) {
- return FWL_WGTHITTEST_SPB_DownButton;
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FWL_ERR CFWL_SpinButtonImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- CFX_RectF rtClip(m_rtClient);
- if (pMatrix != NULL) {
- pMatrix->TransformRect(rtClip);
- }
- IFWL_ThemeProvider *pTheme = GetAvailableTheme();
- if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_SPB_Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_SPB_Edge, pTheme, pMatrix);
- }
- DrawUpButton(pGraphics, pTheme, pMatrix);
- DrawDownButton(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer)
-{
- if (m_hTimer) {
- CFWL_EvtSpbClick wmPosChanged;
- wmPosChanged.m_pSrcTarget = m_pInterface;
- wmPosChanged.m_bUp = m_iButtonIndex == 0;
- DispatchEvent(&wmPosChanged);
- }
- return 1;
-}
-FWL_ERR CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp)
-{
- if (bUp) {
- if (bEnable) {
- m_dwUpState = FWL_PARTSTATE_SPB_Normal;
- } else {
- m_dwUpState = FWL_PARTSTATE_SPB_Disabled;
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- } else {
- if (bEnable) {
- m_dwDnState = FWL_PARTSTATE_SPB_Normal;
- } else {
- m_dwDnState = FWL_PARTSTATE_SPB_Disabled;
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
}
- }
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_SpinButtonImp::IsButtonEnable(FX_BOOL bUp)
-{
- if (bUp) {
- return (m_dwUpState != FWL_PARTSTATE_SPB_Disabled);
- }
- return (m_dwDnState != FWL_PARTSTATE_SPB_Disabled);
-}
-void CFWL_SpinButtonImp::DrawUpButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_SPB_UpButton;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = m_dwUpState + 1;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- params.m_rtPart = m_rtUpButton;
- pTheme->DrawBackground(¶ms);
-}
-void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground params;
- params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_SPB_DownButton;
- params.m_pGraphics = pGraphics;
- params.m_dwStates = m_dwDnState + 1;
- if (pMatrix) {
- params.m_matrix.Concat(*pMatrix);
- }
- params.m_rtPart = m_rtDnButton;
- pTheme->DrawBackground(¶ms);
-}
-CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate(CFWL_SpinButtonImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- int32_t iRet = 1;
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- FX_DWORD dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMsg);
- break;
- }
- default: {
- }
- }
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_MsgKey *pKey = (CFWL_MsgKey*)pMessage;
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
- OnKeyDown((CFWL_MsgKey*)pKey);
- }
- break;
- }
- default: {
- iRet = 0;
- break;
- }
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet )
-{
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->m_bLButtonDwn = TRUE;
- m_pOwner->SetGrab(TRUE);
- m_pOwner->SetFocus(TRUE);
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider);
- FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) &&
- m_pOwner->IsButtonEnable(TRUE));
- FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) &&
- m_pOwner->IsButtonEnable(FALSE));
- if (!bUpPress && !bDnPress) {
- return;
- }
- if (bUpPress) {
- m_pOwner->m_iButtonIndex = 0;
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Pressed;
- }
- if (bDnPress) {
- m_pOwner->m_iButtonIndex = 1;
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Pressed;
- }
- CFWL_EvtSpbClick wmPosChanged;
- wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface;
- wmPosChanged.m_bUp = bUpPress;
- m_pOwner->DispatchEvent(&wmPosChanged);
- m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton : &m_pOwner->m_rtDnButton);
- m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SPIN_Elapse);
-}
-void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- if (m_pOwner->m_pProperties->m_dwStates & FWL_PARTSTATE_SPB_Disabled) {
- return;
- }
- m_pOwner->m_bLButtonDwn = FALSE;
- m_pOwner->SetGrab(FALSE);
- m_pOwner->SetFocus(FALSE);
- if (m_pOwner->m_hTimer) {
- FWL_StopTimer(m_pOwner->m_hTimer);
- m_pOwner->m_hTimer = NULL;
- }
- FX_BOOL bRepaint = FALSE;
- CFX_RectF rtInvalidate;
- if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Pressed && m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave(pMsg);
+ break;
+ }
+ default: {}
+ }
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ CFWL_MsgKey* pKey = (CFWL_MsgKey*)pMessage;
+ if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ OnKeyDown((CFWL_MsgKey*)pKey);
+ }
+ break;
+ }
+ default: {
+ iRet = 0;
+ break;
+ }
+ }
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ return iRet;
+}
+FWL_ERR CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ if (bSet) {
+ m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
+ } else {
+ m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ m_pOwner->m_bLButtonDwn = TRUE;
+ m_pOwner->SetGrab(TRUE);
+ m_pOwner->SetFocus(TRUE);
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider);
+ FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) &&
+ m_pOwner->IsButtonEnable(TRUE));
+ FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) &&
+ m_pOwner->IsButtonEnable(FALSE));
+ if (!bUpPress && !bDnPress) {
+ return;
+ }
+ if (bUpPress) {
+ m_pOwner->m_iButtonIndex = 0;
+ m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Pressed;
+ }
+ if (bDnPress) {
+ m_pOwner->m_iButtonIndex = 1;
+ m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Pressed;
+ }
+ CFWL_EvtSpbClick wmPosChanged;
+ wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface;
+ wmPosChanged.m_bUp = bUpPress;
+ m_pOwner->DispatchEvent(&wmPosChanged);
+ m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton
+ : &m_pOwner->m_rtDnButton);
+ m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SPIN_Elapse);
+}
+void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (m_pOwner->m_pProperties->m_dwStates & FWL_PARTSTATE_SPB_Disabled) {
+ return;
+ }
+ m_pOwner->m_bLButtonDwn = FALSE;
+ m_pOwner->SetGrab(FALSE);
+ m_pOwner->SetFocus(FALSE);
+ if (m_pOwner->m_hTimer) {
+ FWL_StopTimer(m_pOwner->m_hTimer);
+ m_pOwner->m_hTimer = NULL;
+ }
+ FX_BOOL bRepaint = FALSE;
+ CFX_RectF rtInvalidate;
+ if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Pressed &&
+ m_pOwner->IsButtonEnable(TRUE)) {
+ m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ bRepaint = TRUE;
+ rtInvalidate = m_pOwner->m_rtUpButton;
+ } else if (m_pOwner->m_dwDnState == FWL_PARTSTATE_SPB_Pressed &&
+ m_pOwner->IsButtonEnable(FALSE)) {
+ m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ bRepaint = TRUE;
+ rtInvalidate = m_pOwner->m_rtDnButton;
+ }
+ if (bRepaint) {
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+}
+void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider);
+ if (m_pOwner->m_bLButtonDwn) {
+ return;
+ }
+ FX_BOOL bRepaint = FALSE;
+ CFX_RectF rtInvlidate;
+ rtInvlidate.Reset();
+ if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_pOwner->IsButtonEnable(TRUE)) {
+ if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Hovered) {
+ m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Hovered;
bRepaint = TRUE;
- rtInvalidate = m_pOwner->m_rtUpButton;
- } else if (m_pOwner->m_dwDnState == FWL_PARTSTATE_SPB_Pressed && m_pOwner->IsButtonEnable(FALSE)) {
+ rtInvlidate = m_pOwner->m_rtUpButton;
+ }
+ if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal &&
+ m_pOwner->IsButtonEnable(FALSE)) {
m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
- bRepaint = TRUE;
- rtInvalidate = m_pOwner->m_rtDnButton;
- }
- if (bRepaint) {
- m_pOwner->Repaint(&rtInvalidate);
- }
-}
-void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider);
- if (m_pOwner->m_bLButtonDwn) {
- return;
- }
- FX_BOOL bRepaint = FALSE;
- CFX_RectF rtInvlidate;
- rtInvlidate.Reset();
- if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->IsButtonEnable(TRUE)) {
- if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Hovered) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Hovered;
- bRepaint = TRUE;
- rtInvlidate = m_pOwner->m_rtUpButton;
- }
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal && m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
- if (bRepaint) {
- rtInvlidate.Union(m_pOwner->m_rtDnButton);
- } else {
- rtInvlidate = m_pOwner->m_rtDnButton;
- }
- bRepaint = TRUE;
- }
- }
- if (!m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->EnableButton(FALSE, FALSE);
- }
- } else if (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->IsButtonEnable(FALSE)) {
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Hovered) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Hovered;
- bRepaint = TRUE;
- rtInvlidate = m_pOwner->m_rtDnButton;
- }
- if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal && m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
- if (bRepaint) {
- rtInvlidate.Union(m_pOwner->m_rtUpButton);
- } else {
- rtInvlidate = m_pOwner->m_rtUpButton;
- }
- bRepaint = TRUE;
- }
- }
- } else if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal || m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal) {
- if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
- bRepaint = TRUE;
- rtInvlidate = m_pOwner->m_rtUpButton;
- }
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
- if (bRepaint) {
- rtInvlidate.Union(m_pOwner->m_rtDnButton);
- } else {
- rtInvlidate = m_pOwner->m_rtDnButton;
- }
- bRepaint = TRUE;
+ if (bRepaint) {
+ rtInvlidate.Union(m_pOwner->m_rtDnButton);
+ } else {
+ rtInvlidate = m_pOwner->m_rtDnButton;
}
+ bRepaint = TRUE;
+ }
}
- if (bRepaint) {
- m_pOwner->Repaint(&rtInvlidate);
+ if (!m_pOwner->IsButtonEnable(FALSE)) {
+ m_pOwner->EnableButton(FALSE, FALSE);
}
-}
-void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- _FWL_RETURN_IF_FAIL(pMsg);
- if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal && m_pOwner->IsButtonEnable(TRUE)) {
+ } else if (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_pOwner->IsButtonEnable(FALSE)) {
+ if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Hovered) {
+ m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Hovered;
+ bRepaint = TRUE;
+ rtInvlidate = m_pOwner->m_rtDnButton;
+ }
+ if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal &&
+ m_pOwner->IsButtonEnable(TRUE)) {
m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
- }
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal && m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
-}
-void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey *pMsg)
-{
- _FWL_RETURN_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider);
- FX_BOOL bUp = pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left;
- FX_BOOL bDown = pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right;
- if (!bUp && !bDown) {
- return;
- }
- FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE);
- FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE);
- if (!bUpEnable && !bDownEnable) {
- return;
- }
- CFWL_EvtSpbClick wmPosChanged;
- wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface;
- wmPosChanged.m_bUp = bUpEnable;
- m_pOwner->DispatchEvent(&wmPosChanged);
- m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton : &m_pOwner->m_rtDnButton);
+ if (bRepaint) {
+ rtInvlidate.Union(m_pOwner->m_rtUpButton);
+ } else {
+ rtInvlidate = m_pOwner->m_rtUpButton;
+ }
+ bRepaint = TRUE;
+ }
+ }
+ } else if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal ||
+ m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal) {
+ if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal) {
+ m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ bRepaint = TRUE;
+ rtInvlidate = m_pOwner->m_rtUpButton;
+ }
+ if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal) {
+ m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ if (bRepaint) {
+ rtInvlidate.Union(m_pOwner->m_rtDnButton);
+ } else {
+ rtInvlidate = m_pOwner->m_rtDnButton;
+ }
+ bRepaint = TRUE;
+ }
+ }
+ if (bRepaint) {
+ m_pOwner->Repaint(&rtInvlidate);
+ }
+}
+void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ _FWL_RETURN_IF_FAIL(pMsg);
+ if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal &&
+ m_pOwner->IsButtonEnable(TRUE)) {
+ m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ }
+ if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal &&
+ m_pOwner->IsButtonEnable(FALSE)) {
+ m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtClient);
+}
+void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+ _FWL_RETURN_IF_FAIL(m_pOwner->m_pProperties->m_pDataProvider);
+ FX_BOOL bUp =
+ pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left;
+ FX_BOOL bDown =
+ pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right;
+ if (!bUp && !bDown) {
+ return;
+ }
+ FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE);
+ FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE);
+ if (!bUpEnable && !bDownEnable) {
+ return;
+ }
+ CFWL_EvtSpbClick wmPosChanged;
+ wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface;
+ wmPosChanged.m_bUp = bUpEnable;
+ m_pOwner->DispatchEvent(&wmPosChanged);
+ m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton
+ : &m_pOwner->m_rtDnButton);
}
diff --git a/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp b/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp index 920bcb73e1..a0a9a85634 100644 --- a/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp @@ -11,328 +11,304 @@ #include "../core/include/fwl_panelimp.h"
#include "../core/include/fwl_formimp.h"
#include "include/fwl_tooltipctrlimp.h"
-IFWL_ToolTip *IFWL_ToolTip::Create()
-{
- return new IFWL_ToolTip;
+IFWL_ToolTip* IFWL_ToolTip::Create() {
+ return new IFWL_ToolTip;
}
-FWL_ERR IFWL_ToolTip::Initialize(IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ToolTipImp(pOuter);
- ((CFWL_ToolTipImp*)m_pData)->SetInterface(this);
- return ((CFWL_ToolTipImp*)m_pData)->Initialize();
+FWL_ERR IFWL_ToolTip::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ToolTipImp(pOuter);
+ ((CFWL_ToolTipImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ToolTipImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_ToolTip::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter)
-{
- m_pData = FX_NEW CFWL_ToolTipImp(properties, pOuter);
- ((CFWL_ToolTipImp*)m_pData)->SetInterface(this);
- return ((CFWL_ToolTipImp*)m_pData)->Initialize();
+FWL_ERR IFWL_ToolTip::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_ToolTipImp(properties, pOuter);
+ ((CFWL_ToolTipImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ToolTipImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF &rtAnchor)
-{
- return ((CFWL_ToolTipImp*)m_pData)->SetAnchor( rtAnchor);
+FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
+ return ((CFWL_ToolTipImp*)m_pData)->SetAnchor(rtAnchor);
}
-FWL_ERR IFWL_ToolTip::Show()
-{
- return ((CFWL_ToolTipImp*)m_pData)->Show();
+FWL_ERR IFWL_ToolTip::Show() {
+ return ((CFWL_ToolTipImp*)m_pData)->Show();
}
-FWL_ERR IFWL_ToolTip::Hide()
-{
- return ((CFWL_ToolTipImp*)m_pData)->Hide();
+FWL_ERR IFWL_ToolTip::Hide() {
+ return ((CFWL_ToolTipImp*)m_pData)->Hide();
}
-IFWL_ToolTip::IFWL_ToolTip()
-{
- m_pData = NULL;
-}
-IFWL_ToolTip::~IFWL_ToolTip()
-{
- if (m_pData) {
- delete (CFWL_ToolTipImp*)m_pData;
- m_pData = NULL;
- }
+IFWL_ToolTip::IFWL_ToolTip() {
+ m_pData = NULL;
}
-CFWL_ToolTipImp::CFWL_ToolTipImp(IFWL_Widget *pOuter )
- : CFWL_FormImp(pOuter)
- , m_bBtnDown(FALSE)
- , m_dwTTOStyles(FDE_TTOSTYLE_SingleLine)
- , m_iTTOAlign(FDE_TTOALIGNMENT_Center)
- , m_hTimerShow(NULL)
- , m_hTimerHide(NULL)
- , m_pTimer(NULL)
-{
- m_rtClient.Set(0, 0, 0, 0);
- m_rtCaption.Set(0, 0, 0, 0);
+IFWL_ToolTip::~IFWL_ToolTip() {
+ if (m_pData) {
+ delete (CFWL_ToolTipImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+CFWL_ToolTipImp::CFWL_ToolTipImp(IFWL_Widget* pOuter)
+ : CFWL_FormImp(pOuter),
+ m_bBtnDown(FALSE),
+ m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
+ m_iTTOAlign(FDE_TTOALIGNMENT_Center),
+ m_hTimerShow(NULL),
+ m_hTimerHide(NULL),
+ m_pTimer(NULL) {
+ m_rtClient.Set(0, 0, 0, 0);
+ m_rtCaption.Set(0, 0, 0, 0);
+ m_pTimer = NULL;
+ m_TimerShow.m_pToolTip = this;
+ m_TimerHide.m_pToolTip = this;
+}
+CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_FormImp(properties, pOuter),
+ m_bBtnDown(FALSE),
+ m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
+ m_iTTOAlign(FDE_TTOALIGNMENT_Center),
+ m_hTimerShow(NULL),
+ m_hTimerHide(NULL),
+ m_pTimer(NULL) {
+ m_rtClient.Set(0, 0, 0, 0);
+ m_rtCaption.Set(0, 0, 0, 0);
+ m_rtAnchor.Set(0, 0, 0, 0);
+ m_TimerShow.m_pToolTip = this;
+ m_TimerHide.m_pToolTip = this;
+}
+CFWL_ToolTipImp::~CFWL_ToolTipImp() {
+ if (m_pTimer) {
+ delete m_pTimer;
m_pTimer = NULL;
- m_TimerShow.m_pToolTip = this;
- m_TimerHide.m_pToolTip = this;
-}
-CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_FormImp(properties, pOuter)
- , m_bBtnDown(FALSE)
- , m_dwTTOStyles(FDE_TTOSTYLE_SingleLine)
- , m_iTTOAlign(FDE_TTOALIGNMENT_Center)
- , m_hTimerShow(NULL)
- , m_hTimerHide(NULL)
- , m_pTimer(NULL)
-{
- m_rtClient.Set(0, 0, 0, 0);
- m_rtCaption.Set(0, 0, 0, 0);
- m_rtAnchor.Set(0, 0, 0, 0);
- m_TimerShow.m_pToolTip = this;
- m_TimerHide.m_pToolTip = this;
-}
-CFWL_ToolTipImp::~CFWL_ToolTipImp()
-{
- if (m_pTimer) {
- delete m_pTimer;
- m_pTimer = NULL;
- }
-}
-FWL_ERR CFWL_ToolTipImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_ToolTip;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ToolTipImp::GetClassID() const
-{
- return FWL_CLASSHASH_ToolTip;
-}
-FWL_ERR CFWL_ToolTipImp::Initialize()
-{
- m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
- m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child;
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_ToolTipImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ToolTipImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_ToolTipImpDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Set(0, 0, 0, 0);
- if (m_pProperties->m_pThemeProvider == NULL) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- CFX_WideString wsCaption;
- IFWL_ToolTipDP *pData = (IFWL_ToolTipDP*)m_pProperties->m_pDataProvider;
- if (pData) {
- pData->GetCaption(m_pInterface, wsCaption);
- }
- int32_t iLen = wsCaption.GetLength();
- if (iLen > 0) {
- CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
- rect.Set(0, 0, sz.x, sz.y);
- rect.width += FWL_WGTCAPACITY_CXBorder * 25;
- rect.height += FWL_WGTCAPACITY_CYBorder * 8;
- }
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ToolTipImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
- UpdateTextOutStyles();
- GetClientRect(m_rtClient);
- m_rtCaption = m_rtClient;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF &rect)
-{
- FX_FLOAT x = 0;
- FX_FLOAT y = 0;
- FX_FLOAT t = 0;
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (pTheme) {
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- FX_FLOAT * value = NULL;
- value = (FX_FLOAT *) pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder);
- x = *value;
- value = (FX_FLOAT *) pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder);
- y = *value;
- }
- rect = m_pProperties->m_rtWidget;
- rect.Offset(-rect.left, -rect.top);
- rect.Deflate(x, t, x, y);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ToolTipImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- IFWL_ToolTipTarget * toolTipTarget = CFWL_ToolTipContainer::getInstance()->GetCurrentToolTipTarget();
- if (toolTipTarget && !toolTipTarget->UseDefaultTheme()) {
- return toolTipTarget->DrawToolTip(pGraphics, pMatrix, m_pInterface);
+ }
+}
+FWL_ERR CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_ToolTip;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ToolTipImp::GetClassID() const {
+ return FWL_CLASSHASH_ToolTip;
+}
+FWL_ERR CFWL_ToolTipImp::Initialize() {
+ m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
+ m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child;
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_ToolTipImpDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ToolTipImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_ToolTipImpDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Set(0, 0, 0, 0);
+ if (m_pProperties->m_pThemeProvider == NULL) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- DrawBkground(pGraphics, pTheme, pMatrix);
- DrawText(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
-}
-void CFWL_ToolTipImp::DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_TTP_Background;
- param.m_dwStates = m_pProperties->m_dwStates;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- param.m_rtPart = m_rtClient;
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- param.m_pData = &m_rtCaption;
- }
- pTheme->DrawBackground(¶m);
-}
-void CFWL_ToolTipImp::DrawText(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
CFX_WideString wsCaption;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
- if (wsCaption.IsEmpty()) {
- return;
- }
- CFWL_ThemeText param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_TTP_Caption;
- param.m_dwStates = m_pProperties->m_dwStates;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
+ IFWL_ToolTipDP* pData = (IFWL_ToolTipDP*)m_pProperties->m_pDataProvider;
+ if (pData) {
+ pData->GetCaption(m_pInterface, wsCaption);
}
- param.m_rtPart = m_rtCaption;
- param.m_wsText = wsCaption;
- param.m_dwTTOStyles = m_dwTTOStyles;
- param.m_iTTOAlign = m_iTTOAlign;
- pTheme->DrawText(¶m);
-}
-void CFWL_ToolTipImp::UpdateTextOutStyles()
-{
- m_iTTOAlign = FDE_TTOALIGNMENT_Center;
- m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
- m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
- }
- if ( m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) {
- m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine;
- }
-}
-FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF &rtAnchor)
-{
- m_rtAnchor = rtAnchor;
- return TRUE;
-}
-FWL_ERR CFWL_ToolTipImp::Show()
-{
- IFWL_ToolTipDP *pData = (IFWL_ToolTipDP*)m_pProperties->m_pDataProvider;
- int32_t nInitDelay = pData->GetInitialDelay(m_pInterface);
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) {
- m_hTimerShow = FWL_StartTimer( &m_TimerShow, nInitDelay, FALSE);
+ int32_t iLen = wsCaption.GetLength();
+ if (iLen > 0) {
+ CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
+ rect.Set(0, 0, sz.x, sz.y);
+ rect.width += FWL_WGTCAPACITY_CXBorder * 25;
+ rect.height += FWL_WGTCAPACITY_CYBorder * 8;
}
- return TRUE;
-}
-FWL_ERR CFWL_ToolTipImp::Hide()
-{
- SetStates( FWL_WGTSTATE_Invisible, TRUE);
- if ( m_hTimerHide) {
- FWL_StopTimer(m_hTimerHide);
- m_hTimerHide = NULL;
- }
- if ( m_hTimerShow) {
- FWL_StopTimer(m_hTimerShow);
- m_hTimerShow = NULL;
+ CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ToolTipImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
+ UpdateTextOutStyles();
+ GetClientRect(m_rtClient);
+ m_rtCaption = m_rtClient;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) {
+ FX_FLOAT x = 0;
+ FX_FLOAT y = 0;
+ FX_FLOAT t = 0;
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (pTheme) {
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ FX_FLOAT* value = NULL;
+ value = (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder);
+ x = *value;
+ value = (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder);
+ y = *value;
+ }
+ rect = m_pProperties->m_rtWidget;
+ rect.Offset(-rect.left, -rect.top);
+ rect.Deflate(x, t, x, y);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ToolTipImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ IFWL_ToolTipTarget* toolTipTarget =
+ CFWL_ToolTipContainer::getInstance()->GetCurrentToolTipTarget();
+ if (toolTipTarget && !toolTipTarget->UseDefaultTheme()) {
+ return toolTipTarget->DrawToolTip(pGraphics, pMatrix, m_pInterface);
+ }
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ DrawBkground(pGraphics, pTheme, pMatrix);
+ DrawText(pGraphics, pTheme, pMatrix);
+ return FWL_ERR_Succeeded;
+}
+void CFWL_ToolTipImp::DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_TTP_Background;
+ param.m_dwStates = m_pProperties->m_dwStates;
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = m_rtClient;
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ param.m_pData = &m_rtCaption;
+ }
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_ToolTipImp::DrawText(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(m_pProperties->m_pDataProvider);
+ CFX_WideString wsCaption;
+ m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
+ if (wsCaption.IsEmpty()) {
+ return;
+ }
+ CFWL_ThemeText param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_TTP_Caption;
+ param.m_dwStates = m_pProperties->m_dwStates;
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ param.m_rtPart = m_rtCaption;
+ param.m_wsText = wsCaption;
+ param.m_dwTTOStyles = m_dwTTOStyles;
+ param.m_iTTOAlign = m_iTTOAlign;
+ pTheme->DrawText(¶m);
+}
+void CFWL_ToolTipImp::UpdateTextOutStyles() {
+ m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
+ m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
+ }
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) {
+ m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine;
+ }
+}
+FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) {
+ m_rtAnchor = rtAnchor;
+ return TRUE;
+}
+FWL_ERR CFWL_ToolTipImp::Show() {
+ IFWL_ToolTipDP* pData = (IFWL_ToolTipDP*)m_pProperties->m_pDataProvider;
+ int32_t nInitDelay = pData->GetInitialDelay(m_pInterface);
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) {
+ m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE);
+ }
+ return TRUE;
+}
+FWL_ERR CFWL_ToolTipImp::Hide() {
+ SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ if (m_hTimerHide) {
+ FWL_StopTimer(m_hTimerHide);
+ m_hTimerHide = NULL;
+ }
+ if (m_hTimerShow) {
+ FWL_StopTimer(m_hTimerShow);
+ m_hTimerShow = NULL;
+ }
+ return TRUE;
+}
+FWL_ERR CFWL_ToolTipImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) {
+ IFWL_ToolTipDP* pData = (IFWL_ToolTipDP*)m_pProperties->m_pDataProvider;
+ int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface);
+ m_hTimerHide = FWL_StartTimer(&m_TimerHide, nAutoPopDelay, FALSE);
+ }
+ return CFWL_WidgetImp::SetStates(dwStates, bSet);
+}
+void CFWL_ToolTipImp::RefreshToolTipPos() {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) {
+ CFX_RectF rtPopup;
+ CFX_RectF rtWidget(m_pProperties->m_rtWidget);
+ CFX_RectF rtAnchor(m_rtAnchor);
+ rtPopup.Set(0, 0, 0, 0);
+ FX_FLOAT fx = rtAnchor.Center().x + 20;
+ FX_FLOAT fy = rtAnchor.Center().y + 20;
+ rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height());
+ FX_FLOAT fScreenWidth = 0;
+ FX_FLOAT fScreenHeight = 0;
+ GetScreenSize(fScreenWidth, fScreenHeight);
+ if (rtPopup.bottom() > fScreenHeight) {
+ rtPopup.Offset(0, fScreenHeight - rtPopup.bottom());
}
- return TRUE;
-}
-FWL_ERR CFWL_ToolTipImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
- if ( (dwStates & FWL_WGTSTATE_Invisible) && !bSet) {
- IFWL_ToolTipDP *pData = (IFWL_ToolTipDP*)m_pProperties->m_pDataProvider;
- int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface);
- m_hTimerHide = FWL_StartTimer( &m_TimerHide, nAutoPopDelay, FALSE);
+ if (rtPopup.right() > fScreenWidth) {
+ rtPopup.Offset(fScreenWidth - rtPopup.right(), 0);
}
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
-}
-void CFWL_ToolTipImp::RefreshToolTipPos()
-{
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) {
- CFX_RectF rtPopup;
- CFX_RectF rtWidget(m_pProperties->m_rtWidget);
- CFX_RectF rtAnchor(m_rtAnchor);
- rtPopup.Set( 0, 0, 0, 0);
- FX_FLOAT fx = rtAnchor.Center().x + 20;
- FX_FLOAT fy = rtAnchor.Center().y + 20;
- rtPopup.Set( fx, fy, rtWidget.Width(), rtWidget.Height());
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
- if (rtPopup.bottom() > fScreenHeight) {
- rtPopup.Offset( 0, fScreenHeight - rtPopup.bottom());
- }
- if ( rtPopup.right() > fScreenWidth) {
- rtPopup.Offset( fScreenWidth - rtPopup.right(), 0);
- }
- if ( rtPopup.left < 0) {
- rtPopup.Offset(0 - rtPopup.left, 0);
- }
- if ( rtPopup.top < 0) {
- rtPopup.Offset( 0, 0 - rtPopup.top);
- }
- SetWidgetRect(rtPopup);
- Update();
+ if (rtPopup.left < 0) {
+ rtPopup.Offset(0 - rtPopup.left, 0);
}
-}
-CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp * pToolTip)
- : m_pToolTip(pToolTip)
-{
-}
-int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer)
-{
- if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) {
- if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) {
- m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- m_pToolTip->RefreshToolTipPos();
- FWL_StopTimer(m_pToolTip->m_hTimerShow);
- m_pToolTip->m_hTimerShow = NULL;
- return TRUE;
- }
+ if (rtPopup.top < 0) {
+ rtPopup.Offset(0, 0 - rtPopup.top);
}
- if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) {
- m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- FWL_StopTimer(m_pToolTip->m_hTimerHide);
- m_pToolTip->m_hTimerHide = NULL;
- return TRUE;
+ SetWidgetRect(rtPopup);
+ Update();
+ }
+}
+CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip)
+ : m_pToolTip(pToolTip) {}
+int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) {
+ if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) {
+ if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) {
+ m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ m_pToolTip->RefreshToolTipPos();
+ FWL_StopTimer(m_pToolTip->m_hTimerShow);
+ m_pToolTip->m_hTimerShow = NULL;
+ return TRUE;
}
+ }
+ if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) {
+ m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ FWL_StopTimer(m_pToolTip->m_hTimerHide);
+ m_pToolTip->m_hTimerHide = NULL;
return TRUE;
+ }
+ return TRUE;
}
-CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner)
+ : m_pOwner(pOwner) {}
+int32_t CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
}
-FWL_ERR CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/xfa/src/fwl/src/basewidget/fxmath_barcodeimp.cpp b/xfa/src/fwl/src/basewidget/fxmath_barcodeimp.cpp index caa811a345..f20fe0f6db 100644 --- a/xfa/src/fwl/src/basewidget/fxmath_barcodeimp.cpp +++ b/xfa/src/fwl/src/basewidget/fxmath_barcodeimp.cpp @@ -6,395 +6,372 @@ #include "../../../foxitlib.h"
#include "include/fxmath_barcodeimp.h"
-static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type)
-{
- switch(type) {
- case BC_CODE39:
- return FX_NEW CBC_Code39();
- case BC_CODABAR:
- return FX_NEW CBC_Codabar();
- case BC_CODE128:
- return FX_NEW CBC_Code128(BC_CODE128_B);
- case BC_CODE128_B:
- return FX_NEW CBC_Code128(BC_CODE128_B);
- case BC_CODE128_C:
- return FX_NEW CBC_Code128(BC_CODE128_C);
- case BC_EAN8:
- return FX_NEW CBC_EAN8();
- case BC_UPCA:
- return FX_NEW CBC_UPCA();
- case BC_EAN13:
- return FX_NEW CBC_EAN13();
- case BC_QR_CODE:
- return FX_NEW CBC_QRCode();
- case BC_PDF417:
- return FX_NEW CBC_PDF417I();
- case BC_DATAMATRIX:
- return FX_NEW CBC_DataMatrix();
- case BC_UNKNOWN:
- default:
- return NULL;
- }
-}
-CFX_Barcode::CFX_Barcode()
-{
-}
-CFX_Barcode::~CFX_Barcode()
-{
- if(m_pBCEngine) {
- delete m_pBCEngine;
- m_pBCEngine = NULL;
- }
-}
-FX_BOOL CFX_Barcode::Crreate(BC_TYPE type)
-{
- m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type);
- return m_pBCEngine != NULL;
-}
-void CFX_Barcode::Release()
-{
- delete this;
-}
-BC_TYPE CFX_Barcode::GetType()
-{
- return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
-}
-FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding)
-{
- return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE;
-}
-FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight)
-{
- return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE;
-}
-FX_BOOL CFX_Barcode::SetModuleWidth(int32_t moduleWidth)
-{
- return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE;
-}
-FX_BOOL CFX_Barcode::SetHeight(int32_t height)
-{
- return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE;
-}
-FX_BOOL CFX_Barcode::SetWidth(int32_t width)
-{
- return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE;
-}
-FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? ((CBC_OneCode*)m_pBCEngine)->CheckContentValidity(contents)
- : TRUE;
- default:
- return TRUE;
- }
-}
-FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetPrintChecksum(checksum), TRUE)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetDataLength(int32_t length)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetDataLength(length), TRUE)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetCalChecksum(state), TRUE)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? ((CBC_OneCode*)m_pBCEngine)->SetFont(pFont)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetFontSize(size), TRUE)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetFontStyle(int32_t style)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetFontStyle(style), TRUE)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color)
-{
- switch(GetType()) {
- case BC_CODE39:
- case BC_CODABAR:
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- case BC_EAN8:
- case BC_EAN13:
- case BC_UPCA:
- return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetFontColor(color), TRUE)
- : FALSE;
- default:
- return FALSE;
- }
-}
-FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location)
-{
- typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_CODE39:
- memptr = (memptrtype)&CBC_Code39::SetTextLocation;
- break;
- case BC_CODABAR:
- memptr = (memptrtype)&CBC_Codabar::SetTextLocation;
- break;
- case BC_CODE128:
- case BC_CODE128_B:
- case BC_CODE128_C:
- memptr = (memptrtype)&CBC_Code128::SetTextLocation;
- break;
- default:
- break;
- }
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location)
- : FALSE;
-}
-FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio)
-{
- typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_CODE39:
- memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio;
- break;
- case BC_CODABAR:
- memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio;
- break;
- default:
- break;
- }
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio)
- : FALSE;
-}
-FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start)
-{
- typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_CODABAR:
- memptr = (memptrtype)&CBC_Codabar::SetStartChar;
- break;
- default:
- break;
- }
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start)
- : FALSE;
-}
-FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end)
-{
- typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_CODABAR:
- memptr = (memptrtype)&CBC_Codabar::SetEndChar;
- break;
- default:
- break;
- }
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end)
- : FALSE;
-}
-FX_BOOL CFX_Barcode::SetVersion(int32_t version)
-{
- typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_QR_CODE:
- memptr = (memptrtype)&CBC_QRCode::SetVersion;
- break;
- default:
- break;
- }
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version)
- : FALSE;
-}
-FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level)
-{
- typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_QR_CODE:
- memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel;
- break;
- case BC_PDF417:
- memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel;
- break;
- default:
- return FALSE;
- }
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level)
- : FALSE;
-}
-FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated)
-{
- typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL);
- memptrtype memptr = NULL;
- switch(GetType()) {
- case BC_PDF417:
- memptr = (memptrtype)&CBC_PDF417I::SetTruncated;
- break;
- default:
- break;
- }
- return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE)
- : FALSE;
+static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) {
+ switch (type) {
+ case BC_CODE39:
+ return FX_NEW CBC_Code39();
+ case BC_CODABAR:
+ return FX_NEW CBC_Codabar();
+ case BC_CODE128:
+ return FX_NEW CBC_Code128(BC_CODE128_B);
+ case BC_CODE128_B:
+ return FX_NEW CBC_Code128(BC_CODE128_B);
+ case BC_CODE128_C:
+ return FX_NEW CBC_Code128(BC_CODE128_C);
+ case BC_EAN8:
+ return FX_NEW CBC_EAN8();
+ case BC_UPCA:
+ return FX_NEW CBC_UPCA();
+ case BC_EAN13:
+ return FX_NEW CBC_EAN13();
+ case BC_QR_CODE:
+ return FX_NEW CBC_QRCode();
+ case BC_PDF417:
+ return FX_NEW CBC_PDF417I();
+ case BC_DATAMATRIX:
+ return FX_NEW CBC_DataMatrix();
+ case BC_UNKNOWN:
+ default:
+ return NULL;
+ }
+}
+CFX_Barcode::CFX_Barcode() {}
+CFX_Barcode::~CFX_Barcode() {
+ if (m_pBCEngine) {
+ delete m_pBCEngine;
+ m_pBCEngine = NULL;
+ }
+}
+FX_BOOL CFX_Barcode::Crreate(BC_TYPE type) {
+ m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type);
+ return m_pBCEngine != NULL;
+}
+void CFX_Barcode::Release() {
+ delete this;
+}
+BC_TYPE CFX_Barcode::GetType() {
+ return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
+}
+FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) {
+ return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) {
+ return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetModuleWidth(int32_t moduleWidth) {
+ return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetHeight(int32_t height) {
+ return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetWidth(int32_t width) {
+ return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE;
+}
+FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? ((CBC_OneCode*)m_pBCEngine)->CheckContentValidity(contents)
+ : TRUE;
+ default:
+ return TRUE;
+ }
+}
+FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? (((CBC_OneCode*)m_pBCEngine)->SetPrintChecksum(checksum),
+ TRUE)
+ : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetDataLength(int32_t length) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? (((CBC_OneCode*)m_pBCEngine)->SetDataLength(length), TRUE)
+ : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? (((CBC_OneCode*)m_pBCEngine)->SetCalChecksum(state), TRUE)
+ : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine ? ((CBC_OneCode*)m_pBCEngine)->SetFont(pFont) : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? (((CBC_OneCode*)m_pBCEngine)->SetFontSize(size), TRUE)
+ : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetFontStyle(int32_t style) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? (((CBC_OneCode*)m_pBCEngine)->SetFontStyle(style), TRUE)
+ : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color) {
+ switch (GetType()) {
+ case BC_CODE39:
+ case BC_CODABAR:
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ case BC_EAN8:
+ case BC_EAN13:
+ case BC_UPCA:
+ return m_pBCEngine
+ ? (((CBC_OneCode*)m_pBCEngine)->SetFontColor(color), TRUE)
+ : FALSE;
+ default:
+ return FALSE;
+ }
+}
+FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) {
+ typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_CODE39:
+ memptr = (memptrtype)&CBC_Code39::SetTextLocation;
+ break;
+ case BC_CODABAR:
+ memptr = (memptrtype)&CBC_Codabar::SetTextLocation;
+ break;
+ case BC_CODE128:
+ case BC_CODE128_B:
+ case BC_CODE128_C:
+ memptr = (memptrtype)&CBC_Code128::SetTextLocation;
+ break;
+ default:
+ break;
+ }
+ return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
+ typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_CODE39:
+ memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio;
+ break;
+ case BC_CODABAR:
+ memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio;
+ break;
+ default:
+ break;
+ }
+ return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
+ typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_CODABAR:
+ memptr = (memptrtype)&CBC_Codabar::SetStartChar;
+ break;
+ default:
+ break;
+ }
+ return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
+ typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_CODABAR:
+ memptr = (memptrtype)&CBC_Codabar::SetEndChar;
+ break;
+ default:
+ break;
+ }
+ return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
+ typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_QR_CODE:
+ memptr = (memptrtype)&CBC_QRCode::SetVersion;
+ break;
+ default:
+ break;
+ }
+ return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
+ typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_QR_CODE:
+ memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel;
+ break;
+ case BC_PDF417:
+ memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel;
+ break;
+ default:
+ return FALSE;
+ }
+ return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE;
+}
+FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
+ typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL);
+ memptrtype memptr = NULL;
+ switch (GetType()) {
+ case BC_PDF417:
+ memptr = (memptrtype)&CBC_PDF417I::SetTruncated;
+ break;
+ default:
+ break;
+ }
+ return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE)
+ : FALSE;
}
#ifndef BCExceptionNO
-#define BCExceptionNO 0
+#define BCExceptionNO 0
#endif
#ifndef BCExceptionFormatException
-#define BCExceptionFormatException 8
+#define BCExceptionFormatException 8
#endif
#ifndef BCExceptionUnSupportedBarcode
-#define BCExceptionUnSupportedBarcode 18
+#define BCExceptionUnSupportedBarcode 18
#endif
-FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t &e)
-{
- if(!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->Encode(contents, isDevice, e);
-}
-FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matirx, int32_t &e)
-{
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->RenderDevice(device, matirx, e);
-}
-FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap *&pOutBitmap, int32_t &e)
-{
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->RenderBitmap(pOutBitmap, e);
+FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) {
+ if (!m_pBCEngine) {
+ return FALSE;
+ }
+ return m_pBCEngine->Encode(contents, isDevice, e);
+}
+FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device,
+ const CFX_Matrix* matirx,
+ int32_t& e) {
+ if (!m_pBCEngine) {
+ return FALSE;
+ }
+ return m_pBCEngine->RenderDevice(device, matirx, e);
+}
+FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
+ if (!m_pBCEngine) {
+ return FALSE;
+ }
+ return m_pBCEngine->RenderBitmap(pOutBitmap, e);
}
#define BC_TYPE_MIN BC_CODE39
#define BC_TYPE_MAX BC_DATAMATRIX
-CFX_WideString CFX_Barcode::Decode(uint8_t* buf, int32_t width, int32_t height, int32_t &errorCode)
-{
- for(BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; t = (BC_TYPE)((int32_t)t + 1)) {
- CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
- if(!pTmpEngine) {
- continue;
- }
- CFX_WideString ret = pTmpEngine->Decode(buf, width, height, errorCode);
- if(errorCode == BCExceptionNO) {
- return ret;
- }
+CFX_WideString CFX_Barcode::Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& errorCode) {
+ for (BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX;
+ t = (BC_TYPE)((int32_t)t + 1)) {
+ CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
+ if (!pTmpEngine) {
+ continue;
}
- errorCode = BCExceptionUnSupportedBarcode;
- return CFX_WideString();
-}
-CFX_WideString CFX_Barcode::Decode(CFX_DIBitmap *pBitmap, int32_t &errorCode)
-{
- for(BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; t = (BC_TYPE)((int32_t)t + 1)) {
- CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
- if(!pTmpEngine) {
- continue;
- }
- CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode);
- if(errorCode == BCExceptionNO) {
- return ret;
- }
+ CFX_WideString ret = pTmpEngine->Decode(buf, width, height, errorCode);
+ if (errorCode == BCExceptionNO) {
+ return ret;
}
- errorCode = BCExceptionUnSupportedBarcode;
- return CFX_WideString();
-}
-IFX_Barcode* FX_Barcode_Create(BC_TYPE type)
-{
- CFX_Barcode* pBarcode = FX_NEW CFX_Barcode;
- if (pBarcode->Crreate(type)) {
- return pBarcode;
+ }
+ errorCode = BCExceptionUnSupportedBarcode;
+ return CFX_WideString();
+}
+CFX_WideString CFX_Barcode::Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode) {
+ for (BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX;
+ t = (BC_TYPE)((int32_t)t + 1)) {
+ CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
+ if (!pTmpEngine) {
+ continue;
+ }
+ CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode);
+ if (errorCode == BCExceptionNO) {
+ return ret;
}
- pBarcode->Release();
- return NULL;
+ }
+ errorCode = BCExceptionUnSupportedBarcode;
+ return CFX_WideString();
+}
+IFX_Barcode* FX_Barcode_Create(BC_TYPE type) {
+ CFX_Barcode* pBarcode = FX_NEW CFX_Barcode;
+ if (pBarcode->Crreate(type)) {
+ return pBarcode;
+ }
+ pBarcode->Release();
+ return NULL;
}
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_barcodeimp.h b/xfa/src/fwl/src/basewidget/include/fwl_barcodeimp.h index 7a4681b6f8..b939885f75 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_barcodeimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_barcodeimp.h @@ -16,36 +16,37 @@ class CFWL_BarcodeEdit; class CFWL_BarcodeEditDelegate;
class CFWL_BarcodeImp;
class CFWL_BarcodeImpDelegate;
-#define XFA_BCS_NeedUpdate 0x0001
-#define XFA_BCS_EncodeSuccess 0x0002
-class CFWL_BarcodeImp : public CFWL_EditImp
-{
-public:
- CFWL_BarcodeImp(IFWL_Widget *pOuter = NULL);
- CFWL_BarcodeImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_BarcodeImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_ERR SetText(const CFX_WideString &wsText);
- virtual void SetType(BC_TYPE type);
- FX_BOOL IsProtectedType();
-protected:
- void GenerateBarcodeImageCache();
- void CreateBarcodeEngine();
- void ReleaseBarcodeEngine();
- IFX_Barcode *m_pBarcodeEngine;
- FX_DWORD m_dwStatus;
- BC_TYPE m_type;
- friend class CFWL_BarcodeImpDelegate;
+#define XFA_BCS_NeedUpdate 0x0001
+#define XFA_BCS_EncodeSuccess 0x0002
+class CFWL_BarcodeImp : public CFWL_EditImp {
+ public:
+ CFWL_BarcodeImp(IFWL_Widget* pOuter = NULL);
+ CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_BarcodeImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_ERR SetText(const CFX_WideString& wsText);
+ virtual void SetType(BC_TYPE type);
+ FX_BOOL IsProtectedType();
+
+ protected:
+ void GenerateBarcodeImageCache();
+ void CreateBarcodeEngine();
+ void ReleaseBarcodeEngine();
+ IFX_Barcode* m_pBarcodeEngine;
+ FX_DWORD m_dwStatus;
+ BC_TYPE m_type;
+ friend class CFWL_BarcodeImpDelegate;
};
-class CFWL_BarcodeImpDelegate : public CFWL_EditImpDelegate
-{
-public:
- CFWL_BarcodeImpDelegate(CFWL_BarcodeImp *pOwner);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
+class CFWL_BarcodeImpDelegate : public CFWL_EditImpDelegate {
+ public:
+ CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_caretimp.h b/xfa/src/fwl/src/basewidget/include/fwl_caretimp.h index 6e9d197097..a01d2efe5a 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_caretimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_caretimp.h @@ -12,53 +12,54 @@ class CFWL_WidgetImpDelegate; class IFWL_Widget;
class CFWL_CaretImp;
class CFWL_CaretImpDelegate;
-class CFWL_CaretImp : public CFWL_WidgetImp
-{
-public:
- CFWL_CaretImp(IFWL_Widget *pOuter = NULL);
- CFWL_CaretImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_CaretImp();
+class CFWL_CaretImp : public CFWL_WidgetImp {
+ public:
+ CFWL_CaretImp(IFWL_Widget* pOuter = NULL);
+ CFWL_CaretImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_CaretImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE);
- virtual FWL_ERR GetFrequency(FX_DWORD &elapse);
- virtual FWL_ERR SetFrequency(FX_DWORD elapse);
- virtual FWL_ERR SetColor(CFX_Color crFill);
-protected:
- FX_BOOL DrawCaretBK(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- class CFWL_CaretTimer
- {
- public:
- CFWL_CaretTimer(CFWL_CaretImp *m_pCaret);
- virtual ~CFWL_CaretTimer() {}
- virtual int32_t Run(FWL_HTIMER hTimer);
- CFWL_CaretImp *m_pCaret;
-
- };
- CFWL_CaretTimer *m_pTimer;
- FWL_HTIMER m_hTimer;
- FX_DWORD m_dwElapse;
- CFX_Color m_crFill;
- FX_BOOL m_bSetColor;
- friend class CFWL_CaretImpDelegate;
- friend class CFWL_CaretTimer;
+ virtual FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE);
+ virtual FWL_ERR GetFrequency(FX_DWORD& elapse);
+ virtual FWL_ERR SetFrequency(FX_DWORD elapse);
+ virtual FWL_ERR SetColor(CFX_Color crFill);
+ protected:
+ FX_BOOL DrawCaretBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ class CFWL_CaretTimer {
+ public:
+ CFWL_CaretTimer(CFWL_CaretImp* m_pCaret);
+ virtual ~CFWL_CaretTimer() {}
+ virtual int32_t Run(FWL_HTIMER hTimer);
+ CFWL_CaretImp* m_pCaret;
+ };
+ CFWL_CaretTimer* m_pTimer;
+ FWL_HTIMER m_hTimer;
+ FX_DWORD m_dwElapse;
+ CFX_Color m_crFill;
+ FX_BOOL m_bSetColor;
+ friend class CFWL_CaretImpDelegate;
+ friend class CFWL_CaretTimer;
};
-class CFWL_CaretImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_CaretImpDelegate(CFWL_CaretImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
+class CFWL_CaretImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
-protected:
- CFWL_CaretImp *m_pOwner;
+ protected:
+ CFWL_CaretImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_checkboximp.h b/xfa/src/fwl/src/basewidget/include/fwl_checkboximp.h index 490202dc9a..24d0b1989a 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_checkboximp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_checkboximp.h @@ -12,49 +12,52 @@ class CFWL_WidgetImpDelegate; class IFWL_Widget;
class CFWL_CheckBoxImp;
class CFWL_CheckBoxImpDelegate;
-class CFWL_CheckBoxImp : public CFWL_WidgetImp
-{
-public:
- CFWL_CheckBoxImp(IFWL_Widget *pOuter = NULL);
- CFWL_CheckBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_CheckBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual int32_t GetCheckState();
- virtual FWL_ERR SetCheckState(int32_t iCheck);
-protected:
- void Layout();
- FX_DWORD GetPartStates();
- void UpdateTextOutStyles();
- void NextStates();
- CFX_RectF m_rtClient;
- CFX_RectF m_rtBox;
- CFX_RectF m_rtCaption;
- CFX_RectF m_rtFocus;
- FX_DWORD m_dwTTOStyles;
- int32_t m_iTTOAlign;
- FX_BOOL m_bBtnDown;
- friend class CFWL_CheckBoxImpDelegate;
+class CFWL_CheckBoxImp : public CFWL_WidgetImp {
+ public:
+ CFWL_CheckBoxImp(IFWL_Widget* pOuter = NULL);
+ CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_CheckBoxImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual int32_t GetCheckState();
+ virtual FWL_ERR SetCheckState(int32_t iCheck);
+
+ protected:
+ void Layout();
+ FX_DWORD GetPartStates();
+ void UpdateTextOutStyles();
+ void NextStates();
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtBox;
+ CFX_RectF m_rtCaption;
+ CFX_RectF m_rtFocus;
+ FX_DWORD m_dwTTOStyles;
+ int32_t m_iTTOAlign;
+ FX_BOOL m_bBtnDown;
+ friend class CFWL_CheckBoxImpDelegate;
};
-class CFWL_CheckBoxImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnActivate(CFWL_Message *pMsg);
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- void OnKeyDown(CFWL_MsgKey *pMsg);
- CFWL_CheckBoxImp *m_pOwner;
+class CFWL_CheckBoxImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnActivate(CFWL_Message* pMsg);
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ void OnKeyDown(CFWL_MsgKey* pMsg);
+ CFWL_CheckBoxImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h b/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h index 059e657182..86b26f2bd7 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h @@ -22,206 +22,217 @@ class CFWL_ComboListDelegate; class CFWL_ComboBoxImp;
class CFWL_ComboBoxImpDelegate;
class CFWL_ComboProxyImpDelegate;
-class CFWL_ComboEdit : public CFWL_EditImp
-{
-public:
- CFWL_ComboEdit(IFWL_Widget *pOuter);
- CFWL_ComboEdit(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
+class CFWL_ComboEdit : public CFWL_EditImp {
+ public:
+ CFWL_ComboEdit(IFWL_Widget* pOuter);
+ CFWL_ComboEdit(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
- void ClearSelected();
- void SetSelected();
- void EndCaret();
- void FlagFocus(FX_BOOL bSet);
-protected:
- void SetComboBoxFocus(FX_BOOL bSet);
- CFWL_ComboBoxImp *m_pOuter;
- friend class CFWL_ComboEditDelegate;
+ void ClearSelected();
+ void SetSelected();
+ void EndCaret();
+ void FlagFocus(FX_BOOL bSet);
+
+ protected:
+ void SetComboBoxFocus(FX_BOOL bSet);
+ CFWL_ComboBoxImp* m_pOuter;
+ friend class CFWL_ComboEditDelegate;
};
-class CFWL_ComboEditDelegate : public CFWL_EditImpDelegate
-{
-public:
- CFWL_ComboEditDelegate(CFWL_ComboEdit *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
-protected:
- CFWL_ComboEdit *m_pOwner;
+class CFWL_ComboEditDelegate : public CFWL_EditImpDelegate {
+ public:
+ CFWL_ComboEditDelegate(CFWL_ComboEdit* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+
+ protected:
+ CFWL_ComboEdit* m_pOwner;
};
-class CFWL_ComboList : public CFWL_ListBoxImp
-{
-public:
- CFWL_ComboList(IFWL_Widget *pOuter);
- CFWL_ComboList(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- int32_t MatchItem(const CFX_WideString &wsMatch);
- void ChangeSelected(int32_t iSel);
- int32_t CountItems();
- void GetItemRect(int32_t nIndex, CFX_RectF &rtItem);
- void ClientToOuter(FX_FLOAT &fx, FX_FLOAT &fy);
- void SetFocus(FX_BOOL bSet);
- FX_BOOL m_bNotifyOwner;
- friend class CFWL_ComboListDelegate;
- friend class CFWL_ComboBoxImp;
+class CFWL_ComboList : public CFWL_ListBoxImp {
+ public:
+ CFWL_ComboList(IFWL_Widget* pOuter);
+ CFWL_ComboList(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ int32_t MatchItem(const CFX_WideString& wsMatch);
+ void ChangeSelected(int32_t iSel);
+ int32_t CountItems();
+ void GetItemRect(int32_t nIndex, CFX_RectF& rtItem);
+ void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
+ void SetFocus(FX_BOOL bSet);
+ FX_BOOL m_bNotifyOwner;
+ friend class CFWL_ComboListDelegate;
+ friend class CFWL_ComboBoxImp;
};
-class CFWL_ComboListDelegate : public CFWL_ListBoxImpDelegate
-{
-public:
- CFWL_ComboListDelegate(CFWL_ComboList *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
-protected:
- void OnDropListFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- int32_t OnDropListMouseMove(CFWL_MsgMouse *pMsg);
- int32_t OnDropListLButtonDown(CFWL_MsgMouse *pMsg);
- int32_t OnDropListLButtonUp(CFWL_MsgMouse *pMsg);
- int32_t OnDropListKey(CFWL_MsgKey *pKey);
- void OnDropListKeyDown(CFWL_MsgKey *pKey);
- CFWL_ComboList *m_pOwner;
+class CFWL_ComboListDelegate : public CFWL_ListBoxImpDelegate {
+ public:
+ CFWL_ComboListDelegate(CFWL_ComboList* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+
+ protected:
+ void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg);
+ int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg);
+ int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg);
+ int32_t OnDropListKey(CFWL_MsgKey* pKey);
+ void OnDropListKeyDown(CFWL_MsgKey* pKey);
+ CFWL_ComboList* m_pOwner;
};
-class CFWL_ComboBoxImp : public CFWL_WidgetImp
-{
-public:
- CFWL_ComboBoxImp(IFWL_Widget *pOuter = NULL);
- CFWL_ComboBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_ComboBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);
- virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);
- virtual int32_t GetCurSel();
- virtual FWL_ERR SetCurSel(int32_t iSel);
- virtual FWL_ERR SetEditText(const CFX_WideString &wsText);
- virtual int32_t GetEditTextLength() const;
- virtual FWL_ERR GetEditText(CFX_WideString &wsText, int32_t nStart = 0, int32_t nCount = -1) const;
- virtual FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
- virtual int32_t GetEditSelRange(int32_t nIndex, int32_t &nStart);
- virtual int32_t GetEditLimit();
- virtual FWL_ERR SetEditLimit(int32_t nLimit);
- virtual FWL_ERR EditDoClipboard(int32_t iCmd);
- virtual FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
- virtual FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
- virtual IFWL_ListBox* GetListBoxt();
- virtual FX_BOOL AfterFocusShowDropList();
- virtual FX_ERR OpenDropDownList(FX_BOOL bActivate);
- virtual FX_BOOL EditCanUndo();
- virtual FX_BOOL EditCanRedo();
- virtual FX_BOOL EditUndo();
- virtual FX_BOOL EditRedo();
- virtual FX_BOOL EditCanCopy();
- virtual FX_BOOL EditCanCut();
- virtual FX_BOOL EditCanSelectAll();
- virtual FX_BOOL EditCopy(CFX_WideString &wsCopy);
- virtual FX_BOOL EditCut(CFX_WideString &wsCut);
- virtual FX_BOOL EditPaste(const CFX_WideString &wsPaste);
- virtual FX_BOOL EditSelectAll();
- virtual FX_BOOL EditDelete();
- virtual FX_BOOL EditDeSelect();
- virtual FWL_ERR GetBBox(CFX_RectF &rect);
- virtual FWL_ERR EditModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);
-protected:
- void DrawStretchHandler(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix);
- FX_FLOAT GetListHeight();
- void ShowDropList(FX_BOOL bActivate);
- FX_BOOL IsDropListShowed();
- FX_BOOL IsDropDownStyle() const;
- void MatchEditText();
- void SynchrEditText(int32_t iListItem);
- void Layout();
- void ReSetTheme();
- void ReSetEditAlignment();
- void ReSetListItemAlignment();
- void ProcessSelChanged(FX_BOOL bLButtonUp);
- void InitProxyForm();
-protected:
- FWL_ERR DisForm_Initialize();
- void DisForm_InitComboList();
- void DisForm_InitComboEdit();
- void DisForm_ShowDropList(FX_BOOL bActivate);
- FX_BOOL DisForm_IsDropListShowed();
- FWL_ERR DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);
- FWL_ERR DisForm_Update();
- FX_DWORD DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
- FWL_ERR DisForm_DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- FWL_ERR DisForm_GetBBox(CFX_RectF &rect);
- void DisForm_Layout();
-protected:
- CFX_RectF m_rtClient;
- CFX_RectF m_rtContent;
- CFX_RectF m_rtBtn;
- CFX_RectF m_rtList;
- CFX_RectF m_rtProxy;
- CFX_RectF m_rtHandler;
- IFWL_Edit *m_pEdit;
- IFWL_ListBox *m_pListBox;
- IFWL_Form *m_pForm;
- FX_BOOL m_bLButtonDown;
- FX_BOOL m_bUpFormHandler;
- int32_t m_iCurSel;
- int32_t m_iBtnState;
- FX_FLOAT m_fComboFormHandler;
- FX_FLOAT m_fItemHeight;
- FX_BOOL m_bNeedShowList;
- CFWL_FormProxyImp *m_pProxy;
- CFWL_ComboProxyImpDelegate *m_pListProxyDelegate;
+class CFWL_ComboBoxImp : public CFWL_WidgetImp {
+ public:
+ CFWL_ComboBoxImp(IFWL_Widget* pOuter = NULL);
+ CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_ComboBoxImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved);
+ virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
+ virtual FWL_ERR Update();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ virtual int32_t GetCurSel();
+ virtual FWL_ERR SetCurSel(int32_t iSel);
+ virtual FWL_ERR SetEditText(const CFX_WideString& wsText);
+ virtual int32_t GetEditTextLength() const;
+ virtual FWL_ERR GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ virtual FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
+ virtual int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
+ virtual int32_t GetEditLimit();
+ virtual FWL_ERR SetEditLimit(int32_t nLimit);
+ virtual FWL_ERR EditDoClipboard(int32_t iCmd);
+ virtual FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
+ virtual FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
+ virtual IFWL_ListBox* GetListBoxt();
+ virtual FX_BOOL AfterFocusShowDropList();
+ virtual FX_ERR OpenDropDownList(FX_BOOL bActivate);
+ virtual FX_BOOL EditCanUndo();
+ virtual FX_BOOL EditCanRedo();
+ virtual FX_BOOL EditUndo();
+ virtual FX_BOOL EditRedo();
+ virtual FX_BOOL EditCanCopy();
+ virtual FX_BOOL EditCanCut();
+ virtual FX_BOOL EditCanSelectAll();
+ virtual FX_BOOL EditCopy(CFX_WideString& wsCopy);
+ virtual FX_BOOL EditCut(CFX_WideString& wsCut);
+ virtual FX_BOOL EditPaste(const CFX_WideString& wsPaste);
+ virtual FX_BOOL EditSelectAll();
+ virtual FX_BOOL EditDelete();
+ virtual FX_BOOL EditDeSelect();
+ virtual FWL_ERR GetBBox(CFX_RectF& rect);
+ virtual FWL_ERR EditModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved);
+
+ protected:
+ void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix);
+ FX_FLOAT GetListHeight();
+ void ShowDropList(FX_BOOL bActivate);
+ FX_BOOL IsDropListShowed();
+ FX_BOOL IsDropDownStyle() const;
+ void MatchEditText();
+ void SynchrEditText(int32_t iListItem);
+ void Layout();
+ void ReSetTheme();
+ void ReSetEditAlignment();
+ void ReSetListItemAlignment();
+ void ProcessSelChanged(FX_BOOL bLButtonUp);
+ void InitProxyForm();
+
+ protected:
+ FWL_ERR DisForm_Initialize();
+ void DisForm_InitComboList();
+ void DisForm_InitComboEdit();
+ void DisForm_ShowDropList(FX_BOOL bActivate);
+ FX_BOOL DisForm_IsDropListShowed();
+ FWL_ERR DisForm_ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved);
+ FWL_ERR DisForm_Update();
+ FX_DWORD DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_ERR DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ FWL_ERR DisForm_GetBBox(CFX_RectF& rect);
+ void DisForm_Layout();
- friend class CFWL_ComboList;
- friend class CFWL_ComboEdit;
- friend class CFWL_ComboEditDelegate;
- friend class CFWL_ComboListDelegate;
- friend class CFWL_ComboBoxImpDelegate;
- friend class CFWL_ComboProxyImpDelegate;
+ protected:
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtContent;
+ CFX_RectF m_rtBtn;
+ CFX_RectF m_rtList;
+ CFX_RectF m_rtProxy;
+ CFX_RectF m_rtHandler;
+ IFWL_Edit* m_pEdit;
+ IFWL_ListBox* m_pListBox;
+ IFWL_Form* m_pForm;
+ FX_BOOL m_bLButtonDown;
+ FX_BOOL m_bUpFormHandler;
+ int32_t m_iCurSel;
+ int32_t m_iBtnState;
+ FX_FLOAT m_fComboFormHandler;
+ FX_FLOAT m_fItemHeight;
+ FX_BOOL m_bNeedShowList;
+ CFWL_FormProxyImp* m_pProxy;
+ CFWL_ComboProxyImpDelegate* m_pListProxyDelegate;
+
+ friend class CFWL_ComboList;
+ friend class CFWL_ComboEdit;
+ friend class CFWL_ComboEditDelegate;
+ friend class CFWL_ComboListDelegate;
+ friend class CFWL_ComboBoxImpDelegate;
+ friend class CFWL_ComboProxyImpDelegate;
};
-class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
+class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ void OnKey(CFWL_MsgKey* pMsg);
+ void DoSubCtrlKey(CFWL_MsgKey* pMsg);
-protected:
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- void OnKey(CFWL_MsgKey *pMsg);
- void DoSubCtrlKey(CFWL_MsgKey *pMsg);
-protected:
- int32_t DisForm_OnProcessMessage(CFWL_Message *pMessage);
- void DisForm_OnLButtonDown(CFWL_MsgMouse *pMsg);
- void DisForm_OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void DisForm_OnKey(CFWL_MsgKey *pMsg);
-protected:
- CFWL_ComboBoxImp *m_pOwner;
- friend class CFWL_ComboEditDelegate;
- friend class CFWL_ComboListDelegate;
+ protected:
+ int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage);
+ void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void DisForm_OnKey(CFWL_MsgKey* pMsg);
+
+ protected:
+ CFWL_ComboBoxImp* m_pOwner;
+ friend class CFWL_ComboEditDelegate;
+ friend class CFWL_ComboListDelegate;
};
-class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_ComboProxyImpDelegate(IFWL_Form *pForm, CFWL_ComboBoxImp *pComboBox);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- void Reset()
- {
- m_bLButtonUpSelf = FALSE;
- }
-protected:
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnDeactive(CFWL_MsgDeactivate *pMsg);
- void OnFocusChanged(CFWL_MsgKillFocus *pMsg, FX_BOOL bSet );
- FX_BOOL m_bLButtonDown;
- FX_BOOL m_bLButtonUpSelf;
- FX_FLOAT m_fStartPos;
- IFWL_Form *m_pForm;
- CFWL_ComboBoxImp *m_pComboBox;
+class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, CFWL_ComboBoxImp* pComboBox);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ void Reset() { m_bLButtonUpSelf = FALSE; }
+
+ protected:
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnDeactive(CFWL_MsgDeactivate* pMsg);
+ void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet);
+ FX_BOOL m_bLButtonDown;
+ FX_BOOL m_bLButtonUpSelf;
+ FX_FLOAT m_fStartPos;
+ IFWL_Form* m_pForm;
+ CFWL_ComboBoxImp* m_pComboBox;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h b/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h index f07dcb5532..13beecdd8c 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h @@ -20,187 +20,195 @@ class CFWL_DateTimeCalendar; class CFWL_DateTimeCalendarDelegate;
class CFWL_DateTimePickerImp;
class CFWL_DateTimePickerImpDelegate;
-class IFWL_DateTimeForm : public IFWL_Form
-{
-public:
- FWL_ERR Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
+class IFWL_DateTimeForm : public IFWL_Form {
+ public:
+ FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
};
-class IFWL_DateTimeCalender : public IFWL_MonthCalendar
-{
-public:
- FWL_ERR Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
+class IFWL_DateTimeCalender : public IFWL_MonthCalendar {
+ public:
+ FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
};
-class IFWL_DateTimeEdit : public IFWL_Edit
-{
-public:
- FWL_ERR Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
+class IFWL_DateTimeEdit : public IFWL_Edit {
+ public:
+ FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
};
-class CFWL_DateTimeEdit : public CFWL_EditImp
-{
-public:
- CFWL_DateTimeEdit(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-protected:
- friend class CFWL_DateTimeEditDelegate;
+class CFWL_DateTimeEdit : public CFWL_EditImp {
+ public:
+ CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+
+ protected:
+ friend class CFWL_DateTimeEditDelegate;
};
-class CFWL_DateTimeEditDelegate : public CFWL_EditImpDelegate
-{
-public:
- CFWL_DateTimeEditDelegate(CFWL_DateTimeEdit *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
-private:
- int32_t DisForm_OnProcessMessage(CFWL_Message *pMessage);
-
-protected:
- CFWL_DateTimeEdit *m_pOwner;
+class CFWL_DateTimeEditDelegate : public CFWL_EditImpDelegate {
+ public:
+ CFWL_DateTimeEditDelegate(CFWL_DateTimeEdit* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+
+ private:
+ int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage);
+
+ protected:
+ CFWL_DateTimeEdit* m_pOwner;
};
-class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp
-{
-public:
- CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-protected:
- friend class CFWL_DateTimeCalendarDelegate;
+class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp {
+ public:
+ CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+
+ protected:
+ friend class CFWL_DateTimeCalendarDelegate;
};
-class CFWL_DateTimeCalendarDelegate : public CFWL_MonthCalendarImpDelegate
-{
-public:
- CFWL_DateTimeCalendarDelegate(CFWL_DateTimeCalendar *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- void OnLButtonDownEx(CFWL_MsgMouse *pMsg);
- void OnLButtonUpEx(CFWL_MsgMouse *pMsg);
- void OnMouseMoveEx(CFWL_MsgMouse *pMsg);
-private:
- int32_t DisForm_OnProcessMessage(CFWL_Message *pMessage);
- void DisForm_OnLButtonUpEx(CFWL_MsgMouse *pMsg);
-protected:
- CFWL_DateTimeCalendar *m_pOwner;
- FX_BOOL m_bFlag;
+class CFWL_DateTimeCalendarDelegate : public CFWL_MonthCalendarImpDelegate {
+ public:
+ CFWL_DateTimeCalendarDelegate(CFWL_DateTimeCalendar* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ void OnLButtonDownEx(CFWL_MsgMouse* pMsg);
+ void OnLButtonUpEx(CFWL_MsgMouse* pMsg);
+ void OnMouseMoveEx(CFWL_MsgMouse* pMsg);
+
+ private:
+ int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage);
+ void DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg);
+
+ protected:
+ CFWL_DateTimeCalendar* m_pOwner;
+ FX_BOOL m_bFlag;
};
-class CFWL_DateTimePickerImp : public CFWL_WidgetImp
-{
-public:
- CFWL_DateTimePickerImp(IFWL_Widget *pOuter = NULL);
- CFWL_DateTimePickerImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_DateTimePickerImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider *pTP);
- virtual FWL_ERR GetCurSel(int32_t &iYear, int32_t &iMonth, int32_t &iDay);
- virtual FWL_ERR SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
- virtual FWL_ERR SetEditText(const CFX_WideString &wsText);
- virtual FWL_ERR GetEditText(CFX_WideString &wsText, int32_t nStart = 0, int32_t nCount = -1) const;
-public:
- virtual FX_BOOL CanUndo();
- virtual FX_BOOL CanRedo();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual FX_BOOL CanCopy();
- virtual FX_BOOL CanCut();
- virtual FX_BOOL CanSelectAll();
- virtual FX_BOOL Copy(CFX_WideString &wsCopy);
- virtual FX_BOOL Cut(CFX_WideString &wsCut);
- virtual FX_BOOL Paste(const CFX_WideString &wsPaste);
- virtual FX_BOOL SelectAll();
- virtual FX_BOOL Delete();
- virtual FX_BOOL DeSelect();
- virtual FWL_ERR GetBBox(CFX_RectF &rect);
- virtual FWL_ERR SetEditLimit(int32_t nLimit);
- virtual FWL_ERR ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);
-public:
- IFWL_DateTimeEdit* GetDataTimeEdit();
-protected:
- void DrawDropDownButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void FormatDateString(int32_t iYear, int32_t iMonth, int32_t iDay, CFX_WideString &wsText);
- void ShowMonthCalendar(FX_BOOL bActivate);
- FX_BOOL IsMonthCalendarShowed();
- void ReSetEditAlignment();
- void InitProxyForm();
- void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
-private:
- FWL_ERR DisForm_Initialize();
- void DisForm_InitDateTimeCalendar();
- void DisForm_InitDateTimeEdit();
- FX_BOOL DisForm_IsMonthCalendarShowed();
- void DisForm_ShowMonthCalendar(FX_BOOL bActivate);
- FX_DWORD DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
- FX_BOOL DisForm_IsNeedShowButton();
- FWL_ERR DisForm_Update();
- FWL_ERR DisForm_GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- FWL_ERR DisForm_GetBBox(CFX_RectF &rect);
- FWL_ERR DisForm_DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
-
- CFX_RectF m_rtBtn;
- CFX_RectF m_rtClient;
- int32_t m_iBtnState;
- int32_t m_iYear;
- int32_t m_iMonth;
- int32_t m_iDay;
- FX_BOOL m_bLBtnDown;
- IFWL_DateTimeEdit *m_pEdit;
- IFWL_DateTimeCalender *m_pMonthCal;
- IFWL_DateTimeForm *m_pForm;
- FX_FLOAT m_fBtn;
- class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP
- {
- public:
- CFWL_MonthCalendarImpDP()
- {
- m_iCurYear = 2010;
- m_iCurMonth = 3;
- m_iCurDay = 29;
- }
- virtual FWL_ERR GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
- {
- return FWL_ERR_Succeeded;
- }
- virtual int32_t GetCurDay(IFWL_Widget *pWidget)
- {
- return m_iCurDay;
- }
- virtual int32_t GetCurMonth(IFWL_Widget *pWidget)
- {
- return m_iCurMonth;
- }
- virtual int32_t GetCurYear(IFWL_Widget *pWidget)
- {
- return m_iCurYear;
- }
- int32_t m_iCurDay;
- int32_t m_iCurYear;
- int32_t m_iCurMonth;
- };
-
- CFWL_MonthCalendarImpDP m_MonthCalendarDP;
- friend class CFWL_DateTimeEditDelegate;
- friend class CFWL_DateTimeCalendar;
- friend class CFWL_DateTimeCalendarDelegate;
- friend class CFWL_DateTimePickerImpDelegate;
+class CFWL_DateTimePickerImp : public CFWL_WidgetImp {
+ public:
+ CFWL_DateTimePickerImp(IFWL_Widget* pOuter = NULL);
+ CFWL_DateTimePickerImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_DateTimePickerImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pTP);
+ virtual FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ virtual FWL_ERR SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
+ virtual FWL_ERR SetEditText(const CFX_WideString& wsText);
+ virtual FWL_ERR GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+
+ public:
+ virtual FX_BOOL CanUndo();
+ virtual FX_BOOL CanRedo();
+ virtual FX_BOOL Undo();
+ virtual FX_BOOL Redo();
+ virtual FX_BOOL CanCopy();
+ virtual FX_BOOL CanCut();
+ virtual FX_BOOL CanSelectAll();
+ virtual FX_BOOL Copy(CFX_WideString& wsCopy);
+ virtual FX_BOOL Cut(CFX_WideString& wsCut);
+ virtual FX_BOOL Paste(const CFX_WideString& wsPaste);
+ virtual FX_BOOL SelectAll();
+ virtual FX_BOOL Delete();
+ virtual FX_BOOL DeSelect();
+ virtual FWL_ERR GetBBox(CFX_RectF& rect);
+ virtual FWL_ERR SetEditLimit(int32_t nLimit);
+ virtual FWL_ERR ModifyEditStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved);
+
+ public:
+ IFWL_DateTimeEdit* GetDataTimeEdit();
+
+ protected:
+ void DrawDropDownButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void FormatDateString(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay,
+ CFX_WideString& wsText);
+ void ShowMonthCalendar(FX_BOOL bActivate);
+ FX_BOOL IsMonthCalendarShowed();
+ void ReSetEditAlignment();
+ void InitProxyForm();
+ void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
+
+ private:
+ FWL_ERR DisForm_Initialize();
+ void DisForm_InitDateTimeCalendar();
+ void DisForm_InitDateTimeEdit();
+ FX_BOOL DisForm_IsMonthCalendarShowed();
+ void DisForm_ShowMonthCalendar(FX_BOOL bActivate);
+ FX_DWORD DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FX_BOOL DisForm_IsNeedShowButton();
+ FWL_ERR DisForm_Update();
+ FWL_ERR DisForm_GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ FWL_ERR DisForm_GetBBox(CFX_RectF& rect);
+ FWL_ERR DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ CFX_RectF m_rtBtn;
+ CFX_RectF m_rtClient;
+ int32_t m_iBtnState;
+ int32_t m_iYear;
+ int32_t m_iMonth;
+ int32_t m_iDay;
+ FX_BOOL m_bLBtnDown;
+ IFWL_DateTimeEdit* m_pEdit;
+ IFWL_DateTimeCalender* m_pMonthCal;
+ IFWL_DateTimeForm* m_pForm;
+ FX_FLOAT m_fBtn;
+ class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP {
+ public:
+ CFWL_MonthCalendarImpDP() {
+ m_iCurYear = 2010;
+ m_iCurMonth = 3;
+ m_iCurDay = 29;
+ }
+ virtual FWL_ERR GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_ERR_Succeeded;
+ }
+ virtual int32_t GetCurDay(IFWL_Widget* pWidget) { return m_iCurDay; }
+ virtual int32_t GetCurMonth(IFWL_Widget* pWidget) { return m_iCurMonth; }
+ virtual int32_t GetCurYear(IFWL_Widget* pWidget) { return m_iCurYear; }
+ int32_t m_iCurDay;
+ int32_t m_iCurYear;
+ int32_t m_iCurMonth;
+ };
+
+ CFWL_MonthCalendarImpDP m_MonthCalendarDP;
+ friend class CFWL_DateTimeEditDelegate;
+ friend class CFWL_DateTimeCalendar;
+ friend class CFWL_DateTimeCalendarDelegate;
+ friend class CFWL_DateTimePickerImpDelegate;
};
-class CFWL_DateTimePickerImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_DateTimePickerImpDelegate(CFWL_DateTimePickerImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
-
- CFWL_DateTimePickerImp *m_pOwner;
-private:
- void DisForm_OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
+class CFWL_DateTimePickerImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_DateTimePickerImpDelegate(CFWL_DateTimePickerImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+
+ CFWL_DateTimePickerImp* m_pOwner;
+
+ private:
+ void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_editimp.h b/xfa/src/fwl/src/basewidget/include/fwl_editimp.h index 532e055f99..ac9cc41bea 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_editimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_editimp.h @@ -14,156 +14,187 @@ class IFWL_Caret; class IFWL_AdapterTextField;
class CFWL_EditImp;
class CFWL_EditImpDelegate;
-class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink
-{
-public:
- CFWL_EditImp(IFWL_Widget *pOuter = NULL);
- CFWL_EditImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_EditImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF &rect);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);
- virtual FWL_ERR SetText(const CFX_WideString &wsText);
- virtual int32_t GetTextLength() const;
- virtual FWL_ERR GetText(CFX_WideString &wsText, int32_t nStart = 0, int32_t nCount = -1) const;
- virtual FWL_ERR ClearText();
- virtual int32_t GetCaretPos() const;
- virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
- virtual FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1);
- virtual int32_t CountSelRanges();
- virtual int32_t GetSelRange(int32_t nIndex, int32_t &nStart);
- virtual FWL_ERR ClearSelections();
- virtual int32_t GetLimit();
- virtual FWL_ERR SetLimit(int32_t nLimit);
- virtual FWL_ERR SetAliasChar(FX_WCHAR wAlias);
- virtual FWL_ERR SetFormatString(const CFX_WideString &wsFormat);
- virtual FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
- virtual FWL_ERR DeleteSelections();
- virtual FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1);
- virtual FWL_ERR ReplaceSelections(const CFX_WideStringC &wsReplace);
- virtual FWL_ERR Replace(int32_t nStart, int32_t nLen, const CFX_WideStringC &wsReplace);
- virtual FWL_ERR DoClipboard(int32_t iCmd);
- virtual FX_BOOL Copy(CFX_WideString &wsCopy);
- virtual FX_BOOL Cut(CFX_WideString &wsCut);
- virtual FX_BOOL Paste(const CFX_WideString &wsPaste);
- virtual FX_BOOL Delete();
- virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
- virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual FX_BOOL CanUndo();
- virtual FX_BOOL CanRedo();
- virtual FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
- virtual FWL_ERR SetOuter(IFWL_Widget *pOuter);
- virtual FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax);
- void On_CaretChanged(IFDE_TxtEdtEngine *pEdit, int32_t nPage, FX_BOOL bVisible = true) override;
- void On_TextChanged(IFDE_TxtEdtEngine * pEdit, FDE_TXTEDT_TEXTCHANGE_INFO &ChangeInfo) override;
- void On_PageCountChanged(IFDE_TxtEdtEngine *pEdit) override {}
- void On_SelChanged(IFDE_TxtEdtEngine *pEdit) override;
- FX_BOOL On_PageLoad(IFDE_TxtEdtEngine *pEdit, int32_t nPageIndex, int32_t nPurpose) override;
- FX_BOOL On_PageUnload(IFDE_TxtEdtEngine *pEdit, int32_t nPageIndex, int32_t nPurpose) override;
- FX_BOOL On_PageChange(IFDE_TxtEdtEngine *pEdit, int32_t nPageIndex) override
- {
- return TRUE;
- }
- void On_AddDoRecord(IFDE_TxtEdtEngine *pEdit, const CFX_ByteStringC& bsDoRecord) override;
- FX_BOOL On_ValidateField(IFDE_TxtEdtEngine *pEdit, int32_t nBlockIndex, int32_t nFieldIndex, \
- const CFX_WideString &wsFieldText, int32_t nCharIndex) override;
- FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine *pEdit, int32_t nBlockIndex) override;
- FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine *pEdit, int32_t nBlockIndex, CFX_WideString &wsBlockText) override;
- FX_BOOL On_Validate(IFDE_TxtEdtEngine * pEdit, CFX_WideString &wsText) override;
- virtual FWL_ERR SetBackgroundColor(FX_DWORD color);
- virtual FWL_ERR SetFont(const CFX_WideString &wsFont, FX_FLOAT fSize);
- void SetScrollOffset(FX_FLOAT fScrollOffset);
- FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray &sSuggest);
- FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, const CFX_ByteStringC& bsReplace);
-protected:
- void DrawTextBk(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void DrawContent(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void UpdateEditEngine();
- void UpdateEditParams();
- void UpdateEditLayout();
- FX_BOOL UpdateOffset();
- FX_BOOL UpdateOffset(IFWL_ScrollBar *pScrollBar, FX_FLOAT fPosChanged);
- void UpdateVAlignment();
- void UpdateCaret();
- IFWL_ScrollBar* UpdateScroll();
- void Layout();
- void LayoutScrollBar();
- void DeviceToEngine(CFX_PointF &pt);
- void InitScrollBar(FX_BOOL bVert = TRUE);
- void InitEngine();
- virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF *pRect = NULL);
- FX_BOOL ValidateNumberChar(FX_WCHAR cNum);
- void InitCaret();
- void ClearRecord();
- FX_BOOL IsShowScrollBar(FX_BOOL bVert);
- FX_BOOL IsContentHeightOverflow();
- int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord);
- void ProcessInsertError(int32_t iError);
+class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
+ public:
+ CFWL_EditImp(IFWL_Widget* pOuter = NULL);
+ CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_EditImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
+ virtual FWL_ERR Update();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ virtual FWL_ERR SetText(const CFX_WideString& wsText);
+ virtual int32_t GetTextLength() const;
+ virtual FWL_ERR GetText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ virtual FWL_ERR ClearText();
+ virtual int32_t GetCaretPos() const;
+ virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
+ virtual FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1);
+ virtual int32_t CountSelRanges();
+ virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
+ virtual FWL_ERR ClearSelections();
+ virtual int32_t GetLimit();
+ virtual FWL_ERR SetLimit(int32_t nLimit);
+ virtual FWL_ERR SetAliasChar(FX_WCHAR wAlias);
+ virtual FWL_ERR SetFormatString(const CFX_WideString& wsFormat);
+ virtual FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
+ virtual FWL_ERR DeleteSelections();
+ virtual FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1);
+ virtual FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace);
+ virtual FWL_ERR Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace);
+ virtual FWL_ERR DoClipboard(int32_t iCmd);
+ virtual FX_BOOL Copy(CFX_WideString& wsCopy);
+ virtual FX_BOOL Cut(CFX_WideString& wsCut);
+ virtual FX_BOOL Paste(const CFX_WideString& wsPaste);
+ virtual FX_BOOL Delete();
+ virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
+ virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
+ virtual FX_BOOL Undo();
+ virtual FX_BOOL Redo();
+ virtual FX_BOOL CanUndo();
+ virtual FX_BOOL CanRedo();
+ virtual FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ virtual FWL_ERR SetOuter(IFWL_Widget* pOuter);
+ virtual FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax);
+ void On_CaretChanged(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPage,
+ FX_BOOL bVisible = true) override;
+ void On_TextChanged(IFDE_TxtEdtEngine* pEdit,
+ FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) override;
+ void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) override {}
+ void On_SelChanged(IFDE_TxtEdtEngine* pEdit) override;
+ FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPageIndex,
+ int32_t nPurpose) override;
+ FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPageIndex,
+ int32_t nPurpose) override;
+ FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit, int32_t nPageIndex) override {
+ return TRUE;
+ }
+ void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit,
+ const CFX_ByteStringC& bsDoRecord) override;
+ FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit,
+ int32_t nBlockIndex,
+ int32_t nFieldIndex,
+ const CFX_WideString& wsFieldText,
+ int32_t nCharIndex) override;
+ FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit,
+ int32_t nBlockIndex) override;
+ FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit,
+ int32_t nBlockIndex,
+ CFX_WideString& wsBlockText) override;
+ FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit,
+ CFX_WideString& wsText) override;
+ virtual FWL_ERR SetBackgroundColor(FX_DWORD color);
+ virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
+ void SetScrollOffset(FX_FLOAT fScrollOffset);
+ FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest);
+ FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
+ const CFX_ByteStringC& bsReplace);
- void DrawSpellCheck(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- void AddSpellCheckObj(CFX_Path& PathData, int32_t nStart, int32_t nCount, FX_FLOAT fOffSetX, FX_FLOAT fOffSetY);
- int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount);
- CFX_RectF m_rtClient;
- CFX_RectF m_rtEngine;
- CFX_RectF m_rtStatic;
- FX_FLOAT m_fVAlignOffset;
- FX_FLOAT m_fScrollOffsetX;
- FX_FLOAT m_fScrollOffsetY;
- IFDE_TxtEdtEngine* m_pEdtEngine;
- FX_BOOL m_bLButtonDown;
- int32_t m_nSelStart;
- int32_t m_nLimit;
- FX_FLOAT m_fSpaceAbove;
- FX_FLOAT m_fSpaceBelow;
- FX_FLOAT m_fFontSize;
- FX_ARGB m_argbSel;
- FX_BOOL m_bSetRange;
- int32_t m_iMin;
- int32_t m_iMax;
- IFWL_ScrollBar* m_pVertScrollBar;
- IFWL_ScrollBar* m_pHorzScrollBar;
- IFWL_Caret* m_pCaret;
- IFWL_AdapterTextField* m_pTextField;
- CFX_WideString m_wsCache;
- friend class CFWL_TxtEdtEventSink;
- friend class CFWL_EditImpDelegate;
- FX_DWORD m_backColor;
- FX_BOOL m_updateBackColor;
- CFX_WideString m_wsFont;
- CFX_ByteStringArray m_RecordArr;
- int32_t m_iCurRecord;
- int32_t m_iMaxRecord;
+ protected:
+ void DrawTextBk(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawContent(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void UpdateEditEngine();
+ void UpdateEditParams();
+ void UpdateEditLayout();
+ FX_BOOL UpdateOffset();
+ FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged);
+ void UpdateVAlignment();
+ void UpdateCaret();
+ IFWL_ScrollBar* UpdateScroll();
+ void Layout();
+ void LayoutScrollBar();
+ void DeviceToEngine(CFX_PointF& pt);
+ void InitScrollBar(FX_BOOL bVert = TRUE);
+ void InitEngine();
+ virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = NULL);
+ FX_BOOL ValidateNumberChar(FX_WCHAR cNum);
+ void InitCaret();
+ void ClearRecord();
+ FX_BOOL IsShowScrollBar(FX_BOOL bVert);
+ FX_BOOL IsContentHeightOverflow();
+ int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord);
+ void ProcessInsertError(int32_t iError);
+
+ void DrawSpellCheck(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ void AddSpellCheckObj(CFX_Path& PathData,
+ int32_t nStart,
+ int32_t nCount,
+ FX_FLOAT fOffSetX,
+ FX_FLOAT fOffSetY);
+ int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount);
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtEngine;
+ CFX_RectF m_rtStatic;
+ FX_FLOAT m_fVAlignOffset;
+ FX_FLOAT m_fScrollOffsetX;
+ FX_FLOAT m_fScrollOffsetY;
+ IFDE_TxtEdtEngine* m_pEdtEngine;
+ FX_BOOL m_bLButtonDown;
+ int32_t m_nSelStart;
+ int32_t m_nLimit;
+ FX_FLOAT m_fSpaceAbove;
+ FX_FLOAT m_fSpaceBelow;
+ FX_FLOAT m_fFontSize;
+ FX_ARGB m_argbSel;
+ FX_BOOL m_bSetRange;
+ int32_t m_iMin;
+ int32_t m_iMax;
+ IFWL_ScrollBar* m_pVertScrollBar;
+ IFWL_ScrollBar* m_pHorzScrollBar;
+ IFWL_Caret* m_pCaret;
+ IFWL_AdapterTextField* m_pTextField;
+ CFX_WideString m_wsCache;
+ friend class CFWL_TxtEdtEventSink;
+ friend class CFWL_EditImpDelegate;
+ FX_DWORD m_backColor;
+ FX_BOOL m_updateBackColor;
+ CFX_WideString m_wsFont;
+ CFX_ByteStringArray m_RecordArr;
+ int32_t m_iCurRecord;
+ int32_t m_iMaxRecord;
};
-class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_EditImpDelegate(CFWL_EditImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void DoActivate(CFWL_MsgActivate *pMsg);
- void DoDeactivate(CFWL_MsgDeactivate *pMsg);
- void DoButtonDown(CFWL_MsgMouse *pMsg);
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnButtonDblClk(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnKeyDown(CFWL_MsgKey *pMsg);
- void OnChar(CFWL_MsgKey *pMsg);
- FX_BOOL OnScroll(IFWL_ScrollBar *pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos);
- void DoCursor(CFWL_MsgMouse *pMsg);
- CFWL_EditImp *m_pOwner;
+class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_EditImpDelegate(CFWL_EditImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void DoActivate(CFWL_MsgActivate* pMsg);
+ void DoDeactivate(CFWL_MsgDeactivate* pMsg);
+ void DoButtonDown(CFWL_MsgMouse* pMsg);
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnButtonDblClk(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnKeyDown(CFWL_MsgKey* pMsg);
+ void OnChar(CFWL_MsgKey* pMsg);
+ FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos);
+ void DoCursor(CFWL_MsgMouse* pMsg);
+ CFWL_EditImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_formproxyimp.h b/xfa/src/fwl/src/basewidget/include/fwl_formproxyimp.h index 30d2c1f21f..0e5baf0b47 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_formproxyimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_formproxyimp.h @@ -12,28 +12,30 @@ class CFWL_WidgetImpDelegate; class CFWL_FormImp;
class CFWL_FormProxyImp;
class CFWL_FormProxyImpDelegate;
-class CFWL_FormProxyImp : public CFWL_FormImp
-{
-public:
- CFWL_FormProxyImp(IFWL_Widget *pOuter);
- CFWL_FormProxyImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter);
- ~CFWL_FormProxyImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- friend class CFWL_FormProxyImpDelegate;
+class CFWL_FormProxyImp : public CFWL_FormImp {
+ public:
+ CFWL_FormProxyImp(IFWL_Widget* pOuter);
+ CFWL_FormProxyImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
+ ~CFWL_FormProxyImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ friend class CFWL_FormProxyImpDelegate;
};
-class CFWL_FormProxyImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_FormProxyImpDelegate(CFWL_FormProxyImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
-protected:
- CFWL_FormProxyImp *m_pOwner;
+class CFWL_FormProxyImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+
+ protected:
+ CFWL_FormProxyImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h b/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h index 7cbb0b8cfd..a2d6e65347 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h @@ -13,86 +13,105 @@ class CFWL_ScrollBarImp; class IFWL_Widget;
class CFWL_ListBoxImp;
class CFWL_ListBoxImpDelegate;
-class CFWL_ListBoxImp : public CFWL_WidgetImp
-{
-public:
- CFWL_ListBoxImp(IFWL_Widget *pOuter = NULL);
- CFWL_ListBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_ListBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);
- virtual int32_t CountSelItems();
- virtual FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
- virtual int32_t GetSelIndex(int32_t nIndex);
- virtual FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
- virtual FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString &wsText);
- virtual FWL_ERR GetScrollPos(FX_FLOAT &fPos, FX_BOOL bVert = TRUE);
- virtual FWL_ERR* Sort(IFWL_ListBoxCompare *pCom);
-protected:
- FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, FX_DWORD dwKeyCode);
- void SetSelection(FWL_HLISTITEM hStart, FWL_HLISTITEM hEnd, FX_BOOL bSelected);
- void SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect);
- FX_BOOL IsItemSelected(FWL_HLISTITEM hItem);
- void ClearSelection();
- void SelectAll();
- FWL_HLISTITEM GetFocusedItem();
- void SetFocusItem(FWL_HLISTITEM hItem);
- FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
- FX_BOOL GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF &rtCheck);
- FX_BOOL SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked);
- FX_BOOL GetItemChecked(FWL_HLISTITEM hItem);
- FX_BOOL ScrollToVisible(FWL_HLISTITEM hItem);
- void DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void DrawItems(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void DrawItem(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FWL_HLISTITEM hItem, int32_t Index, const CFX_RectF &rtItem, const CFX_Matrix *pMatrix = NULL);
- void DrawStatic(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme);
- CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE);
- void GetItemSize(CFX_SizeF &size, FWL_HLISTITEM hItem, FX_FLOAT fWidth, FX_FLOAT fHeight, FX_BOOL bAutoSize = FALSE);
- FX_FLOAT GetMaxTextWidth();
- FX_FLOAT GetScrollWidth();
- FX_FLOAT GetItemHeigt();
- void InitScrollBar(FX_BOOL bVert = TRUE);
- void SortItem();
- FX_BOOL IsShowScrollBar(FX_BOOL bVert);
- void ProcessSelChanged();
-protected:
- CFX_RectF m_rtClient;
- CFX_RectF m_rtStatic;
- CFX_RectF m_rtConent;
- IFWL_ScrollBar* m_pHorzScrollBar;
- IFWL_ScrollBar* m_pVertScrollBar;
- FX_DWORD m_dwTTOStyles;
- int32_t m_iTTOAligns;
- FWL_HLISTITEM m_hAnchor;
- FX_FLOAT m_fItemHeight;
- FX_FLOAT m_fScorllBarWidth;
- FX_BOOL m_bLButtonDown;
- IFWL_ThemeProvider *m_pScrollBarTP;
- friend class CFWL_ListBoxImpDelegate;
+class CFWL_ListBoxImp : public CFWL_WidgetImp {
+ public:
+ CFWL_ListBoxImp(IFWL_Widget* pOuter = NULL);
+ CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_ListBoxImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ virtual int32_t CountSelItems();
+ virtual FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
+ virtual int32_t GetSelIndex(int32_t nIndex);
+ virtual FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
+ virtual FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
+ virtual FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
+ virtual FWL_ERR* Sort(IFWL_ListBoxCompare* pCom);
+
+ protected:
+ FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, FX_DWORD dwKeyCode);
+ void SetSelection(FWL_HLISTITEM hStart,
+ FWL_HLISTITEM hEnd,
+ FX_BOOL bSelected);
+ void SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect);
+ FX_BOOL IsItemSelected(FWL_HLISTITEM hItem);
+ void ClearSelection();
+ void SelectAll();
+ FWL_HLISTITEM GetFocusedItem();
+ void SetFocusItem(FWL_HLISTITEM hItem);
+ FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
+ FX_BOOL GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF& rtCheck);
+ FX_BOOL SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked);
+ FX_BOOL GetItemChecked(FWL_HLISTITEM hItem);
+ FX_BOOL ScrollToVisible(FWL_HLISTITEM hItem);
+ void DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawItems(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawItem(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ FWL_HLISTITEM hItem,
+ int32_t Index,
+ const CFX_RectF& rtItem,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
+ CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE);
+ void GetItemSize(CFX_SizeF& size,
+ FWL_HLISTITEM hItem,
+ FX_FLOAT fWidth,
+ FX_FLOAT fHeight,
+ FX_BOOL bAutoSize = FALSE);
+ FX_FLOAT GetMaxTextWidth();
+ FX_FLOAT GetScrollWidth();
+ FX_FLOAT GetItemHeigt();
+ void InitScrollBar(FX_BOOL bVert = TRUE);
+ void SortItem();
+ FX_BOOL IsShowScrollBar(FX_BOOL bVert);
+ void ProcessSelChanged();
+
+ protected:
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtStatic;
+ CFX_RectF m_rtConent;
+ IFWL_ScrollBar* m_pHorzScrollBar;
+ IFWL_ScrollBar* m_pVertScrollBar;
+ FX_DWORD m_dwTTOStyles;
+ int32_t m_iTTOAligns;
+ FWL_HLISTITEM m_hAnchor;
+ FX_FLOAT m_fItemHeight;
+ FX_FLOAT m_fScorllBarWidth;
+ FX_BOOL m_bLButtonDown;
+ IFWL_ThemeProvider* m_pScrollBarTP;
+ friend class CFWL_ListBoxImpDelegate;
};
-class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_ListBoxImpDelegate(CFWL_ListBoxImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseWheel(CFWL_MsgMouseWheel *pMsg);
- void OnKeyDown(CFWL_MsgKey *pMsg);
- void OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl);
- FX_BOOL OnScroll(IFWL_ScrollBar *pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos);
- void DispatchSelChangedEv();
- CFWL_ListBoxImp *m_pOwner;
+class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
+ void OnKeyDown(CFWL_MsgKey* pMsg);
+ void OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl);
+ FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos);
+ void DispatchSelChangedEv();
+ CFWL_ListBoxImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_monthcalendarimp.h b/xfa/src/fwl/src/basewidget/include/fwl_monthcalendarimp.h index 0cf2ed444a..7cc1a19724 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_monthcalendarimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_monthcalendarimp.h @@ -15,189 +15,235 @@ class CFDE_DateTime; extern uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
class CFWL_MonthCalendarImp;
class CFWL_MonthCalendarImpDelegate;
-class CFWL_MonthCalendarImp : public CFWL_WidgetImp
-{
-public:
- CFWL_MonthCalendarImp(IFWL_Widget *pOuter = NULL);
- CFWL_MonthCalendarImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_MonthCalendarImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual int32_t CountSelect();
- virtual FX_BOOL GetSelect(int32_t &iYear, int32_t &iMonth, int32_t &iDay, int32_t nIndex = 0);
- virtual FX_BOOL SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay);
-protected:
- void DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawHeadBK(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawLButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawRButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawCaption(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawSeperator(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawDatesInBK(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawWeek(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawWeekNumber(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawWeekNumberSep(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawToday(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawDatesIn(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawDatesOut(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawDatesInCircle(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawTodayCircle(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE);
- void LayOut();
- void CalcHeadSize();
- void CalcTodaySize();
- void CalDateItem();
- void GetCapValue();
- int32_t CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay);
+class CFWL_MonthCalendarImp : public CFWL_WidgetImp {
+ public:
+ CFWL_MonthCalendarImp(IFWL_Widget* pOuter = NULL);
+ CFWL_MonthCalendarImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_MonthCalendarImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual int32_t CountSelect();
+ virtual FX_BOOL GetSelect(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay,
+ int32_t nIndex = 0);
+ virtual FX_BOOL SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay);
- FX_BOOL GetMinDate(int32_t &iYear, int32_t &iMonth, int32_t &iDay);
- FX_BOOL SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay);
- FX_BOOL GetMaxDate(int32_t &iYear, int32_t &iMonth, int32_t &iDay);
- FX_BOOL SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay);
- FX_BOOL InitDate();
- void ClearDateItem();
- void ReSetDateItem();
- FX_BOOL NextMonth();
- FX_BOOL PrevMonth();
- void ChangeToMonth(int32_t iYear, int32_t iMonth);
- FX_BOOL RemoveSelDay(int32_t iDay, FX_BOOL bAll = FALSE);
- FX_BOOL AddSelDay(int32_t iDay);
- FX_BOOL JumpToToday();
- void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString &wsHead);
- void GetTodayText(int32_t iYear, int32_t iMonth, int32_t iDay, CFX_WideString &wsToday);
- int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y);
- FX_BOOL GetDayRect(int32_t iDay, CFX_RectF &rtDay);
- typedef struct _DATE {
- _DATE()
- {
- iYear = 0;
- iMonth = 0;
- iDay = 0;
- }
- _DATE(int32_t year, int32_t month, int32_t day) : iYear(year), iMonth(month), iDay(day) {}
- FX_BOOL operator < (const _DATE &right)
- {
- if (iYear < right.iYear) {
- return TRUE;
- } else if (iYear == right.iYear) {
- if (iMonth < right.iMonth) {
- return TRUE;
- } else if (iMonth == right.iMonth) {
- return iDay < right.iDay;
- }
- }
- return FALSE;
+ protected:
+ void DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawHeadBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawLButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawRButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawCaption(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawSeperator(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawDatesInBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawWeek(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawWeekNumber(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawWeekNumberSep(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawToday(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawDatesIn(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawDatesOut(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawDatesInCircle(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawTodayCircle(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE);
+ void LayOut();
+ void CalcHeadSize();
+ void CalcTodaySize();
+ void CalDateItem();
+ void GetCapValue();
+ int32_t CalWeekNumber(int32_t iYear, int32_t iMonth, int32_t iDay);
+
+ FX_BOOL GetMinDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ FX_BOOL SetMinDate(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FX_BOOL GetMaxDate(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ FX_BOOL SetMaxDate(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FX_BOOL InitDate();
+ void ClearDateItem();
+ void ReSetDateItem();
+ FX_BOOL NextMonth();
+ FX_BOOL PrevMonth();
+ void ChangeToMonth(int32_t iYear, int32_t iMonth);
+ FX_BOOL RemoveSelDay(int32_t iDay, FX_BOOL bAll = FALSE);
+ FX_BOOL AddSelDay(int32_t iDay);
+ FX_BOOL JumpToToday();
+ void GetHeadText(int32_t iYear, int32_t iMonth, CFX_WideString& wsHead);
+ void GetTodayText(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay,
+ CFX_WideString& wsToday);
+ int32_t GetDayAtPoint(FX_FLOAT x, FX_FLOAT y);
+ FX_BOOL GetDayRect(int32_t iDay, CFX_RectF& rtDay);
+ typedef struct _DATE {
+ _DATE() {
+ iYear = 0;
+ iMonth = 0;
+ iDay = 0;
+ }
+ _DATE(int32_t year, int32_t month, int32_t day)
+ : iYear(year), iMonth(month), iDay(day) {}
+ FX_BOOL operator<(const _DATE& right) {
+ if (iYear < right.iYear) {
+ return TRUE;
+ } else if (iYear == right.iYear) {
+ if (iMonth < right.iMonth) {
+ return TRUE;
+ } else if (iMonth == right.iMonth) {
+ return iDay < right.iDay;
}
- FX_BOOL operator > (const _DATE &right)
- {
- if (iYear > right.iYear) {
- return TRUE;
- } else if (iYear == right.iYear) {
- if (iMonth > right.iMonth) {
- return TRUE;
- } else if (iMonth == right.iMonth) {
- return iDay > right.iDay;
- }
- }
- return FALSE;
+ }
+ return FALSE;
+ }
+ FX_BOOL operator>(const _DATE& right) {
+ if (iYear > right.iYear) {
+ return TRUE;
+ } else if (iYear == right.iYear) {
+ if (iMonth > right.iMonth) {
+ return TRUE;
+ } else if (iMonth == right.iMonth) {
+ return iDay > right.iDay;
}
- int32_t iYear;
- int32_t iMonth;
- int32_t iDay;
+ }
+ return FALSE;
+ }
+ int32_t iYear;
+ int32_t iMonth;
+ int32_t iDay;
- } DATE, *LPDATE;
- FX_BOOL m_bInit;
- CFX_RectF m_rtHead;
- CFX_RectF m_rtWeek;
- CFX_RectF m_rtLBtn;
- CFX_RectF m_rtRBtn;
- CFX_RectF m_rtDates;
- CFX_RectF m_rtHSep;
- CFX_RectF m_rtHeadText;
- CFX_RectF m_rtToday;
- CFX_RectF m_rtTodayFlag;
- CFX_RectF m_rtWeekNum;
- CFX_RectF m_rtWeekNumSep;
- CFX_RectF m_rtTemp;
- CFX_WideString m_wsHead;
- CFX_WideString m_wsToday;
- CFX_DateTime *m_pDateTime;
- CFX_PtrArray m_arrDates;
- int32_t m_iCurYear;
- int32_t m_iCurMonth;
- int32_t m_iYear;
- int32_t m_iMonth;
- int32_t m_iDay;
- int32_t m_iHovered;
- int32_t m_iLBtnPartStates;
- int32_t m_iRBtnPartStates;
- DATE m_dtMin;
- DATE m_dtMax;
- CFX_SizeF m_szHead;
- CFX_SizeF m_szCell;
- CFX_SizeF m_szToday;
- typedef CFX_ArrayTemplate<int32_t> CFWL_Int32Array;
- CFWL_Int32Array m_arrSelDays;
- int32_t m_iMaxSel;
- CFX_RectF m_rtClient;
- FX_FLOAT m_fHeadWid;
- FX_FLOAT m_fHeadHei;
- FX_FLOAT m_fHeadBtnWid;
- FX_FLOAT m_fHeadBtnHei;
- FX_FLOAT m_fHeadBtnHMargin;
- FX_FLOAT m_fHeadBtnVMargin;
- FX_FLOAT m_fHeadTextWid;
- FX_FLOAT m_fHeadTextHei;
- FX_FLOAT m_fHeadTextHMargin;
- FX_FLOAT m_fHeadTextVMargin;
- FX_FLOAT m_fHSepWid;
- FX_FLOAT m_fHSepHei;
+ } DATE, *LPDATE;
+ FX_BOOL m_bInit;
+ CFX_RectF m_rtHead;
+ CFX_RectF m_rtWeek;
+ CFX_RectF m_rtLBtn;
+ CFX_RectF m_rtRBtn;
+ CFX_RectF m_rtDates;
+ CFX_RectF m_rtHSep;
+ CFX_RectF m_rtHeadText;
+ CFX_RectF m_rtToday;
+ CFX_RectF m_rtTodayFlag;
+ CFX_RectF m_rtWeekNum;
+ CFX_RectF m_rtWeekNumSep;
+ CFX_RectF m_rtTemp;
+ CFX_WideString m_wsHead;
+ CFX_WideString m_wsToday;
+ CFX_DateTime* m_pDateTime;
+ CFX_PtrArray m_arrDates;
+ int32_t m_iCurYear;
+ int32_t m_iCurMonth;
+ int32_t m_iYear;
+ int32_t m_iMonth;
+ int32_t m_iDay;
+ int32_t m_iHovered;
+ int32_t m_iLBtnPartStates;
+ int32_t m_iRBtnPartStates;
+ DATE m_dtMin;
+ DATE m_dtMax;
+ CFX_SizeF m_szHead;
+ CFX_SizeF m_szCell;
+ CFX_SizeF m_szToday;
+ typedef CFX_ArrayTemplate<int32_t> CFWL_Int32Array;
+ CFWL_Int32Array m_arrSelDays;
+ int32_t m_iMaxSel;
+ CFX_RectF m_rtClient;
+ FX_FLOAT m_fHeadWid;
+ FX_FLOAT m_fHeadHei;
+ FX_FLOAT m_fHeadBtnWid;
+ FX_FLOAT m_fHeadBtnHei;
+ FX_FLOAT m_fHeadBtnHMargin;
+ FX_FLOAT m_fHeadBtnVMargin;
+ FX_FLOAT m_fHeadTextWid;
+ FX_FLOAT m_fHeadTextHei;
+ FX_FLOAT m_fHeadTextHMargin;
+ FX_FLOAT m_fHeadTextVMargin;
+ FX_FLOAT m_fHSepWid;
+ FX_FLOAT m_fHSepHei;
- FX_FLOAT m_fWeekNumWid;
- FX_FLOAT m_fSepDOffset;
- FX_FLOAT m_fSepX;
- FX_FLOAT m_fSepY;
+ FX_FLOAT m_fWeekNumWid;
+ FX_FLOAT m_fSepDOffset;
+ FX_FLOAT m_fSepX;
+ FX_FLOAT m_fSepY;
- FX_FLOAT m_fWeekNumHeigh;
- FX_FLOAT m_fWeekWid;
- FX_FLOAT m_fWeekHei;
- FX_FLOAT m_fDateCellWid;
- FX_FLOAT m_fDateCellHei;
+ FX_FLOAT m_fWeekNumHeigh;
+ FX_FLOAT m_fWeekWid;
+ FX_FLOAT m_fWeekHei;
+ FX_FLOAT m_fDateCellWid;
+ FX_FLOAT m_fDateCellHei;
- FX_FLOAT m_fTodayWid;
- FX_FLOAT m_fTodayHei;
- FX_FLOAT m_fTodayFlagWid;
+ FX_FLOAT m_fTodayWid;
+ FX_FLOAT m_fTodayHei;
+ FX_FLOAT m_fTodayFlagWid;
- FX_FLOAT m_fMCWid;
- FX_FLOAT m_fMCHei;
- friend class CFWL_MonthCalendarImpDelegate;
+ FX_FLOAT m_fMCWid;
+ FX_FLOAT m_fMCHei;
+ friend class CFWL_MonthCalendarImpDelegate;
};
typedef struct _DATEINFO {
- _DATEINFO(int32_t day, int32_t dayofweek, FX_DWORD dwSt, CFX_RectF rc, CFX_WideString &wsday) : iDay(day), iDayOfWeek(dayofweek), dwStates(dwSt), rect(rc), wsDay(wsday) {}
- int32_t iDay;
- int32_t iDayOfWeek;
- FX_DWORD dwStates;
- CFX_RectF rect;
- CFX_WideString wsDay;
+ _DATEINFO(int32_t day,
+ int32_t dayofweek,
+ FX_DWORD dwSt,
+ CFX_RectF rc,
+ CFX_WideString& wsday)
+ : iDay(day),
+ iDayOfWeek(dayofweek),
+ dwStates(dwSt),
+ rect(rc),
+ wsDay(wsday) {}
+ int32_t iDay;
+ int32_t iDayOfWeek;
+ FX_DWORD dwStates;
+ CFX_RectF rect;
+ CFX_WideString wsDay;
} DATEINFO, *LPDATEINFO;
-class CFWL_MonthCalendarImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_MonthCalendarImpDelegate(CFWL_MonthCalendarImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnActivate(CFWL_Message *pMsg);
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- CFWL_MonthCalendarImp *m_pOwner;
+class CFWL_MonthCalendarImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_MonthCalendarImpDelegate(CFWL_MonthCalendarImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnActivate(CFWL_Message* pMsg);
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ CFWL_MonthCalendarImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_pictureboximp.h b/xfa/src/fwl/src/basewidget/include/fwl_pictureboximp.h index 038ebeb535..2bd1d8ce58 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_pictureboximp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_pictureboximp.h @@ -12,36 +12,41 @@ class CFWL_WidgetImpDelegate; class IFWL_Widget;
class CFWL_PictureBoxImp;
class CFWL_PictureBoxImpDelegate;
-class CFWL_PictureBoxImp : public CFWL_WidgetImp
-{
-public:
- CFWL_PictureBoxImp(IFWL_Widget *pOuter = NULL);
- CFWL_PictureBoxImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_PictureBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- FX_BOOL VStyle(FX_BOOL dwStyle);
- CFX_RectF m_rtClient;
- CFX_RectF m_rtImage;
- CFX_Matrix m_matrix;
- FX_BOOL m_bTop;
- FX_BOOL m_bVCenter;
- FX_BOOL m_bButton;
- friend class CFWL_PictureBoxImpDelegate;
+class CFWL_PictureBoxImp : public CFWL_WidgetImp {
+ public:
+ CFWL_PictureBoxImp(IFWL_Widget* pOuter = NULL);
+ CFWL_PictureBoxImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_PictureBoxImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL VStyle(FX_BOOL dwStyle);
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtImage;
+ CFX_Matrix m_matrix;
+ FX_BOOL m_bTop;
+ FX_BOOL m_bVCenter;
+ FX_BOOL m_bButton;
+ friend class CFWL_PictureBoxImpDelegate;
};
-class CFWL_PictureBoxImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_PictureBoxImpDelegate(CFWL_PictureBoxImp *pOwner);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- CFWL_PictureBoxImp *m_pOwner;
+class CFWL_PictureBoxImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_PictureBoxImpDelegate(CFWL_PictureBoxImp* pOwner);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ CFWL_PictureBoxImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_pushbuttonimp.h b/xfa/src/fwl/src/basewidget/include/fwl_pushbuttonimp.h index 5238884979..b346e52f12 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_pushbuttonimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_pushbuttonimp.h @@ -12,46 +12,53 @@ class CFWL_WidgetImpDelegate; class IFWL_Widget;
class CFWL_PushButtonImp;
class CFWL_PushButtonImpDelegate;
-class CFWL_PushButtonImp : public CFWL_WidgetImp
-{
-public:
- CFWL_PushButtonImp(IFWL_Widget *pOuter = NULL);
- CFWL_PushButtonImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_PushButtonImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawText(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- FX_DWORD GetPartStates();
- void UpdateTextOutStyles();
- CFX_RectF m_rtClient;
- CFX_RectF m_rtCaption;
- FX_BOOL m_bBtnDown;
- FX_DWORD m_dwTTOStyles;
- int32_t m_iTTOAlign;
- friend class CFWL_PushButtonImpDelegate;
+class CFWL_PushButtonImp : public CFWL_WidgetImp {
+ public:
+ CFWL_PushButtonImp(IFWL_Widget* pOuter = NULL);
+ CFWL_PushButtonImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_PushButtonImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawText(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ FX_DWORD GetPartStates();
+ void UpdateTextOutStyles();
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtCaption;
+ FX_BOOL m_bBtnDown;
+ FX_DWORD m_dwTTOStyles;
+ int32_t m_iTTOAlign;
+ friend class CFWL_PushButtonImpDelegate;
};
-class CFWL_PushButtonImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_PushButtonImpDelegate(CFWL_PushButtonImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- void OnKeyDown(CFWL_MsgKey *pMsg);
- CFWL_PushButtonImp *m_pOwner;
+class CFWL_PushButtonImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_PushButtonImpDelegate(CFWL_PushButtonImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ void OnKeyDown(CFWL_MsgKey* pMsg);
+ CFWL_PushButtonImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_scrollbarimp.h b/xfa/src/fwl/src/basewidget/include/fwl_scrollbarimp.h index 9b8dc19efb..1aef7584e5 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_scrollbarimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_scrollbarimp.h @@ -14,100 +14,127 @@ class IFWL_Timer; class IFWL_TimerDelegate;
class CFWL_ScrollBarImp;
class CFWL_ScrollBarImpDelegate;
-class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer
-{
-public:
- CFWL_ScrollBarImp(IFWL_Widget *pOuter = NULL);
- CFWL_ScrollBarImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_ScrollBarImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FX_BOOL IsVertical() ;
- virtual FWL_ERR GetRange(FX_FLOAT &fMin, FX_FLOAT &fMax);
- virtual FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
- virtual FX_FLOAT GetPageSize();
- virtual FWL_ERR SetPageSize(FX_FLOAT fPageSize);
- virtual FX_FLOAT GetStepSize();
- virtual FWL_ERR SetStepSize(FX_FLOAT fStepSize);
- virtual FX_FLOAT GetPos();
- virtual FWL_ERR SetPos(FX_FLOAT fPos);
- virtual FX_FLOAT GetTrackPos();
- virtual FWL_ERR SetTrackPos(FX_FLOAT fTrackPos);
- virtual FX_BOOL DoScroll(FX_DWORD dwCode, FX_FLOAT fPos = 0.0f);
- virtual FWL_ERR SetOuter(IFWL_Widget *pOuter);
- virtual int32_t Run(FWL_HTIMER hTimer);
-protected:
- void DrawTrack(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FX_BOOL bLower = TRUE, const CFX_Matrix *pMatrix = NULL);
- void DrawArrowBtn(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, FX_BOOL bMinBtn = TRUE, const CFX_Matrix *pMatrix = NULL);
- void DrawThumb(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void Layout();
- void CalcButtonLen();
- void CalcMinButtonRect(CFX_RectF &rect);
- void CalcMaxButtonRect(CFX_RectF &rect);
- void CalcThumbButtonRect(CFX_RectF &rect);
- void CalcMinTrackRect(CFX_RectF &rect);
- void CalcMaxTrackRect(CFX_RectF &rect);
+class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer {
+ public:
+ CFWL_ScrollBarImp(IFWL_Widget* pOuter = NULL);
+ CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_ScrollBarImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FX_BOOL IsVertical();
+ virtual FWL_ERR GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
+ virtual FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
+ virtual FX_FLOAT GetPageSize();
+ virtual FWL_ERR SetPageSize(FX_FLOAT fPageSize);
+ virtual FX_FLOAT GetStepSize();
+ virtual FWL_ERR SetStepSize(FX_FLOAT fStepSize);
+ virtual FX_FLOAT GetPos();
+ virtual FWL_ERR SetPos(FX_FLOAT fPos);
+ virtual FX_FLOAT GetTrackPos();
+ virtual FWL_ERR SetTrackPos(FX_FLOAT fTrackPos);
+ virtual FX_BOOL DoScroll(FX_DWORD dwCode, FX_FLOAT fPos = 0.0f);
+ virtual FWL_ERR SetOuter(IFWL_Widget* pOuter);
+ virtual int32_t Run(FWL_HTIMER hTimer);
- FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy);
- void GetTrackRect(CFX_RectF &rect, FX_BOOL bLower = TRUE);
- FX_BOOL SendEvent();
- FX_BOOL OnScroll(FX_DWORD dwCode, FX_FLOAT fPos);
- FWL_HTIMER m_hTimer;
- FX_FLOAT m_fRangeMin;
- FX_FLOAT m_fRangeMax;
- FX_FLOAT m_fPageSize;
- FX_FLOAT m_fStepSize;
- FX_FLOAT m_fPos;
- FX_FLOAT m_fTrackPos;
- int32_t m_iMinButtonState;
- int32_t m_iMaxButtonState;
- int32_t m_iThumbButtonState;
- int32_t m_iMinTrackState;
- int32_t m_iMaxTrackState;
- FX_FLOAT m_fLastTrackPos;
- FX_FLOAT m_cpTrackPointX;
- FX_FLOAT m_cpTrackPointY;
- int32_t m_iMouseWheel;
- FX_BOOL m_bTrackMouseLeave;
- FX_BOOL m_bMouseHover;
- FX_BOOL m_bMouseDown;
- FX_BOOL m_bRepaintThumb;
+ protected:
+ void DrawTrack(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ FX_BOOL bLower = TRUE,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawArrowBtn(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ FX_BOOL bMinBtn = TRUE,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawThumb(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void Layout();
+ void CalcButtonLen();
+ void CalcMinButtonRect(CFX_RectF& rect);
+ void CalcMaxButtonRect(CFX_RectF& rect);
+ void CalcThumbButtonRect(CFX_RectF& rect);
+ void CalcMinTrackRect(CFX_RectF& rect);
+ void CalcMaxTrackRect(CFX_RectF& rect);
- FX_FLOAT m_fButtonLen;
- FX_BOOL m_bMinSize;
- CFX_RectF m_rtClient;
- CFX_RectF m_rtThumb;
- CFX_RectF m_rtMinBtn;
- CFX_RectF m_rtMaxBtn;
- CFX_RectF m_rtMinTrack;
- CFX_RectF m_rtMaxTrack;
- FX_BOOL m_bCustomLayout;
- FX_FLOAT m_fMinThumb;
- friend class CFWL_ScrollBarImpDelegate;
+ FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy);
+ void GetTrackRect(CFX_RectF& rect, FX_BOOL bLower = TRUE);
+ FX_BOOL SendEvent();
+ FX_BOOL OnScroll(FX_DWORD dwCode, FX_FLOAT fPos);
+ FWL_HTIMER m_hTimer;
+ FX_FLOAT m_fRangeMin;
+ FX_FLOAT m_fRangeMax;
+ FX_FLOAT m_fPageSize;
+ FX_FLOAT m_fStepSize;
+ FX_FLOAT m_fPos;
+ FX_FLOAT m_fTrackPos;
+ int32_t m_iMinButtonState;
+ int32_t m_iMaxButtonState;
+ int32_t m_iThumbButtonState;
+ int32_t m_iMinTrackState;
+ int32_t m_iMaxTrackState;
+ FX_FLOAT m_fLastTrackPos;
+ FX_FLOAT m_cpTrackPointX;
+ FX_FLOAT m_cpTrackPointY;
+ int32_t m_iMouseWheel;
+ FX_BOOL m_bTrackMouseLeave;
+ FX_BOOL m_bMouseHover;
+ FX_BOOL m_bMouseDown;
+ FX_BOOL m_bRepaintThumb;
+
+ FX_FLOAT m_fButtonLen;
+ FX_BOOL m_bMinSize;
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtThumb;
+ CFX_RectF m_rtMinBtn;
+ CFX_RectF m_rtMaxBtn;
+ CFX_RectF m_rtMinTrack;
+ CFX_RectF m_rtMaxTrack;
+ FX_BOOL m_bCustomLayout;
+ FX_FLOAT m_fMinThumb;
+ friend class CFWL_ScrollBarImpDelegate;
};
-class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- void OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- void OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- void OnMouseLeave();
- void OnMouseWheel(FX_FLOAT fx, FX_FLOAT fy, FX_DWORD dwFlags, FX_FLOAT fDeltaX, FX_FLOAT fDeltaY);
- void DoMouseDown(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState, FX_FLOAT fx, FX_FLOAT fy);
- void DoMouseUp(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState, FX_FLOAT fx, FX_FLOAT fy);
- void DoMouseMove(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState, FX_FLOAT fx, FX_FLOAT fy);
- void DoMouseLeave(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState);
- void DoMouseHover(int32_t iItem, const CFX_RectF &rtItem, int32_t &iState);
+class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
+ void OnLButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
+ void OnMouseMove(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
+ void OnMouseLeave();
+ void OnMouseWheel(FX_FLOAT fx,
+ FX_FLOAT fy,
+ FX_DWORD dwFlags,
+ FX_FLOAT fDeltaX,
+ FX_FLOAT fDeltaY);
+ void DoMouseDown(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy);
+ void DoMouseUp(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy);
+ void DoMouseMove(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy);
+ void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState);
+ void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState);
- CFWL_ScrollBarImp *m_pOwner;
+ CFWL_ScrollBarImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_spinbuttonimp.h b/xfa/src/fwl/src/basewidget/include/fwl_spinbuttonimp.h index 808903c1d0..f196b37f51 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_spinbuttonimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_spinbuttonimp.h @@ -13,50 +13,57 @@ class IFWL_Widget; class IFWL_Timer;
class CFWL_SpinButtonImp;
class CFWL_SpinButtonImpDelegate;
-class CFWL_SpinButtonImp : public CFWL_WidgetImp, public IFWL_Timer
-{
-public:
- CFWL_SpinButtonImp(IFWL_Widget *pOuter = NULL);
- CFWL_SpinButtonImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- ~CFWL_SpinButtonImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual int32_t Run(FWL_HTIMER hTimer);
- FWL_ERR EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
- FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE);
-protected:
- void DrawUpButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawDownButton(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- CFX_RectF m_rtClient;
- CFX_RectF m_rtUpButton;
- CFX_RectF m_rtDnButton;
- FX_DWORD m_dwUpState;
- FX_DWORD m_dwDnState;
- int32_t m_iButtonIndex;
- FX_BOOL m_bLButtonDwn;
- FWL_HTIMER m_hTimer;
- friend class CFWL_SpinButtonImpDelegate;
+class CFWL_SpinButtonImp : public CFWL_WidgetImp, public IFWL_Timer {
+ public:
+ CFWL_SpinButtonImp(IFWL_Widget* pOuter = NULL);
+ CFWL_SpinButtonImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ ~CFWL_SpinButtonImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual int32_t Run(FWL_HTIMER hTimer);
+ FWL_ERR EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
+ FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE);
+
+ protected:
+ void DrawUpButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawDownButton(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtUpButton;
+ CFX_RectF m_rtDnButton;
+ FX_DWORD m_dwUpState;
+ FX_DWORD m_dwDnState;
+ int32_t m_iButtonIndex;
+ FX_BOOL m_bLButtonDwn;
+ FWL_HTIMER m_hTimer;
+ friend class CFWL_SpinButtonImpDelegate;
};
-class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_SpinButtonImpDelegate(CFWL_SpinButtonImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- void OnKeyDown(CFWL_MsgKey *pMsg);
- CFWL_SpinButtonImp *m_pOwner;
+class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_SpinButtonImpDelegate(CFWL_SpinButtonImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ void OnKeyDown(CFWL_MsgKey* pMsg);
+ CFWL_SpinButtonImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h b/xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h index 6532ebab53..c652346e51 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h @@ -13,66 +13,72 @@ class IFWL_Widget; class IFWL_Timer;
class CFWL_ToolTipImp;
class CFWL_ToolTipImpDelegate;
-class CFWL_ToolTipImp : public CFWL_FormImp
-{
-public:
- CFWL_ToolTipImp(IFWL_Widget *pOuter = NULL);
- CFWL_ToolTipImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_ToolTipImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet );
- virtual FWL_ERR GetClientRect(CFX_RectF &rect);
- FWL_ERR SetAnchor(const CFX_RectF &rtAnchor);
- FWL_ERR Show();
- FWL_ERR Hide();
-protected:
- void DrawBkground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void DrawText(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix);
- void UpdateTextOutStyles();
- void RefreshToolTipPos();
- class CFWL_ToolTipTimer : public IFWL_Timer
- {
- public:
- CFWL_ToolTipTimer() {};
- ~CFWL_ToolTipTimer() {};
- CFWL_ToolTipTimer(CFWL_ToolTipImp * pToolTip);
- virtual int32_t Run(FWL_HTIMER hTimer);
- CFWL_ToolTipImp *m_pToolTip;
- };
- CFX_RectF m_rtClient;
- CFX_RectF m_rtCaption;
- FX_BOOL m_bBtnDown;
- FX_DWORD m_dwTTOStyles;
- int32_t m_iTTOAlign;
- CFX_RectF m_rtAnchor;
- FWL_HTIMER m_hTimerShow;
- FWL_HTIMER m_hTimerHide;
- CFWL_ToolTipTimer* m_pTimer;
- CFWL_ToolTipTimer m_TimerShow;
- CFWL_ToolTipTimer m_TimerHide;
- friend class CFWL_ToolTipImpDelegate;
- friend class CFWL_ToolTipTimer;
+class CFWL_ToolTipImp : public CFWL_FormImp {
+ public:
+ CFWL_ToolTipImp(IFWL_Widget* pOuter = NULL);
+ CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_ToolTipImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet);
+ virtual FWL_ERR GetClientRect(CFX_RectF& rect);
+ FWL_ERR SetAnchor(const CFX_RectF& rtAnchor);
+ FWL_ERR Show();
+ FWL_ERR Hide();
+
+ protected:
+ void DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawText(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void UpdateTextOutStyles();
+ void RefreshToolTipPos();
+ class CFWL_ToolTipTimer : public IFWL_Timer {
+ public:
+ CFWL_ToolTipTimer(){};
+ ~CFWL_ToolTipTimer(){};
+ CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip);
+ virtual int32_t Run(FWL_HTIMER hTimer);
+ CFWL_ToolTipImp* m_pToolTip;
+ };
+ CFX_RectF m_rtClient;
+ CFX_RectF m_rtCaption;
+ FX_BOOL m_bBtnDown;
+ FX_DWORD m_dwTTOStyles;
+ int32_t m_iTTOAlign;
+ CFX_RectF m_rtAnchor;
+ FWL_HTIMER m_hTimerShow;
+ FWL_HTIMER m_hTimerHide;
+ CFWL_ToolTipTimer* m_pTimer;
+ CFWL_ToolTipTimer m_TimerShow;
+ CFWL_ToolTipTimer m_TimerHide;
+ friend class CFWL_ToolTipImpDelegate;
+ friend class CFWL_ToolTipTimer;
};
-class CFWL_ToolTipImpDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_ToolTipImpDelegate(CFWL_ToolTipImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnFocusChanged(CFWL_Message *pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- void OnKeyDown(CFWL_MsgKey *pMsg);
- CFWL_ToolTipImp *m_pOwner;
+class CFWL_ToolTipImpDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ void OnKeyDown(CFWL_MsgKey* pMsg);
+ CFWL_ToolTipImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/basewidget/include/fxmath_barcodeimp.h b/xfa/src/fwl/src/basewidget/include/fxmath_barcodeimp.h index ea8be75702..22b75b8341 100644 --- a/xfa/src/fwl/src/basewidget/include/fxmath_barcodeimp.h +++ b/xfa/src/fwl/src/basewidget/include/fxmath_barcodeimp.h @@ -6,40 +6,47 @@ #ifndef _FXMATH_BARCODEIMP_H_
#define _FXMATH_BARCODEIMP_H_
-class CFX_Barcode : public IFX_Barcode
-{
-public:
- CFX_Barcode();
- ~CFX_Barcode();
- FX_BOOL Crreate(BC_TYPE type);
- virtual void Release();
- virtual BC_TYPE GetType();
- virtual FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t &e);
- virtual FX_BOOL RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matirx, int32_t &e);
- virtual FX_BOOL RenderBitmap(CFX_DIBitmap *&pOutBitmap, int32_t &e);
- virtual CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t height, int32_t &errorCode);
- virtual CFX_WideString Decode(CFX_DIBitmap *pBitmap, int32_t &errorCode);
- virtual FX_BOOL SetCharEncoding(BC_CHAR_ENCODING encoding);
- virtual FX_BOOL SetModuleHeight(int32_t moduleHeight);
- virtual FX_BOOL SetModuleWidth(int32_t moduleWidth);
- virtual FX_BOOL SetHeight(int32_t height);
- virtual FX_BOOL SetWidth(int32_t width);
- virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents);
- virtual FX_BOOL SetPrintChecksum(FX_BOOL checksum);
- virtual FX_BOOL SetDataLength(int32_t length);
- virtual FX_BOOL SetCalChecksum(int32_t state);
- virtual FX_BOOL SetFont(CFX_Font* pFont);
- virtual FX_BOOL SetFontSize(FX_FLOAT size);
- virtual FX_BOOL SetFontStyle(int32_t style);
- virtual FX_BOOL SetFontColor(FX_ARGB color);
- virtual FX_BOOL SetTextLocation(BC_TEXT_LOC location);
- virtual FX_BOOL SetWideNarrowRatio(int32_t ratio);
- virtual FX_BOOL SetStartChar(FX_CHAR start);
- virtual FX_BOOL SetEndChar(FX_CHAR end);
- virtual FX_BOOL SetVersion(int32_t version);
- virtual FX_BOOL SetErrorCorrectionLevel(int32_t level);
- virtual FX_BOOL SetTruncated(FX_BOOL truncated);
-protected:
- CBC_CodeBase* m_pBCEngine;
+class CFX_Barcode : public IFX_Barcode {
+ public:
+ CFX_Barcode();
+ ~CFX_Barcode();
+ FX_BOOL Crreate(BC_TYPE type);
+ virtual void Release();
+ virtual BC_TYPE GetType();
+ virtual FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e);
+ virtual FX_BOOL RenderDevice(CFX_RenderDevice* device,
+ const CFX_Matrix* matirx,
+ int32_t& e);
+ virtual FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
+ virtual CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& errorCode);
+ virtual CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode);
+ virtual FX_BOOL SetCharEncoding(BC_CHAR_ENCODING encoding);
+ virtual FX_BOOL SetModuleHeight(int32_t moduleHeight);
+ virtual FX_BOOL SetModuleWidth(int32_t moduleWidth);
+ virtual FX_BOOL SetHeight(int32_t height);
+ virtual FX_BOOL SetWidth(int32_t width);
+ virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents);
+ virtual FX_BOOL SetPrintChecksum(FX_BOOL checksum);
+ virtual FX_BOOL SetDataLength(int32_t length);
+ virtual FX_BOOL SetCalChecksum(int32_t state);
+ virtual FX_BOOL SetFont(CFX_Font* pFont);
+ virtual FX_BOOL SetFontSize(FX_FLOAT size);
+ virtual FX_BOOL SetFontStyle(int32_t style);
+ virtual FX_BOOL SetFontColor(FX_ARGB color);
+ virtual FX_BOOL SetTextLocation(BC_TEXT_LOC location);
+ virtual FX_BOOL SetWideNarrowRatio(int32_t ratio);
+ virtual FX_BOOL SetStartChar(FX_CHAR start);
+ virtual FX_BOOL SetEndChar(FX_CHAR end);
+ virtual FX_BOOL SetVersion(int32_t version);
+ virtual FX_BOOL SetErrorCorrectionLevel(int32_t level);
+ virtual FX_BOOL SetTruncated(FX_BOOL truncated);
+
+ protected:
+ CBC_CodeBase* m_pBCEngine;
};
#endif
diff --git a/xfa/src/fwl/src/core/fwl_appimp.cpp b/xfa/src/fwl/src/core/fwl_appimp.cpp index 33d2fff886..f59032a6a4 100644 --- a/xfa/src/fwl/src/core/fwl_appimp.cpp +++ b/xfa/src/fwl/src/core/fwl_appimp.cpp @@ -10,101 +10,85 @@ #include "include/fwl_noteimp.h"
#include "include/fwl_widgetmgrimp.h"
#include "include/fwl_appimp.h"
-IFWL_App* IFWL_App::Create(IFWL_AdapterNative *pAdapter)
-{
- return (IFWL_App*) FX_NEW CFWL_AppImp(pAdapter);
-}
-CFWL_AppImp::CFWL_AppImp(IFWL_AdapterNative *pAdapter)
- : m_pWidgetMgr(NULL)
- , m_pThemeProvider(NULL)
-{
- if (!pAdapter) {
- pAdapter = FWL_CreateFuelAdapterNative();
- m_bFuelAdapter = TRUE;
- } else {
- m_bFuelAdapter = FALSE;
- }
- m_pAdapterNative = pAdapter;
-}
-CFWL_AppImp::~CFWL_AppImp()
-{
- CFWL_ToolTipContainer::DeleteInstance();
- if (m_bFuelAdapter) {
- FWL_ReleaseFuelAdapterNative(m_pAdapterNative);
- m_pAdapterNative = NULL;
- }
- if (m_pWidgetMgr) {
- delete m_pWidgetMgr;
- m_pWidgetMgr = NULL;
- }
-}
-FWL_ERR CFWL_AppImp::Initialize()
-{
- if (!m_pWidgetMgr) {
- m_pWidgetMgr = FX_NEW CFWL_WidgetMgr(m_pAdapterNative);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_AppImp::Finalize()
-{
- if (m_pWidgetMgr) {
- delete m_pWidgetMgr;
- m_pWidgetMgr = NULL;
- }
- return FWL_ERR_Succeeded;
-}
-IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative()
-{
- return m_pAdapterNative;
-}
-IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr()
-{
- return ((CFWL_WidgetMgr*)FWL_GetWidgetMgr())->GetAdapterWidgetMgr();
-}
-IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr()
-{
- return (IFWL_WidgetMgr*)m_pWidgetMgr;
-}
-FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider)
-{
- m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode )
-{
- while (m_pNoteDriver->PopNoteLoop());
- return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0);
-}
-IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider()
-{
- return m_pThemeProvider;
-}
-IFWL_AdapterNative* FWL_GetAdapterNative()
-{
- IFWL_App* pApp = FWL_GetApp();
- _FWL_RETURN_VALUE_IF_FAIL(pApp, NULL);
- return pApp->GetAdapterNative();
-}
-IFWL_ThemeProvider* FWL_GetThemeProvider()
-{
- return NULL;
-}
-static IFWL_App *_theApp = NULL;
-IFWL_App* FWL_GetApp()
-{
- return _theApp;
-}
-void FWL_SetApp(IFWL_App *pApp)
-{
- _theApp = pApp;
-}
-FWL_ERR FWL_SetFullScreen(IFWL_Widget *pWidget, FX_BOOL bFullScreen)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Succeeded);
- IFWL_NoteThread *pNoteTread = pWidget->GetOwnerThread();
- _FWL_RETURN_VALUE_IF_FAIL(pNoteTread, FWL_ERR_Succeeded);
- CFWL_NoteDriver *pNoteDriver = (CFWL_NoteDriver*)pNoteTread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(pNoteTread, FWL_ERR_Succeeded);
- pNoteDriver->NotifyFullScreenMode(pWidget, bFullScreen);
- return FWL_GetAdapterWidgetMgr()->SetFullScreen(pWidget, bFullScreen);
+IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) {
+ return (IFWL_App*)FX_NEW CFWL_AppImp(pAdapter);
+}
+CFWL_AppImp::CFWL_AppImp(IFWL_AdapterNative* pAdapter)
+ : m_pWidgetMgr(NULL), m_pThemeProvider(NULL) {
+ if (!pAdapter) {
+ pAdapter = FWL_CreateFuelAdapterNative();
+ m_bFuelAdapter = TRUE;
+ } else {
+ m_bFuelAdapter = FALSE;
+ }
+ m_pAdapterNative = pAdapter;
+}
+CFWL_AppImp::~CFWL_AppImp() {
+ CFWL_ToolTipContainer::DeleteInstance();
+ if (m_bFuelAdapter) {
+ FWL_ReleaseFuelAdapterNative(m_pAdapterNative);
+ m_pAdapterNative = NULL;
+ }
+ if (m_pWidgetMgr) {
+ delete m_pWidgetMgr;
+ m_pWidgetMgr = NULL;
+ }
+}
+FWL_ERR CFWL_AppImp::Initialize() {
+ if (!m_pWidgetMgr) {
+ m_pWidgetMgr = FX_NEW CFWL_WidgetMgr(m_pAdapterNative);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_AppImp::Finalize() {
+ if (m_pWidgetMgr) {
+ delete m_pWidgetMgr;
+ m_pWidgetMgr = NULL;
+ }
+ return FWL_ERR_Succeeded;
+}
+IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() {
+ return m_pAdapterNative;
+}
+IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
+ return ((CFWL_WidgetMgr*)FWL_GetWidgetMgr())->GetAdapterWidgetMgr();
+}
+IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() {
+ return (IFWL_WidgetMgr*)m_pWidgetMgr;
+}
+FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ m_pThemeProvider = pThemeProvider;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode) {
+ while (m_pNoteDriver->PopNoteLoop())
+ ;
+ return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0);
+}
+IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() {
+ return m_pThemeProvider;
+}
+IFWL_AdapterNative* FWL_GetAdapterNative() {
+ IFWL_App* pApp = FWL_GetApp();
+ _FWL_RETURN_VALUE_IF_FAIL(pApp, NULL);
+ return pApp->GetAdapterNative();
+}
+IFWL_ThemeProvider* FWL_GetThemeProvider() {
+ return NULL;
+}
+static IFWL_App* _theApp = NULL;
+IFWL_App* FWL_GetApp() {
+ return _theApp;
+}
+void FWL_SetApp(IFWL_App* pApp) {
+ _theApp = pApp;
+}
+FWL_ERR FWL_SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Succeeded);
+ IFWL_NoteThread* pNoteTread = pWidget->GetOwnerThread();
+ _FWL_RETURN_VALUE_IF_FAIL(pNoteTread, FWL_ERR_Succeeded);
+ CFWL_NoteDriver* pNoteDriver = (CFWL_NoteDriver*)pNoteTread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(pNoteTread, FWL_ERR_Succeeded);
+ pNoteDriver->NotifyFullScreenMode(pWidget, bFullScreen);
+ return FWL_GetAdapterWidgetMgr()->SetFullScreen(pWidget, bFullScreen);
}
diff --git a/xfa/src/fwl/src/core/fwl_contentimp.cpp b/xfa/src/fwl/src/core/fwl_contentimp.cpp index 93c8c3b612..9a9f8ba2cd 100644 --- a/xfa/src/fwl/src/core/fwl_contentimp.cpp +++ b/xfa/src/fwl/src/core/fwl_contentimp.cpp @@ -11,121 +11,100 @@ #include "include/fwl_widgetimp.h"
#include "include/fwl_contentimp.h"
#include "include/fwl_widgetmgrimp.h"
-IFWL_Content* IFWL_Content::Create()
-{
- return new IFWL_Content;
-}
-FWL_ERR IFWL_Content::Initialize()
-{
- m_pData = FX_NEW CFWL_ContentImp;
- ((CFWL_ContentImp*)m_pData)->SetInterface(this);
- return ((CFWL_ContentImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Content::InsertWidget(IFWL_Widget *pChild, int32_t nIndex )
-{
- return ((CFWL_ContentImp*)m_pData)->InsertWidget(pChild, nIndex);
-}
-FWL_ERR IFWL_Content::RemoveWidget(IFWL_Widget *pWidget)
-{
- return ((CFWL_ContentImp*)m_pData)->RemoveWidget(pWidget);
-}
-FWL_ERR IFWL_Content::RemoveAllWidgets()
-{
- return ((CFWL_ContentImp*)m_pData)->RemoveAllWidgets();
-}
-FWL_ERR IFWL_Content::GetMinSize(FX_FLOAT &fWidth, FX_FLOAT &fHeight)
-{
- return ((CFWL_ContentImp*)m_pData)->GetMinSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight)
-{
- return ((CFWL_ContentImp*)m_pData)->SetMinSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::GetMaxSize(FX_FLOAT &fWidth, FX_FLOAT &fHeight)
-{
- return ((CFWL_ContentImp*)m_pData)->GetMaxSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight)
-{
- return ((CFWL_ContentImp*)m_pData)->SetMaxSize(fWidth, fHeight);
-}
-IFWL_Content::IFWL_Content()
-{
- m_pData = NULL;
+IFWL_Content* IFWL_Content::Create() {
+ return new IFWL_Content;
}
-IFWL_Content::~IFWL_Content()
-{
- if (m_pData) {
- delete (CFWL_ContentImp*)m_pData;
- m_pData = NULL;
- }
-}
-CFWL_ContentImp::CFWL_ContentImp()
-{
- m_fWidthMin = 0;
- m_fWidthMax = 10000;
- m_fHeightMin = 0;
- m_fHeightMax = 10000;
-}
-CFWL_ContentImp::CFWL_ContentImp(const CFWL_WidgetImpProperties &properties)
- : CFWL_WidgetImp(properties)
-{
- m_fWidthMin = 0;
- m_fWidthMax = 10000;
- m_fHeightMin = 0;
- m_fHeightMax = 10000;
-}
-CFWL_ContentImp::~CFWL_ContentImp()
-{
-}
-FWL_ERR CFWL_ContentImp::InsertWidget(IFWL_Widget *pChild, int32_t nIndex )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pChild, FWL_ERR_Indefinite);
- pChild->SetParent(m_pInterface);
- if (nIndex == -1) {
- return FWL_ERR_Succeeded;
- }
- CFWL_WidgetMgr *pMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pMgr, FWL_ERR_Indefinite);
- pMgr->SetWidgetIndex(pChild, nIndex);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Content::Initialize() {
+ m_pData = FX_NEW CFWL_ContentImp;
+ ((CFWL_ContentImp*)m_pData)->SetInterface(this);
+ return ((CFWL_ContentImp*)m_pData)->Initialize();
}
-FWL_ERR CFWL_ContentImp::RemoveWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);
- pWidget->SetParent(NULL);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Content::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
+ return ((CFWL_ContentImp*)m_pData)->InsertWidget(pChild, nIndex);
}
-FWL_ERR CFWL_ContentImp::RemoveAllWidgets()
-{
- CFWL_WidgetMgr *pMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pMgr, FWL_ERR_Indefinite);
- while (IFWL_Widget * widget = pMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild)) {
- pMgr->SetParent(NULL, widget);
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Content::RemoveWidget(IFWL_Widget* pWidget) {
+ return ((CFWL_ContentImp*)m_pData)->RemoveWidget(pWidget);
}
-FWL_ERR CFWL_ContentImp::GetMinSize(FX_FLOAT &fWidth, FX_FLOAT &fHeight)
-{
- fWidth = m_fWidthMin;
- fHeight = m_fHeightMin;
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Content::RemoveAllWidgets() {
+ return ((CFWL_ContentImp*)m_pData)->RemoveAllWidgets();
}
-FWL_ERR CFWL_ContentImp::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight)
-{
- m_fWidthMin = fWidth;
- m_fHeightMin = fHeight;
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Content::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
+ return ((CFWL_ContentImp*)m_pData)->GetMinSize(fWidth, fHeight);
}
-FWL_ERR CFWL_ContentImp::GetMaxSize(FX_FLOAT &fWidth, FX_FLOAT &fHeight)
-{
- fWidth = m_fWidthMax;
- fHeight = m_fHeightMax;
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Content::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
+ return ((CFWL_ContentImp*)m_pData)->SetMinSize(fWidth, fHeight);
+}
+FWL_ERR IFWL_Content::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
+ return ((CFWL_ContentImp*)m_pData)->GetMaxSize(fWidth, fHeight);
+}
+FWL_ERR IFWL_Content::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
+ return ((CFWL_ContentImp*)m_pData)->SetMaxSize(fWidth, fHeight);
}
-FWL_ERR CFWL_ContentImp::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight)
-{
- m_fWidthMax = fWidth;
- m_fHeightMax = fHeight;
+IFWL_Content::IFWL_Content() {
+ m_pData = NULL;
+}
+IFWL_Content::~IFWL_Content() {
+ if (m_pData) {
+ delete (CFWL_ContentImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+CFWL_ContentImp::CFWL_ContentImp() {
+ m_fWidthMin = 0;
+ m_fWidthMax = 10000;
+ m_fHeightMin = 0;
+ m_fHeightMax = 10000;
+}
+CFWL_ContentImp::CFWL_ContentImp(const CFWL_WidgetImpProperties& properties)
+ : CFWL_WidgetImp(properties) {
+ m_fWidthMin = 0;
+ m_fWidthMax = 10000;
+ m_fHeightMin = 0;
+ m_fHeightMax = 10000;
+}
+CFWL_ContentImp::~CFWL_ContentImp() {}
+FWL_ERR CFWL_ContentImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
+ _FWL_RETURN_VALUE_IF_FAIL(pChild, FWL_ERR_Indefinite);
+ pChild->SetParent(m_pInterface);
+ if (nIndex == -1) {
return FWL_ERR_Succeeded;
+ }
+ CFWL_WidgetMgr* pMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pMgr, FWL_ERR_Indefinite);
+ pMgr->SetWidgetIndex(pChild, nIndex);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ContentImp::RemoveWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);
+ pWidget->SetParent(NULL);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ContentImp::RemoveAllWidgets() {
+ CFWL_WidgetMgr* pMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pMgr, FWL_ERR_Indefinite);
+ while (IFWL_Widget* widget =
+ pMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild)) {
+ pMgr->SetParent(NULL, widget);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ContentImp::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
+ fWidth = m_fWidthMin;
+ fHeight = m_fHeightMin;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ContentImp::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
+ m_fWidthMin = fWidth;
+ m_fHeightMin = fHeight;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ContentImp::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
+ fWidth = m_fWidthMax;
+ fHeight = m_fHeightMax;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ContentImp::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
+ m_fWidthMax = fWidth;
+ m_fHeightMax = fHeight;
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/core/fwl_formimp.cpp b/xfa/src/fwl/src/core/fwl_formimp.cpp index 36838548e4..b18cdb12b5 100644 --- a/xfa/src/fwl/src/core/fwl_formimp.cpp +++ b/xfa/src/fwl/src/core/fwl_formimp.cpp @@ -13,1422 +13,1431 @@ #include "include/fwl_formimp.h"
#include "include/fwl_widgetmgrimp.h"
#include "include/fwl_appimp.h"
-#define FWL_SYSBTNSIZE 21
-#define FWL_SYSBTNMARGIN 5
-#define FWL_SYSBTNSPAN 2
-#define FWL_CornerEnlarge 10
-IFWL_Form* IFWL_Form::Create()
-{
- return new IFWL_Form;
-}
-FWL_ERR IFWL_Form::Initialize(IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_FormImp(pOuter);
- ((CFWL_FormImp*)m_pData)->SetInterface(this);
- return ((CFWL_FormImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Form::Initialize(CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_FormImp(properties, pOuter);
- ((CFWL_FormImp*)m_pData)->SetInterface(this);
- return ((CFWL_FormImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Form::Initialize(CFWL_WidgetImpProperties &properties, CFX_WideString *classname, IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_FormImp(properties, pOuter);
- ((CFWL_FormImp*)m_pData)->SetInterface(this);
- ((CFWL_FormImp*)m_pData)->SetPrivateData(this, classname, NULL);
- return ((CFWL_FormImp*)m_pData)->Initialize();
-}
-FWL_FORMSIZE IFWL_Form::GetFormSize()
-{
- return ((CFWL_FormImp*)m_pData)->GetFormSize();
-}
-FWL_ERR IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize)
-{
- return ((CFWL_FormImp*)m_pData)->SetFormSize(eFormSize);
-}
-IFWL_Widget* IFWL_Form::DoModal()
-{
- return ((CFWL_FormImp*)m_pData)->DoModal();
-}
-IFWL_Widget* IFWL_Form::DoModal(FX_DWORD &dwCommandID)
-{
- return ((CFWL_FormImp*)m_pData)->DoModal(dwCommandID);
-}
-FWL_ERR IFWL_Form::EndDoModal()
-{
- return ((CFWL_FormImp*)m_pData)->EndDoModal();
-}
-FWL_ERR IFWL_Form::SetBorderRegion(CFX_Path *pPath)
-{
- return ((CFWL_FormImp*)m_pData)->SetBorderRegion(pPath);
-}
-IFWL_Form::IFWL_Form()
-{
+#define FWL_SYSBTNSIZE 21
+#define FWL_SYSBTNMARGIN 5
+#define FWL_SYSBTNSPAN 2
+#define FWL_CornerEnlarge 10
+IFWL_Form* IFWL_Form::Create() {
+ return new IFWL_Form;
+}
+FWL_ERR IFWL_Form::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_FormImp(pOuter);
+ ((CFWL_FormImp*)m_pData)->SetInterface(this);
+ return ((CFWL_FormImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Form::Initialize(CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_FormImp(properties, pOuter);
+ ((CFWL_FormImp*)m_pData)->SetInterface(this);
+ return ((CFWL_FormImp*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Form::Initialize(CFWL_WidgetImpProperties& properties,
+ CFX_WideString* classname,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_FormImp(properties, pOuter);
+ ((CFWL_FormImp*)m_pData)->SetInterface(this);
+ ((CFWL_FormImp*)m_pData)->SetPrivateData(this, classname, NULL);
+ return ((CFWL_FormImp*)m_pData)->Initialize();
+}
+FWL_FORMSIZE IFWL_Form::GetFormSize() {
+ return ((CFWL_FormImp*)m_pData)->GetFormSize();
+}
+FWL_ERR IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) {
+ return ((CFWL_FormImp*)m_pData)->SetFormSize(eFormSize);
+}
+IFWL_Widget* IFWL_Form::DoModal() {
+ return ((CFWL_FormImp*)m_pData)->DoModal();
+}
+IFWL_Widget* IFWL_Form::DoModal(FX_DWORD& dwCommandID) {
+ return ((CFWL_FormImp*)m_pData)->DoModal(dwCommandID);
+}
+FWL_ERR IFWL_Form::EndDoModal() {
+ return ((CFWL_FormImp*)m_pData)->EndDoModal();
+}
+FWL_ERR IFWL_Form::SetBorderRegion(CFX_Path* pPath) {
+ return ((CFWL_FormImp*)m_pData)->SetBorderRegion(pPath);
+}
+IFWL_Form::IFWL_Form() {
+ m_pData = NULL;
+}
+IFWL_Form::~IFWL_Form() {
+ if (m_pData) {
+ delete (CFWL_FormImp*)m_pData;
m_pData = NULL;
-}
-IFWL_Form::~IFWL_Form()
-{
- if (m_pData) {
- delete (CFWL_FormImp*)m_pData;
- m_pData = NULL;
- }
-}
-CFWL_FormImp::CFWL_FormImp(IFWL_Widget *pOuter )
- : CFWL_PanelImp(pOuter)
- , m_pCloseBox(NULL)
- , m_pMinBox(NULL)
- , m_pMaxBox(NULL)
- , m_pCaptionBox(NULL)
- , m_pNoteLoop(NULL)
- , m_pSubFocus(NULL)
- , m_fCXBorder(0)
- , m_fCYBorder(0)
- , m_iCaptureBtn(-1)
- , m_iSysBox(0)
- , m_eResizeType(FORM_RESIZETYPE_None)
- , m_bLButtonDown(FALSE)
- , m_bMaximized(FALSE)
- , m_bSetMaximize(FALSE)
- , m_bCustomizeLayout(FALSE)
- , m_eFormSize(FWL_FORMSIZE_Manual)
- , m_bDoModalFlag(FALSE)
- , m_pBigIcon(NULL)
- , m_pSmallIcon(NULL)
- , m_bMouseIn(FALSE)
-{
- m_rtRelative.Reset();
- m_rtCaption.Reset();
- m_rtRestore.Reset();
- m_rtCaptionText.Reset();
- m_rtIcon.Reset();
- m_InfoStart.m_ptStart.Reset();
- m_InfoStart.m_szStart.Reset();
-}
-CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_PanelImp(properties, pOuter)
- , m_pCloseBox(NULL)
- , m_pMinBox(NULL)
- , m_pMaxBox(NULL)
- , m_pCaptionBox(NULL)
- , m_pNoteLoop(NULL)
- , m_pSubFocus(NULL)
- , m_fCXBorder(0)
- , m_fCYBorder(0)
- , m_iCaptureBtn(-1)
- , m_iSysBox(0)
- , m_eResizeType(FORM_RESIZETYPE_None)
- , m_bLButtonDown(FALSE)
- , m_bMaximized(FALSE)
- , m_bSetMaximize(FALSE)
- , m_bCustomizeLayout(FALSE)
- , m_eFormSize(FWL_FORMSIZE_Manual)
- , m_bDoModalFlag(FALSE)
- , m_pBigIcon(NULL)
- , m_pSmallIcon(NULL)
- , m_bMouseIn(FALSE)
-{
- m_rtRelative.Reset();
- m_rtCaption.Reset();
- m_rtRestore.Reset();
- m_rtCaptionText.Reset();
- m_rtIcon.Reset();
- m_InfoStart.m_ptStart.Reset();
- m_InfoStart.m_szStart.Reset();
-}
-CFWL_FormImp::~CFWL_FormImp()
-{
- RemoveSysButtons();
- if (m_pNoteLoop) {
- delete m_pNoteLoop;
- m_pNoteLoop = NULL;
- }
-}
-FWL_ERR CFWL_FormImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_Form;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_FormImp::GetClassID() const
-{
- return FWL_CLASSHASH_Form;
-}
-FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const
-{
- if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) {
- return TRUE;
- }
- return CFWL_PanelImp::IsInstance(wsClass);
-}
-FWL_ERR CFWL_FormImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(), FWL_ERR_Indefinite);
- RegisterForm();
- RegisterEventTarget();
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_FormDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormImp::Finalize()
-{
- if ( m_pDelegate) {
- delete (CFWL_FormDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- UnregisterEventTarget();
- UnRegisterForm();
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_FormImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.Reset();
- FX_FLOAT fCapHeight = GetCaptionHeight();
- FX_FLOAT fCXBorder = GetBorderSize(TRUE);
- FX_FLOAT fCYBorder = GetBorderSize(FALSE);
- FX_FLOAT fEdge = GetEdgeWidth();
- if (m_pContent) {
- m_pContent->GetWidgetRect(rect, TRUE);
- }
- rect.height += fCapHeight + fCYBorder + fEdge + fEdge;
- rect.width += fCXBorder + fCXBorder + fEdge + fEdge;
- } else {
- rect = m_pProperties->m_rtWidget;
+ }
+}
+CFWL_FormImp::CFWL_FormImp(IFWL_Widget* pOuter)
+ : CFWL_PanelImp(pOuter),
+ m_pCloseBox(NULL),
+ m_pMinBox(NULL),
+ m_pMaxBox(NULL),
+ m_pCaptionBox(NULL),
+ m_pNoteLoop(NULL),
+ m_pSubFocus(NULL),
+ m_fCXBorder(0),
+ m_fCYBorder(0),
+ m_iCaptureBtn(-1),
+ m_iSysBox(0),
+ m_eResizeType(FORM_RESIZETYPE_None),
+ m_bLButtonDown(FALSE),
+ m_bMaximized(FALSE),
+ m_bSetMaximize(FALSE),
+ m_bCustomizeLayout(FALSE),
+ m_eFormSize(FWL_FORMSIZE_Manual),
+ m_bDoModalFlag(FALSE),
+ m_pBigIcon(NULL),
+ m_pSmallIcon(NULL),
+ m_bMouseIn(FALSE) {
+ m_rtRelative.Reset();
+ m_rtCaption.Reset();
+ m_rtRestore.Reset();
+ m_rtCaptionText.Reset();
+ m_rtIcon.Reset();
+ m_InfoStart.m_ptStart.Reset();
+ m_InfoStart.m_szStart.Reset();
+}
+CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_PanelImp(properties, pOuter),
+ m_pCloseBox(NULL),
+ m_pMinBox(NULL),
+ m_pMaxBox(NULL),
+ m_pCaptionBox(NULL),
+ m_pNoteLoop(NULL),
+ m_pSubFocus(NULL),
+ m_fCXBorder(0),
+ m_fCYBorder(0),
+ m_iCaptureBtn(-1),
+ m_iSysBox(0),
+ m_eResizeType(FORM_RESIZETYPE_None),
+ m_bLButtonDown(FALSE),
+ m_bMaximized(FALSE),
+ m_bSetMaximize(FALSE),
+ m_bCustomizeLayout(FALSE),
+ m_eFormSize(FWL_FORMSIZE_Manual),
+ m_bDoModalFlag(FALSE),
+ m_pBigIcon(NULL),
+ m_pSmallIcon(NULL),
+ m_bMouseIn(FALSE) {
+ m_rtRelative.Reset();
+ m_rtCaption.Reset();
+ m_rtRestore.Reset();
+ m_rtCaptionText.Reset();
+ m_rtIcon.Reset();
+ m_InfoStart.m_ptStart.Reset();
+ m_InfoStart.m_szStart.Reset();
+}
+CFWL_FormImp::~CFWL_FormImp() {
+ RemoveSysButtons();
+ if (m_pNoteLoop) {
+ delete m_pNoteLoop;
+ m_pNoteLoop = NULL;
+ }
+}
+FWL_ERR CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_Form;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_FormImp::GetClassID() const {
+ return FWL_CLASSHASH_Form;
+}
+FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const {
+ if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) {
+ return TRUE;
+ }
+ return CFWL_PanelImp::IsInstance(wsClass);
+}
+FWL_ERR CFWL_FormImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_WidgetImp::Initialize(),
+ FWL_ERR_Indefinite);
+ RegisterForm();
+ RegisterEventTarget();
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_FormDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_FormImp::Finalize() {
+ if (m_pDelegate) {
+ delete (CFWL_FormDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ UnregisterEventTarget();
+ UnRegisterForm();
+ return CFWL_WidgetImp::Finalize();
+}
+FWL_ERR CFWL_FormImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.Reset();
+ FX_FLOAT fCapHeight = GetCaptionHeight();
+ FX_FLOAT fCXBorder = GetBorderSize(TRUE);
+ FX_FLOAT fCYBorder = GetBorderSize(FALSE);
+ FX_FLOAT fEdge = GetEdgeWidth();
+ if (m_pContent) {
+ m_pContent->GetWidgetRect(rect, TRUE);
}
- return FWL_ERR_Succeeded;
+ rect.height += fCapHeight + fCYBorder + fEdge + fEdge;
+ rect.width += fCXBorder + fCXBorder + fEdge + fEdge;
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_FormImp::GetClientRect(CFX_RectF &rect)
-{
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) {
- rect = m_pProperties->m_rtWidget;
- rect.Offset(-rect.left, -rect.top);
- return FWL_ERR_Succeeded;
- }
-#ifdef FWL_UseMacSystemBorder
- rect = m_rtRelative;
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
- IFWL_AdapterWidgetMgr * adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- adapterWidgetMgr->GetSystemBorder(l, t, r, b);
- rect.Deflate(l, t, r, b);
- rect.left = rect.top = 0;
- return FWL_ERR_Succeeded;
-#else
- FX_FLOAT x = 0;
- FX_FLOAT y = 0;
- FX_FLOAT t = 0;
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- if (pTheme) {
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- FX_FLOAT * value = NULL;
- value = (FX_FLOAT *) pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder);
- x = *value;
- value = (FX_FLOAT *) pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder);
- y = *value;
- value = (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FRM_CYCaption);
- t = *value;
- }
+FWL_ERR CFWL_FormImp::GetClientRect(CFX_RectF& rect) {
+ if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) {
rect = m_pProperties->m_rtWidget;
rect.Offset(-rect.left, -rect.top);
- rect.Deflate(x, t, x, y);
return FWL_ERR_Succeeded;
+ }
+#ifdef FWL_UseMacSystemBorder
+ rect = m_rtRelative;
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
+ IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
+ FX_FLOAT l, t, r, b;
+ l = t = r = b = 0;
+ adapterWidgetMgr->GetSystemBorder(l, t, r, b);
+ rect.Deflate(l, t, r, b);
+ rect.left = rect.top = 0;
+ return FWL_ERR_Succeeded;
+#else
+ FX_FLOAT x = 0;
+ FX_FLOAT y = 0;
+ FX_FLOAT t = 0;
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ if (pTheme) {
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ FX_FLOAT* value = NULL;
+ value = (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder);
+ x = *value;
+ value = (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder);
+ y = *value;
+ value =
+ (FX_FLOAT*)pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FRM_CYCaption);
+ t = *value;
+ }
+ rect = m_pProperties->m_rtWidget;
+ rect.Offset(-rect.left, -rect.top);
+ rect.Deflate(x, t, x, y);
+ return FWL_ERR_Succeeded;
#endif
}
-FWL_ERR CFWL_FormImp::Update()
-{
- if (m_iLock > 0) {
- return FWL_ERR_Succeeded;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
+FWL_ERR CFWL_FormImp::Update() {
+ if (m_iLock > 0) {
+ return FWL_ERR_Succeeded;
+ }
+ if (!m_pProperties->m_pThemeProvider) {
+ m_pProperties->m_pThemeProvider = GetAvailableTheme();
+ }
#ifdef FWL_UseMacSystemBorder
#else
- SetThemeData();
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
- UpdateIcon();
- }
+ SetThemeData();
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
+ UpdateIcon();
+ }
#endif
- UpdateCaption();
- Layout();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- IFWL_ThemeProvider *pTheme = GetAvailableTheme();
- if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_CloseBox;
- }
- if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MaxBox;
- }
- if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MinBox;
- }
- CFX_RectF rtCap;
- rtCap.Set(m_rtCaption.left + m_fCYBorder,
- m_rtCaption.top + m_fCXBorder,
- m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder,
- m_rtCaption.height - m_fCXBorder);
- if (rtCap.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Titlebar;
- }
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) {
- FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + FWL_CornerEnlarge);
- FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + FWL_CornerEnlarge);
- CFX_RectF rt;
- rt.Set(0, m_fCXBorder + FWL_CornerEnlarge, m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Left;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + FWL_CornerEnlarge, m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Right;
- }
- rt.Set(m_fCYBorder + FWL_CornerEnlarge, 0, fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Top;
- }
- rt.Set(m_fCYBorder + FWL_CornerEnlarge, m_rtRelative.height - m_fCXBorder, fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Bottom;
- }
- rt.Set(0, 0, m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftTop;
- }
- rt.Set(0, m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftBottom;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge, 0,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightTop;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge,
- m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
- m_fCYBorder + FWL_CornerEnlarge,
- m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightBottom;
- }
- }
- return FWL_WGTHITTEST_Client;
-}
-FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider, FWL_ERR_Indefinite);
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- FX_BOOL bInactive = !IsActive();
- int32_t iState = bInactive ? FWL_PARTSTATE_FRM_Inactive : FWL_PARTSTATE_FRM_Normal;
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) {
- DrawBackground(pGraphics, pTheme);
- }
+ UpdateCaption();
+ Layout();
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ IFWL_ThemeProvider* pTheme = GetAvailableTheme();
+ if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_CloseBox;
+ }
+ if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_MaxBox;
+ }
+ if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_MinBox;
+ }
+ CFX_RectF rtCap;
+ rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
+ m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder,
+ m_rtCaption.height - m_fCXBorder);
+ if (rtCap.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Titlebar;
+ }
+ if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) {
+ FX_FLOAT fWidth =
+ m_rtRelative.width - 2 * (m_fCYBorder + FWL_CornerEnlarge);
+ FX_FLOAT fHeight =
+ m_rtRelative.height - 2 * (m_fCXBorder + FWL_CornerEnlarge);
+ CFX_RectF rt;
+ rt.Set(0, m_fCXBorder + FWL_CornerEnlarge, m_fCYBorder, fHeight);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Left;
+ }
+ rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + FWL_CornerEnlarge,
+ m_fCYBorder, fHeight);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Right;
+ }
+ rt.Set(m_fCYBorder + FWL_CornerEnlarge, 0, fWidth, m_fCXBorder);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Top;
+ }
+ rt.Set(m_fCYBorder + FWL_CornerEnlarge, m_rtRelative.height - m_fCXBorder,
+ fWidth, m_fCXBorder);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Bottom;
+ }
+ rt.Set(0, 0, m_fCYBorder + FWL_CornerEnlarge,
+ m_fCXBorder + FWL_CornerEnlarge);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_LeftTop;
+ }
+ rt.Set(0, m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
+ m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_LeftBottom;
+ }
+ rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge, 0,
+ m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_RightTop;
+ }
+ rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge,
+ m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
+ m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
+ if (rt.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_RightBottom;
+ }
+ }
+ return FWL_WGTHITTEST_Client;
+}
+FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties->m_pThemeProvider,
+ FWL_ERR_Indefinite);
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ FX_BOOL bInactive = !IsActive();
+ int32_t iState =
+ bInactive ? FWL_PARTSTATE_FRM_Inactive : FWL_PARTSTATE_FRM_Normal;
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) {
+ DrawBackground(pGraphics, pTheme);
+ }
#ifdef FWL_UseMacSystemBorder
- return FWL_ERR_Succeeded;
+ return FWL_ERR_Succeeded;
#endif
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_dwStates = iState;
+ param.m_pGraphics = pGraphics;
+ param.m_rtPart = m_rtRelative;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
+ param.m_iPart = FWL_PART_FRM_Border;
+ pTheme->DrawBackground(¶m);
+ }
+ if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) !=
+ FWL_WGTSTYLE_EdgeNone) {
+ CFX_RectF rtEdge;
+ GetEdgeRect(rtEdge);
+ param.m_iPart = FWL_PART_FRM_Edge;
+ param.m_rtPart = rtEdge;
param.m_dwStates = iState;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = m_rtRelative;
- if(pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
- param.m_iPart = FWL_PART_FRM_Border;
- pTheme->DrawBackground(¶m);
+ pTheme->DrawBackground(¶m);
+ }
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
+ param.m_iPart = FWL_PART_FRM_Caption;
+ param.m_dwStates = iState;
+ param.m_rtPart = m_rtCaption;
+ pTheme->DrawBackground(¶m);
+ DrawCaptionText(pGraphics, pTheme, pMatrix);
+ } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
+ param.m_iPart = FWL_PART_FRM_NarrowCaption;
+ param.m_dwStates = iState;
+ param.m_rtPart = m_rtCaption;
+ pTheme->DrawBackground(¶m);
+ DrawCaptionText(pGraphics, pTheme, pMatrix);
+ }
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
+ param.m_iPart = FWL_PART_FRM_Icon;
+ if (HasIcon()) {
+ DrawIconImage(pGraphics, pTheme, pMatrix);
}
- if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) != FWL_WGTSTYLE_EdgeNone) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- param.m_iPart = FWL_PART_FRM_Edge;
- param.m_rtPart = rtEdge;
- param.m_dwStates = iState;
- pTheme->DrawBackground(¶m);
+ }
+#if (_FX_OS_ == _FX_MACOSX_)
+ {
+ if (m_pCloseBox) {
+ param.m_iPart = FWL_PART_FRM_CloseBox;
+ param.m_dwStates = m_pCloseBox->GetPartState();
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
+ param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
+ } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
+ param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
+ }
+ param.m_rtPart = m_pCloseBox->m_rtBtn;
+ pTheme->DrawBackground(¶m);
}
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
- param.m_iPart = FWL_PART_FRM_Caption;
- param.m_dwStates = iState;
- param.m_rtPart = m_rtCaption;
- pTheme->DrawBackground(¶m);
- DrawCaptionText(pGraphics, pTheme, pMatrix);
- } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
- param.m_iPart = FWL_PART_FRM_NarrowCaption;
- param.m_dwStates = iState;
- param.m_rtPart = m_rtCaption;
- pTheme->DrawBackground(¶m);
- DrawCaptionText(pGraphics, pTheme, pMatrix);
+ if (m_pMaxBox) {
+ param.m_iPart = FWL_PART_FRM_MaximizeBox;
+ param.m_dwStates = m_pMaxBox->GetPartState();
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
+ param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
+ } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
+ param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
+ }
+ param.m_rtPart = m_pMaxBox->m_rtBtn;
+ param.m_dwData = m_bMaximized;
+ pTheme->DrawBackground(¶m);
}
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
- param.m_iPart = FWL_PART_FRM_Icon;
- if (HasIcon()) {
- DrawIconImage(pGraphics, pTheme, pMatrix);
- }
+ if (m_pMinBox) {
+ param.m_iPart = FWL_PART_FRM_MinimizeBox;
+ param.m_dwStates = m_pMinBox->GetPartState();
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
+ param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
+ } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
+ param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
+ }
+ param.m_rtPart = m_pMinBox->m_rtBtn;
+ pTheme->DrawBackground(¶m);
+ }
+ m_bMouseIn = FALSE;
+ }
+#else
+ {
+ if (m_pCloseBox) {
+ param.m_iPart = FWL_PART_FRM_CloseBox;
+ param.m_dwStates = m_pCloseBox->GetPartState();
+ param.m_rtPart = m_pCloseBox->m_rtBtn;
+ pTheme->DrawBackground(¶m);
}
-#if (_FX_OS_==_FX_MACOSX_)
- {
- if (m_pCloseBox) {
- param.m_iPart = FWL_PART_FRM_CloseBox;
- param.m_dwStates = m_pCloseBox->GetPartState();
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
- }
- param.m_rtPart = m_pCloseBox->m_rtBtn;
- pTheme->DrawBackground(¶m);
- }
- if (m_pMaxBox) {
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
- param.m_dwStates = m_pMaxBox->GetPartState();
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
- }
- param.m_rtPart = m_pMaxBox->m_rtBtn;
- param.m_dwData = m_bMaximized;
- pTheme->DrawBackground(¶m);
- }
- if (m_pMinBox) {
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
- param.m_dwStates = m_pMinBox->GetPartState();
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
- }
- param.m_rtPart = m_pMinBox->m_rtBtn;
- pTheme->DrawBackground(¶m);
- }
- m_bMouseIn = FALSE;
+ if (m_pMaxBox) {
+ param.m_iPart = FWL_PART_FRM_MaximizeBox;
+ param.m_dwStates = m_pMaxBox->GetPartState();
+ param.m_rtPart = m_pMaxBox->m_rtBtn;
+ param.m_dwData = m_bMaximized;
+ pTheme->DrawBackground(¶m);
}
-#else
- {
- if (m_pCloseBox) {
- param.m_iPart = FWL_PART_FRM_CloseBox;
- param.m_dwStates = m_pCloseBox->GetPartState();
- param.m_rtPart = m_pCloseBox->m_rtBtn;
- pTheme->DrawBackground(¶m);
- }
- if (m_pMaxBox) {
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
- param.m_dwStates = m_pMaxBox->GetPartState();
- param.m_rtPart = m_pMaxBox->m_rtBtn;
- param.m_dwData = m_bMaximized;
- pTheme->DrawBackground(¶m);
- }
- if (m_pMinBox) {
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
- param.m_dwStates = m_pMinBox->GetPartState();
- param.m_rtPart = m_pMinBox->m_rtBtn;
- pTheme->DrawBackground(¶m);
- }
+ if (m_pMinBox) {
+ param.m_iPart = FWL_PART_FRM_MinimizeBox;
+ param.m_dwStates = m_pMinBox->GetPartState();
+ param.m_rtPart = m_pMinBox->m_rtBtn;
+ pTheme->DrawBackground(¶m);
}
+ }
#endif
- return FWL_ERR_Succeeded;
-}
-FWL_FORMSIZE CFWL_FormImp::GetFormSize()
-{
- return m_eFormSize;
-}
-FWL_ERR CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize)
-{
- m_eFormSize = eFormSize;
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_FormImp::DoModal()
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_VALUE_IF_FAIL(pThread, NULL);
- IFWL_NoteDriver *pDriver = pThread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(pDriver, NULL);
- m_pNoteLoop = FX_NEW CFWL_NoteLoop(this);
- pDriver->PushNoteLoop((IFWL_NoteLoop*)m_pNoteLoop);
- m_bDoModalFlag = TRUE;
- SetStates(FWL_WGTSTATE_Invisible, FALSE);
- pDriver->Run();
-#if (_FX_OS_==_FX_MACOSX_)
+ return FWL_ERR_Succeeded;
+}
+FWL_FORMSIZE CFWL_FormImp::GetFormSize() {
+ return m_eFormSize;
+}
+FWL_ERR CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) {
+ m_eFormSize = eFormSize;
+ return FWL_ERR_Succeeded;
+}
+IFWL_Widget* CFWL_FormImp::DoModal() {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_VALUE_IF_FAIL(pThread, NULL);
+ IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(pDriver, NULL);
+ m_pNoteLoop = FX_NEW CFWL_NoteLoop(this);
+ pDriver->PushNoteLoop((IFWL_NoteLoop*)m_pNoteLoop);
+ m_bDoModalFlag = TRUE;
+ SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ pDriver->Run();
+#if (_FX_OS_ == _FX_MACOSX_)
#else
- pDriver->PopNoteLoop();
+ pDriver->PopNoteLoop();
#endif
- delete m_pNoteLoop;
- m_pNoteLoop = NULL;
- return NULL;
-}
-IFWL_Widget* CFWL_FormImp::DoModal(FX_DWORD &dwCommandID)
-{
- return DoModal();
-}
-FWL_ERR CFWL_FormImp::EndDoModal()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pNoteLoop, FWL_ERR_Indefinite);
- m_bDoModalFlag = FALSE;
-#if (_FX_OS_==_FX_MACOSX_)
- m_pNoteLoop->EndModalLoop();
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_VALUE_IF_FAIL(pThread, NULL);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(pDriver, NULL);
- pDriver->PopNoteLoop();
- SetStates(FWL_WGTSTATE_Invisible, TRUE);
- return FWL_ERR_Succeeded;
+ delete m_pNoteLoop;
+ m_pNoteLoop = NULL;
+ return NULL;
+}
+IFWL_Widget* CFWL_FormImp::DoModal(FX_DWORD& dwCommandID) {
+ return DoModal();
+}
+FWL_ERR CFWL_FormImp::EndDoModal() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pNoteLoop, FWL_ERR_Indefinite);
+ m_bDoModalFlag = FALSE;
+#if (_FX_OS_ == _FX_MACOSX_)
+ m_pNoteLoop->EndModalLoop();
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_VALUE_IF_FAIL(pThread, NULL);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(pDriver, NULL);
+ pDriver->PopNoteLoop();
+ SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ return FWL_ERR_Succeeded;
#else
- SetStates(FWL_WGTSTATE_Invisible, TRUE);
- return m_pNoteLoop->EndModalLoop();
+ SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ return m_pNoteLoop->EndModalLoop();
#endif
}
-FWL_ERR CFWL_FormImp::SetBorderRegion(CFX_Path *pPath)
-{
- return FWL_ERR_Succeeded;
-}
-void CFWL_FormImp::DrawBackground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme)
-{
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Background;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = m_rtRelative;
- param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder, m_fCXBorder);
- pTheme->DrawBackground(¶m);
-}
-CFWL_WidgetImp* CFWL_FormImp::GetSubFocus()
-{
- return m_pSubFocus;
-}
-void CFWL_FormImp::SetSubFocus(CFWL_WidgetImp *pWidget)
-{
- m_pSubFocus = pWidget;
-}
-CFX_MapAccelerators& CFWL_FormImp::GetAccelerator()
-{
- return m_mapAccelerators;
-}
-void CFWL_FormImp::SetAccelerator(CFX_MapAccelerators *pAccelerators)
-{
- _FWL_RETURN_IF_FAIL(pAccelerators);
- m_mapAccelerators.RemoveAll();
- FX_DWORD vrKey, rValue;
- FX_POSITION pos = pAccelerators->GetStartPosition();
- while (pos) {
- pAccelerators->GetNextAssoc(pos, vrKey, rValue);
- m_mapAccelerators.SetAt(vrKey, rValue);
- }
-}
-void CFWL_FormImp::ShowChildWidget(IFWL_Widget *pParent)
-{
- IFWL_App *pApp = FWL_GetApp();
- _FWL_RETURN_IF_FAIL(pApp);
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)pApp->GetWidgetMgr();
- _FWL_RETURN_IF_FAIL(pWidgetMgr);
- IFWL_Widget *pChild = pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
- while (pChild) {
- pWidgetMgr->ShowWidget_Native(pChild);
- ShowChildWidget(pChild);
- pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
- }
-}
-void CFWL_FormImp::RemoveSysButtons()
-{
- m_rtCaption.Reset();
- if (m_pCloseBox) {
- delete m_pCloseBox;
- m_pCloseBox = NULL;
- }
- if (m_pMinBox) {
- delete m_pMinBox;
- m_pMinBox = NULL;
- }
- if (m_pMaxBox) {
- delete m_pMaxBox;
- m_pMaxBox = NULL;
- }
- if (m_pCaptionBox) {
- delete m_pCaptionBox;
- m_pCaptionBox = NULL;
- }
-}
-void CFWL_FormImp::CalcContentRect(CFX_RectF &rtContent)
-{
+FWL_ERR CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) {
+ return FWL_ERR_Succeeded;
+}
+void CFWL_FormImp::DrawBackground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_FRM_Background;
+ param.m_pGraphics = pGraphics;
+ param.m_rtPart = m_rtRelative;
+ param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder,
+ m_fCXBorder);
+ pTheme->DrawBackground(¶m);
+}
+CFWL_WidgetImp* CFWL_FormImp::GetSubFocus() {
+ return m_pSubFocus;
+}
+void CFWL_FormImp::SetSubFocus(CFWL_WidgetImp* pWidget) {
+ m_pSubFocus = pWidget;
+}
+CFX_MapAccelerators& CFWL_FormImp::GetAccelerator() {
+ return m_mapAccelerators;
+}
+void CFWL_FormImp::SetAccelerator(CFX_MapAccelerators* pAccelerators) {
+ _FWL_RETURN_IF_FAIL(pAccelerators);
+ m_mapAccelerators.RemoveAll();
+ FX_DWORD vrKey, rValue;
+ FX_POSITION pos = pAccelerators->GetStartPosition();
+ while (pos) {
+ pAccelerators->GetNextAssoc(pos, vrKey, rValue);
+ m_mapAccelerators.SetAt(vrKey, rValue);
+ }
+}
+void CFWL_FormImp::ShowChildWidget(IFWL_Widget* pParent) {
+ IFWL_App* pApp = FWL_GetApp();
+ _FWL_RETURN_IF_FAIL(pApp);
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)pApp->GetWidgetMgr();
+ _FWL_RETURN_IF_FAIL(pWidgetMgr);
+ IFWL_Widget* pChild =
+ pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
+ while (pChild) {
+ pWidgetMgr->ShowWidget_Native(pChild);
+ ShowChildWidget(pChild);
+ pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
+ }
+}
+void CFWL_FormImp::RemoveSysButtons() {
+ m_rtCaption.Reset();
+ if (m_pCloseBox) {
+ delete m_pCloseBox;
+ m_pCloseBox = NULL;
+ }
+ if (m_pMinBox) {
+ delete m_pMinBox;
+ m_pMinBox = NULL;
+ }
+ if (m_pMaxBox) {
+ delete m_pMaxBox;
+ m_pMaxBox = NULL;
+ }
+ if (m_pCaptionBox) {
+ delete m_pCaptionBox;
+ m_pCaptionBox = NULL;
+ }
+}
+void CFWL_FormImp::CalcContentRect(CFX_RectF& rtContent) {
#ifdef FWL_UseMacSystemBorder
- rtContent = m_rtRelative;
+ rtContent = m_rtRelative;
#else
- GetEdgeRect(rtContent);
- if (HasEdge()) {
- FX_FLOAT fEdge = GetEdgeWidth();
- rtContent.Deflate(fEdge, fEdge);
- }
+ GetEdgeRect(rtContent);
+ if (HasEdge()) {
+ FX_FLOAT fEdge = GetEdgeWidth();
+ rtContent.Deflate(fEdge, fEdge);
+ }
#endif
}
-CFWL_SysBtn* CFWL_FormImp::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy)
-{
- if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
- return m_pCloseBox;
- }
- if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
- return m_pMaxBox;
- }
- if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
- return m_pMinBox;
- }
- if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) {
- return m_pCaptionBox;
- }
- return NULL;
-}
-CFWL_SysBtn* CFWL_FormImp::GetSysBtnByState(FX_DWORD dwState)
-{
- if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) {
- return m_pCloseBox;
- }
- if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) {
- return m_pMaxBox;
- }
- if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) {
- return m_pMinBox;
- }
- if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) {
- return m_pCaptionBox;
- }
+CFWL_SysBtn* CFWL_FormImp::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
+ return m_pCloseBox;
+ }
+ if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
+ return m_pMaxBox;
+ }
+ if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
+ return m_pMinBox;
+ }
+ if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) {
+ return m_pCaptionBox;
+ }
+ return NULL;
+}
+CFWL_SysBtn* CFWL_FormImp::GetSysBtnByState(FX_DWORD dwState) {
+ if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) {
+ return m_pCloseBox;
+ }
+ if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) {
+ return m_pMaxBox;
+ }
+ if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) {
+ return m_pMinBox;
+ }
+ if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) {
+ return m_pCaptionBox;
+ }
+ return NULL;
+}
+CFWL_SysBtn* CFWL_FormImp::GetSysBtnByIndex(int32_t nIndex) {
+ if (nIndex < 0) {
return NULL;
-}
-CFWL_SysBtn* CFWL_FormImp::GetSysBtnByIndex(int32_t nIndex)
-{
- if (nIndex < 0) {
- return NULL;
- }
- CFX_PtrArray arrBtn;
- if (m_pMinBox) {
- arrBtn.Add(m_pMinBox);
- }
- if (m_pMaxBox) {
- arrBtn.Add(m_pMaxBox);
- }
- if (m_pCloseBox) {
- arrBtn.Add(m_pCloseBox);
- }
- return (CFWL_SysBtn*) arrBtn[nIndex];
-}
-int32_t CFWL_FormImp::GetSysBtnIndex(CFWL_SysBtn *pBtn)
-{
- CFX_PtrArray arrBtn;
- if (m_pMinBox) {
- arrBtn.Add(m_pMinBox);
- }
- if (m_pMaxBox) {
- arrBtn.Add(m_pMaxBox);
- }
- if (m_pCloseBox) {
- arrBtn.Add(m_pCloseBox);
- }
- return arrBtn.Find(pBtn);
-}
-FX_FLOAT CFWL_FormImp::GetCaptionHeight()
-{
- FX_DWORD dwCapacity = 0;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
- dwCapacity = FWL_WGTCAPACITY_FRM_CYCaption;
- } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
- dwCapacity = FWL_WGTCAPACITY_FRM_CYNarrowCaption;
- }
- if (dwCapacity > 0) {
- FX_FLOAT *pfCapHeight = (FX_FLOAT*)GetThemeCapacity(dwCapacity);
- _FWL_RETURN_VALUE_IF_FAIL(pfCapHeight, 0);
- return *pfCapHeight;
- }
- return 0;
-}
-void CFWL_FormImp::DrawCaptionText(CFX_Graphics *pGs, IFWL_ThemeProvider *pTheme, const CFX_Matrix* pMatrix )
-{
- CFX_WideString wsText;
- IFWL_DataProvider *pData = m_pProperties->m_pDataProvider;
- pData->GetCaption(m_pInterface, wsText);
- if (wsText.IsEmpty()) {
- return;
- }
- CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_FRM_Caption;
- textParam.m_dwStates = FWL_PARTSTATE_FRM_Normal;
- textParam.m_pGraphics = pGs;
- if (pMatrix) {
- textParam.m_matrix.Concat(*pMatrix);
- }
- CFX_RectF rtText;
- if (m_bCustomizeLayout) {
- rtText = m_rtCaptionText;
- rtText.top -= 5;
- } else {
- rtText = m_rtCaption;
- FX_FLOAT fpos;
- fpos = HasIcon() ? 29.0f : 13.0f;
- rtText.left += fpos;
- }
- textParam.m_rtPart = rtText;
- textParam.m_wsText = wsText;
- textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis;
- textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center : FDE_TTOALIGNMENT_CenterLeft;
- pTheme->DrawText(&textParam);
-}
-void CFWL_FormImp::DrawIconImage(CFX_Graphics *pGs, IFWL_ThemeProvider *pTheme, const CFX_Matrix* pMatrix )
-{
- IFWL_FormDP *pData = (IFWL_FormDP *)m_pProperties->m_pDataProvider;
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Icon;
- param.m_pGraphics = pGs;
- param.m_pImage = pData->GetIcon(m_pInterface, FALSE);
- param.m_rtPart = m_rtIcon;
- if(pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(¶m);
-}
-void CFWL_FormImp::GetEdgeRect(CFX_RectF &rtEdge)
-{
- rtEdge = m_rtRelative;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
- FX_FLOAT fCX = GetBorderSize();
- FX_FLOAT fCY = GetBorderSize(FALSE);
- rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY);
- }
-}
-void CFWL_FormImp::SetWorkAreaRect()
-{
- m_rtRestore = m_pProperties->m_rtWidget;
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_IF_FAIL(pWidgetMgr);
- m_bSetMaximize = TRUE;
- pWidgetMgr->SetMaximize_Native(m_pInterface);
- Repaint(&m_rtRelative);
-}
-void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy)
-{
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- IFWL_AdapterCursorMgr *pCursorMgr = pNative->GetCursorMgr();
- _FWL_RETURN_IF_FAIL(pCursorMgr);
- FX_DWORD dwHitTest = HitTest(fx, fy);
- switch (dwHitTest) {
- case FWL_WGTHITTEST_Right: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_Right;
- break;
- }
- case FWL_WGTHITTEST_Bottom: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_Bottom;
- break;
- }
- case FWL_WGTHITTEST_Left: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_Left;
- break;
- }
- case FWL_WGTHITTEST_Top: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_Top;
- break;
- }
- case FWL_WGTHITTEST_LeftTop: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_LeftTop;
- break;
- }
- case FWL_WGTHITTEST_LeftBottom: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_LeftBottom;
- break;
- }
- case FWL_WGTHITTEST_RightTop: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_RightTop;
- break;
- }
- case FWL_WGTHITTEST_RightBottom: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- m_eResizeType = FORM_RESIZETYPE_RightBottom;
- break;
- }
- default: {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_Arrow);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- }
- }
-}
-void CFWL_FormImp::Layout()
-{
- GetRelativeRect(m_rtRelative);
+ }
+ CFX_PtrArray arrBtn;
+ if (m_pMinBox) {
+ arrBtn.Add(m_pMinBox);
+ }
+ if (m_pMaxBox) {
+ arrBtn.Add(m_pMaxBox);
+ }
+ if (m_pCloseBox) {
+ arrBtn.Add(m_pCloseBox);
+ }
+ return (CFWL_SysBtn*)arrBtn[nIndex];
+}
+int32_t CFWL_FormImp::GetSysBtnIndex(CFWL_SysBtn* pBtn) {
+ CFX_PtrArray arrBtn;
+ if (m_pMinBox) {
+ arrBtn.Add(m_pMinBox);
+ }
+ if (m_pMaxBox) {
+ arrBtn.Add(m_pMaxBox);
+ }
+ if (m_pCloseBox) {
+ arrBtn.Add(m_pCloseBox);
+ }
+ return arrBtn.Find(pBtn);
+}
+FX_FLOAT CFWL_FormImp::GetCaptionHeight() {
+ FX_DWORD dwCapacity = 0;
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
+ dwCapacity = FWL_WGTCAPACITY_FRM_CYCaption;
+ } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
+ dwCapacity = FWL_WGTCAPACITY_FRM_CYNarrowCaption;
+ }
+ if (dwCapacity > 0) {
+ FX_FLOAT* pfCapHeight = (FX_FLOAT*)GetThemeCapacity(dwCapacity);
+ _FWL_RETURN_VALUE_IF_FAIL(pfCapHeight, 0);
+ return *pfCapHeight;
+ }
+ return 0;
+}
+void CFWL_FormImp::DrawCaptionText(CFX_Graphics* pGs,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFX_WideString wsText;
+ IFWL_DataProvider* pData = m_pProperties->m_pDataProvider;
+ pData->GetCaption(m_pInterface, wsText);
+ if (wsText.IsEmpty()) {
+ return;
+ }
+ CFWL_ThemeText textParam;
+ textParam.m_pWidget = m_pInterface;
+ textParam.m_iPart = FWL_PART_FRM_Caption;
+ textParam.m_dwStates = FWL_PARTSTATE_FRM_Normal;
+ textParam.m_pGraphics = pGs;
+ if (pMatrix) {
+ textParam.m_matrix.Concat(*pMatrix);
+ }
+ CFX_RectF rtText;
+ if (m_bCustomizeLayout) {
+ rtText = m_rtCaptionText;
+ rtText.top -= 5;
+ } else {
+ rtText = m_rtCaption;
+ FX_FLOAT fpos;
+ fpos = HasIcon() ? 29.0f : 13.0f;
+ rtText.left += fpos;
+ }
+ textParam.m_rtPart = rtText;
+ textParam.m_wsText = wsText;
+ textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis;
+ textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center
+ : FDE_TTOALIGNMENT_CenterLeft;
+ pTheme->DrawText(&textParam);
+}
+void CFWL_FormImp::DrawIconImage(CFX_Graphics* pGs,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ IFWL_FormDP* pData = (IFWL_FormDP*)m_pProperties->m_pDataProvider;
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_FRM_Icon;
+ param.m_pGraphics = pGs;
+ param.m_pImage = pData->GetIcon(m_pInterface, FALSE);
+ param.m_rtPart = m_rtIcon;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix);
+ }
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_FormImp::GetEdgeRect(CFX_RectF& rtEdge) {
+ rtEdge = m_rtRelative;
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
+ FX_FLOAT fCX = GetBorderSize();
+ FX_FLOAT fCY = GetBorderSize(FALSE);
+ rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY);
+ }
+}
+void CFWL_FormImp::SetWorkAreaRect() {
+ m_rtRestore = m_pProperties->m_rtWidget;
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_IF_FAIL(pWidgetMgr);
+ m_bSetMaximize = TRUE;
+ pWidgetMgr->SetMaximize_Native(m_pInterface);
+ Repaint(&m_rtRelative);
+}
+void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr();
+ _FWL_RETURN_IF_FAIL(pCursorMgr);
+ FX_DWORD dwHitTest = HitTest(fx, fy);
+ switch (dwHitTest) {
+ case FWL_WGTHITTEST_Right: {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_Right;
+ break;
+ }
+ case FWL_WGTHITTEST_Bottom: {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_Bottom;
+ break;
+ }
+ case FWL_WGTHITTEST_Left: {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_Left;
+ break;
+ }
+ case FWL_WGTHITTEST_Top: {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_Top;
+ break;
+ }
+ case FWL_WGTHITTEST_LeftTop: {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_LeftTop;
+ break;
+ }
+ case FWL_WGTHITTEST_LeftBottom: {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_LeftBottom;
+ break;
+ }
+ case FWL_WGTHITTEST_RightTop: {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_RightTop;
+ break;
+ }
+ case FWL_WGTHITTEST_RightBottom: {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ m_eResizeType = FORM_RESIZETYPE_RightBottom;
+ break;
+ }
+ default: {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_Arrow);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ }
+ }
+}
+void CFWL_FormImp::Layout() {
+ GetRelativeRect(m_rtRelative);
#ifndef FWL_UseMacSystemBorder
- ReSetSysBtn();
+ ReSetSysBtn();
#endif
- if (m_pContent) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- m_pContent->SetWidgetRect(rtClient);
- m_pContent->Update();
- }
-}
-void CFWL_FormImp::ReSetSysBtn()
-{
- m_fCXBorder = *(FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_CXBorder);
- m_fCYBorder = *(FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_CYBorder);
- RemoveSysButtons();
- IFWL_ThemeProvider *pTheme = m_pProperties->m_pThemeProvider;
- m_bCustomizeLayout = pTheme->IsCustomizedLayout(m_pInterface);
- FX_FLOAT fCapHeight = GetCaptionHeight();
- if (fCapHeight > 0) {
- m_rtCaption = m_rtRelative;
- m_rtCaption.height = fCapHeight;
- }
- m_iSysBox = 0;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) {
- m_pCloseBox = FX_NEW CFWL_SysBtn;
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_CloseBox;
- pTheme->GetPartRect(¶m, m_pCloseBox->m_rtBtn);
- } else {
- m_pCloseBox->m_rtBtn.Set(m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN,
- FWL_SYSBTNSIZE,
- FWL_SYSBTNSIZE);
- }
- m_iSysBox ++;
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) {
- m_pMaxBox = FX_NEW CFWL_SysBtn;
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
- pTheme->GetPartRect(¶m, m_pMaxBox->m_rtBtn);
- } else {
- if (m_pCloseBox) {
- m_pMaxBox->m_rtBtn.Set(m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pCloseBox->m_rtBtn.top,
- FWL_SYSBTNSIZE,
- FWL_SYSBTNSIZE);
- } else {
- m_pMaxBox->m_rtBtn.Set(m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN,
- FWL_SYSBTNSIZE,
- FWL_SYSBTNSIZE);
- }
- }
- m_iSysBox ++;
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) {
- m_pMinBox = FX_NEW CFWL_SysBtn;
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
- pTheme->GetPartRect(¶m, m_pMinBox->m_rtBtn);
- } else {
- if (m_pMaxBox) {
- m_pMinBox->m_rtBtn.Set(m_pMaxBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pMaxBox->m_rtBtn.top,
- FWL_SYSBTNSIZE,
- FWL_SYSBTNSIZE);
- } else if (m_pCloseBox) {
- m_pMinBox->m_rtBtn.Set(m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pCloseBox->m_rtBtn.top,
- FWL_SYSBTNSIZE,
- FWL_SYSBTNSIZE);
- } else {
- m_pMinBox->m_rtBtn.Set(m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN,
- FWL_SYSBTNSIZE,
- FWL_SYSBTNSIZE);
- }
- }
- m_iSysBox ++;
- }
- IFWL_FormDP *pData = (IFWL_FormDP *)m_pProperties->m_pDataProvider;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && pData->GetIcon(m_pInterface, FALSE)) {
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Icon;
- CFX_WideString wsText;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsText);
- param.m_pData = &wsText;
- pTheme->GetPartRect(¶m, m_rtIcon);
- } else {
- m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz, m_fSmallIconSz);
- }
- }
+ if (m_pContent) {
+ CFX_RectF rtClient;
+ GetClientRect(rtClient);
+ m_pContent->SetWidgetRect(rtClient);
+ m_pContent->Update();
+ }
+}
+void CFWL_FormImp::ReSetSysBtn() {
+ m_fCXBorder = *(FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_CXBorder);
+ m_fCYBorder = *(FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_CYBorder);
+ RemoveSysButtons();
+ IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
+ m_bCustomizeLayout = pTheme->IsCustomizedLayout(m_pInterface);
+ FX_FLOAT fCapHeight = GetCaptionHeight();
+ if (fCapHeight > 0) {
+ m_rtCaption = m_rtRelative;
+ m_rtCaption.height = fCapHeight;
+ }
+ m_iSysBox = 0;
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) {
+ m_pCloseBox = FX_NEW CFWL_SysBtn;
if (m_bCustomizeLayout) {
- CFWL_ThemeText parma;
- parma.m_pWidget = m_pInterface;
- parma.m_iPart = FWL_PART_FRM_HeadText;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, parma.m_wsText);
- pTheme->GetPartRect(&parma, m_rtCaptionText);
- }
-}
-void CFWL_FormImp::RegisterForm()
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pDriver);
- pDriver->RegisterForm(this);
-}
-void CFWL_FormImp::UnRegisterForm()
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pDriver);
- pDriver->UnRegisterForm(this);
-}
-FX_BOOL CFWL_FormImp::IsDoModal()
-{
- return m_bDoModalFlag;
-}
-void CFWL_FormImp::SetThemeData()
-{
- m_fSmallIconSz = *(FX_FLOAT *)GetThemeCapacity(FWL_WGTCAPACITY_FRM_SmallIcon);
- m_fBigIconSz = *(FX_FLOAT *)GetThemeCapacity(FWL_WGTCAPACITY_FRM_BigIcon);
-}
-FX_BOOL CFWL_FormImp::HasIcon()
-{
- IFWL_FormDP *pData = (IFWL_FormDP *)m_pProperties->m_pDataProvider;
- return pData->GetIcon(m_pInterface, FALSE) ? TRUE : FALSE;
-}
-void CFWL_FormImp::UpdateIcon()
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_IF_FAIL(pWidgetMgr);
- IFWL_FormDP *pData = (IFWL_FormDP *)m_pProperties->m_pDataProvider;
- CFX_DIBitmap *pBigIcon = pData->GetIcon(m_pInterface, TRUE);
- CFX_DIBitmap *pSmallIcon = pData->GetIcon(m_pInterface, FALSE);
- if (pBigIcon && pBigIcon != m_pBigIcon) {
- m_pBigIcon = pBigIcon;
- pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE);
- }
- if (pSmallIcon && pSmallIcon != m_pSmallIcon) {
- m_pSmallIcon = pSmallIcon;
- pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, FALSE);
- }
-}
-void CFWL_FormImp::UpdateCaption()
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_IF_FAIL(pWidgetMgr);
- IFWL_FormDP *pData = (IFWL_FormDP *)m_pProperties->m_pDataProvider;
- _FWL_RETURN_IF_FAIL(pData);
- CFX_WideString text;
- pData->GetCaption(m_pInterface, text);
- pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text);
-}
-void CFWL_FormImp::DoWidthLimit(FX_FLOAT &fLeft, FX_FLOAT &fWidth, FX_FLOAT fCurX, FX_FLOAT fSpace, FX_FLOAT fLimitMin, FX_FLOAT fLimitMax, FX_BOOL bLeft)
-{
- FX_FLOAT fx = fCurX;
- FX_FLOAT fy = 0 ;
- TransformTo(NULL, fx, fy);
- FX_FLOAT fTemp = bLeft ? (fWidth - fx + fLeft + fSpace ) : (fx - fLeft + fSpace);
- if (fTemp >= fLimitMin && fTemp <= fLimitMax) {
- fWidth = fTemp;
- fLeft += bLeft ? (fx - fLeft - fSpace ) : 0;
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_FRM_CloseBox;
+ pTheme->GetPartRect(¶m, m_pCloseBox->m_rtBtn);
} else {
- if (fTemp < fLimitMin && fWidth > fLimitMin) {
- fLeft += bLeft ? (fWidth - fLimitMin) : 0;
- fWidth = fLimitMin;
- } else if (fTemp > fLimitMax && fWidth < fLimitMax) {
- fLeft -= bLeft ? (fLimitMax - fWidth) : 0;
- fWidth = fLimitMax;
- }
- }
-}
-void CFWL_FormImp::DoHeightLimit(FX_FLOAT &fTop, FX_FLOAT &fHeight, FX_FLOAT fCurY, FX_FLOAT fSpace, FX_FLOAT fLimitMin, FX_FLOAT fLimitMax, FX_BOOL bTop)
-{
- FX_FLOAT fx = 0;
- FX_FLOAT fy = fCurY ;
- TransformTo(NULL, fx, fy);
- FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace ) : (fy - fTop + fSpace);
- if (fTemp >= fLimitMin && fTemp <= fLimitMax) {
- fHeight = fTemp;
- fTop += bTop ? (fy - fTop - fSpace ) : 0;
+ m_pCloseBox->m_rtBtn.Set(
+ m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
+ FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ }
+ m_iSysBox++;
+ }
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) {
+ m_pMaxBox = FX_NEW CFWL_SysBtn;
+ if (m_bCustomizeLayout) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_FRM_MaximizeBox;
+ pTheme->GetPartRect(¶m, m_pMaxBox->m_rtBtn);
} else {
- if (fTemp < fLimitMin && fHeight > fLimitMin) {
- fTop += bTop ? (fHeight - fLimitMin) : 0;
- fHeight = fLimitMin;
- } else if (fTemp > fLimitMax && fHeight < fLimitMax) {
- fTop -= bTop ? (fLimitMax - fHeight) : 0;
- fHeight = fLimitMax;
- }
- }
-}
-CFWL_FormDelegate::CFWL_FormDelegate(CFWL_FormImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_FormDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
+ if (m_pCloseBox) {
+ m_pMaxBox->m_rtBtn.Set(
+ m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
+ m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ } else {
+ m_pMaxBox->m_rtBtn.Set(
+ m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
+ FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ }
+ }
+ m_iSysBox++;
+ }
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) {
+ m_pMinBox = FX_NEW CFWL_SysBtn;
+ if (m_bCustomizeLayout) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_FRM_MinimizeBox;
+ pTheme->GetPartRect(¶m, m_pMinBox->m_rtBtn);
+ } else {
+ if (m_pMaxBox) {
+ m_pMinBox->m_rtBtn.Set(
+ m_pMaxBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
+ m_pMaxBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ } else if (m_pCloseBox) {
+ m_pMinBox->m_rtBtn.Set(
+ m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
+ m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ } else {
+ m_pMinBox->m_rtBtn.Set(
+ m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
+ FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ }
+ }
+ m_iSysBox++;
+ }
+ IFWL_FormDP* pData = (IFWL_FormDP*)m_pProperties->m_pDataProvider;
+ if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon &&
+ pData->GetIcon(m_pInterface, FALSE)) {
+ if (m_bCustomizeLayout) {
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = FWL_PART_FRM_Icon;
+ CFX_WideString wsText;
+ m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsText);
+ param.m_pData = &wsText;
+ pTheme->GetPartRect(¶m, m_rtIcon);
+ } else {
+ m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz,
+ m_fSmallIconSz);
+ }
+ }
+ if (m_bCustomizeLayout) {
+ CFWL_ThemeText parma;
+ parma.m_pWidget = m_pInterface;
+ parma.m_iPart = FWL_PART_FRM_HeadText;
+ m_pProperties->m_pDataProvider->GetCaption(m_pInterface, parma.m_wsText);
+ pTheme->GetPartRect(&parma, m_rtCaptionText);
+ }
+}
+void CFWL_FormImp::RegisterForm() {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pDriver);
+ pDriver->RegisterForm(this);
+}
+void CFWL_FormImp::UnRegisterForm() {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pDriver);
+ pDriver->UnRegisterForm(this);
+}
+FX_BOOL CFWL_FormImp::IsDoModal() {
+ return m_bDoModalFlag;
+}
+void CFWL_FormImp::SetThemeData() {
+ m_fSmallIconSz = *(FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_FRM_SmallIcon);
+ m_fBigIconSz = *(FX_FLOAT*)GetThemeCapacity(FWL_WGTCAPACITY_FRM_BigIcon);
+}
+FX_BOOL CFWL_FormImp::HasIcon() {
+ IFWL_FormDP* pData = (IFWL_FormDP*)m_pProperties->m_pDataProvider;
+ return pData->GetIcon(m_pInterface, FALSE) ? TRUE : FALSE;
+}
+void CFWL_FormImp::UpdateIcon() {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_IF_FAIL(pWidgetMgr);
+ IFWL_FormDP* pData = (IFWL_FormDP*)m_pProperties->m_pDataProvider;
+ CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE);
+ CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE);
+ if (pBigIcon && pBigIcon != m_pBigIcon) {
+ m_pBigIcon = pBigIcon;
+ pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE);
+ }
+ if (pSmallIcon && pSmallIcon != m_pSmallIcon) {
+ m_pSmallIcon = pSmallIcon;
+ pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, FALSE);
+ }
+}
+void CFWL_FormImp::UpdateCaption() {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_IF_FAIL(pWidgetMgr);
+ IFWL_FormDP* pData = (IFWL_FormDP*)m_pProperties->m_pDataProvider;
+ _FWL_RETURN_IF_FAIL(pData);
+ CFX_WideString text;
+ pData->GetCaption(m_pInterface, text);
+ pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text);
+}
+void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft,
+ FX_FLOAT& fWidth,
+ FX_FLOAT fCurX,
+ FX_FLOAT fSpace,
+ FX_FLOAT fLimitMin,
+ FX_FLOAT fLimitMax,
+ FX_BOOL bLeft) {
+ FX_FLOAT fx = fCurX;
+ FX_FLOAT fy = 0;
+ TransformTo(NULL, fx, fy);
+ FX_FLOAT fTemp =
+ bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace);
+ if (fTemp >= fLimitMin && fTemp <= fLimitMax) {
+ fWidth = fTemp;
+ fLeft += bLeft ? (fx - fLeft - fSpace) : 0;
+ } else {
+ if (fTemp < fLimitMin && fWidth > fLimitMin) {
+ fLeft += bLeft ? (fWidth - fLimitMin) : 0;
+ fWidth = fLimitMin;
+ } else if (fTemp > fLimitMax && fWidth < fLimitMax) {
+ fLeft -= bLeft ? (fLimitMax - fWidth) : 0;
+ fWidth = fLimitMax;
+ }
+ }
+}
+void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop,
+ FX_FLOAT& fHeight,
+ FX_FLOAT fCurY,
+ FX_FLOAT fSpace,
+ FX_FLOAT fLimitMin,
+ FX_FLOAT fLimitMax,
+ FX_BOOL bTop) {
+ FX_FLOAT fx = 0;
+ FX_FLOAT fy = fCurY;
+ TransformTo(NULL, fx, fy);
+ FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace);
+ if (fTemp >= fLimitMin && fTemp <= fLimitMax) {
+ fHeight = fTemp;
+ fTop += bTop ? (fy - fTop - fSpace) : 0;
+ } else {
+ if (fTemp < fLimitMin && fHeight > fLimitMin) {
+ fTop += bTop ? (fHeight - fLimitMin) : 0;
+ fHeight = fLimitMin;
+ } else if (fTemp > fLimitMax && fHeight < fLimitMax) {
+ fTop -= bTop ? (fLimitMax - fHeight) : 0;
+ fHeight = fLimitMax;
+ }
+ }
+}
+CFWL_FormDelegate::CFWL_FormDelegate(CFWL_FormImp* pOwner) : m_pOwner(pOwner) {}
+int32_t CFWL_FormDelegate::OnProcessMessage(CFWL_Message* pMessage) {
#ifdef FWL_UseMacSystemBorder
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- }
- return FWL_ERR_Succeeded;
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_Activate: {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
+ m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ break;
+ }
+ case FWL_MSGHASH_Deactivate: {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
+ m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ break;
+ }
+ }
+ return FWL_ERR_Succeeded;
#else
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- IFWL_NoteThread *pThread = m_pOwner->GetOwnerThread();
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- CFWL_WidgetImp *pSubFocusImp = m_pOwner->GetSubFocus();
- IFWL_Widget *pSubFocus = pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
- if (pSubFocus && pSubFocus != pDriver->GetFocus()) {
- pDriver->SetFocus(pSubFocus);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- IFWL_NoteThread *pThread = m_pOwner->GetOwnerThread();
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- CFWL_WidgetImp *pSubFocusImp = m_pOwner->GetSubFocus();
- IFWL_Widget *pSubFocus = pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
- if (pSubFocus) {
- if (pSubFocus == pDriver->GetFocus()) {
- pDriver->SetFocus(NULL);
- } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) {
- CFWL_MsgKillFocus ms;
- IFWL_WidgetDelegate *pDelegate = pSubFocus->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(&ms);
- }
- }
- }
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- switch (pMsg->m_dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseHover: {
- OnMouseHover(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonDblClk: {
- OnLButtonDblClk(pMsg);
- break;
- }
- }
- break;
- }
- case FWL_MSGHASH_Size: {
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, 0);
- pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface);
- if (!m_pOwner->m_bSetMaximize) {
- break;
- }
- m_pOwner->m_bSetMaximize = FALSE;
- CFWL_MsgSize *pMsg = (CFWL_MsgSize*)pMessage;
- CFX_RectF rt;
- pWidgetMgr->GetWidgetRect_Native(m_pOwner->m_pInterface, rt);
- m_pOwner->m_pProperties->m_rtWidget.left = rt.left;
- m_pOwner->m_pProperties->m_rtWidget.top = rt.top;
- m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth;
- m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight;
- m_pOwner->Update();
- break;
- }
- case FWL_MSGHASH_WindowMove: {
- OnWindowMove((CFWL_MsgWindowMove* )pMessage);
- break;
- }
- case FWL_MSGHASH_Close: {
- OnClose((CFWL_MsgClose* )pMessage);
- break;
- }
- default: {
- iRet = 0;
- }
- }
- return iRet;
-#endif
-}
-FWL_ERR CFWL_FormDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pEvent, FWL_ERR_Indefinite);
- if (pEvent->GetClassID() == FWL_EVTHASH_Close && pEvent->m_pSrcTarget == m_pOwner->m_pInterface) {
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_FormDelegate::OnLButtonDown(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->SetGrab(TRUE);
- m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->m_eResizeType = FORM_RESIZETYPE_None;
- CFWL_SysBtn *pPressBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->m_iCaptureBtn = m_pOwner->GetSysBtnIndex(pPressBtn);
- CFX_RectF rtCap;
- rtCap.Set(m_pOwner->m_rtCaption.left + m_pOwner->m_fCYBorder,
- m_pOwner->m_rtCaption.top + m_pOwner->m_fCXBorder,
- m_pOwner->m_rtCaption.width - FWL_SYSBTNSIZE * m_pOwner->m_iSysBox - 2 * m_pOwner->m_fCYBorder,
- m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder);
- if (pPressBtn) {
- pPressBtn->SetPressed();
- m_pOwner->Repaint(&pPressBtn->m_rtBtn);
- } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_eResizeType = FORM_RESIZETYPE_Cap;
- } else if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
- (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
- !m_pOwner->m_bMaximized) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
- }
- m_pOwner->m_InfoStart.m_ptStart.Set(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->m_InfoStart.m_szStart.Set(m_pOwner->m_pProperties->m_rtWidget.width, m_pOwner->m_pProperties->m_rtWidget.height);
-}
-void CFWL_FormDelegate::OnLButtonUp(CFWL_MsgMouse *pMsg)
-{
- m_pOwner->SetGrab(FALSE);
- m_pOwner->m_bLButtonDown = FALSE;
- CFWL_SysBtn *pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
- CFWL_SysBtn *pPressedBtn = m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn);
- if (!pPressedBtn || pPointBtn != pPressedBtn) {
- return;
- }
- if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) {
- pPressedBtn->SetNormal();
- }
- if (pPressedBtn == m_pOwner->m_pMaxBox) {
- if (m_pOwner->m_bMaximized) {
- m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
- m_pOwner->Update();
- m_pOwner->Repaint();
- } else {
- m_pOwner->SetWorkAreaRect();
- m_pOwner->Update();
- }
- m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
- } else if (pPressedBtn == m_pOwner->m_pMinBox) {
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_IF_FAIL(pWidgetMgr);
- pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface);
- } else {
- CFWL_EvtClose eClose;
- eClose.m_pSrcTarget = m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&eClose);
- }
-}
-void CFWL_FormDelegate::OnMouseMove(CFWL_MsgMouse *pMsg)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- if (m_pOwner->m_bLButtonDown) {
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- IFWL_AdapterCursorMgr *pCursorMgr = pNative->GetCursorMgr();
- _FWL_RETURN_IF_FAIL(pCursorMgr);
- CFWL_SysBtn *pPressedBtn = m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn);
- FX_FLOAT fTop, fLeft, fWidth, fHeight;
- fTop = m_pOwner->m_pProperties->m_rtWidget.top;
- fLeft = m_pOwner->m_pProperties->m_rtWidget.left;
- fWidth = m_pOwner->m_pProperties->m_rtWidget.width;
- fHeight = m_pOwner->m_pProperties->m_rtWidget.height;
- FX_FLOAT fWidthMax, fWidthMin, fHeightMax, fHeightMin;
- if (m_pOwner->m_pContent) {
- m_pOwner->GetContent()->GetMaxSize(fWidthMax, fHeightMax);
- m_pOwner->GetContent()->GetMinSize(fWidthMin, fHeightMin);
- } else {
- fWidthMax = fHeightMax = 1024 * 4;
- fWidthMin = fHeightMin = 0;
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ int32_t iRet = 1;
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_Activate: {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
+ IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread();
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
+ IFWL_Widget* pSubFocus =
+ pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
+ if (pSubFocus && pSubFocus != pDriver->GetFocus()) {
+ pDriver->SetFocus(pSubFocus);
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ break;
+ }
+ case FWL_MSGHASH_Deactivate: {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
+ IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread();
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
+ IFWL_Widget* pSubFocus =
+ pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
+ if (pSubFocus) {
+ if (pSubFocus == pDriver->GetFocus()) {
+ pDriver->SetFocus(NULL);
+ } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) {
+ CFWL_MsgKillFocus ms;
+ IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL);
+ if (pDelegate) {
+ pDelegate->OnProcessMessage(&ms);
+ }
}
- FX_BOOL bWidthlimit = (fWidthMin != 0 || fWidthMax != 0);
- FX_BOOL bHeightlimit = (fHeightMin != 0 || fHeightMax != 0);
- FX_BOOL bSizelimit = bWidthlimit || bHeightlimit;
- if (fWidthMax != 0 || fHeightMax != 0 || fWidthMin != 0 || fHeightMin != 0) {
- bSizelimit = TRUE;
- }
- if (pPressedBtn) {
- if (!pPressedBtn->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- pPressedBtn->SetNormal();
- } else {
- pPressedBtn->SetPressed();
- }
- m_pOwner->Repaint(&pPressedBtn->m_rtBtn);
- return;
- } else if (m_pOwner->m_bMaximized) {
- return;
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Cap) {
- m_pOwner->m_pProperties->m_rtWidget.Offset(pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x, pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y);
- pWidgetMgr->SetWidgetPosition_Native(m_pOwner->m_pInterface,
- m_pOwner->m_pProperties->m_rtWidget.left,
- m_pOwner->m_pProperties->m_rtWidget.top);
- return;
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Right) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bWidthlimit) {
- fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x;
- m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
- } else {
- m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, m_pOwner->m_InfoStart.m_szStart.x - m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, fWidthMax, FALSE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Left) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bWidthlimit) {
- fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
- fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
- } else {
- m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, fWidthMax, TRUE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Bottom) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bHeightlimit) {
- fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
- } else {
- m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, m_pOwner->m_InfoStart.m_szStart.y - m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, fHeightMax, FALSE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Top) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bHeightlimit) {
- fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- } else {
- m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, fHeightMax, TRUE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_LeftTop) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bSizelimit) {
- fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
- fTop += pMsg->m_fy - m_pOwner-> m_InfoStart.m_ptStart.y;
- fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
- fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
- m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
- } else {
- m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, fWidthMax, TRUE);
- m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, fHeightMax, TRUE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_LeftBottom) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bSizelimit) {
- fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
- fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
- fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
- m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
- } else {
- m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, fWidthMax, TRUE);
- m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, m_pOwner->m_InfoStart.m_szStart.y - m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, fHeightMax, FALSE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_RightTop) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bSizelimit) {
- fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x;
- fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
- m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
- } else {
- m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, m_pOwner->m_InfoStart.m_szStart.x - m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, fWidthMax, FALSE);
- m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, fHeightMax, TRUE);
- }
- } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_RightBottom) {
- FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
- pCursorMgr->SetCursor(hCursor);
- pCursorMgr->ShowCursor(TRUE);
- if (!bSizelimit) {
- fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x;
- fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
- m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
- m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
- } else {
- m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, m_pOwner->m_InfoStart.m_szStart.x - m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, fWidthMax, FALSE);
- m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, m_pOwner->m_InfoStart.m_szStart.y - m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, fHeightMax, FALSE);
- }
- }
- if (m_pOwner->m_pContent) {
- }
- CFX_RectF rtForm;
- rtForm.Set(fLeft, fTop, fWidth, fHeight);
-#if (_FX_OS_==_FX_MACOSX_)
- m_pOwner->m_pProperties->m_rtWidget = rtForm;
- m_pOwner->Update();
- m_pOwner->SetWidgetRect(rtForm);
-#else
- m_pOwner->SetWidgetRect(rtForm);
- m_pOwner->Update();
-#endif
- return;
- }
- if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
- (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
- !m_pOwner->m_bMaximized) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
- }
- CFX_RectF rtInvalidate;
- rtInvalidate.Reset();
- CFWL_SysBtn *pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
- CFWL_SysBtn *pOldHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
-#if (_FX_OS_==_FX_MACOSX_)
- {
- if (pOldHover && pPointBtn != pOldHover) {
- pOldHover->SetNormal();
+ }
+ m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ switch (pMsg->m_dwCmd) {
+ case FWL_MSGMOUSECMD_LButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
}
- if (pPointBtn && pPointBtn != pOldHover) {
- pPointBtn->SetHover();
+ case FWL_MSGMOUSECMD_LButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
}
- if (m_pOwner->m_pCloseBox) {
- rtInvalidate = m_pOwner->m_pCloseBox->m_rtBtn;
+ case FWL_MSGMOUSECMD_MouseMove: {
+ OnMouseMove(pMsg);
+ break;
}
- if (m_pOwner->m_pMaxBox) {
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = m_pOwner->m_pMaxBox->m_rtBtn;
- } else {
- rtInvalidate.Union(m_pOwner->m_pMaxBox->m_rtBtn);
- }
+ case FWL_MSGMOUSECMD_MouseHover: {
+ OnMouseHover(pMsg);
+ break;
}
- if (m_pOwner->m_pMinBox) {
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = m_pOwner->m_pMinBox->m_rtBtn;
- } else {
- rtInvalidate.Union(m_pOwner->m_pMinBox->m_rtBtn);
- }
+ case FWL_MSGMOUSECMD_MouseLeave: {
+ OnMouseLeave(pMsg);
+ break;
}
- if (!rtInvalidate.IsEmpty() && rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_bMouseIn = TRUE;
+ case FWL_MSGMOUSECMD_LButtonDblClk: {
+ OnLButtonDblClk(pMsg);
+ break;
}
- }
-#else
- {
- if (pOldHover && pPointBtn != pOldHover) {
- pOldHover->SetNormal();
- rtInvalidate = pOldHover->m_rtBtn;
- }
- if (pPointBtn && pPointBtn != pOldHover) {
- pPointBtn->SetHover();
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = pPointBtn->m_rtBtn;
- } else {
- rtInvalidate.Union(pPointBtn->m_rtBtn);
- }
- }
- }
+ }
+ break;
+ }
+ case FWL_MSGHASH_Size: {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, 0);
+ pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface);
+ if (!m_pOwner->m_bSetMaximize) {
+ break;
+ }
+ m_pOwner->m_bSetMaximize = FALSE;
+ CFWL_MsgSize* pMsg = (CFWL_MsgSize*)pMessage;
+ CFX_RectF rt;
+ pWidgetMgr->GetWidgetRect_Native(m_pOwner->m_pInterface, rt);
+ m_pOwner->m_pProperties->m_rtWidget.left = rt.left;
+ m_pOwner->m_pProperties->m_rtWidget.top = rt.top;
+ m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth;
+ m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight;
+ m_pOwner->Update();
+ break;
+ }
+ case FWL_MSGHASH_WindowMove: {
+ OnWindowMove((CFWL_MsgWindowMove*)pMessage);
+ break;
+ }
+ case FWL_MSGHASH_Close: {
+ OnClose((CFWL_MsgClose*)pMessage);
+ break;
+ }
+ default: { iRet = 0; }
+ }
+ return iRet;
#endif
- if (!rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
}
-void CFWL_FormDelegate::OnMouseHover(CFWL_MsgMouse *pMsg)
-{
+FWL_ERR CFWL_FormDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ _FWL_RETURN_VALUE_IF_FAIL(pEvent, FWL_ERR_Indefinite);
+ if (pEvent->GetClassID() == FWL_EVTHASH_Close &&
+ pEvent->m_pSrcTarget == m_pOwner->m_pInterface) {
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_FormDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
+}
+void CFWL_FormDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ m_pOwner->SetGrab(TRUE);
+ m_pOwner->m_bLButtonDown = TRUE;
+ m_pOwner->m_eResizeType = FORM_RESIZETYPE_None;
+ CFWL_SysBtn* pPressBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
+ m_pOwner->m_iCaptureBtn = m_pOwner->GetSysBtnIndex(pPressBtn);
+ CFX_RectF rtCap;
+ rtCap.Set(m_pOwner->m_rtCaption.left + m_pOwner->m_fCYBorder,
+ m_pOwner->m_rtCaption.top + m_pOwner->m_fCXBorder,
+ m_pOwner->m_rtCaption.width - FWL_SYSBTNSIZE * m_pOwner->m_iSysBox -
+ 2 * m_pOwner->m_fCYBorder,
+ m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder);
+ if (pPressBtn) {
+ pPressBtn->SetPressed();
+ m_pOwner->Repaint(&pPressBtn->m_rtBtn);
+ } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_eResizeType = FORM_RESIZETYPE_Cap;
+ } else if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
+ (m_pOwner->m_pProperties->m_dwStyleExes &
+ FWL_STYLEEXT_FRM_Resize) &&
+ !m_pOwner->m_bMaximized) {
m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
-}
-void CFWL_FormDelegate::OnMouseLeave(CFWL_MsgMouse *pMsg)
-{
- CFWL_SysBtn *pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
- if (pHover) {
- pHover->SetNormal();
- m_pOwner->Repaint(&pHover->m_rtBtn);
- }
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave && !m_pOwner->m_bLButtonDown) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
- }
-}
-void CFWL_FormDelegate::OnLButtonDblClk(CFWL_MsgMouse *pMsg)
-{
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WGTHITTEST_Titlebar) {
- if (m_pOwner->m_bMaximized) {
- m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
- } else {
- m_pOwner->SetWorkAreaRect();
- }
- m_pOwner->Update();
- m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
+ }
+ m_pOwner->m_InfoStart.m_ptStart.Set(pMsg->m_fx, pMsg->m_fy);
+ m_pOwner->m_InfoStart.m_szStart.Set(
+ m_pOwner->m_pProperties->m_rtWidget.width,
+ m_pOwner->m_pProperties->m_rtWidget.height);
+}
+void CFWL_FormDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_pOwner->SetGrab(FALSE);
+ m_pOwner->m_bLButtonDown = FALSE;
+ CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
+ CFWL_SysBtn* pPressedBtn =
+ m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn);
+ if (!pPressedBtn || pPointBtn != pPressedBtn) {
+ return;
+ }
+ if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) {
+ pPressedBtn->SetNormal();
+ }
+ if (pPressedBtn == m_pOwner->m_pMaxBox) {
+ if (m_pOwner->m_bMaximized) {
+ m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
+ m_pOwner->Update();
+ m_pOwner->Repaint();
+ } else {
+ m_pOwner->SetWorkAreaRect();
+ m_pOwner->Update();
}
-}
-void CFWL_FormDelegate::OnWindowMove(CFWL_MsgWindowMove *pMsg)
-{
- m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx;
- m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy;
-}
-void CFWL_FormDelegate::OnClose(CFWL_MsgClose *pMsg)
-{
+ m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
+ } else if (pPressedBtn == m_pOwner->m_pMinBox) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_IF_FAIL(pWidgetMgr);
+ pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface);
+ } else {
CFWL_EvtClose eClose;
eClose.m_pSrcTarget = m_pOwner->m_pInterface;
m_pOwner->DispatchEvent(&eClose);
+ }
}
-FWL_ERR FWL_Accelerator_SetForm(IFWL_Form *pFrom, CFX_MapAccelerators *pMapAccel)
-{
- CFWL_FormImp *pImp = (CFWL_FormImp*)((IFWL_TargetData*)pFrom)->GetData();
- _FWL_RETURN_VALUE_IF_FAIL(pImp, FWL_ERR_Indefinite);
- return FWL_ERR_Succeeded;
+void CFWL_FormDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ if (m_pOwner->m_bLButtonDown) {
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr();
+ _FWL_RETURN_IF_FAIL(pCursorMgr);
+ CFWL_SysBtn* pPressedBtn =
+ m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn);
+ FX_FLOAT fTop, fLeft, fWidth, fHeight;
+ fTop = m_pOwner->m_pProperties->m_rtWidget.top;
+ fLeft = m_pOwner->m_pProperties->m_rtWidget.left;
+ fWidth = m_pOwner->m_pProperties->m_rtWidget.width;
+ fHeight = m_pOwner->m_pProperties->m_rtWidget.height;
+ FX_FLOAT fWidthMax, fWidthMin, fHeightMax, fHeightMin;
+ if (m_pOwner->m_pContent) {
+ m_pOwner->GetContent()->GetMaxSize(fWidthMax, fHeightMax);
+ m_pOwner->GetContent()->GetMinSize(fWidthMin, fHeightMin);
+ } else {
+ fWidthMax = fHeightMax = 1024 * 4;
+ fWidthMin = fHeightMin = 0;
+ }
+ FX_BOOL bWidthlimit = (fWidthMin != 0 || fWidthMax != 0);
+ FX_BOOL bHeightlimit = (fHeightMin != 0 || fHeightMax != 0);
+ FX_BOOL bSizelimit = bWidthlimit || bHeightlimit;
+ if (fWidthMax != 0 || fHeightMax != 0 || fWidthMin != 0 ||
+ fHeightMin != 0) {
+ bSizelimit = TRUE;
+ }
+ if (pPressedBtn) {
+ if (!pPressedBtn->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ pPressedBtn->SetNormal();
+ } else {
+ pPressedBtn->SetPressed();
+ }
+ m_pOwner->Repaint(&pPressedBtn->m_rtBtn);
+ return;
+ } else if (m_pOwner->m_bMaximized) {
+ return;
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Cap) {
+ m_pOwner->m_pProperties->m_rtWidget.Offset(
+ pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x,
+ pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y);
+ pWidgetMgr->SetWidgetPosition_Native(
+ m_pOwner->m_pInterface, m_pOwner->m_pProperties->m_rtWidget.left,
+ m_pOwner->m_pProperties->m_rtWidget.top);
+ return;
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Right) {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bWidthlimit) {
+ fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x;
+ m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
+ } else {
+ m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx,
+ m_pOwner->m_InfoStart.m_szStart.x -
+ m_pOwner->m_InfoStart.m_ptStart.x,
+ fWidthMin, fWidthMax, FALSE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Left) {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bWidthlimit) {
+ fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
+ fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
+ } else {
+ m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx,
+ m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin,
+ fWidthMax, TRUE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Bottom) {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bHeightlimit) {
+ fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
+ } else {
+ m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy,
+ m_pOwner->m_InfoStart.m_szStart.y -
+ m_pOwner->m_InfoStart.m_ptStart.y,
+ fHeightMin, fHeightMax, FALSE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Top) {
+ FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bHeightlimit) {
+ fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ } else {
+ m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy,
+ m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin,
+ fHeightMax, TRUE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_LeftTop) {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bSizelimit) {
+ fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
+ fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
+ fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
+ m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
+ } else {
+ m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx,
+ m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin,
+ fWidthMax, TRUE);
+ m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy,
+ m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin,
+ fHeightMax, TRUE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_LeftBottom) {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bSizelimit) {
+ fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
+ fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx;
+ fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
+ m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
+ } else {
+ m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx,
+ m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin,
+ fWidthMax, TRUE);
+ m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy,
+ m_pOwner->m_InfoStart.m_szStart.y -
+ m_pOwner->m_InfoStart.m_ptStart.y,
+ fHeightMin, fHeightMax, FALSE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_RightTop) {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bSizelimit) {
+ fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x;
+ fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
+ m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
+ } else {
+ m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx,
+ m_pOwner->m_InfoStart.m_szStart.x -
+ m_pOwner->m_InfoStart.m_ptStart.x,
+ fWidthMin, fWidthMax, FALSE);
+ m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy,
+ m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin,
+ fHeightMax, TRUE);
+ }
+ } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_RightBottom) {
+ FWL_HCURSOR hCursor =
+ pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE);
+ pCursorMgr->SetCursor(hCursor);
+ pCursorMgr->ShowCursor(TRUE);
+ if (!bSizelimit) {
+ fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x;
+ fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y;
+ m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx;
+ m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy;
+ } else {
+ m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx,
+ m_pOwner->m_InfoStart.m_szStart.x -
+ m_pOwner->m_InfoStart.m_ptStart.x,
+ fWidthMin, fWidthMax, FALSE);
+ m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy,
+ m_pOwner->m_InfoStart.m_szStart.y -
+ m_pOwner->m_InfoStart.m_ptStart.y,
+ fHeightMin, fHeightMax, FALSE);
+ }
+ }
+ if (m_pOwner->m_pContent) {
+ }
+ CFX_RectF rtForm;
+ rtForm.Set(fLeft, fTop, fWidth, fHeight);
+#if (_FX_OS_ == _FX_MACOSX_)
+ m_pOwner->m_pProperties->m_rtWidget = rtForm;
+ m_pOwner->Update();
+ m_pOwner->SetWidgetRect(rtForm);
+#else
+ m_pOwner->SetWidgetRect(rtForm);
+ m_pOwner->Update();
+#endif
+ return;
+ }
+ if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
+ (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
+ !m_pOwner->m_bMaximized) {
+ m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
+ }
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Reset();
+ CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
+ CFWL_SysBtn* pOldHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
+#if (_FX_OS_ == _FX_MACOSX_)
+ {
+ if (pOldHover && pPointBtn != pOldHover) {
+ pOldHover->SetNormal();
+ }
+ if (pPointBtn && pPointBtn != pOldHover) {
+ pPointBtn->SetHover();
+ }
+ if (m_pOwner->m_pCloseBox) {
+ rtInvalidate = m_pOwner->m_pCloseBox->m_rtBtn;
+ }
+ if (m_pOwner->m_pMaxBox) {
+ if (rtInvalidate.IsEmpty()) {
+ rtInvalidate = m_pOwner->m_pMaxBox->m_rtBtn;
+ } else {
+ rtInvalidate.Union(m_pOwner->m_pMaxBox->m_rtBtn);
+ }
+ }
+ if (m_pOwner->m_pMinBox) {
+ if (rtInvalidate.IsEmpty()) {
+ rtInvalidate = m_pOwner->m_pMinBox->m_rtBtn;
+ } else {
+ rtInvalidate.Union(m_pOwner->m_pMinBox->m_rtBtn);
+ }
+ }
+ if (!rtInvalidate.IsEmpty() &&
+ rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pOwner->m_bMouseIn = TRUE;
+ }
+ }
+#else
+ {
+ if (pOldHover && pPointBtn != pOldHover) {
+ pOldHover->SetNormal();
+ rtInvalidate = pOldHover->m_rtBtn;
+ }
+ if (pPointBtn && pPointBtn != pOldHover) {
+ pPointBtn->SetHover();
+ if (rtInvalidate.IsEmpty()) {
+ rtInvalidate = pPointBtn->m_rtBtn;
+ } else {
+ rtInvalidate.Union(pPointBtn->m_rtBtn);
+ }
+ }
+ }
+#endif
+ if (!rtInvalidate.IsEmpty()) {
+ m_pOwner->Repaint(&rtInvalidate);
+ }
+}
+void CFWL_FormDelegate::OnMouseHover(CFWL_MsgMouse* pMsg) {
+ m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
+}
+void CFWL_FormDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ CFWL_SysBtn* pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
+ if (pHover) {
+ pHover->SetNormal();
+ m_pOwner->Repaint(&pHover->m_rtBtn);
+ }
+ if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave &&
+ !m_pOwner->m_bLButtonDown) {
+ m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
+ }
+}
+void CFWL_FormDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) {
+ if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
+ m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WGTHITTEST_Titlebar) {
+ if (m_pOwner->m_bMaximized) {
+ m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
+ } else {
+ m_pOwner->SetWorkAreaRect();
+ }
+ m_pOwner->Update();
+ m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
+ }
+}
+void CFWL_FormDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) {
+ m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx;
+ m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy;
+}
+void CFWL_FormDelegate::OnClose(CFWL_MsgClose* pMsg) {
+ CFWL_EvtClose eClose;
+ eClose.m_pSrcTarget = m_pOwner->m_pInterface;
+ m_pOwner->DispatchEvent(&eClose);
+}
+FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom,
+ CFX_MapAccelerators* pMapAccel) {
+ CFWL_FormImp* pImp = (CFWL_FormImp*)((IFWL_TargetData*)pFrom)->GetData();
+ _FWL_RETURN_VALUE_IF_FAIL(pImp, FWL_ERR_Indefinite);
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/core/fwl_gridimp.cpp b/xfa/src/fwl/src/core/fwl_gridimp.cpp index 56eb655231..d6e011ab16 100644 --- a/xfa/src/fwl/src/core/fwl_gridimp.cpp +++ b/xfa/src/fwl/src/core/fwl_gridimp.cpp @@ -11,1349 +11,1366 @@ #include "include/fwl_widgetimp.h"
#include "include/fwl_contentimp.h"
#include "include/fwl_gridimp.h"
-IFWL_Grid* IFWL_Grid::Create()
-{
- return new IFWL_Grid;
-}
-FWL_ERR IFWL_Grid::Initialize()
-{
- m_pData = FX_NEW CFWL_GridImp;
- ((CFWL_GridImp*)m_pData)->SetInterface(this);
- return ((CFWL_GridImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Grid::Initialize(CFWL_WidgetImpProperties &properties)
-{
- m_pData = FX_NEW CFWL_GridImp(properties);
- ((CFWL_GridImp*)m_pData)->SetInterface(this);
- return ((CFWL_GridImp*)m_pData)->Initialize();
-}
-FWL_HGRIDCOLROW IFWL_Grid::InsertColRow(FX_BOOL bColumn, int32_t nIndex )
-{
- return ((CFWL_GridImp*)m_pData)->InsertColRow(bColumn, nIndex);
-}
-int32_t IFWL_Grid::CountColRows(FX_BOOL bColumn)
-{
- return ((CFWL_GridImp*)m_pData)->CountColRows(bColumn);
-}
-FWL_HGRIDCOLROW IFWL_Grid::GetColRow(FX_BOOL bColumn, int32_t nIndex)
-{
- return ((CFWL_GridImp*)m_pData)->GetColRow(bColumn, nIndex);
-}
-int32_t IFWL_Grid::GetIndex(FWL_HGRIDCOLROW hColRow)
-{
- return ((CFWL_GridImp*)m_pData)->GetIndex(hColRow);
-}
-FX_FLOAT IFWL_Grid::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->GetSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->SetSize(hColRow, fSize, eUnit);
-}
-FX_FLOAT IFWL_Grid::GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->GetMinSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetMinSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->SetMinSize(hColRow, fSize, eUnit);
-}
-FX_FLOAT IFWL_Grid::GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->GetMaxSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetMaxSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->SetMaxSize(hColRow, fSize, eUnit);
-}
-FX_BOOL IFWL_Grid::DeleteColRow(FWL_HGRIDCOLROW hColRow)
-{
- return ((CFWL_GridImp*)m_pData)->DeleteColRow(hColRow);
-}
-FX_BOOL IFWL_Grid::IsColumn(FWL_HGRIDCOLROW hColRow)
-{
- return ((CFWL_GridImp*)m_pData)->IsColumn(hColRow);
-}
-int32_t IFWL_Grid::GetWidgetPos(IFWL_Widget *pWidget, FX_BOOL bColumn)
-{
- return ((CFWL_GridImp*)m_pData)->GetWidgetPos(pWidget, bColumn);
-}
-FWL_ERR IFWL_Grid::SetWidgetPos(IFWL_Widget *pWidget, int32_t iPos, FX_BOOL bColumn)
-{
- return ((CFWL_GridImp*)m_pData)->SetWidgetPos(pWidget, iPos, bColumn);
-}
-int32_t IFWL_Grid::GetWidgetSpan(IFWL_Widget *pWidget, FX_BOOL bColumn)
-{
- return ((CFWL_GridImp*)m_pData)->GetWidgetSpan(pWidget, bColumn);
-}
-FWL_ERR IFWL_Grid::SetWidgetSpan(IFWL_Widget *pWidget, int32_t iSpan, FX_BOOL bColumn)
-{
- return ((CFWL_GridImp*)m_pData)->SetWidgetSpan(pWidget, iSpan , bColumn);
-}
-FX_FLOAT IFWL_Grid::GetWidgetSize(IFWL_Widget *pWidget, FWL_GRIDSIZE eSize, FWL_GRIDUNIT &eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->GetWidgetSize(pWidget, eSize, eUnit);
-}
-FWL_ERR IFWL_Grid::SetWidgetSize(IFWL_Widget *pWidget, FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit)
-{
- return ((CFWL_GridImp*)m_pData)->SetWidgetSize(pWidget, eSize, fSize, eUit);
-}
-FX_BOOL IFWL_Grid::GetWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin, FX_FLOAT &fMargin)
-{
- return ((CFWL_GridImp*)m_pData)->GetWidgetMargin(pWidget, eMargin, fMargin);
-}
-FWL_ERR IFWL_Grid::SetWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin, FX_FLOAT fMargin)
-{
- return ((CFWL_GridImp*)m_pData)->SetWidgetMargin(pWidget, eMargin, fMargin);
-}
-FWL_ERR IFWL_Grid::RemoveWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin)
-{
- return ((CFWL_GridImp*)m_pData)->RemoveWidgetMargin(pWidget, eMargin);
-}
-FX_FLOAT IFWL_Grid::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT &eUnit)
-{
- return ((CFWL_GridImp*)m_pData)->GetGridSize(eSize, eUnit);
+IFWL_Grid* IFWL_Grid::Create() {
+ return new IFWL_Grid;
}
-FWL_ERR IFWL_Grid::SetGridSize(FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit)
-{
- return ((CFWL_GridImp*)m_pData)->SetGridSize(eSize, fSize, eUit);
+FWL_ERR IFWL_Grid::Initialize() {
+ m_pData = FX_NEW CFWL_GridImp;
+ ((CFWL_GridImp*)m_pData)->SetInterface(this);
+ return ((CFWL_GridImp*)m_pData)->Initialize();
}
-IFWL_Grid::IFWL_Grid()
-{
- m_pData = NULL;
+FWL_ERR IFWL_Grid::Initialize(CFWL_WidgetImpProperties& properties) {
+ m_pData = FX_NEW CFWL_GridImp(properties);
+ ((CFWL_GridImp*)m_pData)->SetInterface(this);
+ return ((CFWL_GridImp*)m_pData)->Initialize();
}
-IFWL_Grid::~IFWL_Grid()
-{
- if (m_pData) {
- delete (CFWL_GridImp*)m_pData;
- m_pData = NULL;
- }
+FWL_HGRIDCOLROW IFWL_Grid::InsertColRow(FX_BOOL bColumn, int32_t nIndex) {
+ return ((CFWL_GridImp*)m_pData)->InsertColRow(bColumn, nIndex);
}
-CFWL_GridImp::CFWL_GridImp()
-{
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
-}
-CFWL_GridImp::CFWL_GridImp(const CFWL_WidgetImpProperties &properties)
- : CFWL_ContentImp(properties)
-{
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
-}
-CFWL_GridImp::~CFWL_GridImp()
-{
- int32_t iCount = m_Columns.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- delete (CFWL_GridColRow *) m_Columns[i];
- }
- m_Columns.RemoveAll();
- iCount = m_Rows.GetSize();
- for (int32_t j = 0; j < iCount; j++) {
- delete (CFWL_GridColRow*) m_Rows[j];
- }
- m_Rows.RemoveAll();
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget;
- CFWL_GridWidgetInfo *pInfo;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- delete pInfo;
- }
- m_mapWidgetInfo.RemoveAll();
- if (m_pDelegate) {
- delete (CFWL_GridDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
+int32_t IFWL_Grid::CountColRows(FX_BOOL bColumn) {
+ return ((CFWL_GridImp*)m_pData)->CountColRows(bColumn);
}
-FWL_ERR CFWL_GridImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_Grid;
- return FWL_ERR_Succeeded;
+FWL_HGRIDCOLROW IFWL_Grid::GetColRow(FX_BOOL bColumn, int32_t nIndex) {
+ return ((CFWL_GridImp*)m_pData)->GetColRow(bColumn, nIndex);
}
-FX_DWORD CFWL_GridImp::GetClassID() const
-{
- return FWL_CLASSHASH_Grid;
+int32_t IFWL_Grid::GetIndex(FWL_HGRIDCOLROW hColRow) {
+ return ((CFWL_GridImp*)m_pData)->GetIndex(hColRow);
}
-FWL_ERR CFWL_GridImp::Initialize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ContentImp::Initialize(), FWL_ERR_Indefinite);
- m_pDelegate = (IFWL_WidgetDelegate*) FX_NEW CFWL_GridDelegate(this);
- return FWL_ERR_Succeeded;
+FX_FLOAT IFWL_Grid::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
+ return ((CFWL_GridImp*)m_pData)->GetSize(hColRow, eUnit);
}
-FWL_ERR CFWL_GridImp::Finalize()
-{
- _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ContentImp::Finalize(), FWL_ERR_Indefinite);
- if (m_pDelegate) {
- delete (CFWL_GridDelegate*)m_pDelegate;
- m_pDelegate = NULL;
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Grid::SetSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit) {
+ return ((CFWL_GridImp*)m_pData)->SetSize(hColRow, fSize, eUnit);
}
-FWL_ERR CFWL_GridImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- rect.left = 0;
- rect.top = 0;
- rect.width = ProcessUnCertainColumns();
- rect.height = ProcessUnCertainRows();
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
+FX_FLOAT IFWL_Grid::GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
+ return ((CFWL_GridImp*)m_pData)->GetMinSize(hColRow, eUnit);
}
-FWL_ERR CFWL_GridImp::SetWidgetRect(const CFX_RectF &rect)
-{
- CFWL_WidgetImp::SetWidgetRect(rect);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Grid::SetMinSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit) {
+ return ((CFWL_GridImp*)m_pData)->SetMinSize(hColRow, fSize, eUnit);
}
-FWL_ERR CFWL_GridImp::Update()
-{
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- ProcessColumns(m_pProperties->m_rtWidget.width);
- ProcessRows(m_pProperties->m_rtWidget.height);
- SetAllWidgetsRect();
- return FWL_ERR_Succeeded;
+FX_FLOAT IFWL_Grid::GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
+ return ((CFWL_GridImp*)m_pData)->GetMaxSize(hColRow, eUnit);
}
-FWL_ERR CFWL_GridImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- if ((m_pProperties->m_dwStyleExes & FWL_GRIDSTYLEEXT_ShowGridLines) == 0) {
- return FWL_ERR_Succeeded;
- }
- pGraphics->SaveGraphState();
- if (pMatrix) {
- pGraphics->ConcatMatrix((CFX_Matrix*)pMatrix);
- }
- {
- FX_BOOL bDrawLine = FALSE;
- CFX_Path path;
- path.Create();
- int32_t iColumns = m_Columns.GetSize();
- for (int32_t i = 1; i < iColumns; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Columns[i];
- if (!pColRow) {
- continue;
- }
- if (!bDrawLine) {
- bDrawLine = TRUE;
- }
- path.AddLine(pColRow->m_fActualPos,
- 0,
- pColRow->m_fActualPos,
- m_pProperties->m_rtWidget.height);
- }
- int32_t iRows = m_Rows.GetSize();
- for (int32_t j = 1; j < iRows; j++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Rows[j];
- if (!pColRow) {
- continue;
- }
- if (!bDrawLine) {
- bDrawLine = TRUE;
- }
- path.AddLine(0,
- pColRow->m_fActualPos,
- m_pProperties->m_rtWidget.width,
- pColRow->m_fActualPos);
- }
- if (bDrawLine) {
- CFX_Color cr(0xFFFF0000);
- pGraphics->SetStrokeColor(&cr);
- pGraphics->StrokePath(&path);
- }
- }
- pGraphics->RestoreGraphState();
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Grid::SetMaxSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit) {
+ return ((CFWL_GridImp*)m_pData)->SetMaxSize(hColRow, fSize, eUnit);
}
-FWL_ERR CFWL_GridImp::InsertWidget(IFWL_Widget *pChild, int32_t nIndex )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pChild, FWL_ERR_Indefinite);
- CFWL_ContentImp::InsertWidget(pChild, nIndex);
- if (!m_mapWidgetInfo.GetValueAt(pChild)) {
- CFWL_GridWidgetInfo *pInfo = FX_NEW CFWL_GridWidgetInfo;
- m_mapWidgetInfo.SetAt(pChild, pInfo);
- m_Widgets.Add(pChild);
- }
- return FWL_ERR_Succeeded;
+FX_BOOL IFWL_Grid::DeleteColRow(FWL_HGRIDCOLROW hColRow) {
+ return ((CFWL_GridImp*)m_pData)->DeleteColRow(hColRow);
}
-FWL_ERR CFWL_GridImp::RemoveWidget(IFWL_Widget* pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);
- CFWL_ContentImp::RemoveWidget(pWidget);
- if (CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)m_mapWidgetInfo.GetValueAt(pWidget)) {
- m_mapWidgetInfo.RemoveKey(pWidget);
- delete pInfo;
- int32_t nIndex = m_Widgets.Find(pWidget);
- m_Widgets.RemoveAt(nIndex, 1);
- }
- return FWL_ERR_Succeeded;
+FX_BOOL IFWL_Grid::IsColumn(FWL_HGRIDCOLROW hColRow) {
+ return ((CFWL_GridImp*)m_pData)->IsColumn(hColRow);
}
-FWL_HGRIDCOLROW CFWL_GridImp::InsertColRow(FX_BOOL bColumn, int32_t nIndex )
-{
- if (bColumn) {
- if (nIndex < 0 || nIndex > m_Columns.GetSize()) {
- nIndex = m_Columns.GetSize();
- }
- CFWL_GridColRow *pColumn = FX_NEW CFWL_GridColRow;
- m_Columns.InsertAt(nIndex, pColumn, 1);
- return (FWL_HGRIDCOLROW)pColumn;
- }
- if (nIndex < 0 || nIndex > m_Rows.GetSize()) {
- nIndex = m_Rows.GetSize();
- }
- CFWL_GridColRow *pRow = FX_NEW CFWL_GridColRow;
- m_Rows.InsertAt(nIndex, pRow, 1);
- return (FWL_HGRIDCOLROW)pRow;
+int32_t IFWL_Grid::GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn) {
+ return ((CFWL_GridImp*)m_pData)->GetWidgetPos(pWidget, bColumn);
}
-int32_t CFWL_GridImp::CountColRows(FX_BOOL bColumn)
-{
- if (bColumn) {
- return m_Columns.GetSize();
- }
- return m_Rows.GetSize();
+FWL_ERR IFWL_Grid::SetWidgetPos(IFWL_Widget* pWidget,
+ int32_t iPos,
+ FX_BOOL bColumn) {
+ return ((CFWL_GridImp*)m_pData)->SetWidgetPos(pWidget, iPos, bColumn);
}
-FWL_HGRIDCOLROW CFWL_GridImp::GetColRow(FX_BOOL bColumn, int32_t nIndex)
-{
- if (bColumn) {
- if (nIndex < 0 || nIndex >= m_Columns.GetSize()) {
- return NULL;
- }
- return (FWL_HGRIDCOLROW)m_Columns[nIndex];
- }
- if (nIndex < 0 || nIndex >= m_Rows.GetSize()) {
- return NULL;
- }
- return (FWL_HGRIDCOLROW)m_Rows[nIndex];
+int32_t IFWL_Grid::GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn) {
+ return ((CFWL_GridImp*)m_pData)->GetWidgetSpan(pWidget, bColumn);
}
-int32_t CFWL_GridImp::GetIndex(FWL_HGRIDCOLROW hColRow)
-{
- if (IsColumn(hColRow)) {
- return m_Columns.Find(hColRow);
- }
- return m_Rows.Find(hColRow);
-}
-FX_FLOAT CFWL_GridImp::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hColRow, -1);
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)hColRow;
- eUnit = pColRow->m_Size.eUnit;
- return pColRow->m_Size.fLength;
-}
-FWL_ERR CFWL_GridImp::SetSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hColRow, FWL_ERR_Indefinite);
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)hColRow;
- pColRow->m_Size.eUnit = eUnit;
- pColRow->m_Size.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hColRow, -1);
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)hColRow;
- eUnit = pColRow->m_MinSize.eUnit;
- return pColRow->m_MinSize.fLength;
-}
-FWL_ERR CFWL_GridImp::SetMinSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hColRow, FWL_ERR_Indefinite);
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)hColRow;
- pColRow->m_MinSize.eUnit = eUnit;
- pColRow->m_MinSize.fLength = fSize;
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Grid::SetWidgetSpan(IFWL_Widget* pWidget,
+ int32_t iSpan,
+ FX_BOOL bColumn) {
+ return ((CFWL_GridImp*)m_pData)->SetWidgetSpan(pWidget, iSpan, bColumn);
}
-FX_FLOAT CFWL_GridImp::GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hColRow, -1);
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)hColRow;
- eUnit = pColRow->m_MaxSize.eUnit;
- return pColRow->m_MaxSize.fLength;
-}
-FWL_ERR CFWL_GridImp::SetMaxSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hColRow, FWL_ERR_Indefinite);
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)hColRow;
- pColRow->m_MaxSize.eUnit = eUnit;
- pColRow->m_MaxSize.fLength = fSize;
- return FWL_ERR_Succeeded;
+FX_FLOAT IFWL_Grid::GetWidgetSize(IFWL_Widget* pWidget,
+ FWL_GRIDSIZE eSize,
+ FWL_GRIDUNIT& eUnit) {
+ return ((CFWL_GridImp*)m_pData)->GetWidgetSize(pWidget, eSize, eUnit);
}
-FX_BOOL CFWL_GridImp::DeleteColRow(FWL_HGRIDCOLROW hColRow)
-{
- int32_t nIndex = m_Columns.Find(hColRow);
- if (nIndex >= 0) {
- m_Columns.RemoveAt(nIndex);
- delete (CFWL_GridColRow*)hColRow;
- return TRUE;
- }
- nIndex = m_Rows.Find(hColRow);
- if (nIndex >= 0) {
- delete (CFWL_GridColRow*)hColRow;
- m_Rows.RemoveAt(nIndex);
- return TRUE;
- }
- return FALSE;
+FWL_ERR IFWL_Grid::SetWidgetSize(IFWL_Widget* pWidget,
+ FWL_GRIDSIZE eSize,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUit) {
+ return ((CFWL_GridImp*)m_pData)->SetWidgetSize(pWidget, eSize, fSize, eUit);
}
-FX_BOOL CFWL_GridImp::IsColumn(FWL_HGRIDCOLROW hColRow)
-{
- return m_Columns.Find(hColRow) != -1;
-}
-int32_t CFWL_GridImp::GetWidgetPos(IFWL_Widget *pWidget, FX_BOOL bColumn)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- return bColumn ? pInfo->m_iColumn : pInfo->m_iRow;
- }
- return -1;
-}
-FWL_ERR CFWL_GridImp::SetWidgetPos(IFWL_Widget *pWidget, int32_t iPos, FX_BOOL bColumn)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- bColumn ? pInfo->m_iColumn = iPos : pInfo->m_iRow = iPos;
- }
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_GridImp::GetWidgetSpan(IFWL_Widget *pWidget, FX_BOOL bColumn)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- return bColumn ? pInfo->m_iColumnSpan : pInfo->m_iRowSpan;
- }
- return 0;
-}
-FWL_ERR CFWL_GridImp::SetWidgetSpan(IFWL_Widget *pWidget, int32_t iSpan, FX_BOOL bColumn)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- bColumn ? pInfo->m_iColumnSpan = iSpan : pInfo->m_iRowSpan = iSpan;
- }
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetWidgetSize(IFWL_Widget *pWidget, FWL_GRIDSIZE eSize, FWL_GRIDUNIT &eUnit)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- eUnit = pInfo->m_Size[eSize].eUnit;
- return pInfo->m_Size[eSize].fLength;
- }
- return 0;
+FX_BOOL IFWL_Grid::GetWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin,
+ FX_FLOAT& fMargin) {
+ return ((CFWL_GridImp*)m_pData)->GetWidgetMargin(pWidget, eMargin, fMargin);
}
-FWL_ERR CFWL_GridImp::SetWidgetSize(IFWL_Widget *pWidget, FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- pInfo->m_Size[eSize].fLength = fSize;
- pInfo->m_Size[eSize].eUnit = eUit;
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Grid::SetWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin,
+ FX_FLOAT fMargin) {
+ return ((CFWL_GridImp*)m_pData)->SetWidgetMargin(pWidget, eMargin, fMargin);
}
-FX_BOOL CFWL_GridImp::GetWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin, FX_FLOAT &fMargin)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- fMargin = pInfo->m_Margin[eMargin];
- return (pInfo->m_dwMarginFlag & (1 << eMargin)) != 0;
- }
- return FALSE;
+FWL_ERR IFWL_Grid::RemoveWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin) {
+ return ((CFWL_GridImp*)m_pData)->RemoveWidgetMargin(pWidget, eMargin);
}
-FWL_ERR CFWL_GridImp::SetWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin, FX_FLOAT fMargin)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- pInfo->m_Margin[eMargin] = fMargin;
- pInfo->m_dwMarginFlag |= (1 << eMargin);
- }
- return FWL_ERR_Succeeded;
+FX_FLOAT IFWL_Grid::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit) {
+ return ((CFWL_GridImp*)m_pData)->GetGridSize(eSize, eUnit);
}
-FWL_ERR CFWL_GridImp::RemoveWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin)
-{
- CFWL_GridWidgetInfo *pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
- if (pInfo) {
- pInfo->m_dwMarginFlag &= ~(1 << eMargin);
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Grid::SetGridSize(FWL_GRIDSIZE eSize,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUit) {
+ return ((CFWL_GridImp*)m_pData)->SetGridSize(eSize, fSize, eUit);
}
-FX_FLOAT CFWL_GridImp::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT &eUnit)
-{
- eUnit = m_Size[eSize].eUnit;
- return m_Size[eSize].fLength;
+IFWL_Grid::IFWL_Grid() {
+ m_pData = NULL;
}
-FWL_ERR CFWL_GridImp::SetGridSize(FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit)
-{
- m_Size[eSize].fLength = fSize;
- m_Size[eSize].eUnit = eUit;
+IFWL_Grid::~IFWL_Grid() {
+ if (m_pData) {
+ delete (CFWL_GridImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+CFWL_GridImp::CFWL_GridImp() {
+ m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
+ m_Size[FWL_GRIDSIZE_Width].fLength = 0;
+ m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
+ m_Size[FWL_GRIDSIZE_Height].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
+ m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
+ m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
+ m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
+ m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
+}
+CFWL_GridImp::CFWL_GridImp(const CFWL_WidgetImpProperties& properties)
+ : CFWL_ContentImp(properties) {
+ m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
+ m_Size[FWL_GRIDSIZE_Width].fLength = 0;
+ m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
+ m_Size[FWL_GRIDSIZE_Height].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
+ m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
+ m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
+ m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
+ m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
+}
+CFWL_GridImp::~CFWL_GridImp() {
+ int32_t iCount = m_Columns.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ delete (CFWL_GridColRow*)m_Columns[i];
+ }
+ m_Columns.RemoveAll();
+ iCount = m_Rows.GetSize();
+ for (int32_t j = 0; j < iCount; j++) {
+ delete (CFWL_GridColRow*)m_Rows[j];
+ }
+ m_Rows.RemoveAll();
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget;
+ CFWL_GridWidgetInfo* pInfo;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ delete pInfo;
+ }
+ m_mapWidgetInfo.RemoveAll();
+ if (m_pDelegate) {
+ delete (CFWL_GridDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+}
+FWL_ERR CFWL_GridImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_Grid;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_GridImp::GetClassID() const {
+ return FWL_CLASSHASH_Grid;
+}
+FWL_ERR CFWL_GridImp::Initialize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ContentImp::Initialize(),
+ FWL_ERR_Indefinite);
+ m_pDelegate = (IFWL_WidgetDelegate*)FX_NEW CFWL_GridDelegate(this);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::Finalize() {
+ _FWL_ERR_CHECK_RETURN_VALUE_IF_FAIL(CFWL_ContentImp::Finalize(),
+ FWL_ERR_Indefinite);
+ if (m_pDelegate) {
+ delete (CFWL_GridDelegate*)m_pDelegate;
+ m_pDelegate = NULL;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
+ rect.left = 0;
+ rect.top = 0;
+ rect.width = ProcessUnCertainColumns();
+ rect.height = ProcessUnCertainRows();
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::SetWidgetRect(const CFX_RectF& rect) {
+ CFWL_WidgetImp::SetWidgetRect(rect);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::Update() {
+ if (IsLocked()) {
+ return FWL_ERR_Indefinite;
+ }
+ ProcessColumns(m_pProperties->m_rtWidget.width);
+ ProcessRows(m_pProperties->m_rtWidget.height);
+ SetAllWidgetsRect();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ if ((m_pProperties->m_dwStyleExes & FWL_GRIDSTYLEEXT_ShowGridLines) == 0) {
return FWL_ERR_Succeeded;
-}
-CFWL_GridWidgetInfo* CFWL_GridImp::GetWidgetInfo(IFWL_Widget* pWidget)
-{
- return (CFWL_GridWidgetInfo*)m_mapWidgetInfo.GetValueAt(pWidget);
-}
-void CFWL_GridImp::ProcFixedColRow(CFWL_GridColRow *pColRow, int32_t nIndex, FX_FLOAT fColRowSize, FX_BOOL bColumn)
-{
- pColRow->m_fActualSize = fColRowSize;
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (bColumn) {
- if (pInfo->m_iColumn == nIndex && pInfo->m_iColumnSpan == 1) {
- CalcWidgetWidth(pWidget, pInfo, pColRow->m_fActualSize);
- }
- } else {
- if (pInfo->m_iRow == nIndex && pInfo->m_iRowSpan == 1) {
- CalcWidgetHeigt(pWidget, pInfo, pColRow->m_fActualSize);
- }
- }
- }
-}
-void CFWL_GridImp::ProcAutoColRow(CFWL_GridColRow *pColRow, int32_t nIndex, FX_BOOL bColumn)
-{
- _FWL_RETURN_IF_FAIL(pColRow);
- FX_FLOAT fMaxSize = 0, fWidgetSize = 0;
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget*pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pWidget || !pInfo) {
- continue;
- }
- if (bColumn) {
- if (pInfo->m_iColumn != nIndex || pInfo->m_iColumnSpan != 1) {
- continue;
- }
- fWidgetSize = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fMaxSize < fWidgetSize) {
- fMaxSize = fWidgetSize;
- }
- } else {
- if (pInfo->m_iRow != nIndex || pInfo->m_iRowSpan != 1) {
- continue;
- }
- fWidgetSize = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fMaxSize < fWidgetSize) {
- fMaxSize = fWidgetSize;
- }
- }
- }
- SetColRowActualSize(pColRow, fMaxSize);
-}
-void CFWL_GridImp::ProcScaledColRow(CFWL_GridColRow *pColRow, int32_t nIndex, FX_FLOAT fColRowSize, FX_BOOL bColumn)
-{
- if (fColRowSize > 0) {
- ProcFixedColRow(pColRow, nIndex, fColRowSize, bColumn);
+ }
+ pGraphics->SaveGraphState();
+ if (pMatrix) {
+ pGraphics->ConcatMatrix((CFX_Matrix*)pMatrix);
+ }
+ {
+ FX_BOOL bDrawLine = FALSE;
+ CFX_Path path;
+ path.Create();
+ int32_t iColumns = m_Columns.GetSize();
+ for (int32_t i = 1; i < iColumns; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Columns[i];
+ if (!pColRow) {
+ continue;
+ }
+ if (!bDrawLine) {
+ bDrawLine = TRUE;
+ }
+ path.AddLine(pColRow->m_fActualPos, 0, pColRow->m_fActualPos,
+ m_pProperties->m_rtWidget.height);
}
-}
-void CFWL_GridImp::CalcWidgetWidth(IFWL_Widget *pWidget, CFWL_GridWidgetInfo* pInfo, FX_FLOAT fColunmWidth)
-{
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
+ int32_t iRows = m_Rows.GetSize();
+ for (int32_t j = 1; j < iRows; j++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Rows[j];
+ if (!pColRow) {
+ continue;
+ }
+ if (!bDrawLine) {
+ bDrawLine = TRUE;
+ }
+ path.AddLine(0, pColRow->m_fActualPos, m_pProperties->m_rtWidget.width,
+ pColRow->m_fActualPos);
+ }
+ if (bDrawLine) {
+ CFX_Color cr(0xFFFF0000);
+ pGraphics->SetStrokeColor(&cr);
+ pGraphics->StrokePath(&path);
+ }
+ }
+ pGraphics->RestoreGraphState();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
+ _FWL_RETURN_VALUE_IF_FAIL(pChild, FWL_ERR_Indefinite);
+ CFWL_ContentImp::InsertWidget(pChild, nIndex);
+ if (!m_mapWidgetInfo.GetValueAt(pChild)) {
+ CFWL_GridWidgetInfo* pInfo = FX_NEW CFWL_GridWidgetInfo;
+ m_mapWidgetInfo.SetAt(pChild, pInfo);
+ m_Widgets.Add(pChild);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::RemoveWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);
+ CFWL_ContentImp::RemoveWidget(pWidget);
+ if (CFWL_GridWidgetInfo* pInfo =
+ (CFWL_GridWidgetInfo*)m_mapWidgetInfo.GetValueAt(pWidget)) {
+ m_mapWidgetInfo.RemoveKey(pWidget);
+ delete pInfo;
+ int32_t nIndex = m_Widgets.Find(pWidget);
+ m_Widgets.RemoveAt(nIndex, 1);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_HGRIDCOLROW CFWL_GridImp::InsertColRow(FX_BOOL bColumn, int32_t nIndex) {
+ if (bColumn) {
+ if (nIndex < 0 || nIndex > m_Columns.GetSize()) {
+ nIndex = m_Columns.GetSize();
+ }
+ CFWL_GridColRow* pColumn = FX_NEW CFWL_GridColRow;
+ m_Columns.InsertAt(nIndex, pColumn, 1);
+ return (FWL_HGRIDCOLROW)pColumn;
+ }
+ if (nIndex < 0 || nIndex > m_Rows.GetSize()) {
+ nIndex = m_Rows.GetSize();
+ }
+ CFWL_GridColRow* pRow = FX_NEW CFWL_GridColRow;
+ m_Rows.InsertAt(nIndex, pRow, 1);
+ return (FWL_HGRIDCOLROW)pRow;
+}
+int32_t CFWL_GridImp::CountColRows(FX_BOOL bColumn) {
+ if (bColumn) {
+ return m_Columns.GetSize();
+ }
+ return m_Rows.GetSize();
+}
+FWL_HGRIDCOLROW CFWL_GridImp::GetColRow(FX_BOOL bColumn, int32_t nIndex) {
+ if (bColumn) {
+ if (nIndex < 0 || nIndex >= m_Columns.GetSize()) {
+ return NULL;
+ }
+ return (FWL_HGRIDCOLROW)m_Columns[nIndex];
+ }
+ if (nIndex < 0 || nIndex >= m_Rows.GetSize()) {
+ return NULL;
+ }
+ return (FWL_HGRIDCOLROW)m_Rows[nIndex];
+}
+int32_t CFWL_GridImp::GetIndex(FWL_HGRIDCOLROW hColRow) {
+ if (IsColumn(hColRow)) {
+ return m_Columns.Find(hColRow);
+ }
+ return m_Rows.Find(hColRow);
+}
+FX_FLOAT CFWL_GridImp::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
+ _FWL_RETURN_VALUE_IF_FAIL(hColRow, -1);
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)hColRow;
+ eUnit = pColRow->m_Size.eUnit;
+ return pColRow->m_Size.fLength;
+}
+FWL_ERR CFWL_GridImp::SetSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit) {
+ _FWL_RETURN_VALUE_IF_FAIL(hColRow, FWL_ERR_Indefinite);
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)hColRow;
+ pColRow->m_Size.eUnit = eUnit;
+ pColRow->m_Size.fLength = fSize;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_GridImp::GetMinSize(FWL_HGRIDCOLROW hColRow,
+ FWL_GRIDUNIT& eUnit) {
+ _FWL_RETURN_VALUE_IF_FAIL(hColRow, -1);
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)hColRow;
+ eUnit = pColRow->m_MinSize.eUnit;
+ return pColRow->m_MinSize.fLength;
+}
+FWL_ERR CFWL_GridImp::SetMinSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit) {
+ _FWL_RETURN_VALUE_IF_FAIL(hColRow, FWL_ERR_Indefinite);
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)hColRow;
+ pColRow->m_MinSize.eUnit = eUnit;
+ pColRow->m_MinSize.fLength = fSize;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_GridImp::GetMaxSize(FWL_HGRIDCOLROW hColRow,
+ FWL_GRIDUNIT& eUnit) {
+ _FWL_RETURN_VALUE_IF_FAIL(hColRow, -1);
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)hColRow;
+ eUnit = pColRow->m_MaxSize.eUnit;
+ return pColRow->m_MaxSize.fLength;
+}
+FWL_ERR CFWL_GridImp::SetMaxSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit) {
+ _FWL_RETURN_VALUE_IF_FAIL(hColRow, FWL_ERR_Indefinite);
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)hColRow;
+ pColRow->m_MaxSize.eUnit = eUnit;
+ pColRow->m_MaxSize.fLength = fSize;
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_GridImp::DeleteColRow(FWL_HGRIDCOLROW hColRow) {
+ int32_t nIndex = m_Columns.Find(hColRow);
+ if (nIndex >= 0) {
+ m_Columns.RemoveAt(nIndex);
+ delete (CFWL_GridColRow*)hColRow;
+ return TRUE;
+ }
+ nIndex = m_Rows.Find(hColRow);
+ if (nIndex >= 0) {
+ delete (CFWL_GridColRow*)hColRow;
+ m_Rows.RemoveAt(nIndex);
+ return TRUE;
+ }
+ return FALSE;
+}
+FX_BOOL CFWL_GridImp::IsColumn(FWL_HGRIDCOLROW hColRow) {
+ return m_Columns.Find(hColRow) != -1;
+}
+int32_t CFWL_GridImp::GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ return bColumn ? pInfo->m_iColumn : pInfo->m_iRow;
+ }
+ return -1;
+}
+FWL_ERR CFWL_GridImp::SetWidgetPos(IFWL_Widget* pWidget,
+ int32_t iPos,
+ FX_BOOL bColumn) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ bColumn ? pInfo->m_iColumn = iPos : pInfo->m_iRow = iPos;
+ }
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_GridImp::GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ return bColumn ? pInfo->m_iColumnSpan : pInfo->m_iRowSpan;
+ }
+ return 0;
+}
+FWL_ERR CFWL_GridImp::SetWidgetSpan(IFWL_Widget* pWidget,
+ int32_t iSpan,
+ FX_BOOL bColumn) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ bColumn ? pInfo->m_iColumnSpan = iSpan : pInfo->m_iRowSpan = iSpan;
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_GridImp::GetWidgetSize(IFWL_Widget* pWidget,
+ FWL_GRIDSIZE eSize,
+ FWL_GRIDUNIT& eUnit) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ eUnit = pInfo->m_Size[eSize].eUnit;
+ return pInfo->m_Size[eSize].fLength;
+ }
+ return 0;
+}
+FWL_ERR CFWL_GridImp::SetWidgetSize(IFWL_Widget* pWidget,
+ FWL_GRIDSIZE eSize,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUit) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ pInfo->m_Size[eSize].fLength = fSize;
+ pInfo->m_Size[eSize].eUnit = eUit;
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_GridImp::GetWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin,
+ FX_FLOAT& fMargin) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ fMargin = pInfo->m_Margin[eMargin];
+ return (pInfo->m_dwMarginFlag & (1 << eMargin)) != 0;
+ }
+ return FALSE;
+}
+FWL_ERR CFWL_GridImp::SetWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin,
+ FX_FLOAT fMargin) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ pInfo->m_Margin[eMargin] = fMargin;
+ pInfo->m_dwMarginFlag |= (1 << eMargin);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_GridImp::RemoveWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin) {
+ CFWL_GridWidgetInfo* pInfo = (CFWL_GridWidgetInfo*)GetWidgetInfo(pWidget);
+ if (pInfo) {
+ pInfo->m_dwMarginFlag &= ~(1 << eMargin);
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_GridImp::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit) {
+ eUnit = m_Size[eSize].eUnit;
+ return m_Size[eSize].fLength;
+}
+FWL_ERR CFWL_GridImp::SetGridSize(FWL_GRIDSIZE eSize,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUit) {
+ m_Size[eSize].fLength = fSize;
+ m_Size[eSize].eUnit = eUit;
+ return FWL_ERR_Succeeded;
+}
+CFWL_GridWidgetInfo* CFWL_GridImp::GetWidgetInfo(IFWL_Widget* pWidget) {
+ return (CFWL_GridWidgetInfo*)m_mapWidgetInfo.GetValueAt(pWidget);
+}
+void CFWL_GridImp::ProcFixedColRow(CFWL_GridColRow* pColRow,
+ int32_t nIndex,
+ FX_FLOAT fColRowSize,
+ FX_BOOL bColumn) {
+ pColRow->m_fActualSize = fColRowSize;
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (bColumn) {
+ if (pInfo->m_iColumn == nIndex && pInfo->m_iColumnSpan == 1) {
+ CalcWidgetWidth(pWidget, pInfo, pColRow->m_fActualSize);
+ }
} else {
- FX_FLOAT fWidth = 0;
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- if (bLeftMargin && bRightMargin) {
- fWidth = fColunmWidth - fLeftMargin - fRightMargin;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- fWidth = rtAuto.Width();
- }
- SetWidgetActualWidth(pInfo, fWidth);
+ if (pInfo->m_iRow == nIndex && pInfo->m_iRowSpan == 1) {
+ CalcWidgetHeigt(pWidget, pInfo, pColRow->m_fActualSize);
+ }
+ }
+ }
+}
+void CFWL_GridImp::ProcAutoColRow(CFWL_GridColRow* pColRow,
+ int32_t nIndex,
+ FX_BOOL bColumn) {
+ _FWL_RETURN_IF_FAIL(pColRow);
+ FX_FLOAT fMaxSize = 0, fWidgetSize = 0;
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (!pWidget || !pInfo) {
+ continue;
}
-}
-void CFWL_GridImp::CalcWidgetHeigt(IFWL_Widget *pWidget, CFWL_GridWidgetInfo* pInfo, FX_FLOAT fRowHeigt)
-{
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
+ if (bColumn) {
+ if (pInfo->m_iColumn != nIndex || pInfo->m_iColumnSpan != 1) {
+ continue;
+ }
+ fWidgetSize = CalcAutoColumnWidgetWidth(pWidget, pInfo);
+ if (fMaxSize < fWidgetSize) {
+ fMaxSize = fWidgetSize;
+ }
} else {
- FX_FLOAT fHeight = 0;
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (bTopMargin && bBottomMargin) {
- fHeight = fRowHeigt - fTopMargin - fBottomMargin;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- fHeight = rtAuto.Height();
- }
- SetWidgetActualHeight(pInfo, fHeight);
- }
-}
-FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetWidth(IFWL_Widget *pWidget, CFWL_GridWidgetInfo* pInfo)
-{
+ if (pInfo->m_iRow != nIndex || pInfo->m_iRowSpan != 1) {
+ continue;
+ }
+ fWidgetSize = CalcAutoColumnWidgetHeight(pWidget, pInfo);
+ if (fMaxSize < fWidgetSize) {
+ fMaxSize = fWidgetSize;
+ }
+ }
+ }
+ SetColRowActualSize(pColRow, fMaxSize);
+}
+void CFWL_GridImp::ProcScaledColRow(CFWL_GridColRow* pColRow,
+ int32_t nIndex,
+ FX_FLOAT fColRowSize,
+ FX_BOOL bColumn) {
+ if (fColRowSize > 0) {
+ ProcFixedColRow(pColRow, nIndex, fColRowSize, bColumn);
+ }
+}
+void CFWL_GridImp::CalcWidgetWidth(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo,
+ FX_FLOAT fColunmWidth) {
+ if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
+ SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
+ } else {
+ FX_FLOAT fWidth = 0;
FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
+ FX_BOOL bLeftMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
+ FX_BOOL bRightMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
+ if (bLeftMargin && bRightMargin) {
+ fWidth = fColunmWidth - fLeftMargin - fRightMargin;
} else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- FX_FLOAT fWidth = rtAuto.width;
- SetWidgetActualWidth(pInfo, fWidth);
- }
- FX_FLOAT fTotal = pInfo->m_fActualWidth;
- if (bLeftMargin) {
- fTotal += fLeftMargin;
- }
- if (bRightMargin) {
- fTotal += fRightMargin;
- }
- return fTotal;
-}
-FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetHeight(IFWL_Widget *pWidget, CFWL_GridWidgetInfo* pInfo)
-{
+ CFX_RectF rtAuto;
+ pWidget->GetWidgetRect(rtAuto, TRUE);
+ fWidth = rtAuto.Width();
+ }
+ SetWidgetActualWidth(pInfo, fWidth);
+ }
+}
+void CFWL_GridImp::CalcWidgetHeigt(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo,
+ FX_FLOAT fRowHeigt) {
+ if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
+ SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
+ } else {
+ FX_FLOAT fHeight = 0;
FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
+ FX_BOOL bTopMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
+ FX_BOOL bBottomMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
+ if (bTopMargin && bBottomMargin) {
+ fHeight = fRowHeigt - fTopMargin - fBottomMargin;
} else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- FX_FLOAT fHeight = rtAuto.height;
- SetWidgetActualHeight(pInfo, fHeight);
- }
- FX_FLOAT fTotal = pInfo->m_fActualHeight;
- if (bTopMargin) {
- fTotal += fTopMargin;
- }
- if (bBottomMargin) {
- fTotal += fBottomMargin;
- }
- return fTotal;
-}
-FX_FLOAT CFWL_GridImp::ProcessColumns(FX_FLOAT fWidth)
-{
- if (fWidth <= 0) {
- return ProcessUnCertainColumns();
- }
- int32_t iColumns = m_Columns.GetSize();
- if (iColumns < 1) {
- return fWidth;
- }
- FX_FLOAT fFixedWidth = 0;
- FX_FLOAT fAutoWidth = 0;
- CFX_PtrArray autoColumns;
- CFX_PtrArray scaledColumns;
- FX_FLOAT fScaledColumnNum = 0;
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Columns[i];
- if (!pColRow) {
- continue;
- }
- switch(pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedWidth += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, TRUE);
- autoColumns.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- fScaledColumnNum += pColRow->m_Size.fLength;
- scaledColumns.Add(pColRow);
- SetColRowActualSize(pColRow, 0);
- }
- }
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iColumnSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoColumns;
- FX_FLOAT fSpanSize = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
- CFWL_GridColRow *pColumn = (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn + i);
- if (!pColumn) {
- break;
- }
- fSpanSize += pColumn->m_fActualSize;
- if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoColumns.Add(pColumn);
- } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- }
- }
- if (iAutoColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fWidgetWidth > fSpanSize) {
- if (iScaledColRows > 0) {
- } else {
- SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
- }
- }
- }
- int32_t iAutoCols = autoColumns.GetSize();
- for (int32_t k = 0; k < iAutoCols; k++) {
- fAutoWidth += ((CFWL_GridColRow*)autoColumns[k])->m_fActualSize;
- }
- FX_FLOAT fScaledWidth = fWidth - fFixedWidth - fAutoWidth;
- if (fScaledWidth > 0 && fScaledColumnNum > 0) {
- SetScaledColRowsSize(scaledColumns, fScaledWidth, fScaledColumnNum);
- }
+ CFX_RectF rtAuto;
+ pWidget->GetWidgetRect(rtAuto, TRUE);
+ fHeight = rtAuto.Height();
+ }
+ SetWidgetActualHeight(pInfo, fHeight);
+ }
+}
+FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo) {
+ FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
+ FX_BOOL bLeftMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
+ FX_BOOL bRightMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
+ if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
+ SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
+ } else {
+ CFX_RectF rtAuto;
+ pWidget->GetWidgetRect(rtAuto, TRUE);
+ FX_FLOAT fWidth = rtAuto.width;
+ SetWidgetActualWidth(pInfo, fWidth);
+ }
+ FX_FLOAT fTotal = pInfo->m_fActualWidth;
+ if (bLeftMargin) {
+ fTotal += fLeftMargin;
+ }
+ if (bRightMargin) {
+ fTotal += fRightMargin;
+ }
+ return fTotal;
+}
+FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo) {
+ FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
+ FX_BOOL bTopMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
+ FX_BOOL bBottomMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
+ if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
+ SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
+ } else {
+ CFX_RectF rtAuto;
+ pWidget->GetWidgetRect(rtAuto, TRUE);
+ FX_FLOAT fHeight = rtAuto.height;
+ SetWidgetActualHeight(pInfo, fHeight);
+ }
+ FX_FLOAT fTotal = pInfo->m_fActualHeight;
+ if (bTopMargin) {
+ fTotal += fTopMargin;
+ }
+ if (bBottomMargin) {
+ fTotal += fBottomMargin;
+ }
+ return fTotal;
+}
+FX_FLOAT CFWL_GridImp::ProcessColumns(FX_FLOAT fWidth) {
+ if (fWidth <= 0) {
+ return ProcessUnCertainColumns();
+ }
+ int32_t iColumns = m_Columns.GetSize();
+ if (iColumns < 1) {
return fWidth;
-}
-FX_FLOAT CFWL_GridImp::ProcessRows(FX_FLOAT fHeight)
-{
- if (fHeight <= 0) {
- return ProcessUnCertainRows();
- }
- int32_t iRows = m_Rows.GetSize();
- if (iRows < 1) {
- return fHeight;
- }
- FX_FLOAT fFixedHeight = 0;
- FX_FLOAT fAutoHeigt = 0;
- CFX_PtrArray autoRows;
- CFX_PtrArray scaledRows;
- FX_FLOAT fScaledRowNum = 0;
- for (int32_t i = 0; i < iRows; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Rows[i];
- if (!pColRow) {
- continue;
- }
- switch(pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedHeight += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, FALSE);
- autoRows.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- fScaledRowNum += pColRow->m_Size.fLength;
- scaledRows.Add(pColRow);
- SetColRowActualSize(pColRow, 0);
- break;
- }
- }
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iRowSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoRows;
- FX_FLOAT fSpanSize = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
- CFWL_GridColRow *pRow = (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow + i);
- if (!pRow) {
- break;
- }
- fSpanSize += pRow->m_fActualSize;
- if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoRows.Add(pRow);
- } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- }
- }
- if (iAutoColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fWidgetHeight > fSpanSize) {
- if (iScaledColRows > 0) {
- } else {
- SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
- }
- }
- }
- int32_t iAutoRows = autoRows.GetSize();
- for (int32_t k = 0; k < iAutoRows; k++) {
- fAutoHeigt += ((CFWL_GridColRow*)autoRows[k])->m_fActualSize;
- }
- FX_FLOAT fScaledHeight = fHeight - fFixedHeight - fAutoHeigt;
- if (fScaledHeight > 0 && fScaledRowNum > 0) {
- SetScaledColRowsSize(scaledRows, fScaledHeight, fScaledRowNum);
+ }
+ FX_FLOAT fFixedWidth = 0;
+ FX_FLOAT fAutoWidth = 0;
+ CFX_PtrArray autoColumns;
+ CFX_PtrArray scaledColumns;
+ FX_FLOAT fScaledColumnNum = 0;
+ for (int32_t i = 0; i < iColumns; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Columns[i];
+ if (!pColRow) {
+ continue;
+ }
+ switch (pColRow->m_Size.eUnit) {
+ case FWL_GRIDUNIT_Fixed: {
+ SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
+ fFixedWidth += pColRow->m_fActualSize;
+ break;
+ }
+ case FWL_GRIDUNIT_Auto: {
+ ProcAutoColRow(pColRow, i, TRUE);
+ autoColumns.Add(pColRow);
+ break;
+ }
+ case FWL_GRIDUNIT_Scaled:
+ default: {
+ fScaledColumnNum += pColRow->m_Size.fLength;
+ scaledColumns.Add(pColRow);
+ SetColRowActualSize(pColRow, 0);
+ }
+ }
+ }
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (!pInfo || pInfo->m_iColumnSpan < 2) {
+ continue;
+ }
+ CFX_PtrArray spanAutoColumns;
+ FX_FLOAT fSpanSize = 0;
+ int32_t iAutoColRows = 0;
+ int32_t iScaledColRows = 0;
+ for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
+ CFWL_GridColRow* pColumn =
+ (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn + i);
+ if (!pColumn) {
+ break;
+ }
+ fSpanSize += pColumn->m_fActualSize;
+ if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
+ iAutoColRows++;
+ spanAutoColumns.Add(pColumn);
+ } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
+ iScaledColRows++;
+ }
}
+ if (iAutoColRows < 1) {
+ continue;
+ }
+ FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
+ if (fWidgetWidth > fSpanSize) {
+ if (iScaledColRows > 0) {
+ } else {
+ SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
+ }
+ }
+ }
+ int32_t iAutoCols = autoColumns.GetSize();
+ for (int32_t k = 0; k < iAutoCols; k++) {
+ fAutoWidth += ((CFWL_GridColRow*)autoColumns[k])->m_fActualSize;
+ }
+ FX_FLOAT fScaledWidth = fWidth - fFixedWidth - fAutoWidth;
+ if (fScaledWidth > 0 && fScaledColumnNum > 0) {
+ SetScaledColRowsSize(scaledColumns, fScaledWidth, fScaledColumnNum);
+ }
+ return fWidth;
+}
+FX_FLOAT CFWL_GridImp::ProcessRows(FX_FLOAT fHeight) {
+ if (fHeight <= 0) {
+ return ProcessUnCertainRows();
+ }
+ int32_t iRows = m_Rows.GetSize();
+ if (iRows < 1) {
return fHeight;
-}
-FX_FLOAT CFWL_GridImp::ProcessUnCertainColumns()
-{
- int32_t iColumns = m_Columns.GetSize();
- if (iColumns < 1) {
- CFWL_GridColRow *pColRow = new CFWL_GridColRow;
- pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
- ProcAutoColRow(pColRow, 0, TRUE);
- FX_FLOAT fWidth = pColRow->m_fActualSize;
- delete pColRow;
- return fWidth;
- }
- FX_FLOAT fFixedWidth = 0;
- CFX_PtrArray autoColumns;
- CFX_PtrArray scaledColumns;
- FX_FLOAT fScaledColumnNum = 0;
- FX_FLOAT fScaledMaxPerWidth = 0;
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Columns[i];
- if (!pColRow) {
- continue;
- }
- switch(pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedWidth += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, TRUE);
- autoColumns.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- ProcAutoColRow(pColRow, i, TRUE);
- fScaledColumnNum += pColRow->m_Size.fLength;
- scaledColumns.Add(pColRow);
- if (pColRow->m_Size.fLength <= 0) {
- break;
- }
- FX_FLOAT fPerWidth = pColRow->m_fActualSize / pColRow->m_Size.fLength;
- if (fPerWidth > fScaledMaxPerWidth) {
- fScaledMaxPerWidth = fPerWidth;
- }
- }
- }
- }
- iColumns = scaledColumns.GetSize();
- for (int32_t j = 0; j < iColumns; j++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)scaledColumns[j];
- if (!pColRow) {
- continue;
- }
- SetColRowActualSize(pColRow, fScaledMaxPerWidth * pColRow->m_Size.fLength);
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iColumnSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoColumns;
- CFX_PtrArray spanScaledColumns;
- FX_FLOAT fSpanSize = 0;
- FX_FLOAT fScaledSum = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
- CFWL_GridColRow *pColumn = (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn + i);
- if (!pColumn) {
- break;
- }
- fSpanSize += pColumn->m_fActualSize;
- if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoColumns.Add(pColumn);
- } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- fScaledSum += pColumn->m_Size.fLength;
- spanScaledColumns.Add(pColumn);
- }
- }
- if (iAutoColRows < 1 && iScaledColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fWidgetWidth > fSpanSize) {
- if (iScaledColRows > 0 ) {
- if (fScaledSum <= 0) {
- continue;
- }
- SetSpanScaledColRowSize(spanScaledColumns, fWidgetWidth - fSpanSize, fScaledSum);
- } else {
- SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
- }
- }
- }
- FX_FLOAT fAutoWidth = 0;
- int32_t iAutoCols = autoColumns.GetSize();
- for (int32_t m = 0; m < iAutoCols; m++) {
- fAutoWidth += ((CFWL_GridColRow*)autoColumns[m])->m_fActualSize;
+ }
+ FX_FLOAT fFixedHeight = 0;
+ FX_FLOAT fAutoHeigt = 0;
+ CFX_PtrArray autoRows;
+ CFX_PtrArray scaledRows;
+ FX_FLOAT fScaledRowNum = 0;
+ for (int32_t i = 0; i < iRows; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Rows[i];
+ if (!pColRow) {
+ continue;
+ }
+ switch (pColRow->m_Size.eUnit) {
+ case FWL_GRIDUNIT_Fixed: {
+ SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
+ fFixedHeight += pColRow->m_fActualSize;
+ break;
+ }
+ case FWL_GRIDUNIT_Auto: {
+ ProcAutoColRow(pColRow, i, FALSE);
+ autoRows.Add(pColRow);
+ break;
+ }
+ case FWL_GRIDUNIT_Scaled:
+ default: {
+ fScaledRowNum += pColRow->m_Size.fLength;
+ scaledRows.Add(pColRow);
+ SetColRowActualSize(pColRow, 0);
+ break;
+ }
+ }
+ }
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (!pInfo || pInfo->m_iRowSpan < 2) {
+ continue;
+ }
+ CFX_PtrArray spanAutoRows;
+ FX_FLOAT fSpanSize = 0;
+ int32_t iAutoColRows = 0;
+ int32_t iScaledColRows = 0;
+ for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
+ CFWL_GridColRow* pRow =
+ (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow + i);
+ if (!pRow) {
+ break;
+ }
+ fSpanSize += pRow->m_fActualSize;
+ if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
+ iAutoColRows++;
+ spanAutoRows.Add(pRow);
+ } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
+ iScaledColRows++;
+ }
}
- FX_FLOAT fScaledWidth = 0;
- iColumns = scaledColumns.GetSize();
- for (int32_t n = 0; n < iColumns; n++) {
- fScaledWidth += ((CFWL_GridColRow*)scaledColumns[n])->m_fActualSize;
- }
- return fFixedWidth + fAutoWidth + fScaledWidth;
-}
-FX_FLOAT CFWL_GridImp::ProcessUnCertainRows()
-{
- int32_t iRows = m_Rows.GetSize();
- if (iRows < 1) {
- CFWL_GridColRow *pColRow = new CFWL_GridColRow;
- pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
- ProcAutoColRow(pColRow, 0, FALSE);
- FX_FLOAT fWidth = pColRow->m_fActualSize;
- delete pColRow;
- return fWidth;
- }
- FX_FLOAT fFixedHeight = 0;
- CFX_PtrArray autoRows;
- CFX_PtrArray scaledRows;
- FX_FLOAT fScaledRowNum = 0;
- FX_FLOAT fScaledMaxPerHeight = 0;
- for (int32_t i = 0; i < iRows; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Rows[i];
- if (!pColRow) {
- continue;
- }
- switch(pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedHeight += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, FALSE);
- autoRows.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- ProcAutoColRow(pColRow, i, FALSE);
- fScaledRowNum += pColRow->m_Size.fLength;
- scaledRows.Add(pColRow);
- if (pColRow->m_Size.fLength > 0) {
- FX_FLOAT fPerHeight = pColRow->m_fActualSize / pColRow->m_Size.fLength;
- if (fPerHeight > fScaledMaxPerHeight) {
- fScaledMaxPerHeight = fPerHeight;
- }
- }
- break;
- }
- }
- }
- iRows = scaledRows.GetSize();
- for (int32_t j = 0; j < iRows; j++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)scaledRows[j];
- if (!pColRow) {
- continue;
- }
- SetColRowActualSize(pColRow, fScaledMaxPerHeight * pColRow->m_Size.fLength);
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (pInfo->m_iRowSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoRows;
- CFX_PtrArray spanScaledRows;
- FX_FLOAT fSpanSize = 0;
- FX_FLOAT fScaledSum = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
- CFWL_GridColRow *pRow = (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow + i);
- if (!pRow) {
- break;
- }
- fSpanSize += pRow->m_fActualSize;
- if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoRows.Add(pRow);
- } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- fScaledSum += pRow->m_Size.fLength;
- spanScaledRows.Add(pRow);
- }
- }
- if (iAutoColRows < 1 && iScaledColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fWidgetHeight > fSpanSize) {
- if (iScaledColRows > 0) {
- if (fScaledSum <= 0) {
- continue;
- }
- SetSpanScaledColRowSize(spanScaledRows, fWidgetHeight - fSpanSize, fScaledSum);
- } else {
- SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
- }
- }
- }
- FX_FLOAT fAutoHeigt = 0;
- int32_t iAutoRows = autoRows.GetSize();
- for (int32_t m = 0; m < iAutoRows; m++) {
- fAutoHeigt += ((CFWL_GridColRow*)autoRows[m])->m_fActualSize;
- }
- FX_FLOAT fScaledHeight = 0;
- iRows = scaledRows.GetSize();
- for (int32_t n = 0; n < iRows; n++) {
- fScaledHeight += ((CFWL_GridColRow*)scaledRows[n])->m_fActualSize;
- }
- return fFixedHeight + fAutoHeigt + fScaledHeight;
-}
-FX_BOOL CFWL_GridImp::SetColRowActualSize(CFWL_GridColRow* pColRow, FX_FLOAT fSize, FX_BOOL bSetBeyond )
-{
- if (pColRow->m_MinSize.eUnit == FWL_GRIDUNIT_Fixed && fSize < pColRow->m_MinSize.fLength) {
- pColRow->m_fActualSize = pColRow->m_MinSize.fLength;
- return FALSE;
- }
- if (pColRow->m_MaxSize.eUnit == FWL_GRIDUNIT_Fixed && fSize > pColRow->m_MaxSize.fLength) {
- pColRow->m_fActualSize = pColRow->m_MaxSize.fLength;
- return FALSE;
- }
- if (bSetBeyond) {
- return TRUE;
- }
- pColRow->m_fActualSize = fSize;
- return TRUE;
-}
-FX_FLOAT CFWL_GridImp::SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fWidth)
-{
- if (pInfo->m_Size[FWL_GRIDSIZE_MinWidth].eUnit == FWL_GRIDUNIT_Fixed &&
- fWidth < pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength) {
- fWidth = pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength;
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].eUnit == FWL_GRIDUNIT_Fixed &&
- fWidth > pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength) {
- fWidth = pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength;
- }
- pInfo->m_fActualWidth = fWidth;
+ if (iAutoColRows < 1) {
+ continue;
+ }
+ FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
+ if (fWidgetHeight > fSpanSize) {
+ if (iScaledColRows > 0) {
+ } else {
+ SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
+ }
+ }
+ }
+ int32_t iAutoRows = autoRows.GetSize();
+ for (int32_t k = 0; k < iAutoRows; k++) {
+ fAutoHeigt += ((CFWL_GridColRow*)autoRows[k])->m_fActualSize;
+ }
+ FX_FLOAT fScaledHeight = fHeight - fFixedHeight - fAutoHeigt;
+ if (fScaledHeight > 0 && fScaledRowNum > 0) {
+ SetScaledColRowsSize(scaledRows, fScaledHeight, fScaledRowNum);
+ }
+ return fHeight;
+}
+FX_FLOAT CFWL_GridImp::ProcessUnCertainColumns() {
+ int32_t iColumns = m_Columns.GetSize();
+ if (iColumns < 1) {
+ CFWL_GridColRow* pColRow = new CFWL_GridColRow;
+ pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
+ ProcAutoColRow(pColRow, 0, TRUE);
+ FX_FLOAT fWidth = pColRow->m_fActualSize;
+ delete pColRow;
return fWidth;
-}
-FX_FLOAT CFWL_GridImp::SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fHeight)
-{
- if (pInfo->m_Size[FWL_GRIDSIZE_MinHeight].eUnit == FWL_GRIDUNIT_Fixed &&
- fHeight < pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength) {
- fHeight = pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength;
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].eUnit == FWL_GRIDUNIT_Fixed &&
- fHeight > pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength) {
- fHeight = pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength;
- }
- pInfo->m_fActualHeight = fHeight;
- return fHeight;
-}
-void CFWL_GridImp::SetAllWidgetsRect()
-{
- FX_FLOAT fStartLeft = 0;
- int32_t iColumns = m_Columns.GetSize();
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Columns[i];
- if (!pColRow) {
- continue;
- }
- pColRow->m_fActualPos = fStartLeft;
- fStartLeft += pColRow->m_fActualSize;
- }
- FX_FLOAT fStartTop = 0;
- int32_t iRows = m_Rows.GetSize();
- for (int32_t j = 0; j < iRows; j++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)m_Rows[j];
- if (!pColRow) {
- continue;
- }
- pColRow->m_fActualPos = fStartTop;
- fStartTop += pColRow->m_fActualSize;
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget *pWidget = NULL;
- CFWL_GridWidgetInfo *pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pWidget || !pInfo) {
- continue;
- }
- FX_FLOAT fColumnStart = 0;
- CFWL_GridColRow *pColumn = (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn);
- if (pColumn) {
- fColumnStart = pColumn->m_fActualPos;
- }
- FX_FLOAT fRowStart = 0;
- CFWL_GridColRow *pRow = (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow);
- if (pRow) {
- fRowStart = pRow->m_fActualPos;
- }
- FX_FLOAT fColumnWidth = 0;
- if (iColumns > 0) {
- for (int32_t j = 0; j < pInfo->m_iColumnSpan; j++) {
- CFWL_GridColRow *pCol = (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn + j);
- if (!pCol) {
- break;
- }
- fColumnWidth += pCol->m_fActualSize;
- }
- } else {
- fColumnWidth = m_pProperties->m_rtWidget.width;
- }
- FX_FLOAT fRowHeight = 0;
- if (iRows > 0) {
- for (int32_t k = 0; k < pInfo->m_iRowSpan; k++) {
- CFWL_GridColRow *pR = (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow + k);
- if (!pR) {
- break;
- }
- fRowHeight += pR->m_fActualSize;
- }
- } else {
- fRowHeight = m_pProperties->m_rtWidget.height;
+ }
+ FX_FLOAT fFixedWidth = 0;
+ CFX_PtrArray autoColumns;
+ CFX_PtrArray scaledColumns;
+ FX_FLOAT fScaledColumnNum = 0;
+ FX_FLOAT fScaledMaxPerWidth = 0;
+ for (int32_t i = 0; i < iColumns; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Columns[i];
+ if (!pColRow) {
+ continue;
+ }
+ switch (pColRow->m_Size.eUnit) {
+ case FWL_GRIDUNIT_Fixed: {
+ SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
+ fFixedWidth += pColRow->m_fActualSize;
+ break;
+ }
+ case FWL_GRIDUNIT_Auto: {
+ ProcAutoColRow(pColRow, i, TRUE);
+ autoColumns.Add(pColRow);
+ break;
+ }
+ case FWL_GRIDUNIT_Scaled:
+ default: {
+ ProcAutoColRow(pColRow, i, TRUE);
+ fScaledColumnNum += pColRow->m_Size.fLength;
+ scaledColumns.Add(pColRow);
+ if (pColRow->m_Size.fLength <= 0) {
+ break;
}
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- FWL_LAYOUTDATA ltd;
- ltd.fWidth = 0;
- ltd.fHeight = 0;
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- ltd.fWidth = pInfo->m_fActualWidth;
- } else {
- if (bLeftMargin && bRightMargin) {
- SetWidgetActualWidth(pInfo, fColumnWidth - fLeftMargin - fRightMargin);
- ltd.fWidth = pInfo->m_fActualWidth;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- SetWidgetActualWidth(pInfo, rtAuto.width);
- }
+ FX_FLOAT fPerWidth = pColRow->m_fActualSize / pColRow->m_Size.fLength;
+ if (fPerWidth > fScaledMaxPerWidth) {
+ fScaledMaxPerWidth = fPerWidth;
}
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- ltd.fHeight = pInfo->m_fActualHeight;
- } else {
- if (bTopMargin && bBottomMargin) {
- SetWidgetActualHeight(pInfo, fRowHeight - fTopMargin - fBottomMargin);
- ltd.fHeight = pInfo->m_fActualHeight;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- SetWidgetActualHeight(pInfo, rtAuto.height);
- }
+ }
+ }
+ }
+ iColumns = scaledColumns.GetSize();
+ for (int32_t j = 0; j < iColumns; j++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)scaledColumns[j];
+ if (!pColRow) {
+ continue;
+ }
+ SetColRowActualSize(pColRow, fScaledMaxPerWidth * pColRow->m_Size.fLength);
+ }
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (!pInfo || pInfo->m_iColumnSpan < 2) {
+ continue;
+ }
+ CFX_PtrArray spanAutoColumns;
+ CFX_PtrArray spanScaledColumns;
+ FX_FLOAT fSpanSize = 0;
+ FX_FLOAT fScaledSum = 0;
+ int32_t iAutoColRows = 0;
+ int32_t iScaledColRows = 0;
+ for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
+ CFWL_GridColRow* pColumn =
+ (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn + i);
+ if (!pColumn) {
+ break;
+ }
+ fSpanSize += pColumn->m_fActualSize;
+ if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
+ iAutoColRows++;
+ spanAutoColumns.Add(pColumn);
+ } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
+ iScaledColRows++;
+ fScaledSum += pColumn->m_Size.fLength;
+ spanScaledColumns.Add(pColumn);
+ }
+ }
+ if (iAutoColRows < 1 && iScaledColRows < 1) {
+ continue;
+ }
+ FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
+ if (fWidgetWidth > fSpanSize) {
+ if (iScaledColRows > 0) {
+ if (fScaledSum <= 0) {
+ continue;
}
- if (bLeftMargin && bRightMargin && pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- fLeftMargin = fColumnStart + fLeftMargin + (fColumnWidth - fLeftMargin - fRightMargin - pInfo->m_fActualWidth) / 2;
- } else if (bLeftMargin) {
- fLeftMargin = fColumnStart + fLeftMargin;
- } else if (bRightMargin) {
- fLeftMargin = fColumnStart + fColumnWidth - fRightMargin - pInfo->m_fActualWidth;
- } else {
- fLeftMargin = fColumnStart;
- }
- if (bTopMargin && bBottomMargin && pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- fTopMargin = fRowStart + fTopMargin + (fRowHeight - fTopMargin - fBottomMargin - pInfo->m_fActualHeight) / 2;
- } else if (bTopMargin) {
- fTopMargin = fRowStart + fTopMargin;
- } else if (bBottomMargin) {
- fTopMargin = fRowStart + fRowHeight - fBottomMargin - pInfo->m_fActualHeight;
- } else {
- fTopMargin = fRowStart;
- }
- CFX_RectF rtWidget, rtOld;
- rtWidget.Set(fLeftMargin, fTopMargin, pInfo->m_fActualWidth, pInfo->m_fActualHeight);
- pWidget->GetWidgetRect(rtOld);
- if (rtWidget == rtOld) {
- continue;
+ SetSpanScaledColRowSize(spanScaledColumns, fWidgetWidth - fSpanSize,
+ fScaledSum);
+ } else {
+ SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
+ }
+ }
+ }
+ FX_FLOAT fAutoWidth = 0;
+ int32_t iAutoCols = autoColumns.GetSize();
+ for (int32_t m = 0; m < iAutoCols; m++) {
+ fAutoWidth += ((CFWL_GridColRow*)autoColumns[m])->m_fActualSize;
+ }
+ FX_FLOAT fScaledWidth = 0;
+ iColumns = scaledColumns.GetSize();
+ for (int32_t n = 0; n < iColumns; n++) {
+ fScaledWidth += ((CFWL_GridColRow*)scaledColumns[n])->m_fActualSize;
+ }
+ return fFixedWidth + fAutoWidth + fScaledWidth;
+}
+FX_FLOAT CFWL_GridImp::ProcessUnCertainRows() {
+ int32_t iRows = m_Rows.GetSize();
+ if (iRows < 1) {
+ CFWL_GridColRow* pColRow = new CFWL_GridColRow;
+ pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
+ ProcAutoColRow(pColRow, 0, FALSE);
+ FX_FLOAT fWidth = pColRow->m_fActualSize;
+ delete pColRow;
+ return fWidth;
+ }
+ FX_FLOAT fFixedHeight = 0;
+ CFX_PtrArray autoRows;
+ CFX_PtrArray scaledRows;
+ FX_FLOAT fScaledRowNum = 0;
+ FX_FLOAT fScaledMaxPerHeight = 0;
+ for (int32_t i = 0; i < iRows; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Rows[i];
+ if (!pColRow) {
+ continue;
+ }
+ switch (pColRow->m_Size.eUnit) {
+ case FWL_GRIDUNIT_Fixed: {
+ SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
+ fFixedHeight += pColRow->m_fActualSize;
+ break;
+ }
+ case FWL_GRIDUNIT_Auto: {
+ ProcAutoColRow(pColRow, i, FALSE);
+ autoRows.Add(pColRow);
+ break;
+ }
+ case FWL_GRIDUNIT_Scaled:
+ default: {
+ ProcAutoColRow(pColRow, i, FALSE);
+ fScaledRowNum += pColRow->m_Size.fLength;
+ scaledRows.Add(pColRow);
+ if (pColRow->m_Size.fLength > 0) {
+ FX_FLOAT fPerHeight =
+ pColRow->m_fActualSize / pColRow->m_Size.fLength;
+ if (fPerHeight > fScaledMaxPerHeight) {
+ fScaledMaxPerHeight = fPerHeight;
+ }
}
- pWidget->SetWidgetRect(rtWidget);
- if (rtWidget.width == rtOld.width && rtWidget.height == rtOld.height) {
- continue;
+ break;
+ }
+ }
+ }
+ iRows = scaledRows.GetSize();
+ for (int32_t j = 0; j < iRows; j++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)scaledRows[j];
+ if (!pColRow) {
+ continue;
+ }
+ SetColRowActualSize(pColRow, fScaledMaxPerHeight * pColRow->m_Size.fLength);
+ }
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (pInfo->m_iRowSpan < 2) {
+ continue;
+ }
+ CFX_PtrArray spanAutoRows;
+ CFX_PtrArray spanScaledRows;
+ FX_FLOAT fSpanSize = 0;
+ FX_FLOAT fScaledSum = 0;
+ int32_t iAutoColRows = 0;
+ int32_t iScaledColRows = 0;
+ for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
+ CFWL_GridColRow* pRow =
+ (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow + i);
+ if (!pRow) {
+ break;
+ }
+ fSpanSize += pRow->m_fActualSize;
+ if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
+ iAutoColRows++;
+ spanAutoRows.Add(pRow);
+ } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
+ iScaledColRows++;
+ fScaledSum += pRow->m_Size.fLength;
+ spanScaledRows.Add(pRow);
+ }
+ }
+ if (iAutoColRows < 1 && iScaledColRows < 1) {
+ continue;
+ }
+ FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
+ if (fWidgetHeight > fSpanSize) {
+ if (iScaledColRows > 0) {
+ if (fScaledSum <= 0) {
+ continue;
}
- pWidget->Update();
- }
-}
-FX_BOOL CFWL_GridImp::IsGrid(IFWL_Widget* pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_Grid;
-}
-void CFWL_GridImp::SetSpanAutoColRowSize(const CFX_PtrArray &spanAutos, FX_FLOAT fTotalSize)
-{
- int32_t iAutoColRows = spanAutos.GetSize();
- if (iAutoColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fAutoPer = fTotalSize / iAutoColRows;
- for (int32_t j = 0; j < iAutoColRows; j++) {
- CFWL_GridColRow *pColumn = (CFWL_GridColRow*)spanAutos[j];
- FX_FLOAT fOrgSize = pColumn->m_fActualSize;
- if (SetColRowActualSize(pColumn, pColumn->m_fActualSize + fAutoPer, TRUE)) {
- autoNoMinMaxs.Add(pColumn);
- } else {
- fTotalSize -= pColumn->m_fActualSize - fOrgSize;
- int32_t iNoMinMax = iAutoColRows - (j + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fAutoPer = fTotalSize / iNoMinMax;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iAutoColRows) {
- fAutoPer = fTotalSize / iNormals;
- for (int32_t k = 0; k < iNormals; k++) {
- CFWL_GridColRow *pColumn = (CFWL_GridColRow*)autoNoMinMaxs[k];
- pColumn->m_fActualSize += fAutoPer;
- }
- } else {
- SetSpanAutoColRowSize(autoNoMinMaxs, fTotalSize);
+ SetSpanScaledColRowSize(spanScaledRows, fWidgetHeight - fSpanSize,
+ fScaledSum);
+ } else {
+ SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
+ }
+ }
+ }
+ FX_FLOAT fAutoHeigt = 0;
+ int32_t iAutoRows = autoRows.GetSize();
+ for (int32_t m = 0; m < iAutoRows; m++) {
+ fAutoHeigt += ((CFWL_GridColRow*)autoRows[m])->m_fActualSize;
+ }
+ FX_FLOAT fScaledHeight = 0;
+ iRows = scaledRows.GetSize();
+ for (int32_t n = 0; n < iRows; n++) {
+ fScaledHeight += ((CFWL_GridColRow*)scaledRows[n])->m_fActualSize;
+ }
+ return fFixedHeight + fAutoHeigt + fScaledHeight;
+}
+FX_BOOL CFWL_GridImp::SetColRowActualSize(CFWL_GridColRow* pColRow,
+ FX_FLOAT fSize,
+ FX_BOOL bSetBeyond) {
+ if (pColRow->m_MinSize.eUnit == FWL_GRIDUNIT_Fixed &&
+ fSize < pColRow->m_MinSize.fLength) {
+ pColRow->m_fActualSize = pColRow->m_MinSize.fLength;
+ return FALSE;
+ }
+ if (pColRow->m_MaxSize.eUnit == FWL_GRIDUNIT_Fixed &&
+ fSize > pColRow->m_MaxSize.fLength) {
+ pColRow->m_fActualSize = pColRow->m_MaxSize.fLength;
+ return FALSE;
+ }
+ if (bSetBeyond) {
+ return TRUE;
+ }
+ pColRow->m_fActualSize = fSize;
+ return TRUE;
+}
+FX_FLOAT CFWL_GridImp::SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo,
+ FX_FLOAT fWidth) {
+ if (pInfo->m_Size[FWL_GRIDSIZE_MinWidth].eUnit == FWL_GRIDUNIT_Fixed &&
+ fWidth < pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength) {
+ fWidth = pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength;
+ }
+ if (pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].eUnit == FWL_GRIDUNIT_Fixed &&
+ fWidth > pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength) {
+ fWidth = pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength;
+ }
+ pInfo->m_fActualWidth = fWidth;
+ return fWidth;
+}
+FX_FLOAT CFWL_GridImp::SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo,
+ FX_FLOAT fHeight) {
+ if (pInfo->m_Size[FWL_GRIDSIZE_MinHeight].eUnit == FWL_GRIDUNIT_Fixed &&
+ fHeight < pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength) {
+ fHeight = pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength;
+ }
+ if (pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].eUnit == FWL_GRIDUNIT_Fixed &&
+ fHeight > pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength) {
+ fHeight = pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength;
+ }
+ pInfo->m_fActualHeight = fHeight;
+ return fHeight;
+}
+void CFWL_GridImp::SetAllWidgetsRect() {
+ FX_FLOAT fStartLeft = 0;
+ int32_t iColumns = m_Columns.GetSize();
+ for (int32_t i = 0; i < iColumns; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Columns[i];
+ if (!pColRow) {
+ continue;
+ }
+ pColRow->m_fActualPos = fStartLeft;
+ fStartLeft += pColRow->m_fActualSize;
+ }
+ FX_FLOAT fStartTop = 0;
+ int32_t iRows = m_Rows.GetSize();
+ for (int32_t j = 0; j < iRows; j++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)m_Rows[j];
+ if (!pColRow) {
+ continue;
+ }
+ pColRow->m_fActualPos = fStartTop;
+ fStartTop += pColRow->m_fActualSize;
+ }
+ FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
+ while (ps) {
+ IFWL_Widget* pWidget = NULL;
+ CFWL_GridWidgetInfo* pInfo = NULL;
+ m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
+ if (!pWidget || !pInfo) {
+ continue;
+ }
+ FX_FLOAT fColumnStart = 0;
+ CFWL_GridColRow* pColumn =
+ (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn);
+ if (pColumn) {
+ fColumnStart = pColumn->m_fActualPos;
+ }
+ FX_FLOAT fRowStart = 0;
+ CFWL_GridColRow* pRow = (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow);
+ if (pRow) {
+ fRowStart = pRow->m_fActualPos;
+ }
+ FX_FLOAT fColumnWidth = 0;
+ if (iColumns > 0) {
+ for (int32_t j = 0; j < pInfo->m_iColumnSpan; j++) {
+ CFWL_GridColRow* pCol =
+ (CFWL_GridColRow*)GetColRow(TRUE, pInfo->m_iColumn + j);
+ if (!pCol) {
+ break;
}
+ fColumnWidth += pCol->m_fActualSize;
+ }
} else {
- }
-}
-void CFWL_GridImp::SetSpanScaledColRowSize(const CFX_PtrArray &spanScaleds, FX_FLOAT fTotalSize, FX_FLOAT fTotalScaledNum)
-{
- int32_t iScaledColRows = spanScaleds.GetSize();
- if (iScaledColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iScaledColRows; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)spanScaleds[i];
- if (SetColRowActualSize(pColRow, pColRow->m_fActualSize + fPerSize * pColRow->m_Size.fLength, TRUE)) {
- autoNoMinMaxs.Add(pColRow);
- } else {
- fTotalSize -= pColRow->m_fActualSize;
- fTotalScaledNum -= pColRow->m_Size.fLength;
- int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fPerSize = fTotalSize / fTotalScaledNum;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iScaledColRows) {
- fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t j = 0; j < iNormals; j++) {
- CFWL_GridColRow *pColumn = (CFWL_GridColRow*)autoNoMinMaxs[j];
- pColumn->m_fActualSize += fPerSize * pColumn->m_Size.fLength;
- }
- } else {
- SetSpanScaledColRowSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
+ fColumnWidth = m_pProperties->m_rtWidget.width;
+ }
+ FX_FLOAT fRowHeight = 0;
+ if (iRows > 0) {
+ for (int32_t k = 0; k < pInfo->m_iRowSpan; k++) {
+ CFWL_GridColRow* pR =
+ (CFWL_GridColRow*)GetColRow(FALSE, pInfo->m_iRow + k);
+ if (!pR) {
+ break;
}
+ fRowHeight += pR->m_fActualSize;
+ }
} else {
+ fRowHeight = m_pProperties->m_rtWidget.height;
}
-}
-void CFWL_GridImp::SetScaledColRowsSize(const CFX_PtrArray &spanScaleds, FX_FLOAT fTotalSize, FX_FLOAT fTotalScaledNum)
-{
- int32_t iScaledColRows = spanScaleds.GetSize();
- if (iScaledColRows < 1) {
- return;
+ FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
+ FX_BOOL bLeftMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
+ FX_BOOL bRightMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
+ FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
+ FX_BOOL bTopMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
+ FX_BOOL bBottomMargin =
+ GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
+ FWL_LAYOUTDATA ltd;
+ ltd.fWidth = 0;
+ ltd.fHeight = 0;
+ if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
+ SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
+ ltd.fWidth = pInfo->m_fActualWidth;
+ } else {
+ if (bLeftMargin && bRightMargin) {
+ SetWidgetActualWidth(pInfo, fColumnWidth - fLeftMargin - fRightMargin);
+ ltd.fWidth = pInfo->m_fActualWidth;
+ } else {
+ CFX_RectF rtAuto;
+ pWidget->GetWidgetRect(rtAuto, TRUE);
+ SetWidgetActualWidth(pInfo, rtAuto.width);
+ }
}
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iScaledColRows; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)spanScaleds[i];
+ if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
+ SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
+ ltd.fHeight = pInfo->m_fActualHeight;
+ } else {
+ if (bTopMargin && bBottomMargin) {
+ SetWidgetActualHeight(pInfo, fRowHeight - fTopMargin - fBottomMargin);
+ ltd.fHeight = pInfo->m_fActualHeight;
+ } else {
+ CFX_RectF rtAuto;
+ pWidget->GetWidgetRect(rtAuto, TRUE);
+ SetWidgetActualHeight(pInfo, rtAuto.height);
+ }
+ }
+ if (bLeftMargin && bRightMargin &&
+ pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
+ fLeftMargin =
+ fColumnStart + fLeftMargin +
+ (fColumnWidth - fLeftMargin - fRightMargin - pInfo->m_fActualWidth) /
+ 2;
+ } else if (bLeftMargin) {
+ fLeftMargin = fColumnStart + fLeftMargin;
+ } else if (bRightMargin) {
+ fLeftMargin =
+ fColumnStart + fColumnWidth - fRightMargin - pInfo->m_fActualWidth;
+ } else {
+ fLeftMargin = fColumnStart;
+ }
+ if (bTopMargin && bBottomMargin &&
+ pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
+ fTopMargin =
+ fRowStart + fTopMargin +
+ (fRowHeight - fTopMargin - fBottomMargin - pInfo->m_fActualHeight) /
+ 2;
+ } else if (bTopMargin) {
+ fTopMargin = fRowStart + fTopMargin;
+ } else if (bBottomMargin) {
+ fTopMargin =
+ fRowStart + fRowHeight - fBottomMargin - pInfo->m_fActualHeight;
+ } else {
+ fTopMargin = fRowStart;
+ }
+ CFX_RectF rtWidget, rtOld;
+ rtWidget.Set(fLeftMargin, fTopMargin, pInfo->m_fActualWidth,
+ pInfo->m_fActualHeight);
+ pWidget->GetWidgetRect(rtOld);
+ if (rtWidget == rtOld) {
+ continue;
+ }
+ pWidget->SetWidgetRect(rtWidget);
+ if (rtWidget.width == rtOld.width && rtWidget.height == rtOld.height) {
+ continue;
+ }
+ pWidget->Update();
+ }
+}
+FX_BOOL CFWL_GridImp::IsGrid(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_Grid;
+}
+void CFWL_GridImp::SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
+ FX_FLOAT fTotalSize) {
+ int32_t iAutoColRows = spanAutos.GetSize();
+ if (iAutoColRows < 1) {
+ return;
+ }
+ CFX_PtrArray autoNoMinMaxs;
+ FX_FLOAT fAutoPer = fTotalSize / iAutoColRows;
+ for (int32_t j = 0; j < iAutoColRows; j++) {
+ CFWL_GridColRow* pColumn = (CFWL_GridColRow*)spanAutos[j];
+ FX_FLOAT fOrgSize = pColumn->m_fActualSize;
+ if (SetColRowActualSize(pColumn, pColumn->m_fActualSize + fAutoPer, TRUE)) {
+ autoNoMinMaxs.Add(pColumn);
+ } else {
+ fTotalSize -= pColumn->m_fActualSize - fOrgSize;
+ int32_t iNoMinMax = iAutoColRows - (j + 1 - autoNoMinMaxs.GetSize());
+ if (iNoMinMax > 0 && fTotalSize > 0) {
+ fAutoPer = fTotalSize / iNoMinMax;
+ } else {
+ break;
+ }
+ }
+ }
+ int32_t iNormals = autoNoMinMaxs.GetSize();
+ if (fTotalSize > 0) {
+ if (iNormals == iAutoColRows) {
+ fAutoPer = fTotalSize / iNormals;
+ for (int32_t k = 0; k < iNormals; k++) {
+ CFWL_GridColRow* pColumn = (CFWL_GridColRow*)autoNoMinMaxs[k];
+ pColumn->m_fActualSize += fAutoPer;
+ }
+ } else {
+ SetSpanAutoColRowSize(autoNoMinMaxs, fTotalSize);
+ }
+ } else {
+ }
+}
+void CFWL_GridImp::SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
+ FX_FLOAT fTotalSize,
+ FX_FLOAT fTotalScaledNum) {
+ int32_t iScaledColRows = spanScaleds.GetSize();
+ if (iScaledColRows < 1) {
+ return;
+ }
+ CFX_PtrArray autoNoMinMaxs;
+ FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
+ for (int32_t i = 0; i < iScaledColRows; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)spanScaleds[i];
+ if (SetColRowActualSize(pColRow, pColRow->m_fActualSize +
+ fPerSize * pColRow->m_Size.fLength,
+ TRUE)) {
+ autoNoMinMaxs.Add(pColRow);
+ } else {
+ fTotalSize -= pColRow->m_fActualSize;
+ fTotalScaledNum -= pColRow->m_Size.fLength;
+ int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
+ if (iNoMinMax > 0 && fTotalSize > 0) {
+ fPerSize = fTotalSize / fTotalScaledNum;
+ } else {
+ break;
+ }
+ }
+ }
+ int32_t iNormals = autoNoMinMaxs.GetSize();
+ if (fTotalSize > 0) {
+ if (iNormals == iScaledColRows) {
+ fPerSize = fTotalSize / fTotalScaledNum;
+ for (int32_t j = 0; j < iNormals; j++) {
+ CFWL_GridColRow* pColumn = (CFWL_GridColRow*)autoNoMinMaxs[j];
+ pColumn->m_fActualSize += fPerSize * pColumn->m_Size.fLength;
+ }
+ } else {
+ SetSpanScaledColRowSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
+ }
+ } else {
+ }
+}
+void CFWL_GridImp::SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
+ FX_FLOAT fTotalSize,
+ FX_FLOAT fTotalScaledNum) {
+ int32_t iScaledColRows = spanScaleds.GetSize();
+ if (iScaledColRows < 1) {
+ return;
+ }
+ CFX_PtrArray autoNoMinMaxs;
+ FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
+ for (int32_t i = 0; i < iScaledColRows; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)spanScaleds[i];
+ if (!pColRow) {
+ continue;
+ }
+ FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
+ FX_FLOAT fOrgSize = pColRow->m_fActualSize;
+ if (SetColRowActualSize(pColRow, fSize, TRUE)) {
+ autoNoMinMaxs.Add(pColRow);
+ } else {
+ fTotalSize -= pColRow->m_fActualSize - fOrgSize;
+ fTotalScaledNum -= pColRow->m_Size.fLength;
+ int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
+ if (iNoMinMax > 0 && fTotalSize > 0) {
+ fPerSize = fTotalSize / fTotalScaledNum;
+ } else {
+ break;
+ }
+ }
+ }
+ int32_t iNormals = autoNoMinMaxs.GetSize();
+ if (fTotalSize > 0) {
+ if (iNormals == iScaledColRows) {
+ fPerSize = fTotalSize / fTotalScaledNum;
+ for (int32_t i = 0; i < iNormals; i++) {
+ CFWL_GridColRow* pColRow = (CFWL_GridColRow*)autoNoMinMaxs[i];
if (!pColRow) {
- continue;
+ continue;
}
FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
- FX_FLOAT fOrgSize = pColRow->m_fActualSize;
- if (SetColRowActualSize(pColRow, fSize, TRUE)) {
- autoNoMinMaxs.Add(pColRow);
- } else {
- fTotalSize -= pColRow->m_fActualSize - fOrgSize;
- fTotalScaledNum -= pColRow->m_Size.fLength;
- int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fPerSize = fTotalSize / fTotalScaledNum;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iScaledColRows) {
- fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iNormals; i++) {
- CFWL_GridColRow *pColRow = (CFWL_GridColRow*)autoNoMinMaxs[i];
- if (!pColRow) {
- continue;
- }
- FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
- pColRow->m_fActualSize = fSize;
- }
- } else {
- SetScaledColRowsSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
- }
+ pColRow->m_fActualSize = fSize;
+ }
} else {
+ SetScaledColRowsSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
}
+ } else {
+ }
}
-CFWL_GridDelegate::CFWL_GridDelegate(CFWL_GridImp *pOwner)
- : m_pOwner(pOwner)
-{
-}
-int32_t CFWL_GridDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- if (pMessage->GetClassID() != FWL_MSGHASH_Mouse) {
- return 0;
- }
- CFWL_MsgMouse *pMsg = (CFWL_MsgMouse*)pMessage;
- if (pMsg->m_dwCmd != FWL_MSGMOUSECMD_LButtonDown) {
- return 0;
- }
- return 1;
+CFWL_GridDelegate::CFWL_GridDelegate(CFWL_GridImp* pOwner) : m_pOwner(pOwner) {}
+int32_t CFWL_GridDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ if (pMessage->GetClassID() != FWL_MSGHASH_Mouse) {
+ return 0;
+ }
+ CFWL_MsgMouse* pMsg = (CFWL_MsgMouse*)pMessage;
+ if (pMsg->m_dwCmd != FWL_MSGMOUSECMD_LButtonDown) {
+ return 0;
+ }
+ return 1;
}
-FWL_ERR CFWL_GridDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+FWL_ERR CFWL_GridDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/xfa/src/fwl/src/core/fwl_noteimp.cpp b/xfa/src/fwl/src/core/fwl_noteimp.cpp index 0ea8975adc..90abc1e275 100644 --- a/xfa/src/fwl/src/core/fwl_noteimp.cpp +++ b/xfa/src/fwl/src/core/fwl_noteimp.cpp @@ -14,1114 +14,1069 @@ #include "include/fwl_threadimp.h"
#include "include/fwl_appimp.h"
#include "../../src/basewidget/include/fwl_tooltipctrlimp.h"
-CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp *pForm )
- : m_pForm(pForm)
- , m_bContinueModal(TRUE)
-{
-}
-FX_BOOL CFWL_NoteLoop::PreProcessMessage(CFWL_Message *pMessage)
-{
- if (!m_pForm) {
- return FALSE;
- }
- return TranslateAccelerator(pMessage);
-}
-FWL_ERR CFWL_NoteLoop::Idle(int32_t count)
-{
-#if (_FX_OS_==_FX_WIN32_DESKTOP_)
- if (count <= 0)
-#endif
- {
- CFWL_EvtIdle ev;
- IFWL_App *pApp = FWL_GetApp();
- _FWL_RETURN_VALUE_IF_FAIL(pApp, FWL_ERR_Indefinite);
- IFWL_NoteDriver *pDriver = pApp->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(pDriver, FWL_ERR_Indefinite);
- pDriver->SendNote(&ev);
- }
- return FWL_ERR_Indefinite;
+CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp* pForm)
+ : m_pForm(pForm), m_bContinueModal(TRUE) {}
+FX_BOOL CFWL_NoteLoop::PreProcessMessage(CFWL_Message* pMessage) {
+ if (!m_pForm) {
+ return FALSE;
+ }
+ return TranslateAccelerator(pMessage);
}
-CFWL_WidgetImp* CFWL_NoteLoop::GetForm()
-{
- return m_pForm;
-}
-FX_BOOL CFWL_NoteLoop::ContinueModal()
-{
- return m_bContinueModal;
-}
-FWL_ERR CFWL_NoteLoop::EndModalLoop()
-{
- m_bContinueModal = FALSE;
-#if (_FX_OS_==_FX_MACOSX_)
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- IFWL_AdapterWidgetMgr * adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- adapterWidgetMgr->EndLoop();
+FWL_ERR CFWL_NoteLoop::Idle(int32_t count) {
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_)
+ if (count <= 0)
#endif
- return FWL_ERR_Succeeded;
+ {
+ CFWL_EvtIdle ev;
+ IFWL_App* pApp = FWL_GetApp();
+ _FWL_RETURN_VALUE_IF_FAIL(pApp, FWL_ERR_Indefinite);
+ IFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(pDriver, FWL_ERR_Indefinite);
+ pDriver->SendNote(&ev);
+ }
+ return FWL_ERR_Indefinite;
}
-FX_BOOL CFWL_NoteLoop::TranslateAccelerator(CFWL_Message *pMessage)
-{
- if (pMessage->GetClassID() != FWL_MSGHASH_Key) {
- return FALSE;
- }
- if (((CFWL_MsgKey*)pMessage)->m_dwCmd != FWL_MSGKEYCMD_KeyDown) {
- return FALSE;
- }
- CFWL_MsgKey *pMsgKey = (CFWL_MsgKey*)pMessage;
- CFX_MapAccelerators &accel = ((CFWL_FormImp*)m_pForm)->GetAccelerator();
- FX_POSITION pos = accel.GetStartPosition();
- if (!pos) {
- return FALSE;
- }
- FX_DWORD vrKey, rValue;
- while (pos) {
- accel.GetNextAssoc(pos, vrKey, rValue);
- FX_DWORD dwFlags = (vrKey & 0xFF00) >> 8;
- FX_DWORD m_dwKeyCode = vrKey & 0x00FF;
- if (pMsgKey->m_dwFlags == dwFlags && pMsgKey->m_dwKeyCode == m_dwKeyCode) {
- GenerateCommondEvent(rValue);
- return TRUE;
- }
- }
- return FALSE;
+CFWL_WidgetImp* CFWL_NoteLoop::GetForm() {
+ return m_pForm;
}
-FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp *pForm)
-{
- m_pForm = pForm;
- return FWL_ERR_Succeeded;
+FX_BOOL CFWL_NoteLoop::ContinueModal() {
+ return m_bContinueModal;
}
-void CFWL_NoteLoop::GenerateCommondEvent(FX_DWORD dwCommand)
-{
- CFWL_EvtMenuCommand ev;
- ev.m_iCommand = dwCommand;
- IFWL_NoteThread *pThread = m_pForm->GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pDriver);
- pDriver->SendNote(&ev);
+FWL_ERR CFWL_NoteLoop::EndModalLoop() {
+ m_bContinueModal = FALSE;
+#if (_FX_OS_ == _FX_MACOSX_)
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
+ adapterWidgetMgr->EndLoop();
+#endif
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_NoteLoop::TranslateAccelerator(CFWL_Message* pMessage) {
+ if (pMessage->GetClassID() != FWL_MSGHASH_Key) {
+ return FALSE;
+ }
+ if (((CFWL_MsgKey*)pMessage)->m_dwCmd != FWL_MSGKEYCMD_KeyDown) {
+ return FALSE;
+ }
+ CFWL_MsgKey* pMsgKey = (CFWL_MsgKey*)pMessage;
+ CFX_MapAccelerators& accel = ((CFWL_FormImp*)m_pForm)->GetAccelerator();
+ FX_POSITION pos = accel.GetStartPosition();
+ if (!pos) {
+ return FALSE;
+ }
+ FX_DWORD vrKey, rValue;
+ while (pos) {
+ accel.GetNextAssoc(pos, vrKey, rValue);
+ FX_DWORD dwFlags = (vrKey & 0xFF00) >> 8;
+ FX_DWORD m_dwKeyCode = vrKey & 0x00FF;
+ if (pMsgKey->m_dwFlags == dwFlags && pMsgKey->m_dwKeyCode == m_dwKeyCode) {
+ GenerateCommondEvent(rValue);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) {
+ m_pForm = pForm;
+ return FWL_ERR_Succeeded;
+}
+void CFWL_NoteLoop::GenerateCommondEvent(FX_DWORD dwCommand) {
+ CFWL_EvtMenuCommand ev;
+ ev.m_iCommand = dwCommand;
+ IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pDriver);
+ pDriver->SendNote(&ev);
}
CFWL_NoteDriver::CFWL_NoteDriver()
- : m_sendEventCalled(0)
- , m_maxSize(500)
- , m_bFullScreen(FALSE)
- , m_pFocus(NULL)
- , m_pHover(NULL)
- , m_pGrab(NULL)
- , m_hook(NULL)
-{
- m_pNoteLoop = FX_NEW CFWL_NoteLoop;
- PushNoteLoop((IFWL_NoteLoop*)m_pNoteLoop);
-}
-CFWL_NoteDriver::~CFWL_NoteDriver()
-{
- if (m_pNoteLoop) {
- delete m_pNoteLoop;
- m_pNoteLoop = NULL;
- }
- ClearInvalidEventTargets(TRUE);
-}
-FX_BOOL CFWL_NoteDriver::SendNote(CFWL_Note *pNote)
-{
- if (pNote->IsEvent()) {
- int32_t iCount = m_eventTargets.GetCount();
- if (iCount < 1) {
- return TRUE;
- }
- if (FWL_EVTHASH_Mouse == ((CFWL_Event*)pNote)->GetClassID()) {
- CFWL_EvtMouse * pMouse = (CFWL_EvtMouse*)pNote;
- if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) {
- if (m_pNoteLoop->GetForm() && CFWL_ToolTipContainer::getInstance()->ProcessEnter(pMouse, m_pNoteLoop->GetForm()->GetInterface())) {
- }
- } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) {
- if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
- }
- } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) && (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) {
- if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
- }
- }
+ : m_sendEventCalled(0),
+ m_maxSize(500),
+ m_bFullScreen(FALSE),
+ m_pFocus(NULL),
+ m_pHover(NULL),
+ m_pGrab(NULL),
+ m_hook(NULL) {
+ m_pNoteLoop = FX_NEW CFWL_NoteLoop;
+ PushNoteLoop((IFWL_NoteLoop*)m_pNoteLoop);
+}
+CFWL_NoteDriver::~CFWL_NoteDriver() {
+ if (m_pNoteLoop) {
+ delete m_pNoteLoop;
+ m_pNoteLoop = NULL;
+ }
+ ClearInvalidEventTargets(TRUE);
+}
+FX_BOOL CFWL_NoteDriver::SendNote(CFWL_Note* pNote) {
+ if (pNote->IsEvent()) {
+ int32_t iCount = m_eventTargets.GetCount();
+ if (iCount < 1) {
+ return TRUE;
+ }
+ if (FWL_EVTHASH_Mouse == ((CFWL_Event*)pNote)->GetClassID()) {
+ CFWL_EvtMouse* pMouse = (CFWL_EvtMouse*)pNote;
+ if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) {
+ if (m_pNoteLoop->GetForm() &&
+ CFWL_ToolTipContainer::getInstance()->ProcessEnter(
+ pMouse, m_pNoteLoop->GetForm()->GetInterface())) {
}
- m_sendEventCalled ++;
- FX_POSITION pos = m_eventTargets.GetStartPosition();
- while (pos) {
- void* key = NULL;
- CFWL_EventTarget *pEventTarget;
- m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
- if (pEventTarget && !pEventTarget->IsInvalid()) {
- pEventTarget->ProcessEvent((CFWL_Event*)pNote);
- }
+ } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) {
+ if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
}
- m_sendEventCalled --;
- } else {
- _FWL_RETURN_VALUE_IF_FAIL(pNote->m_pDstTarget, FALSE);
- IFWL_WidgetDelegate *pDelegate = pNote->m_pDstTarget->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage((CFWL_Message*)pNote);
+ } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) &&
+ (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) {
+ if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
}
+ }
}
- return TRUE;
-}
-extern void FWL_PostMessageToMainRoop(CFWL_Message *pMessage);
-FX_BOOL CFWL_NoteDriver::PostMessage(CFWL_Message *pMessage)
-{
- FWL_PostMessageToMainRoop(pMessage);
- return TRUE;
+ m_sendEventCalled++;
+ FX_POSITION pos = m_eventTargets.GetStartPosition();
+ while (pos) {
+ void* key = NULL;
+ CFWL_EventTarget* pEventTarget;
+ m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
+ if (pEventTarget && !pEventTarget->IsInvalid()) {
+ pEventTarget->ProcessEvent((CFWL_Event*)pNote);
+ }
+ }
+ m_sendEventCalled--;
+ } else {
+ _FWL_RETURN_VALUE_IF_FAIL(pNote->m_pDstTarget, FALSE);
+ IFWL_WidgetDelegate* pDelegate = pNote->m_pDstTarget->SetDelegate(NULL);
+ if (pDelegate) {
+ pDelegate->OnProcessMessage((CFWL_Message*)pNote);
+ }
+ }
+ return TRUE;
+}
+extern void FWL_PostMessageToMainRoop(CFWL_Message* pMessage);
+FX_BOOL CFWL_NoteDriver::PostMessage(CFWL_Message* pMessage) {
+ FWL_PostMessageToMainRoop(pMessage);
+ return TRUE;
}
#define FWL_NoteDriver_EventKey 1100
-FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget *pListener, IFWL_Widget *pEventSource , FX_DWORD dwFilter )
-{
- FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey);
- if (dwkey == 0) {
- void* random = FX_Random_MT_Start(0);
- dwkey = rand();
- FX_Random_MT_Close(random);
- pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, (void*)(uintptr_t)dwkey, NULL);
- }
- CFWL_EventTarget *value = NULL;
- if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
- value = FX_NEW CFWL_EventTarget(this, pListener);
- m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value);
- }
- value->SetEventSource(pEventSource, dwFilter);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget *pListener)
-{
- FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey);
- if (dwkey == 0) {
- return FWL_ERR_Indefinite;
- }
- CFWL_EventTarget *value = NULL;
- if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
- value->FlagInvalid();
- }
- return FWL_ERR_Succeeded;
-}
-void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll)
-{
- ClearInvalidEventTargets(bRemoveAll);
-}
-int32_t CFWL_NoteDriver::GetQueueMaxSize() const
-{
- return m_maxSize;
-}
-FWL_ERR CFWL_NoteDriver::SetQueueMaxSize(const int32_t size)
-{
- m_maxSize = size;
- return FWL_ERR_Succeeded;
-}
-IFWL_NoteThread* CFWL_NoteDriver::GetOwnerThread() const
-{
- return (IFWL_NoteThread *) FWL_GetApp();
-}
-FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop *pNoteLoop)
-{
- m_noteLoopQueue.Add(pNoteLoop);
- return FWL_ERR_Succeeded;
-}
-IFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop()
-{
- int32_t pos = m_noteLoopQueue.GetSize();
- _FWL_RETURN_VALUE_IF_FAIL(pos > 0, NULL);
- IFWL_NoteLoop * p = (IFWL_NoteLoop *) m_noteLoopQueue.GetAt(pos - 1);
- m_noteLoopQueue.RemoveAt(pos - 1);
- return p;
-}
-FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget *pFocus, FX_BOOL bNotify )
-{
- if (m_pFocus == pFocus) {
- return TRUE;
- }
- IFWL_Widget* pPrev = m_pFocus;
- m_pFocus = pFocus;
- if (pPrev) {
- IFWL_Widget *pWidget = FWL_GetWidgetMgr()->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm);
- CFWL_FormImp *pForm = pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
- CFWL_MsgKillFocus ms;
- ms.m_pDstTarget = pPrev;
- ms.m_pSrcTarget = pPrev;
- if (bNotify) {
- ms.m_dwExtend = 1;
- }
- IFWL_WidgetDelegate *pDelegate = pPrev->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(&ms);
- }
- }
- if (pFocus) {
- IFWL_Widget *pWidget = FWL_GetWidgetMgr()->GetWidget(pFocus, FWL_WGTRELATION_SystemForm);
- CFWL_FormImp *pForm = pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
- if (pForm) {
- CFWL_WidgetImp *pNewFocus = (CFWL_WidgetImp*)((IFWL_TargetData*)pFocus)->GetData();
- pForm->SetSubFocus(pNewFocus);
- }
- CFWL_MsgSetFocus ms;
- ms.m_pDstTarget = pFocus;
- if (bNotify) {
- ms.m_dwExtend = 1;
- }
- IFWL_WidgetDelegate *pDelegate = pFocus->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(&ms);
- }
- }
+FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
+ IFWL_Widget* pEventSource,
+ FX_DWORD dwFilter) {
+ FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData(
+ (void*)(uintptr_t)FWL_NoteDriver_EventKey);
+ if (dwkey == 0) {
+ void* random = FX_Random_MT_Start(0);
+ dwkey = rand();
+ FX_Random_MT_Close(random);
+ pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey,
+ (void*)(uintptr_t)dwkey, NULL);
+ }
+ CFWL_EventTarget* value = NULL;
+ if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
+ value = FX_NEW CFWL_EventTarget(this, pListener);
+ m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value);
+ }
+ value->SetEventSource(pEventSource, dwFilter);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
+ FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData(
+ (void*)(uintptr_t)FWL_NoteDriver_EventKey);
+ if (dwkey == 0) {
+ return FWL_ERR_Indefinite;
+ }
+ CFWL_EventTarget* value = NULL;
+ if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
+ value->FlagInvalid();
+ }
+ return FWL_ERR_Succeeded;
+}
+void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) {
+ ClearInvalidEventTargets(bRemoveAll);
+}
+int32_t CFWL_NoteDriver::GetQueueMaxSize() const {
+ return m_maxSize;
+}
+FWL_ERR CFWL_NoteDriver::SetQueueMaxSize(const int32_t size) {
+ m_maxSize = size;
+ return FWL_ERR_Succeeded;
+}
+IFWL_NoteThread* CFWL_NoteDriver::GetOwnerThread() const {
+ return (IFWL_NoteThread*)FWL_GetApp();
+}
+FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop* pNoteLoop) {
+ m_noteLoopQueue.Add(pNoteLoop);
+ return FWL_ERR_Succeeded;
+}
+IFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
+ int32_t pos = m_noteLoopQueue.GetSize();
+ _FWL_RETURN_VALUE_IF_FAIL(pos > 0, NULL);
+ IFWL_NoteLoop* p = (IFWL_NoteLoop*)m_noteLoopQueue.GetAt(pos - 1);
+ m_noteLoopQueue.RemoveAt(pos - 1);
+ return p;
+}
+FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
+ if (m_pFocus == pFocus) {
return TRUE;
-}
-FWL_ERR CFWL_NoteDriver::Run()
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
-#if (_FX_OS_==_FX_MACOSX_)
- IFWL_AdapterWidgetMgr * adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- CFWL_NoteLoop *pTopLoop = GetTopLoop();
- if (pTopLoop) {
- CFWL_WidgetImp *formImp = pTopLoop->GetForm();
- if (formImp) {
- IFWL_Widget *pForm = formImp->GetInterface();
- adapterWidgetMgr->RunLoop(pForm);
- }
- }
-#elif (_FX_OS_==_FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
- FX_BOOL bIdle = TRUE;
- int32_t iIdleCount = 0;
- CFWL_NoteLoop *pTopLoop = NULL;
- for (;;) {
- pTopLoop = GetTopLoop();
- if (!pTopLoop || !pTopLoop->ContinueModal()) {
- break;
- }
- if (UnqueueMessage(pTopLoop)) {
- continue;
- }
- while (bIdle && !(pWidgetMgr->CheckMessage_Native())) {
- if (FWL_ERR_Indefinite == pTopLoop->Idle(iIdleCount++)) {
- bIdle = FALSE;
- }
- }
- do {
- if (FWL_ERR_Indefinite == pWidgetMgr->DispatchMessage_Native()) {
- break;
- }
- if (pWidgetMgr->IsIdleMessage_Native()) {
- bIdle = TRUE;
- iIdleCount = 0;
- }
- } while (pWidgetMgr->CheckMessage_Native());
- }
-#elif (_FX_OS_==_FX_LINUX_DESKTOP_)
- CFWL_NoteLoop *pTopLoop = NULL;
- for (;;) {
- pTopLoop = GetTopLoop();
- if (!pTopLoop || !pTopLoop->ContinueModal()) {
- break;
- }
- if (UnqueueMessage(pTopLoop)) {
- continue;
- }
- if(pWidgetMgr->CheckMessage_Native()) {
- pWidgetMgr->DispatchMessage_Native();
- }
- }
+ }
+ IFWL_Widget* pPrev = m_pFocus;
+ m_pFocus = pFocus;
+ if (pPrev) {
+ IFWL_Widget* pWidget =
+ FWL_GetWidgetMgr()->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm);
+ CFWL_FormImp* pForm =
+ pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
+ CFWL_MsgKillFocus ms;
+ ms.m_pDstTarget = pPrev;
+ ms.m_pSrcTarget = pPrev;
+ if (bNotify) {
+ ms.m_dwExtend = 1;
+ }
+ IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(NULL);
+ if (pDelegate) {
+ pDelegate->OnProcessMessage(&ms);
+ }
+ }
+ if (pFocus) {
+ IFWL_Widget* pWidget =
+ FWL_GetWidgetMgr()->GetWidget(pFocus, FWL_WGTRELATION_SystemForm);
+ CFWL_FormImp* pForm =
+ pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
+ if (pForm) {
+ CFWL_WidgetImp* pNewFocus =
+ (CFWL_WidgetImp*)((IFWL_TargetData*)pFocus)->GetData();
+ pForm->SetSubFocus(pNewFocus);
+ }
+ CFWL_MsgSetFocus ms;
+ ms.m_pDstTarget = pFocus;
+ if (bNotify) {
+ ms.m_dwExtend = 1;
+ }
+ IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL);
+ if (pDelegate) {
+ pDelegate->OnProcessMessage(&ms);
+ }
+ }
+ return TRUE;
+}
+FWL_ERR CFWL_NoteDriver::Run() {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
+#if (_FX_OS_ == _FX_MACOSX_)
+ IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
+ CFWL_NoteLoop* pTopLoop = GetTopLoop();
+ if (pTopLoop) {
+ CFWL_WidgetImp* formImp = pTopLoop->GetForm();
+ if (formImp) {
+ IFWL_Widget* pForm = formImp->GetInterface();
+ adapterWidgetMgr->RunLoop(pForm);
+ }
+ }
+#elif(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
+ FX_BOOL bIdle = TRUE;
+ int32_t iIdleCount = 0;
+ CFWL_NoteLoop* pTopLoop = NULL;
+ for (;;) {
+ pTopLoop = GetTopLoop();
+ if (!pTopLoop || !pTopLoop->ContinueModal()) {
+ break;
+ }
+ if (UnqueueMessage(pTopLoop)) {
+ continue;
+ }
+ while (bIdle && !(pWidgetMgr->CheckMessage_Native())) {
+ if (FWL_ERR_Indefinite == pTopLoop->Idle(iIdleCount++)) {
+ bIdle = FALSE;
+ }
+ }
+ do {
+ if (FWL_ERR_Indefinite == pWidgetMgr->DispatchMessage_Native()) {
+ break;
+ }
+ if (pWidgetMgr->IsIdleMessage_Native()) {
+ bIdle = TRUE;
+ iIdleCount = 0;
+ }
+ } while (pWidgetMgr->CheckMessage_Native());
+ }
+#elif(_FX_OS_ == _FX_LINUX_DESKTOP_)
+ CFWL_NoteLoop* pTopLoop = NULL;
+ for (;;) {
+ pTopLoop = GetTopLoop();
+ if (!pTopLoop || !pTopLoop->ContinueModal()) {
+ break;
+ }
+ if (UnqueueMessage(pTopLoop)) {
+ continue;
+ }
+ if (pWidgetMgr->CheckMessage_Native()) {
+ pWidgetMgr->DispatchMessage_Native();
+ }
+ }
#endif
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_NoteDriver::GetFocus()
-{
- return m_pFocus;
-}
-IFWL_Widget* CFWL_NoteDriver::GetHover()
-{
- return m_pHover;
-}
-void CFWL_NoteDriver::SetHover(IFWL_Widget *pHover)
-{
- m_pHover = pHover;
-}
-void CFWL_NoteDriver::SetGrab(IFWL_Widget *pGrab, FX_BOOL bSet)
-{
- m_pGrab = bSet ? pGrab : NULL;
-}
-void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget *pNoteTarget)
-{
- if (m_pFocus == pNoteTarget) {
- m_pFocus = NULL;
- }
- if (m_pHover == pNoteTarget) {
- m_pHover = NULL;
- }
- if (m_pGrab == pNoteTarget) {
- m_pGrab = NULL;
- }
-}
-void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget *pNoteTarget)
-{
- if (m_pFocus == pNoteTarget) {
- m_pFocus = NULL;
- }
- if (m_pHover == pNoteTarget) {
- m_pHover = NULL;
- }
- if (m_pGrab == pNoteTarget) {
- m_pGrab = NULL;
- }
- UnregisterEventTarget(pNoteTarget);
- int32_t count = m_forms.GetSize();
- for (int32_t nIndex = 0; nIndex < count; nIndex ++) {
- CFWL_FormImp *pForm = (CFWL_FormImp*)m_forms[nIndex];
- if (!pForm) {
- continue;
- }
- CFWL_WidgetImp *pSubFocus = pForm->GetSubFocus();
- _FWL_RETURN_IF_FAIL(pSubFocus);
- if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) {
- pForm->SetSubFocus(NULL);
- }
- }
-}
-void CFWL_NoteDriver::NotifyFullScreenMode(IFWL_Widget *pNoteTarget, FX_BOOL bFullScreen)
-{
- m_bFullScreen = bFullScreen;
+ return FWL_ERR_Succeeded;
+}
+IFWL_Widget* CFWL_NoteDriver::GetFocus() {
+ return m_pFocus;
+}
+IFWL_Widget* CFWL_NoteDriver::GetHover() {
+ return m_pHover;
+}
+void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) {
+ m_pHover = pHover;
+}
+void CFWL_NoteDriver::SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) {
+ m_pGrab = bSet ? pGrab : NULL;
+}
+void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) {
+ if (m_pFocus == pNoteTarget) {
+ m_pFocus = NULL;
+ }
+ if (m_pHover == pNoteTarget) {
+ m_pHover = NULL;
+ }
+ if (m_pGrab == pNoteTarget) {
+ m_pGrab = NULL;
+ }
+}
+void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) {
+ if (m_pFocus == pNoteTarget) {
+ m_pFocus = NULL;
+ }
+ if (m_pHover == pNoteTarget) {
+ m_pHover = NULL;
+ }
+ if (m_pGrab == pNoteTarget) {
+ m_pGrab = NULL;
+ }
+ UnregisterEventTarget(pNoteTarget);
+ int32_t count = m_forms.GetSize();
+ for (int32_t nIndex = 0; nIndex < count; nIndex++) {
+ CFWL_FormImp* pForm = (CFWL_FormImp*)m_forms[nIndex];
+ if (!pForm) {
+ continue;
+ }
+ CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
+ _FWL_RETURN_IF_FAIL(pSubFocus);
+ if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) {
+ pForm->SetSubFocus(NULL);
+ }
+ }
+}
+void CFWL_NoteDriver::NotifyFullScreenMode(IFWL_Widget* pNoteTarget,
+ FX_BOOL bFullScreen) {
+ m_bFullScreen = bFullScreen;
+}
+FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) {
+ _FWL_RETURN_VALUE_IF_FAIL(pForm, FWL_ERR_Indefinite);
+ if (m_forms.Find(pForm) >= 0) {
+ return FWL_ERR_Indefinite;
+ }
+ m_forms.Add(pForm);
+ if (m_forms.GetSize() == 1) {
+ CFWL_NoteLoop* pLoop = (CFWL_NoteLoop*)m_noteLoopQueue.GetAt(0);
+ _FWL_RETURN_VALUE_IF_FAIL(pLoop, FWL_ERR_Indefinite);
+ pLoop->SetMainForm(pForm);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) {
+ _FWL_RETURN_VALUE_IF_FAIL(pForm, FWL_ERR_Indefinite);
+ int32_t nIndex = m_forms.Find(pForm);
+ if (nIndex < 0) {
+ return FWL_ERR_Indefinite;
+ }
+ m_forms.RemoveAt(nIndex);
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp *pForm)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pForm, FWL_ERR_Indefinite);
- if (m_forms.Find(pForm) >= 0) {
- return FWL_ERR_Indefinite;
- }
- m_forms.Add(pForm);
- if (m_forms.GetSize() == 1) {
- CFWL_NoteLoop *pLoop = (CFWL_NoteLoop*)m_noteLoopQueue.GetAt(0);
- _FWL_RETURN_VALUE_IF_FAIL(pLoop, FWL_ERR_Indefinite);
- pLoop->SetMainForm(pForm);
- }
- return FWL_ERR_Succeeded;
+FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) {
+ pMessage->Retain();
+ m_noteQueue.Add(pMessage);
+ return TRUE;
}
-FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp *pForm)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pForm, FWL_ERR_Indefinite);
- int32_t nIndex = m_forms.Find(pForm);
- if (nIndex < 0) {
- return FWL_ERR_Indefinite;
+FX_BOOL CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) {
+ if (m_noteQueue.GetSize() < 1) {
+ return FALSE;
+ }
+ CFWL_Message* pMessage = (CFWL_Message*)m_noteQueue[0];
+ m_noteQueue.RemoveAt(0);
+ if (!IsValidMessage(pMessage)) {
+ pMessage->Release();
+ return TRUE;
+ }
+ FX_BOOL bHookMessage = FALSE;
+ if (m_hook) {
+ bHookMessage = (*m_hook)(pMessage, m_hookInfo);
+ }
+ if (!bHookMessage && !pNoteLoop->PreProcessMessage(pMessage)) {
+ ProcessMessage(pMessage);
+ }
+ pMessage->Release();
+ return TRUE;
+}
+CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() {
+ int32_t size = m_noteLoopQueue.GetSize();
+ _FWL_RETURN_VALUE_IF_FAIL(size > 0, NULL);
+ return (CFWL_NoteLoop*)m_noteLoopQueue[size - 1];
+}
+int32_t CFWL_NoteDriver::CountLoop() {
+ return m_noteLoopQueue.GetSize();
+}
+void CFWL_NoteDriver::SetHook(FWLMessageHookCallback callback, void* info) {
+ m_hook = callback;
+ m_hookInfo = info;
+}
+FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled()
+ ? pMessage->m_pDstTarget
+ : GetMessageForm(pMessage->m_pDstTarget);
+ _FWL_RETURN_VALUE_IF_FAIL(pMessageForm, FALSE);
+ if (DispatchMessage(pMessage, pMessageForm)) {
+ if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
+ MouseSecondary((CFWL_MsgMouse*)pMessage);
}
- m_forms.RemoveAt(nIndex);
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message *pMessage)
-{
- pMessage->Retain();
- m_noteQueue.Add(pMessage);
return TRUE;
+ }
+ return FALSE;
+}
+FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
+ IFWL_Widget* pMessageForm) {
+ FX_BOOL bRet = FALSE;
+ switch (pMessage->GetClassID()) {
+ case FWL_MSGHASH_Activate: {
+ bRet = DoActivate((CFWL_MsgActivate*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_Deactivate: {
+ bRet = DoDeactivate((CFWL_MsgDeactivate*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_SetFocus: {
+ bRet = DoSetFocus((CFWL_MsgSetFocus*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_KillFocus: {
+ bRet = DoKillFocus((CFWL_MsgKillFocus*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_Key: {
+ bRet = DoKey((CFWL_MsgKey*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_Mouse: {
+ bRet = DoMouse((CFWL_MsgMouse*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_MouseWheel: {
+ bRet = DoWheel((CFWL_MsgMouseWheel*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_Size: {
+ bRet = DoSize((CFWL_MsgSize*)pMessage);
+ break;
+ }
+ case FWL_MSGHASH_Cursor: {
+ bRet = TRUE;
+ break;
+ }
+ case FWL_MSGHASH_WindowMove: {
+ bRet = DoWindowMove((CFWL_MsgWindowMove*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_DropFiles: {
+ bRet = DoDragFiles((CFWL_MsgDropFiles*)pMessage, pMessageForm);
+ break;
+ }
+ case FWL_MSGHASH_TaskClicked: {
+ bRet = TRUE;
+ break;
+ }
+ case FWL_MSGHASH_Close: {
+ bRet = TRUE;
+ break;
+ }
+ default: {
+ bRet = TRUE;
+ break;
+ }
+ }
+ if (bRet) {
+ IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL);
+ if (pDelegate) {
+ pDelegate->OnProcessMessage(pMessage);
+ }
+ }
+ return bRet;
+}
+FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg,
+ IFWL_Widget* pMessageForm) {
+ if (m_bFullScreen) {
+ return FALSE;
+ }
+ pMsg->m_pDstTarget = pMessageForm;
+ return (pMsg->m_pDstTarget)->GetStates() & FWL_WGTSTATE_Deactivated;
}
-FX_BOOL CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop *pNoteLoop)
-{
- if (m_noteQueue.GetSize() < 1) {
- return FALSE;
- }
- CFWL_Message *pMessage = (CFWL_Message*)m_noteQueue[0];
- m_noteQueue.RemoveAt(0);
- if (!IsValidMessage(pMessage)) {
- pMessage->Release();
- return TRUE;
+FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
+ IFWL_Widget* pMessageForm) {
+ if (m_bFullScreen) {
+ return FALSE;
+ }
+ int32_t iTrackLoop = m_noteLoopQueue.GetSize();
+ _FWL_RETURN_VALUE_IF_FAIL(iTrackLoop > 0, FALSE);
+ if (iTrackLoop == 1) {
+ if (pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
+ return FALSE;
}
- FX_BOOL bHookMessage = FALSE;
- if (m_hook) {
- bHookMessage = (*m_hook)(pMessage, m_hookInfo);
+ if (pMsg->m_pSrcTarget &&
+ pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
+ return FALSE;
}
- if (!bHookMessage && !pNoteLoop->PreProcessMessage(pMessage)) {
- ProcessMessage(pMessage);
+ if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) {
+ return FALSE;
}
- pMessage->Release();
return TRUE;
-}
-CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop()
-{
- int32_t size = m_noteLoopQueue.GetSize();
- _FWL_RETURN_VALUE_IF_FAIL(size > 0, NULL);
- return (CFWL_NoteLoop*)m_noteLoopQueue[size - 1];
-}
-int32_t CFWL_NoteDriver::CountLoop()
-{
- return m_noteLoopQueue.GetSize();
-}
-void CFWL_NoteDriver::SetHook(FWLMessageHookCallback callback, void* info)
-{
- m_hook = callback;
- m_hookInfo = info;
-}
-FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message *pMessage)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- IFWL_Widget *pMessageForm = pWidgetMgr->IsFormDisabled() ? pMessage->m_pDstTarget : GetMessageForm(pMessage->m_pDstTarget);
- _FWL_RETURN_VALUE_IF_FAIL(pMessageForm, FALSE);
- if (DispatchMessage(pMessage, pMessageForm)) {
- if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
- MouseSecondary((CFWL_MsgMouse*)pMessage);
- }
- return TRUE;
- }
- return FALSE;
-}
-FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message *pMessage, IFWL_Widget *pMessageForm)
-{
- FX_BOOL bRet = FALSE;
- switch (pMessage->GetClassID()) {
- case FWL_MSGHASH_Activate: {
- bRet = DoActivate((CFWL_MsgActivate*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- bRet = DoDeactivate((CFWL_MsgDeactivate*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_SetFocus: {
- bRet = DoSetFocus((CFWL_MsgSetFocus*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_KillFocus: {
- bRet = DoKillFocus((CFWL_MsgKillFocus*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_Key: {
- bRet = DoKey((CFWL_MsgKey*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- bRet = DoMouse((CFWL_MsgMouse*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_MouseWheel: {
- bRet = DoWheel((CFWL_MsgMouseWheel*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_Size: {
- bRet = DoSize((CFWL_MsgSize*)pMessage);
- break;
- }
- case FWL_MSGHASH_Cursor: {
- bRet = TRUE;
- break;
- }
- case FWL_MSGHASH_WindowMove: {
- bRet = DoWindowMove((CFWL_MsgWindowMove*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_DropFiles: {
- bRet = DoDragFiles((CFWL_MsgDropFiles*)pMessage, pMessageForm);
- break;
- }
- case FWL_MSGHASH_TaskClicked: {
- bRet = TRUE;
- break;
- }
- case FWL_MSGHASH_Close: {
- bRet = TRUE;
- break;
- }
- default: {
- bRet = TRUE;
- break;
- }
- }
- if (bRet) {
- IFWL_WidgetDelegate *pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(pMessage);
+ }
+ IFWL_Widget* pDst = pMsg->m_pDstTarget;
+ _FWL_RETURN_VALUE_IF_FAIL(pDst, FALSE);
+#if (_FX_OS_ == _FX_MACOSX_)
+ if (pDst == pMessageForm && pDst->IsInstance(L"FWL_FORMPROXY")) {
+ return TRUE;
+ }
+#endif
+ return pDst != pMessageForm &&
+ !pDst->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")) &&
+ !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"));
+}
+FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg,
+ IFWL_Widget* pMessageForm) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ if (pWidgetMgr->IsFormDisabled()) {
+ m_pFocus = (IFWL_Widget*)pMsg->m_pDstTarget;
+ return TRUE;
+ } else {
+ IFWL_Widget* pWidget = pMsg->m_pDstTarget;
+ CFWL_FormImp* pForm =
+ pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
+ if (pForm) {
+ CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
+ if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) {
+ pMsg->m_pDstTarget = pSubFocus->GetInterface();
+ if (m_pFocus != pMsg->m_pDstTarget) {
+ m_pFocus = pMsg->m_pDstTarget;
+ return TRUE;
}
+ }
}
- return bRet;
+ }
+ return FALSE;
}
-FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate *pMsg, IFWL_Widget *pMessageForm)
-{
- if (m_bFullScreen) {
- return FALSE;
+FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg,
+ IFWL_Widget* pMessageForm) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ if (pWidgetMgr->IsFormDisabled()) {
+ if (m_pFocus == pMsg->m_pDstTarget) {
+ m_pFocus = NULL;
}
- pMsg->m_pDstTarget = pMessageForm;
- return (pMsg->m_pDstTarget)->GetStates() & FWL_WGTSTATE_Deactivated;
-}
-FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate *pMsg, IFWL_Widget *pMessageForm)
-{
- if (m_bFullScreen) {
- return FALSE;
- }
- int32_t iTrackLoop = m_noteLoopQueue.GetSize();
- _FWL_RETURN_VALUE_IF_FAIL(iTrackLoop > 0, FALSE);
- if (iTrackLoop == 1) {
- if (pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
- return FALSE;
- }
- if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
- return FALSE;
- }
- if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) {
- return FALSE;
+ return TRUE;
+ } else {
+ IFWL_Widget* pWidget = pMsg->m_pDstTarget;
+ CFWL_FormImp* pForm =
+ pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
+ if (pForm) {
+ CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
+ if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) {
+ pMsg->m_pDstTarget = pSubFocus->GetInterface();
+ if (m_pFocus == pMsg->m_pDstTarget) {
+ m_pFocus = NULL;
+ return TRUE;
}
- return TRUE;
- }
- IFWL_Widget *pDst = pMsg->m_pDstTarget;
- _FWL_RETURN_VALUE_IF_FAIL(pDst, FALSE);
-#if (_FX_OS_==_FX_MACOSX_)
- if (pDst == pMessageForm && pDst->IsInstance(L"FWL_FORMPROXY")) {
- return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
+#if (_FX_OS_ != _FX_MACOSX_)
+ if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown &&
+ pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget);
+ IFWL_Widget* pFocus = m_pFocus;
+ if (m_pFocus) {
+ if (pWidgetMgr->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm) !=
+ pForm) {
+ pFocus = NULL;
+ }
+ }
+ FX_BOOL bFind = FALSE;
+ IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind);
+ if (!pNextTabStop) {
+ bFind = FALSE;
+ pNextTabStop = pWidgetMgr->nextTab(pForm, NULL, bFind);
+ }
+ if (pNextTabStop == pFocus) {
+ return TRUE;
+ }
+ if (pNextTabStop) {
+ SetFocus(pNextTabStop);
}
+ return TRUE;
+ }
#endif
- return pDst != pMessageForm &&
- !pDst->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")) &&
- !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"));
-}
-FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus *pMsg, IFWL_Widget *pMessageForm)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- if (pWidgetMgr->IsFormDisabled()) {
- m_pFocus = (IFWL_Widget*)pMsg->m_pDstTarget;
+ if (!m_pFocus) {
+ if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown &&
+ pMsg->m_dwKeyCode == FWL_VKEY_Return) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm);
+ if (defButton) {
+ pMsg->m_pDstTarget = defButton;
return TRUE;
- } else {
- IFWL_Widget* pWidget = pMsg->m_pDstTarget;
- CFWL_FormImp *pForm = pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
- if(pForm) {
- CFWL_WidgetImp *pSubFocus = pForm->GetSubFocus();
- if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) {
- pMsg->m_pDstTarget = pSubFocus->GetInterface();
- if(m_pFocus != pMsg->m_pDstTarget) {
- m_pFocus = pMsg->m_pDstTarget;
- return TRUE;
- }
- }
- }
+ }
}
return FALSE;
-}
-FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus *pMsg, IFWL_Widget *pMessageForm)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- if (pWidgetMgr->IsFormDisabled()) {
- if (m_pFocus == pMsg->m_pDstTarget) {
- m_pFocus = NULL;
- }
- return TRUE;
- } else {
- IFWL_Widget* pWidget = pMsg->m_pDstTarget;
- CFWL_FormImp *pForm = pWidget ? (CFWL_FormImp*)((IFWL_TargetData*)pWidget)->GetData() : NULL;
- if(pForm) {
- CFWL_WidgetImp *pSubFocus = pForm->GetSubFocus();
- if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) {
- pMsg->m_pDstTarget = pSubFocus->GetInterface();
- if (m_pFocus == pMsg->m_pDstTarget) {
- m_pFocus = NULL;
- return TRUE;
- }
- }
- }
- }
+ }
+ pMsg->m_pDstTarget = m_pFocus;
+ return TRUE;
+}
+FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg,
+ IFWL_Widget* pMessageForm) {
+ if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave ||
+ pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseHover ||
+ pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) {
+ return pMsg->m_pDstTarget != NULL;
+ }
+ if (pMsg->m_pDstTarget != pMessageForm) {
+ pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
+ }
+ if (!DoMouseEx(pMsg, pMessageForm)) {
+ pMsg->m_pDstTarget = pMessageForm;
+ }
+ return TRUE;
+}
+FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg,
+ IFWL_Widget* pMessageForm) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FALSE);
+ IFWL_Widget* pDst =
+ pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
+ if (!pDst) {
return FALSE;
-}
-FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey *pMsg, IFWL_Widget *pMessageForm)
-{
-#if(_FX_OS_ != _FX_MACOSX_)
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- IFWL_Widget *pForm = GetMessageForm(pMsg->m_pDstTarget);
- IFWL_Widget *pFocus = m_pFocus;
- if (m_pFocus) {
- if (pWidgetMgr->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm) != pForm) {
- pFocus = NULL;
- }
- }
- FX_BOOL bFind = FALSE;
- IFWL_Widget *pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind);
- if (!pNextTabStop) {
- bFind = FALSE;
- pNextTabStop = pWidgetMgr->nextTab(pForm, NULL, bFind);
- }
- if (pNextTabStop == pFocus) {
- return TRUE;
- }
- if (pNextTabStop) {
- SetFocus(pNextTabStop);
- }
- return TRUE;
- }
-#endif
- if (!m_pFocus) {
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown && pMsg->m_dwKeyCode == FWL_VKEY_Return) {
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- IFWL_Widget *defButton = pWidgetMgr->GetDefaultButton(pMessageForm);
- if (defButton) {
- pMsg->m_pDstTarget = defButton;
- return TRUE;
- }
- }
- return FALSE;
- }
- pMsg->m_pDstTarget = m_pFocus;
+ }
+ while (pDst && pDst->GetClassID() == FWL_CLASSHASH_Grid) {
+ pDst = pDst->GetParent();
+ }
+ pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
+ pMsg->m_pDstTarget = pDst;
+ return TRUE;
+}
+FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FALSE);
+ pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth,
+ (FX_FLOAT)pMsg->m_iHeight);
+ return TRUE;
+}
+FX_BOOL CFWL_NoteDriver::DoWindowMove(CFWL_MsgWindowMove* pMsg,
+ IFWL_Widget* pMessageForm) {
+ return pMsg->m_pDstTarget == pMessageForm;
+}
+FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg,
+ IFWL_Widget* pMessageForm) {
+ return pMsg->m_pDstTarget == pMessageForm;
+}
+FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg,
+ IFWL_Widget* pMessageForm) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FALSE);
+ IFWL_Widget* pTarget = NULL;
+ if (m_pGrab) {
+ { pTarget = m_pGrab; }
+ }
+ if (!pTarget) {
+ pTarget =
+ pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
+ while (pTarget && pTarget->GetClassID() == FWL_CLASSHASH_Grid) {
+ pTarget = pTarget->GetParent();
+ }
+ }
+ if (pTarget) {
+ if (pMessageForm != pTarget) {
+ pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
+ }
+ }
+ if (!pTarget) {
+ return FALSE;
+ }
+ pMsg->m_pDstTarget = pTarget;
+ return TRUE;
+}
+void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) {
+ IFWL_Widget* pTarget = pMsg->m_pDstTarget;
+ if (pTarget == m_pHover) {
+ return;
+ }
+ if (m_pHover) {
+ CFWL_MsgMouse msLeave;
+ msLeave.m_pDstTarget = m_pHover;
+ msLeave.m_fx = pMsg->m_fx;
+ msLeave.m_fy = pMsg->m_fy;
+ pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
+ msLeave.m_dwFlags = 0;
+ msLeave.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave;
+ DispatchMessage(&msLeave, NULL);
+ }
+ if (pTarget->GetClassID() == FWL_CLASSHASH_Form) {
+ m_pHover = NULL;
+ return;
+ }
+ m_pHover = pTarget;
+ CFWL_MsgMouse msHover;
+ msHover.m_pDstTarget = pTarget;
+ msHover.m_fx = pMsg->m_fx;
+ msHover.m_fy = pMsg->m_fy;
+ msHover.m_dwFlags = 0;
+ msHover.m_dwCmd = FWL_MSGMOUSECMD_MouseHover;
+ DispatchMessage(&msHover, NULL);
+}
+FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
+ if (pMessage->GetClassID() == FWL_MSGHASH_Post) {
return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse *pMsg, IFWL_Widget *pMessageForm)
-{
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave ||
- pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseHover ||
- pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) {
- return pMsg->m_pDstTarget != NULL;
- }
- if (pMsg->m_pDstTarget != pMessageForm) {
- pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- }
- if (!DoMouseEx(pMsg, pMessageForm)) {
- pMsg->m_pDstTarget = pMessageForm;
- }
+ }
+ int32_t iCount = m_noteLoopQueue.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_NoteLoop* pNoteLoop = (CFWL_NoteLoop*)m_noteLoopQueue[i];
+ CFWL_WidgetImp* pForm = pNoteLoop->GetForm();
+ if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) {
+ return TRUE;
+ }
+ }
+ iCount = m_forms.GetSize();
+ for (int32_t j = 0; j < iCount; j++) {
+ CFWL_FormImp* pForm = (CFWL_FormImp*)m_forms[j];
+ if (pForm->GetInterface() == pMessage->m_pDstTarget) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) {
+ int32_t iTrackLoop = m_noteLoopQueue.GetSize();
+ _FWL_RETURN_VALUE_IF_FAIL(iTrackLoop > 0, NULL);
+ IFWL_Widget* pMessageForm = NULL;
+ if (iTrackLoop > 1) {
+ CFWL_NoteLoop* pNootLoop = (CFWL_NoteLoop*)m_noteLoopQueue[iTrackLoop - 1];
+ pMessageForm = pNootLoop->GetForm()->GetInterface();
+ } else {
+ pMessageForm = (m_forms.Find(pDstTarget) < 0) ? NULL : pDstTarget;
+ }
+ if (!pMessageForm && pDstTarget) {
+ CFWL_WidgetMgr* pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, NULL);
+ pMessageForm =
+ pWidgetMgr->GetWidget(pDstTarget, FWL_WGTRELATION_SystemForm);
+ }
+ return pMessageForm;
+}
+void CFWL_NoteDriver::ClearInvalidEventTargets(FX_BOOL bRemoveAll) {
+ FX_POSITION pos = m_eventTargets.GetStartPosition();
+ while (pos) {
+ void* key = NULL;
+ CFWL_EventTarget* pEventTarget = NULL;
+ m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
+ if (pEventTarget && (bRemoveAll || pEventTarget->IsInvalid())) {
+ m_eventTargets.RemoveKey(key);
+ delete pEventTarget;
+ }
+ }
+}
+class CFWL_CoreToopTipDP : public IFWL_ToolTipDP {
+ public:
+ FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ int32_t GetInitialDelay(IFWL_Widget* pWidget);
+ int32_t GetAutoPopDelay(IFWL_Widget* pWidget);
+ CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget);
+ CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget);
+ CFX_RectF GetAnchor();
+ CFWL_CoreToopTipDP();
+
+ CFX_WideString m_wsCaption;
+ int32_t m_nInitDelayTime;
+ int32_t m_nAutoPopDelayTime;
+ CFX_RectF m_fAnchor;
+};
+CFWL_CoreToopTipDP::CFWL_CoreToopTipDP() {
+ m_nInitDelayTime = 500;
+ m_nAutoPopDelayTime = 50000;
+ m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
+}
+FWL_ERR CFWL_CoreToopTipDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsCaption;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_CoreToopTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
+ return m_nInitDelayTime;
+}
+int32_t CFWL_CoreToopTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) {
+ return m_nAutoPopDelayTime;
+}
+CFX_DIBitmap* CFWL_CoreToopTipDP::GetToolTipIcon(IFWL_Widget* pWidget) {
+ return NULL;
+}
+CFX_SizeF CFWL_CoreToopTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) {
+ CFX_SizeF sz;
+ sz.Set(0, 0);
+ return sz;
+}
+CFX_RectF CFWL_CoreToopTipDP::GetAnchor() {
+ return m_fAnchor;
+}
+CFWL_EventTarget::~CFWL_EventTarget() {
+ m_eventSources.RemoveAll();
+}
+int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource,
+ FX_DWORD dwFilter) {
+ if (pSource) {
+ m_eventSources.SetAt(pSource, dwFilter);
+ return m_eventSources.GetCount();
+ }
+ return 1;
+}
+FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
+ IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL);
+ _FWL_RETURN_VALUE_IF_FAIL(pDelegate, FALSE);
+ if (m_eventSources.GetCount() == 0) {
+ pDelegate->OnProcessEvent(pEvent);
return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel *pMsg, IFWL_Widget *pMessageForm)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FALSE);
- IFWL_Widget *pDst = pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- if (!pDst) {
- return FALSE;
- }
- while (pDst && pDst->GetClassID() == FWL_CLASSHASH_Grid) {
- pDst = pDst->GetParent();
+ }
+ FX_POSITION pos = m_eventSources.GetStartPosition();
+ while (pos) {
+ IFWL_Widget* pSource = NULL;
+ FX_DWORD dwFilter = 0;
+ m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
+ if (pSource == pEvent->m_pSrcTarget ||
+ pEvent->GetClassID() == FWL_EVTHASH_Idle) {
+ if (IsFilterEvent(pEvent, dwFilter)) {
+ pDelegate->OnProcessEvent(pEvent);
+ return TRUE;
+ }
}
- pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
- pMsg->m_pDstTarget = pDst;
- return TRUE;
+ }
+ return FALSE;
}
-FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize *pMsg)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FALSE);
- pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth, (FX_FLOAT)pMsg->m_iHeight);
+FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter) {
+ if (dwFilter == FWL_EVENT_ALL_MASK) {
return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoWindowMove(CFWL_MsgWindowMove *pMsg, IFWL_Widget *pMessageForm)
-{
- return pMsg->m_pDstTarget == pMessageForm;
-}
-FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles *pMsg, IFWL_Widget *pMessageForm)
-{
- return pMsg->m_pDstTarget == pMessageForm;
-}
-FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse *pMsg, IFWL_Widget *pMessageForm)
-{
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FALSE);
- IFWL_Widget *pTarget = NULL;
- if (m_pGrab) {
- {
- pTarget = m_pGrab;
- }
- }
- if (!pTarget) {
- pTarget = pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- while (pTarget && pTarget->GetClassID() == FWL_CLASSHASH_Grid) {
- pTarget = pTarget->GetParent();
- }
- }
- if (pTarget) {
- if (pMessageForm != pTarget) {
- pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
- }
+ }
+ FX_BOOL bRet = FALSE;
+ switch (pEvent->GetClassID()) {
+ case FWL_EVTHASH_Mouse: {
+ bRet = dwFilter & FWL_EVENT_MOUSE_MASK;
+ break;
}
- if (!pTarget) {
- return FALSE;
+ case FWL_EVTHASH_MouseWheel: {
+ bRet = dwFilter & FWL_EVENT_MOUSEWHEEL_MASK;
+ break;
}
- pMsg->m_pDstTarget = pTarget;
- return TRUE;
-}
-void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse *pMsg)
-{
- IFWL_Widget *pTarget = pMsg->m_pDstTarget;
- if (pTarget == m_pHover) {
- return;
- }
- if (m_pHover) {
- CFWL_MsgMouse msLeave;
- msLeave.m_pDstTarget = m_pHover;
- msLeave.m_fx = pMsg->m_fx;
- msLeave.m_fy = pMsg->m_fy;
- pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
- msLeave.m_dwFlags = 0;
- msLeave.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave;
- DispatchMessage(&msLeave, NULL);
- }
- if (pTarget->GetClassID() == FWL_CLASSHASH_Form) {
- m_pHover = NULL;
- return;
- }
- m_pHover = pTarget;
- CFWL_MsgMouse msHover;
- msHover.m_pDstTarget = pTarget;
- msHover.m_fx = pMsg->m_fx;
- msHover.m_fy = pMsg->m_fy;
- msHover.m_dwFlags = 0;
- msHover.m_dwCmd = FWL_MSGMOUSECMD_MouseHover;
- DispatchMessage(&msHover, NULL);
-}
-FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message *pMessage)
-{
- if (pMessage->GetClassID() == FWL_MSGHASH_Post) {
- return TRUE;
+ case FWL_EVTHASH_Key: {
+ bRet = dwFilter & FWL_EVENT_KEY_MASK;
+ break;
}
- int32_t iCount = m_noteLoopQueue.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_NoteLoop *pNoteLoop = (CFWL_NoteLoop*)m_noteLoopQueue[i];
- CFWL_WidgetImp *pForm = pNoteLoop->GetForm();
- if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) {
- return TRUE;
- }
+ case FWL_EVTHASH_SetFocus:
+ case FWL_EVTHASH_KillFocus: {
+ bRet = dwFilter & FWL_EVENT_FOCUSCHANGED_MASK;
+ break;
}
- iCount = m_forms.GetSize();
- for (int32_t j = 0; j < iCount; j ++) {
- CFWL_FormImp *pForm = (CFWL_FormImp*)m_forms[j];
- if (pForm->GetInterface() == pMessage->m_pDstTarget) {
- return TRUE;
- }
+ case FWL_EVTHASH_Draw: {
+ bRet = dwFilter & FWL_EVENT_DRAW_MASK;
+ break;
}
- return FALSE;
-}
-IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget *pDstTarget)
-{
- int32_t iTrackLoop = m_noteLoopQueue.GetSize();
- _FWL_RETURN_VALUE_IF_FAIL(iTrackLoop > 0, NULL);
- IFWL_Widget *pMessageForm = NULL;
- if (iTrackLoop > 1) {
- CFWL_NoteLoop *pNootLoop = (CFWL_NoteLoop*)m_noteLoopQueue[iTrackLoop - 1];
- pMessageForm = pNootLoop->GetForm()->GetInterface();
- } else {
- pMessageForm = (m_forms.Find(pDstTarget) < 0) ? NULL : pDstTarget;
- }
- if (!pMessageForm && pDstTarget) {
- CFWL_WidgetMgr *pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, NULL);
- pMessageForm = pWidgetMgr->GetWidget(pDstTarget, FWL_WGTRELATION_SystemForm);
- }
- return pMessageForm;
-}
-void CFWL_NoteDriver::ClearInvalidEventTargets(FX_BOOL bRemoveAll)
-{
- FX_POSITION pos = m_eventTargets.GetStartPosition();
- while (pos) {
- void* key = NULL;
- CFWL_EventTarget *pEventTarget = NULL;
- m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
- if (pEventTarget && (bRemoveAll || pEventTarget->IsInvalid())) {
- m_eventTargets.RemoveKey(key);
- delete pEventTarget;
- }
+ case FWL_EVTHASH_Close: {
+ bRet = dwFilter & FWL_EVENT_CLOSE_MASK;
+ break;
}
-}
-class CFWL_CoreToopTipDP : public IFWL_ToolTipDP
-{
-public:
- FWL_ERR GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption);
- int32_t GetInitialDelay(IFWL_Widget *pWidget);
- int32_t GetAutoPopDelay(IFWL_Widget *pWidget);
- CFX_DIBitmap* GetToolTipIcon(IFWL_Widget *pWidget);
- CFX_SizeF GetToolTipIconSize(IFWL_Widget *pWidget);
- CFX_RectF GetAnchor();
- CFWL_CoreToopTipDP();
-
- CFX_WideString m_wsCaption;
- int32_t m_nInitDelayTime;
- int32_t m_nAutoPopDelayTime;
- CFX_RectF m_fAnchor;
-};
-CFWL_CoreToopTipDP::CFWL_CoreToopTipDP()
-{
- m_nInitDelayTime = 500;
- m_nAutoPopDelayTime = 50000;
- m_fAnchor.Set( 0.0, 0.0, 0.0, 0.0);
-}
-FWL_ERR CFWL_CoreToopTipDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_CoreToopTipDP::GetInitialDelay(IFWL_Widget *pWidget)
-{
- return m_nInitDelayTime;
-}
-int32_t CFWL_CoreToopTipDP::GetAutoPopDelay(IFWL_Widget *pWidget)
-{
- return m_nAutoPopDelayTime;
-}
-CFX_DIBitmap* CFWL_CoreToopTipDP::GetToolTipIcon(IFWL_Widget *pWidget)
-{
- return NULL;
-}
-CFX_SizeF CFWL_CoreToopTipDP::GetToolTipIconSize(IFWL_Widget *pWidget)
-{
- CFX_SizeF sz;
- sz.Set(0, 0);
- return sz;
-}
-CFX_RectF CFWL_CoreToopTipDP::GetAnchor()
-{
- return m_fAnchor;
-}
-CFWL_EventTarget::~CFWL_EventTarget()
-{
- m_eventSources.RemoveAll();
-}
-int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget *pSource, FX_DWORD dwFilter)
-{
- if (pSource) {
- m_eventSources.SetAt(pSource, dwFilter);
- return m_eventSources.GetCount();
- }
- return 1;
-}
-FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event *pEvent)
-{
- IFWL_WidgetDelegate *pDelegate = m_pListener->SetDelegate(NULL);
- _FWL_RETURN_VALUE_IF_FAIL(pDelegate, FALSE);
- if (m_eventSources.GetCount() == 0) {
- pDelegate->OnProcessEvent(pEvent);
- return TRUE;
+ case FWL_EVTHASH_SizeChanged: {
+ bRet = dwFilter & FWL_EVENT_SIZECHANGED_MASK;
+ break;
}
- FX_POSITION pos = m_eventSources.GetStartPosition();
- while (pos) {
- IFWL_Widget *pSource = NULL;
- FX_DWORD dwFilter = 0;
- m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
- if (pSource == pEvent->m_pSrcTarget || pEvent->GetClassID() == FWL_EVTHASH_Idle) {
- if (IsFilterEvent(pEvent, dwFilter)) {
- pDelegate->OnProcessEvent(pEvent);
- return TRUE;
- }
- }
+ case FWL_EVTHASH_Idle: {
+ bRet = dwFilter & FWL_EVENT_IDLE_MASK;
+ break;
}
- return FALSE;
-}
-FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event *pEvent, FX_DWORD dwFilter)
-{
- if (dwFilter == FWL_EVENT_ALL_MASK) {
- return TRUE;
+ default: {
+ bRet = dwFilter & FWL_EVENT_CONTROL_MASK;
+ break;
}
- FX_BOOL bRet = FALSE;
- switch (pEvent->GetClassID()) {
- case FWL_EVTHASH_Mouse: {
- bRet = dwFilter & FWL_EVENT_MOUSE_MASK;
- break;
- }
- case FWL_EVTHASH_MouseWheel: {
- bRet = dwFilter & FWL_EVENT_MOUSEWHEEL_MASK;
- break;
- }
- case FWL_EVTHASH_Key: {
- bRet = dwFilter & FWL_EVENT_KEY_MASK;
- break;
- }
- case FWL_EVTHASH_SetFocus:
- case FWL_EVTHASH_KillFocus: {
- bRet = dwFilter & FWL_EVENT_FOCUSCHANGED_MASK;
- break;
- }
- case FWL_EVTHASH_Draw: {
- bRet = dwFilter & FWL_EVENT_DRAW_MASK;
- break;
- }
- case FWL_EVTHASH_Close: {
- bRet = dwFilter & FWL_EVENT_CLOSE_MASK;
- break;
- }
- case FWL_EVTHASH_SizeChanged: {
- bRet = dwFilter & FWL_EVENT_SIZECHANGED_MASK;
- break;
- }
- case FWL_EVTHASH_Idle: {
- bRet = dwFilter & FWL_EVENT_IDLE_MASK;
- break;
- }
- default: {
- bRet = dwFilter & FWL_EVENT_CONTROL_MASK;
- break;
- }
- }
- return bRet;
+ }
+ return bRet;
}
CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = NULL;
CFWL_ToolTipContainer::CFWL_ToolTipContainer()
- : pCurTarget(NULL)
- , m_pToolTipImp(NULL)
-{
- m_ToolTipDp = FX_NEW CFWL_CoreToopTipDP;
- m_ToolTipDp->m_nInitDelayTime = 0;
- m_ToolTipDp->m_nAutoPopDelayTime = 2000;
-}
-CFWL_ToolTipContainer::~CFWL_ToolTipContainer()
-{
- if (m_pToolTipImp) {
- IFWL_ToolTip *pToolTip = (IFWL_ToolTip*)m_pToolTipImp->GetInterface();
- pToolTip->Finalize();
- pToolTip->Release();
- m_pToolTipImp = NULL;
- }
- if (m_ToolTipDp) {
- delete m_ToolTipDp;
- m_ToolTipDp = NULL;
- }
+ : pCurTarget(NULL), m_pToolTipImp(NULL) {
+ m_ToolTipDp = FX_NEW CFWL_CoreToopTipDP;
+ m_ToolTipDp->m_nInitDelayTime = 0;
+ m_ToolTipDp->m_nAutoPopDelayTime = 2000;
+}
+CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
+ if (m_pToolTipImp) {
+ IFWL_ToolTip* pToolTip = (IFWL_ToolTip*)m_pToolTipImp->GetInterface();
+ pToolTip->Finalize();
+ pToolTip->Release();
+ m_pToolTipImp = NULL;
+ }
+ if (m_ToolTipDp) {
+ delete m_ToolTipDp;
+ m_ToolTipDp = NULL;
+ }
}
// static
-CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance()
-{
- if (!s_pInstance) {
- s_pInstance = FX_NEW CFWL_ToolTipContainer;
- }
- return s_pInstance;
+CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() {
+ if (!s_pInstance) {
+ s_pInstance = FX_NEW CFWL_ToolTipContainer;
+ }
+ return s_pInstance;
}
// static
-void CFWL_ToolTipContainer::DeleteInstance()
-{
- if (s_pInstance) {
- delete s_pInstance;
- s_pInstance = NULL;
- }
+void CFWL_ToolTipContainer::DeleteInstance() {
+ if (s_pInstance) {
+ delete s_pInstance;
+ s_pInstance = NULL;
+ }
+}
+FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
+ if (m_arrWidget.Find((void*)pTarget) < 0) {
+ m_arrWidget.Add((void*)pTarget);
+ return FWL_ERR_Succeeded;
+ }
+ return FWL_ERR_Indefinite;
}
-FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget *pTarget)
-{
- if (m_arrWidget.Find((void *)pTarget) < 0) {
- m_arrWidget.Add((void *)pTarget);
- return FWL_ERR_Succeeded;
+FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) {
+ int index = m_arrWidget.Find((void*)pTarget);
+ if (index >= 0) {
+ m_arrWidget.RemoveAt(index);
+ return FWL_ERR_Succeeded;
+ }
+ return FWL_ERR_Indefinite;
+}
+FX_BOOL CFWL_ToolTipContainer::HasToolTip(IFWL_Widget* pWedget) {
+ int32_t iCount = m_arrWidget.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ IFWL_ToolTipTarget* p = (IFWL_ToolTipTarget*)m_arrWidget[i];
+ if (p->GetWidget() == pWedget) {
+ pCurTarget = p;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt,
+ IFWL_Widget* pOwner) {
+ if (HasToolTip(pEvt->m_pDstTarget)) {
+ if (NULL == m_pToolTipImp) {
+ CFWL_WidgetImpProperties prop;
+ prop.m_pDataProvider = m_ToolTipDp;
+ prop.m_pOwner = pOwner;
+ CFX_RectF rtTooltip;
+ rtTooltip.Set(150, 150, 100, 50);
+ prop.m_rtWidget = rtTooltip;
+ m_pToolTipImp = FX_NEW CFWL_ToolTipImp(prop);
+ IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create();
+ m_pToolTipImp->SetInterface(pToolTip);
+ ((IFWL_TargetData*)pToolTip)->SetData(m_pToolTipImp);
+ m_pToolTipImp->Initialize();
+ m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0);
+ m_pToolTipImp->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ }
+ if (pCurTarget->IsShowed()) {
+ CFX_WideString wsCaption;
+ pCurTarget->GetCaption(wsCaption);
+ if (!wsCaption.IsEmpty()) {
+ m_ToolTipDp->m_wsCaption = wsCaption;
+ }
+ CFX_RectF rt;
+ rt.Reset();
+ CFX_SizeF sz;
+ sz.Reset();
+ pCurTarget->GetToolTipSize(sz);
+ if (sz.x > 0 && sz.y > 0) {
+ rt.width = sz.x;
+ rt.height = sz.y;
+ } else {
+ CFX_RectF r;
+ m_pToolTipImp->GetWidgetRect(r, TRUE);
+ rt.width = r.width;
+ rt.height = r.height;
+ }
+ CFX_PointF pt;
+ pt.Set(pEvt->m_fx, pEvt->m_fy);
+ if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) {
+ rt.left = pt.x;
+ rt.top = pt.y;
+ m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0);
+ } else {
+ CFX_RectF rtAnchor;
+ pCurTarget->GetWidget()->GetClientRect(rtAnchor);
+ pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top);
+ m_pToolTipImp->SetAnchor(rtAnchor);
+ m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor);
+ }
+ m_pToolTipImp->SetWidgetRect(rt);
+ m_pToolTipImp->Update();
+ m_pToolTipImp->Show();
}
- return FWL_ERR_Indefinite;
+ return TRUE;
+ }
+ return FALSE;
}
-FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget *pTarget)
-{
- int index = m_arrWidget.Find((void *)pTarget);
- if (index >= 0) {
- m_arrWidget.RemoveAt(index);
- return FWL_ERR_Succeeded;
- }
- return FWL_ERR_Indefinite;
+FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) {
+ if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) {
+ m_pToolTipImp->Hide();
+ pCurTarget = NULL;
+ return TRUE;
+ }
+ return FALSE;
}
-FX_BOOL CFWL_ToolTipContainer::HasToolTip(IFWL_Widget *pWedget)
-{
- int32_t iCount = m_arrWidget.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- IFWL_ToolTipTarget *p = (IFWL_ToolTipTarget *)m_arrWidget[i];
- if (p->GetWidget() == pWedget) {
- pCurTarget = p;
- return TRUE;
- }
- }
- return FALSE;
+IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() {
+ return pCurTarget;
}
-FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse *pEvt, IFWL_Widget *pOwner)
-{
- if (HasToolTip(pEvt->m_pDstTarget)) {
- if (NULL == m_pToolTipImp) {
- CFWL_WidgetImpProperties prop;
- prop.m_pDataProvider = m_ToolTipDp;
- prop.m_pOwner = pOwner;
- CFX_RectF rtTooltip;
- rtTooltip.Set(150, 150, 100, 50);
- prop.m_rtWidget = rtTooltip;
- m_pToolTipImp = FX_NEW CFWL_ToolTipImp(prop);
- IFWL_ToolTip *pToolTip = IFWL_ToolTip::Create();
- m_pToolTipImp->SetInterface(pToolTip);
- ((IFWL_TargetData*)pToolTip)->SetData(m_pToolTipImp);
- m_pToolTipImp->Initialize();
- m_pToolTipImp->ModifyStylesEx( FWL_STYLEEXT_TTP_Multiline, 0);
- m_pToolTipImp->SetStates( FWL_WGTSTATE_Invisible, TRUE);
- }
- if (pCurTarget->IsShowed()) {
- CFX_WideString wsCaption;
- pCurTarget->GetCaption(wsCaption);
- if (!wsCaption.IsEmpty()) {
- m_ToolTipDp->m_wsCaption = wsCaption;
- }
- CFX_RectF rt;
- rt.Reset();
- CFX_SizeF sz;
- sz.Reset();
- pCurTarget->GetToolTipSize(sz);
- if (sz.x > 0 && sz.y > 0) {
- rt.width = sz.x;
- rt.height = sz.y;
- } else {
- CFX_RectF r;
- m_pToolTipImp->GetWidgetRect(r, TRUE);
- rt.width = r.width;
- rt.height = r.height;
- }
- CFX_PointF pt;
- pt.Set(pEvt->m_fx, pEvt->m_fy);
- if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) {
- rt.left = pt.x;
- rt.top = pt.y;
- m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0);
- } else {
- CFX_RectF rtAnchor;
- pCurTarget->GetWidget()->GetClientRect(rtAnchor);
- pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top);
- m_pToolTipImp->SetAnchor(rtAnchor);
- m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor);
- }
- m_pToolTipImp->SetWidgetRect(rt);
- m_pToolTipImp->Update();
- m_pToolTipImp->Show();
- }
- return TRUE;
- }
- return FALSE;
+FX_ERR CFWL_ToolTipContainer::SetToolTipInitialDelay(int32_t nDelayTime) {
+ m_ToolTipDp->m_nInitDelayTime = nDelayTime;
+ return FWL_ERR_Succeeded;
}
-FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse *pEvt)
-{
- if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) {
- m_pToolTipImp->Hide();
- pCurTarget = NULL;
- return TRUE;
- }
- return FALSE;
+FX_ERR CFWL_ToolTipContainer::SetToolTipAutoPopDelay(int32_t nDelayTime) {
+ m_ToolTipDp->m_nAutoPopDelayTime = nDelayTime;
+ return FWL_ERR_Succeeded;
}
-IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget()
-{
- return pCurTarget;
+FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
+ return CFWL_ToolTipContainer::getInstance()->AddToolTipTarget(pTarget);
}
-FX_ERR CFWL_ToolTipContainer::SetToolTipInitialDelay(int32_t nDelayTime)
-{
- m_ToolTipDp->m_nInitDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
+FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) {
+ return CFWL_ToolTipContainer::getInstance()->RemoveToolTipTarget(pTarget);
}
-FX_ERR CFWL_ToolTipContainer::SetToolTipAutoPopDelay(int32_t nDelayTime)
-{
- m_ToolTipDp->m_nAutoPopDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
+FWL_ERR FWL_SetToolTipInitialDelay(int32_t nDelayTime) {
+ return CFWL_ToolTipContainer::getInstance()->SetToolTipInitialDelay(
+ nDelayTime);
}
-FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget *pTarget)
-{
- return CFWL_ToolTipContainer::getInstance()->AddToolTipTarget(pTarget);
-}
-FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget *pTarget)
-{
- return CFWL_ToolTipContainer::getInstance()->RemoveToolTipTarget(pTarget);
-}
-FWL_ERR FWL_SetToolTipInitialDelay(int32_t nDelayTime)
-{
- return CFWL_ToolTipContainer::getInstance()->SetToolTipInitialDelay(nDelayTime);
-}
-FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t nDelayTime)
-{
- return CFWL_ToolTipContainer::getInstance()->SetToolTipAutoPopDelay(nDelayTime);
-}
-IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread *pNoteThread)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pNoteThread, NULL);
- CFWL_NoteDriver *noteDriver = (CFWL_NoteDriver*)pNoteThread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(noteDriver, NULL);
- if (noteDriver->CountLoop() == 1) {
- return NULL;
- }
- CFWL_NoteLoop *topLoop = noteDriver->GetTopLoop();
- _FWL_RETURN_VALUE_IF_FAIL(topLoop, NULL);
- CFWL_WidgetImp *widget = topLoop->GetForm();
- _FWL_RETURN_VALUE_IF_FAIL(widget, NULL);
- return widget->GetInterface();
-}
-FWL_ERR FWL_SetHook(IFWL_NoteDriver *driver, FWLMessageHookCallback callback, void* info)
-{
- CFWL_NoteDriver *noteDriver = (CFWL_NoteDriver*)driver;
- noteDriver->SetHook(callback, info);
- return FWL_ERR_Succeeded;
+FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t nDelayTime) {
+ return CFWL_ToolTipContainer::getInstance()->SetToolTipAutoPopDelay(
+ nDelayTime);
+}
+IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread* pNoteThread) {
+ _FWL_RETURN_VALUE_IF_FAIL(pNoteThread, NULL);
+ CFWL_NoteDriver* noteDriver = (CFWL_NoteDriver*)pNoteThread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(noteDriver, NULL);
+ if (noteDriver->CountLoop() == 1) {
+ return NULL;
+ }
+ CFWL_NoteLoop* topLoop = noteDriver->GetTopLoop();
+ _FWL_RETURN_VALUE_IF_FAIL(topLoop, NULL);
+ CFWL_WidgetImp* widget = topLoop->GetForm();
+ _FWL_RETURN_VALUE_IF_FAIL(widget, NULL);
+ return widget->GetInterface();
+}
+FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver,
+ FWLMessageHookCallback callback,
+ void* info) {
+ CFWL_NoteDriver* noteDriver = (CFWL_NoteDriver*)driver;
+ noteDriver->SetHook(callback, info);
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/core/fwl_panelimp.cpp b/xfa/src/fwl/src/core/fwl_panelimp.cpp index de66a33491..54da08d600 100644 --- a/xfa/src/fwl/src/core/fwl_panelimp.cpp +++ b/xfa/src/fwl/src/core/fwl_panelimp.cpp @@ -9,200 +9,164 @@ #include "include/fwl_noteimp.h"
#include "include/fwl_widgetimp.h"
#include "include/fwl_panelimp.h"
-IFWL_Panel* IFWL_Panel::Create()
-{
- return new IFWL_Panel;
-}
-FWL_ERR IFWL_Panel::Initialize(IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_PanelImp(pOuter);
- ((CFWL_PanelImp*)m_pData)->SetInterface(this);
- return ((CFWL_PanelImp*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Panel::Initialize(CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_PanelImp(properties, pOuter);
- ((CFWL_PanelImp*)m_pData)->SetInterface(this);
- return ((CFWL_PanelImp*)m_pData)->Initialize();
-}
-IFWL_Content* IFWL_Panel::GetContent()
-{
- return ((CFWL_PanelImp*)m_pData)->GetContent();
-}
-FWL_ERR IFWL_Panel::SetContent(IFWL_Content *pContent)
-{
- return ((CFWL_PanelImp*)m_pData)->SetContent(pContent);
-}
-IFWL_Panel::IFWL_Panel()
-{
- m_pData = NULL;
+IFWL_Panel* IFWL_Panel::Create() {
+ return new IFWL_Panel;
}
-IFWL_Panel::~IFWL_Panel()
-{
- if (m_pData) {
- delete (CFWL_PanelImp*)m_pData;
- m_pData = NULL;
- }
+FWL_ERR IFWL_Panel::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_PanelImp(pOuter);
+ ((CFWL_PanelImp*)m_pData)->SetInterface(this);
+ return ((CFWL_PanelImp*)m_pData)->Initialize();
}
-CFWL_PanelImp::CFWL_PanelImp(IFWL_Widget* pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_pContent(NULL)
-{
+FWL_ERR IFWL_Panel::Initialize(CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_PanelImp(properties, pOuter);
+ ((CFWL_PanelImp*)m_pData)->SetInterface(this);
+ return ((CFWL_PanelImp*)m_pData)->Initialize();
}
-CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_pContent(NULL)
-{
+IFWL_Content* IFWL_Panel::GetContent() {
+ return ((CFWL_PanelImp*)m_pData)->GetContent();
}
-CFWL_PanelImp::~CFWL_PanelImp()
-{
+FWL_ERR IFWL_Panel::SetContent(IFWL_Content* pContent) {
+ return ((CFWL_PanelImp*)m_pData)->SetContent(pContent);
}
-FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString &wsClass) const
-{
- wsClass = FWL_CLASS_Panel;
- return FWL_ERR_Succeeded;
+IFWL_Panel::IFWL_Panel() {
+ m_pData = NULL;
}
-FX_DWORD CFWL_PanelImp::GetClassID() const
-{
- return FWL_CLASSHASH_Panel;
-}
-FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- if (m_pContent) {
- m_pContent->GetWidgetRect(rect, TRUE);
- }
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PanelImp::Update()
-{
+IFWL_Panel::~IFWL_Panel() {
+ if (m_pData) {
+ delete (CFWL_PanelImp*)m_pData;
+ m_pData = NULL;
+ }
+}
+CFWL_PanelImp::CFWL_PanelImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter), m_pContent(NULL) {}
+CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter), m_pContent(NULL) {}
+CFWL_PanelImp::~CFWL_PanelImp() {}
+FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass = FWL_CLASS_Panel;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_PanelImp::GetClassID() const {
+ return FWL_CLASSHASH_Panel;
+}
+FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
if (m_pContent) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- FWL_GRIDUNIT eWidth = FWL_GRIDUNIT_Fixed, eHeight = FWL_GRIDUNIT_Fixed;
- IFWL_WidgetMgr *pWidgetMgr = FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
- IFWL_Widget *pParent = pWidgetMgr->GetWidget((IFWL_Widget*)this, FWL_WGTRELATION_Parent);
- if (pParent && pParent->GetClassID() == FWL_CLASSHASH_Grid) {
- IFWL_Grid* pGrid = (IFWL_Grid*)pParent;
- pGrid->GetWidgetSize((IFWL_Widget*)this, FWL_GRIDSIZE_Width, eWidth);
- pGrid->GetWidgetSize((IFWL_Widget*)this, FWL_GRIDSIZE_Height, eHeight);
- }
- if (eWidth != FWL_GRIDUNIT_Auto || eHeight != FWL_GRIDUNIT_Auto) {
- }
- m_pContent->SetWidgetRect(rtClient);
- m_pContent->Update();
+ m_pContent->GetWidgetRect(rect, TRUE);
+ }
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PanelImp::Update() {
+ if (m_pContent) {
+ CFX_RectF rtClient;
+ GetClientRect(rtClient);
+ FWL_GRIDUNIT eWidth = FWL_GRIDUNIT_Fixed, eHeight = FWL_GRIDUNIT_Fixed;
+ IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, FWL_ERR_Indefinite);
+ IFWL_Widget* pParent =
+ pWidgetMgr->GetWidget((IFWL_Widget*)this, FWL_WGTRELATION_Parent);
+ if (pParent && pParent->GetClassID() == FWL_CLASSHASH_Grid) {
+ IFWL_Grid* pGrid = (IFWL_Grid*)pParent;
+ pGrid->GetWidgetSize((IFWL_Widget*)this, FWL_GRIDSIZE_Width, eWidth);
+ pGrid->GetWidgetSize((IFWL_Widget*)this, FWL_GRIDSIZE_Height, eHeight);
+ }
+ if (eWidth != FWL_GRIDUNIT_Auto || eHeight != FWL_GRIDUNIT_Auto) {
}
+ m_pContent->SetWidgetRect(rtClient);
+ m_pContent->Update();
+ }
+ return FWL_ERR_Succeeded;
+}
+IFWL_Content* CFWL_PanelImp::GetContent() {
+ return m_pContent;
+}
+FWL_ERR CFWL_PanelImp::SetContent(IFWL_Content* pContent) {
+ _FWL_RETURN_VALUE_IF_FAIL(pContent, FWL_ERR_Indefinite);
+ m_pContent = pContent;
+ return pContent->SetParent(m_pInterface);
+}
+class CFWL_CustomPanelImp : public CFWL_WidgetImp {
+ public:
+ CFWL_CustomPanelImp(IFWL_Widget* pOuter = NULL);
+ CFWL_CustomPanelImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_CustomPanelImp();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual IFWL_Content* GetContent();
+ virtual FWL_ERR SetContent(IFWL_Content* pContent);
+ FWL_ERR SetProxy(IFWL_Proxy* pProxy);
+
+ protected:
+ IFWL_Content* m_pContent;
+ IFWL_Proxy* m_pProxy;
+};
+CFWL_CustomPanelImp::CFWL_CustomPanelImp(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter), m_pContent(NULL), m_pProxy(NULL) {}
+CFWL_CustomPanelImp::CFWL_CustomPanelImp(
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter), m_pContent(NULL), m_pProxy(NULL) {}
+CFWL_CustomPanelImp::~CFWL_CustomPanelImp() {}
+FWL_ERR CFWL_CustomPanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize && m_pProxy &&
+ (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
return FWL_ERR_Succeeded;
+ }
+ return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
}
-IFWL_Content* CFWL_PanelImp::GetContent()
-{
- return m_pContent;
-}
-FWL_ERR CFWL_PanelImp::SetContent(IFWL_Content *pContent)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pContent, FWL_ERR_Indefinite);
- m_pContent = pContent;
- return pContent->SetParent(m_pInterface);
-}
-class CFWL_CustomPanelImp : public CFWL_WidgetImp
-{
-public:
- CFWL_CustomPanelImp(IFWL_Widget *pOuter = NULL);
- CFWL_CustomPanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_CustomPanelImp();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual IFWL_Content* GetContent();
- virtual FWL_ERR SetContent(IFWL_Content *pContent);
- FWL_ERR SetProxy(IFWL_Proxy *pProxy);
-protected:
- IFWL_Content *m_pContent;
- IFWL_Proxy *m_pProxy;
-};
-CFWL_CustomPanelImp::CFWL_CustomPanelImp(IFWL_Widget* pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_pContent(NULL)
- , m_pProxy(NULL)
-{
-}
-CFWL_CustomPanelImp::CFWL_CustomPanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_pContent(NULL)
- , m_pProxy(NULL)
-{
-}
-CFWL_CustomPanelImp::~CFWL_CustomPanelImp()
-{
-}
-FWL_ERR CFWL_CustomPanelImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize && m_pProxy && (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
+FWL_ERR CFWL_CustomPanelImp::Update() {
+ if (m_pProxy) {
+ return m_pProxy->Update();
+ }
+ return CFWL_WidgetImp::Update();
}
-FWL_ERR CFWL_CustomPanelImp::Update()
-{
- if (m_pProxy) {
- return m_pProxy->Update();
- }
- return CFWL_WidgetImp::Update();
+IFWL_Content* CFWL_CustomPanelImp::GetContent() {
+ return m_pContent;
}
-IFWL_Content* CFWL_CustomPanelImp::GetContent()
-{
- return m_pContent;
+FWL_ERR CFWL_CustomPanelImp::SetContent(IFWL_Content* pContent) {
+ _FWL_RETURN_VALUE_IF_FAIL(pContent, FWL_ERR_Indefinite);
+ m_pContent = pContent;
+ return pContent->SetParent(m_pInterface);
}
-FWL_ERR CFWL_CustomPanelImp::SetContent(IFWL_Content *pContent)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pContent, FWL_ERR_Indefinite);
- m_pContent = pContent;
- return pContent->SetParent(m_pInterface);
+FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy* pProxy) {
+ m_pProxy = pProxy;
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy *pProxy)
-{
- m_pProxy = pProxy;
- return FWL_ERR_Succeeded;
+IFWL_CustomPanel* IFWL_CustomPanel::Create() {
+ return new IFWL_CustomPanel;
}
-IFWL_CustomPanel* IFWL_CustomPanel::Create()
-{
- return new IFWL_CustomPanel;
+FWL_ERR IFWL_CustomPanel::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CustomPanelImp(pOuter);
+ ((CFWL_CustomPanelImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CustomPanelImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_CustomPanel::Initialize(IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_CustomPanelImp(pOuter);
- ((CFWL_CustomPanelImp*)m_pData)->SetInterface(this);
- return ((CFWL_CustomPanelImp*)m_pData)->Initialize();
+FWL_ERR IFWL_CustomPanel::Initialize(CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_CustomPanelImp(properties, pOuter);
+ ((CFWL_CustomPanelImp*)m_pData)->SetInterface(this);
+ return ((CFWL_CustomPanelImp*)m_pData)->Initialize();
}
-FWL_ERR IFWL_CustomPanel::Initialize(CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_CustomPanelImp(properties, pOuter);
- ((CFWL_CustomPanelImp*)m_pData)->SetInterface(this);
- return ((CFWL_CustomPanelImp*)m_pData)->Initialize();
+IFWL_Content* IFWL_CustomPanel::GetContent() {
+ return ((CFWL_CustomPanelImp*)m_pData)->GetContent();
}
-IFWL_Content* IFWL_CustomPanel::GetContent()
-{
- return ((CFWL_CustomPanelImp*)m_pData)->GetContent();
+FWL_ERR IFWL_CustomPanel::SetContent(IFWL_Content* pContent) {
+ return ((CFWL_CustomPanelImp*)m_pData)->SetContent(pContent);
}
-FWL_ERR IFWL_CustomPanel::SetContent(IFWL_Content *pContent)
-{
- return ((CFWL_CustomPanelImp*)m_pData)->SetContent(pContent);
+FWL_ERR IFWL_CustomPanel::SetProxy(IFWL_Proxy* pProxy) {
+ return ((CFWL_CustomPanelImp*)m_pData)->SetProxy(pProxy);
}
-FWL_ERR IFWL_CustomPanel::SetProxy(IFWL_Proxy *pProxy)
-{
- return ((CFWL_CustomPanelImp*)m_pData)->SetProxy(pProxy);
+IFWL_CustomPanel::IFWL_CustomPanel() {
+ m_pData = NULL;
}
-IFWL_CustomPanel::IFWL_CustomPanel()
-{
+IFWL_CustomPanel::~IFWL_CustomPanel() {
+ if (m_pData) {
+ delete (CFWL_CustomPanelImp*)m_pData;
m_pData = NULL;
-}
-IFWL_CustomPanel::~IFWL_CustomPanel()
-{
- if (m_pData) {
- delete (CFWL_CustomPanelImp*)m_pData;
- m_pData = NULL;
- }
+ }
}
diff --git a/xfa/src/fwl/src/core/fwl_sdadapterimp.cpp b/xfa/src/fwl/src/core/fwl_sdadapterimp.cpp index bebad3c331..96776f2707 100644 --- a/xfa/src/fwl/src/core/fwl_sdadapterimp.cpp +++ b/xfa/src/fwl/src/core/fwl_sdadapterimp.cpp @@ -9,179 +9,160 @@ #include "include/fwl_threadimp.h"
#include "include/fwl_noteimp.h"
#include "include/fwl_widgetmgrimp.h"
-CFWL_SDAdapterWidgetMgr::CFWL_SDAdapterWidgetMgr()
-{
+CFWL_SDAdapterWidgetMgr::CFWL_SDAdapterWidgetMgr() {}
+CFWL_SDAdapterWidgetMgr::~CFWL_SDAdapterWidgetMgr() {}
+FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidget(IFWL_Widget* pWidget,
+ IFWL_Widget* pParent) {
+ return FWL_ERR_Succeeded;
}
-CFWL_SDAdapterWidgetMgr::~CFWL_SDAdapterWidgetMgr()
-{
+FWL_ERR CFWL_SDAdapterWidgetMgr::DestroyWidget(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidget(IFWL_Widget *pWidget, IFWL_Widget *pParent )
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetRect(IFWL_Widget* pWidget,
+ const CFX_RectF& rect) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::DestroyWidget(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetPosition(IFWL_Widget* pWidget,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetRect(IFWL_Widget *pWidget, const CFX_RectF &rect)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetParentWidget(IFWL_Widget* pWidget,
+ IFWL_Widget* pParent) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetPosition(IFWL_Widget *pWidget, FX_FLOAT fx, FX_FLOAT fy)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::ShowWidget(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetParentWidget(IFWL_Widget *pWidget, IFWL_Widget *pParent)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::HideWidget(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::ShowWidget(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetNormal(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::HideWidget(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetMaximize(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetNormal(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetMinimize(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMaximize(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::RunWidget(IFWL_Widget* pWidget) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMinimize(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RunWidget(IFWL_Widget *pWidget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::Exit(int32_t iExitCode) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RepaintWidget(IFWL_Widget *pWidget, const CFX_RectF *pRect)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidgetWithNativeId(IFWL_Widget* pWidget,
+ void* vp) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::Exit(int32_t iExitCode)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetRect(IFWL_Widget* pWidget,
+ CFX_RectF& rect) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidgetWithNativeId(IFWL_Widget *pWidget, void *vp)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetIcon(IFWL_Widget* pWidget,
+ const CFX_DIBitmap* pIcon,
+ FX_BOOL bBig) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetRect(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetCaption(
+ IFWL_Widget* pWidget,
+ const CFX_WideStringC& wsCaption) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetIcon(IFWL_Widget *pWidget, const CFX_DIBitmap *pIcon, FX_BOOL bBig)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetBorderRegion(IFWL_Widget* pWidget,
+ CFX_Path* pPath) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetCaption(IFWL_Widget *pWidget, const CFX_WideStringC& wsCaption)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetTransparent(IFWL_Widget* pWidget,
+ FX_DWORD dwAlpha) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetBorderRegion(IFWL_Widget *pWidget, CFX_Path *pPath)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetFullScreen(IFWL_Widget* pWidget,
+ FX_BOOL bFullScreen) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetTransparent(IFWL_Widget *pWidget, FX_DWORD dwAlpha)
-{
- return FWL_ERR_Succeeded;
+FX_BOOL CFWL_SDAdapterWidgetMgr::CheckMessage() {
+ return TRUE;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetFullScreen(IFWL_Widget *pWidget, FX_BOOL bFullScreen)
-{
- return FWL_ERR_Succeeded;
+FX_BOOL CFWL_SDAdapterWidgetMgr::IsIdleMessage() {
+ return TRUE;
}
-FX_BOOL CFWL_SDAdapterWidgetMgr::CheckMessage()
-{
- return TRUE;
+FWL_ERR CFWL_SDAdapterWidgetMgr::DispatchMessage() {
+ return FWL_ERR_Succeeded;
}
-FX_BOOL CFWL_SDAdapterWidgetMgr::IsIdleMessage()
-{
- return TRUE;
+FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetDC(IFWL_Widget* pWidget, void*& pDC) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::DispatchMessage()
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::ReleaseWidgetDC(IFWL_Widget* pWidget,
+ void* pDC,
+ CFX_RectF* pClip) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetDC(IFWL_Widget *pWidget, void* &pDC)
-{
- return FWL_ERR_Succeeded;
+void* CFWL_SDAdapterWidgetMgr::GetWindow(IFWL_Widget* pWidget) {
+ return NULL;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::ReleaseWidgetDC(IFWL_Widget *pWidget, void* pDC, CFX_RectF *pClip)
-{
- return FWL_ERR_Succeeded;
+FX_DWORD CFWL_SDAdapterWidgetMgr::GetKeyState(FX_DWORD dwVirtKey) {
+ return 0;
}
-void* CFWL_SDAdapterWidgetMgr::GetWindow(IFWL_Widget *pWidget)
-{
- return NULL;
+FWL_ERR CFWL_SDAdapterWidgetMgr::RunLoop(IFWL_Widget* widget) {
+ return FWL_ERR_Succeeded;
}
-FX_DWORD CFWL_SDAdapterWidgetMgr::GetKeyState(FX_DWORD dwVirtKey)
-{
- return 0;
+FWL_ERR CFWL_SDAdapterWidgetMgr::EndLoop() {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RunLoop(IFWL_Widget *widget)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::InitMenu(IFWL_Menu* pMenu,
+ IFWL_MenuDP* pMenuData) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::EndLoop()
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::UpdateMenu(IFWL_Menu* pMenu,
+ const void* hItem,
+ int32_t iType) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::InitMenu(IFWL_Menu *pMenu, IFWL_MenuDP *pMenuData)
-{
- return FWL_ERR_Succeeded;
+int32_t CFWL_SDAdapterWidgetMgr::TrackPopupMenu(IFWL_Menu* pMenu,
+ IFWL_MenuDP* pMenuData) {
+ return 0;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::UpdateMenu(IFWL_Menu *pMenu, const void* hItem, int32_t iType)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterWidgetMgr::SetMessageHook(IFWL_AdapterMessageHook* hook) {
+ return FWL_ERR_Succeeded;
}
-int32_t CFWL_SDAdapterWidgetMgr::TrackPopupMenu(IFWL_Menu *pMenu, IFWL_MenuDP *pMenuData)
-{
- return 0;
+FWL_ERR CFWL_SDAdapterWidgetMgr::GetSystemBorder(FX_FLOAT& l,
+ FX_FLOAT& t,
+ FX_FLOAT& r,
+ FX_FLOAT& b) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMessageHook(IFWL_AdapterMessageHook *hook)
-{
- return FWL_ERR_Succeeded;
+FX_BOOL CFWL_SDAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget,
+ FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetSystemBorder(FX_FLOAT &l, FX_FLOAT &t, FX_FLOAT &r, FX_FLOAT &b)
-{
- return FWL_ERR_Succeeded;
+CFWL_SDAdapterThreadMgr::CFWL_SDAdapterThreadMgr() {}
+CFWL_SDAdapterThreadMgr::~CFWL_SDAdapterThreadMgr() {}
+FWL_ERR CFWL_SDAdapterThreadMgr::Start(IFWL_Thread* pThread,
+ FWL_HTHREAD& hThread,
+ FX_BOOL bSuspended) {
+ return FWL_ERR_Succeeded;
}
-FX_BOOL CFWL_SDAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterThreadMgr::Resume(FWL_HTHREAD hThread) {
+ return FWL_ERR_Succeeded;
}
-CFWL_SDAdapterThreadMgr::CFWL_SDAdapterThreadMgr()
-{
+FWL_ERR CFWL_SDAdapterThreadMgr::Suspend(FWL_HTHREAD hThread) {
+ return FWL_ERR_Succeeded;
}
-CFWL_SDAdapterThreadMgr::~CFWL_SDAdapterThreadMgr()
-{
+FWL_ERR CFWL_SDAdapterThreadMgr::Kill(FWL_HTHREAD hThread, int32_t iExitCode) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterThreadMgr::Start(IFWL_Thread *pThread, FWL_HTHREAD &hThread, FX_BOOL bSuspended)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_SDAdapterThreadMgr::Stop(FWL_HTHREAD hThread, int32_t iExitCode) {
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SDAdapterThreadMgr::Resume(FWL_HTHREAD hThread)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Suspend(FWL_HTHREAD hThread)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Kill(FWL_HTHREAD hThread, int32_t iExitCode)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Stop(FWL_HTHREAD hThread, int32_t iExitCode)
-{
- return FWL_ERR_Succeeded;
-}
-IFWL_Thread* CFWL_SDAdapterThreadMgr::GetCurrentThread()
-{
- return FWL_GetApp();
+IFWL_Thread* CFWL_SDAdapterThreadMgr::GetCurrentThread() {
+ return FWL_GetApp();
}
diff --git a/xfa/src/fwl/src/core/fwl_targetimp.cpp b/xfa/src/fwl/src/core/fwl_targetimp.cpp index c6ffd27a22..cd9bf811a8 100644 --- a/xfa/src/fwl/src/core/fwl_targetimp.cpp +++ b/xfa/src/fwl/src/core/fwl_targetimp.cpp @@ -6,96 +6,71 @@ #include "../../../foxitlib.h"
#include "include/fwl_targetimp.h"
-FX_DWORD IFWL_Target::Release()
-{
- FX_DWORD dwRef = ((CFWL_Target*)m_pData)->Release();
- if (!dwRef) {
- m_pData = NULL;
- delete this;
- }
- return dwRef;
-}
-IFWL_Target* IFWL_Target::Retain()
-{
- return ((CFWL_Target*)m_pData)->Retain();
-}
-FX_DWORD IFWL_Target::GetRefCount() const
-{
- return ((CFWL_Target*)m_pData)->GetRefCount();
-}
-FWL_ERR IFWL_Target::GetClassName(CFX_WideString &wsClass) const
-{
- return ((CFWL_Target*)m_pData)->GetClassName(wsClass);
-}
-FX_DWORD IFWL_Target::GetClassID() const
-{
- return ((CFWL_Target*)m_pData)->GetClassID();
-}
-FX_BOOL IFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const
-{
- return ((CFWL_Target*)m_pData)->IsInstance(wsClass);
-}
-FWL_ERR IFWL_Target::Initialize()
-{
- return ((CFWL_Target*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Target::Finalize()
-{
- return ((CFWL_Target*)m_pData)->Finalize();
-}
-IFWL_Target::~IFWL_Target()
-{
-}
-CFWL_Target::CFWL_Target()
- : m_dwRefCount(1)
-{
-}
-CFWL_Target::~CFWL_Target()
-{
-}
-FX_DWORD CFWL_Target::Release()
-{
- m_dwRefCount--;
- FX_DWORD dwRet = m_dwRefCount;
- if (!m_dwRefCount) {
- delete this;
- }
- return dwRet;
-}
-IFWL_Target* CFWL_Target::Retain()
-{
- m_dwRefCount++;
- return (IFWL_Target*)this;
-}
-FX_DWORD CFWL_Target::GetRefCount() const
-{
- return m_dwRefCount;
-}
-FWL_ERR CFWL_Target::GetClassName(CFX_WideString &wsClass) const
-{
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_Target::GetClassID() const
-{
- return 0;
-}
-FX_BOOL CFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const
-{
- return FALSE;
-}
-FWL_ERR CFWL_Target::Initialize()
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_Target::Finalize()
-{
- return FWL_ERR_Succeeded;
-}
-void* IFWL_TargetData::GetData()
-{
- return m_pData;
-}
-void IFWL_TargetData::SetData(void* pData)
-{
- m_pData = pData;
+FX_DWORD IFWL_Target::Release() {
+ FX_DWORD dwRef = ((CFWL_Target*)m_pData)->Release();
+ if (!dwRef) {
+ m_pData = NULL;
+ delete this;
+ }
+ return dwRef;
+}
+IFWL_Target* IFWL_Target::Retain() {
+ return ((CFWL_Target*)m_pData)->Retain();
+}
+FX_DWORD IFWL_Target::GetRefCount() const {
+ return ((CFWL_Target*)m_pData)->GetRefCount();
+}
+FWL_ERR IFWL_Target::GetClassName(CFX_WideString& wsClass) const {
+ return ((CFWL_Target*)m_pData)->GetClassName(wsClass);
+}
+FX_DWORD IFWL_Target::GetClassID() const {
+ return ((CFWL_Target*)m_pData)->GetClassID();
+}
+FX_BOOL IFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const {
+ return ((CFWL_Target*)m_pData)->IsInstance(wsClass);
+}
+FWL_ERR IFWL_Target::Initialize() {
+ return ((CFWL_Target*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Target::Finalize() {
+ return ((CFWL_Target*)m_pData)->Finalize();
+}
+IFWL_Target::~IFWL_Target() {}
+CFWL_Target::CFWL_Target() : m_dwRefCount(1) {}
+CFWL_Target::~CFWL_Target() {}
+FX_DWORD CFWL_Target::Release() {
+ m_dwRefCount--;
+ FX_DWORD dwRet = m_dwRefCount;
+ if (!m_dwRefCount) {
+ delete this;
+ }
+ return dwRet;
+}
+IFWL_Target* CFWL_Target::Retain() {
+ m_dwRefCount++;
+ return (IFWL_Target*)this;
+}
+FX_DWORD CFWL_Target::GetRefCount() const {
+ return m_dwRefCount;
+}
+FWL_ERR CFWL_Target::GetClassName(CFX_WideString& wsClass) const {
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_Target::GetClassID() const {
+ return 0;
+}
+FX_BOOL CFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const {
+ return FALSE;
+}
+FWL_ERR CFWL_Target::Initialize() {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_Target::Finalize() {
+ return FWL_ERR_Succeeded;
+}
+void* IFWL_TargetData::GetData() {
+ return m_pData;
+}
+void IFWL_TargetData::SetData(void* pData) {
+ m_pData = pData;
}
diff --git a/xfa/src/fwl/src/core/fwl_threadimp.cpp b/xfa/src/fwl/src/core/fwl_threadimp.cpp index 7d9609a9cd..ca713346b8 100644 --- a/xfa/src/fwl/src/core/fwl_threadimp.cpp +++ b/xfa/src/fwl/src/core/fwl_threadimp.cpp @@ -9,150 +9,118 @@ #include "include/fwl_noteimp.h"
#include "include/fwl_threadimp.h"
#include "include/fwl_appimp.h"
-CFWL_ControlThread::~CFWL_ControlThread()
-{
-}
-FWL_ERR CFWL_ControlThread::Run(FWL_HTHREAD hThread)
-{
- static int count = 0;
- while (TRUE) {
- }
- return FWL_ERR_Succeeded;
-}
-IFWL_Thread * IFWL_Thread::Create()
-{
- return (IFWL_Thread *) FX_NEW CFWL_Thread;
-}
-CFWL_Thread::CFWL_Thread()
-{
-}
-CFWL_Thread::~CFWL_Thread()
-{
-}
-FWL_ERR CFWL_Thread::Run(FWL_HTHREAD hThread)
-{
- return FWL_ERR_Succeeded;
-}
-CFWL_ControlThread * CFWL_NoteThread::_assistantThreadHandler = NULL;
-FWL_HTHREAD CFWL_NoteThread::_assistantThread = NULL;
-int32_t CFWL_NoteThread::_refCount = 0;
-IFWL_NoteThread* IFWL_NoteThread::Create()
-{
- return (IFWL_NoteThread*) FX_NEW CFWL_NoteThread;
-}
-CFWL_NoteThread::CFWL_NoteThread()
- : m_hThread(NULL)
-{
- m_pNoteDriver = FX_NEW CFWL_NoteDriver;
-}
-CFWL_NoteThread::~CFWL_NoteThread()
-{
- if (m_hThread) {
- FWL_StopThread(m_hThread, 0);
- }
- if (m_pNoteDriver) {
- delete m_pNoteDriver;
- m_pNoteDriver = NULL;
- }
-}
-FWL_ERR CFWL_NoteThread::Run(FWL_HTHREAD hThread)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pNoteDriver, FWL_ERR_Indefinite);
- FWL_ERR result = m_pNoteDriver->Run();
- return result;
-}
-IFWL_NoteDriver* CFWL_NoteThread::GetNoteDriver()
-{
- return (IFWL_NoteDriver*)m_pNoteDriver;
+CFWL_ControlThread::~CFWL_ControlThread() {}
+FWL_ERR CFWL_ControlThread::Run(FWL_HTHREAD hThread) {
+ static int count = 0;
+ while (TRUE) {
+ }
+ return FWL_ERR_Succeeded;
+}
+IFWL_Thread* IFWL_Thread::Create() {
+ return (IFWL_Thread*)FX_NEW CFWL_Thread;
+}
+CFWL_Thread::CFWL_Thread() {}
+CFWL_Thread::~CFWL_Thread() {}
+FWL_ERR CFWL_Thread::Run(FWL_HTHREAD hThread) {
+ return FWL_ERR_Succeeded;
+}
+CFWL_ControlThread* CFWL_NoteThread::_assistantThreadHandler = NULL;
+FWL_HTHREAD CFWL_NoteThread::_assistantThread = NULL;
+int32_t CFWL_NoteThread::_refCount = 0;
+IFWL_NoteThread* IFWL_NoteThread::Create() {
+ return (IFWL_NoteThread*)FX_NEW CFWL_NoteThread;
+}
+CFWL_NoteThread::CFWL_NoteThread() : m_hThread(NULL) {
+ m_pNoteDriver = FX_NEW CFWL_NoteDriver;
+}
+CFWL_NoteThread::~CFWL_NoteThread() {
+ if (m_hThread) {
+ FWL_StopThread(m_hThread, 0);
+ }
+ if (m_pNoteDriver) {
+ delete m_pNoteDriver;
+ m_pNoteDriver = NULL;
+ }
+}
+FWL_ERR CFWL_NoteThread::Run(FWL_HTHREAD hThread) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pNoteDriver, FWL_ERR_Indefinite);
+ FWL_ERR result = m_pNoteDriver->Run();
+ return result;
+}
+IFWL_NoteDriver* CFWL_NoteThread::GetNoteDriver() {
+ return (IFWL_NoteDriver*)m_pNoteDriver;
}
extern IFWL_AdapterNative* FWL_GetAdapterNative();
-FWL_HTHREAD FWL_StartThread(IFWL_Thread *pThread, FX_BOOL bSuspended )
-{
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(pNative, NULL);
- IFWL_AdapterThreadMgr *pThreadMgr = pNative->GetThreadMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pThreadMgr, NULL);
- FWL_HTHREAD hThread = NULL;
- pThreadMgr->Start(pThread, hThread, bSuspended);
- return hThread;
-}
-FWL_ERR FWL_ResumeThread(FWL_HTHREAD hThread)
-{
- IFWL_AdapterNative * Native = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
- IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
- _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
- return ThreadMgr->Resume(hThread);
-}
-FWL_ERR FWL_SuspendThread(FWL_HTHREAD hThread)
-{
- IFWL_AdapterNative * Native = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
- IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
- _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
- return ThreadMgr->Suspend(hThread);
-}
-FWL_ERR FWL_KillThread(FWL_HTHREAD hThread, int32_t iExitCode)
-{
- IFWL_AdapterNative * Native = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
- IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
- _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
- return ThreadMgr->Kill(hThread, iExitCode);
-}
-FWL_ERR FWL_StopThread(FWL_HTHREAD hThread, int32_t iExitCode)
-{
- IFWL_AdapterNative * Native = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
- IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
- _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
- return ThreadMgr->Stop(hThread, iExitCode);
-}
-FWL_HMUTEX FWL_CreateMutex()
-{
- return NULL;
-}
-FWL_ERR FWL_DestroyMutex(FWL_HMUTEX hMutex)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR FWL_LockMutex(FWL_HMUTEX hMutex)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR FWL_TryLockMutex(FWL_HMUTEX hMutex)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR FWL_UnlockMutex(FWL_HMUTEX hMutex)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR FWL_IsLockedMutex(FWL_HMUTEX hMutex, FX_BOOL &bLocked)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_HSEMAPHORE FWL_CreateSemaphore()
-{
- return (FWL_HSEMAPHORE) IFWL_AdapterSemaphore::Create();
-}
-FWL_ERR FWL_DestroySemaphore(FWL_HSEMAPHORE hSemaphore)
-{
- return ((IFWL_AdapterSemaphore*)hSemaphore)->Destroy();
-}
-FWL_ERR FWL_WaitSemaphore(FWL_HSEMAPHORE hSemaphore)
-{
- return ((IFWL_AdapterSemaphore*)hSemaphore)->Wait();
-}
-FWL_ERR FWL_PostSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t down )
-{
- return ((IFWL_AdapterSemaphore*)hSemaphore)->Post();
-}
-FWL_ERR FWL_GetSemaphoreValue(FWL_HSEMAPHORE hSemaphore, int32_t &value)
-{
- return ((IFWL_AdapterSemaphore*)hSemaphore)->Value((FX_DWORD &)value);
-}
-FWL_ERR FWL_ResetSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t init)
-{
- return ((IFWL_AdapterSemaphore*)hSemaphore)->Reset(init);
+FWL_HTHREAD FWL_StartThread(IFWL_Thread* pThread, FX_BOOL bSuspended) {
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(pNative, NULL);
+ IFWL_AdapterThreadMgr* pThreadMgr = pNative->GetThreadMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pThreadMgr, NULL);
+ FWL_HTHREAD hThread = NULL;
+ pThreadMgr->Start(pThread, hThread, bSuspended);
+ return hThread;
+}
+FWL_ERR FWL_ResumeThread(FWL_HTHREAD hThread) {
+ IFWL_AdapterNative* Native = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
+ IFWL_AdapterThreadMgr* ThreadMgr = Native->GetThreadMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
+ return ThreadMgr->Resume(hThread);
+}
+FWL_ERR FWL_SuspendThread(FWL_HTHREAD hThread) {
+ IFWL_AdapterNative* Native = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
+ IFWL_AdapterThreadMgr* ThreadMgr = Native->GetThreadMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
+ return ThreadMgr->Suspend(hThread);
+}
+FWL_ERR FWL_KillThread(FWL_HTHREAD hThread, int32_t iExitCode) {
+ IFWL_AdapterNative* Native = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
+ IFWL_AdapterThreadMgr* ThreadMgr = Native->GetThreadMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
+ return ThreadMgr->Kill(hThread, iExitCode);
+}
+FWL_ERR FWL_StopThread(FWL_HTHREAD hThread, int32_t iExitCode) {
+ IFWL_AdapterNative* Native = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
+ IFWL_AdapterThreadMgr* ThreadMgr = Native->GetThreadMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
+ return ThreadMgr->Stop(hThread, iExitCode);
+}
+FWL_HMUTEX FWL_CreateMutex() {
+ return NULL;
+}
+FWL_ERR FWL_DestroyMutex(FWL_HMUTEX hMutex) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR FWL_LockMutex(FWL_HMUTEX hMutex) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR FWL_TryLockMutex(FWL_HMUTEX hMutex) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR FWL_UnlockMutex(FWL_HMUTEX hMutex) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR FWL_IsLockedMutex(FWL_HMUTEX hMutex, FX_BOOL& bLocked) {
+ return FWL_ERR_Succeeded;
+}
+FWL_HSEMAPHORE FWL_CreateSemaphore() {
+ return (FWL_HSEMAPHORE)IFWL_AdapterSemaphore::Create();
+}
+FWL_ERR FWL_DestroySemaphore(FWL_HSEMAPHORE hSemaphore) {
+ return ((IFWL_AdapterSemaphore*)hSemaphore)->Destroy();
+}
+FWL_ERR FWL_WaitSemaphore(FWL_HSEMAPHORE hSemaphore) {
+ return ((IFWL_AdapterSemaphore*)hSemaphore)->Wait();
+}
+FWL_ERR FWL_PostSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t down) {
+ return ((IFWL_AdapterSemaphore*)hSemaphore)->Post();
+}
+FWL_ERR FWL_GetSemaphoreValue(FWL_HSEMAPHORE hSemaphore, int32_t& value) {
+ return ((IFWL_AdapterSemaphore*)hSemaphore)->Value((FX_DWORD&)value);
+}
+FWL_ERR FWL_ResetSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t init) {
+ return ((IFWL_AdapterSemaphore*)hSemaphore)->Reset(init);
}
diff --git a/xfa/src/fwl/src/core/fwl_timerimp.cpp b/xfa/src/fwl/src/core/fwl_timerimp.cpp index 300ab5cefb..6430176526 100644 --- a/xfa/src/fwl/src/core/fwl_timerimp.cpp +++ b/xfa/src/fwl/src/core/fwl_timerimp.cpp @@ -8,21 +8,21 @@ #include "include/fwl_targetimp.h"
#include "include/fwl_threadimp.h"
#include "include/fwl_appimp.h"
-FWL_HTIMER FWL_StartTimer(IFWL_Timer *pTimer, FX_DWORD dwElapse, FX_BOOL bImmediately )
-{
- IFWL_AdapterNative *pAdapterNative = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(pAdapterNative, NULL);
- IFWL_AdapterTimerMgr *pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pAdapterTimerMgr, NULL);
- FWL_HTIMER hTimer = NULL;
- pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately);
- return hTimer;
+FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer,
+ FX_DWORD dwElapse,
+ FX_BOOL bImmediately) {
+ IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(pAdapterNative, NULL);
+ IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pAdapterTimerMgr, NULL);
+ FWL_HTIMER hTimer = NULL;
+ pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately);
+ return hTimer;
}
-int32_t FWL_StopTimer(FWL_HTIMER hTimer)
-{
- IFWL_AdapterNative *pAdapterNative = FWL_GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(pAdapterNative, FWL_ERR_Indefinite);
- IFWL_AdapterTimerMgr *pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pAdapterTimerMgr, FWL_ERR_Indefinite);
- return pAdapterTimerMgr->Stop(hTimer);
+int32_t FWL_StopTimer(FWL_HTIMER hTimer) {
+ IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(pAdapterNative, FWL_ERR_Indefinite);
+ IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pAdapterTimerMgr, FWL_ERR_Indefinite);
+ return pAdapterTimerMgr->Stop(hTimer);
}
diff --git a/xfa/src/fwl/src/core/fwl_widgetimp.cpp b/xfa/src/fwl/src/core/fwl_widgetimp.cpp index d966296f95..e901dae199 100644 --- a/xfa/src/fwl/src/core/fwl_widgetimp.cpp +++ b/xfa/src/fwl/src/core/fwl_widgetimp.cpp @@ -11,1207 +11,1151 @@ #include "include/fwl_appimp.h"
#include "include/fwl_widgetmgrimp.h"
#include "include/fwl_widgetimp.h"
-FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- return ((CFWL_WidgetImp*)m_pData)->GetWidgetRect(rect, bAutoSize);
+FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ return ((CFWL_WidgetImp*)m_pData)->GetWidgetRect(rect, bAutoSize);
}
-FWL_ERR IFWL_Widget::GetGlobalRect(CFX_RectF &rect)
-{
- return ((CFWL_WidgetImp*)m_pData)->GetGlobalRect(rect);
+FWL_ERR IFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
+ return ((CFWL_WidgetImp*)m_pData)->GetGlobalRect(rect);
}
-FWL_ERR IFWL_Widget::SetWidgetRect(const CFX_RectF &rect)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetWidgetRect(rect);
+FWL_ERR IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
+ return ((CFWL_WidgetImp*)m_pData)->SetWidgetRect(rect);
}
-FWL_ERR IFWL_Widget::GetClientRect(CFX_RectF &rect)
-{
- return ((CFWL_WidgetImp*)m_pData)->GetClientRect(rect);
+FWL_ERR IFWL_Widget::GetClientRect(CFX_RectF& rect) {
+ return ((CFWL_WidgetImp*)m_pData)->GetClientRect(rect);
}
-IFWL_Widget* IFWL_Widget::GetParent()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetParent();
+IFWL_Widget* IFWL_Widget::GetParent() {
+ return ((CFWL_WidgetImp*)m_pData)->GetParent();
}
-FWL_ERR IFWL_Widget::SetParent(IFWL_Widget *pParent)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetParent(pParent);
+FWL_ERR IFWL_Widget::SetParent(IFWL_Widget* pParent) {
+ return ((CFWL_WidgetImp*)m_pData)->SetParent(pParent);
}
-IFWL_Widget* IFWL_Widget::GetOwner()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetOwner();
+IFWL_Widget* IFWL_Widget::GetOwner() {
+ return ((CFWL_WidgetImp*)m_pData)->GetOwner();
}
-FWL_ERR IFWL_Widget::SetOwner(IFWL_Widget *pOwner)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetOwner(pOwner);
-}
-IFWL_Widget* IFWL_Widget::GetOuter()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetOuter();
-}
-FX_DWORD IFWL_Widget::GetStyles()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetStyles();
-}
-FWL_ERR IFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved)
-{
- return ((CFWL_WidgetImp*)m_pData)->ModifyStyles(dwStylesAdded, dwStylesRemoved);
-}
-FX_DWORD IFWL_Widget::GetStylesEx()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetStylesEx();
-}
-FWL_ERR IFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- return ((CFWL_WidgetImp*)m_pData)->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-FX_DWORD IFWL_Widget::GetStates()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetStates();
-}
-FWL_ERR IFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
- return ((CFWL_WidgetImp*)m_pData)->SetStates(dwStates, bSet);
-}
-FWL_ERR IFWL_Widget::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetPrivateData(module_id, pData, callback);
-}
-void* IFWL_Widget::GetPrivateData(void* module_id)
-{
- return ((CFWL_WidgetImp*)m_pData)->GetPrivateData(module_id);
-}
-FWL_ERR IFWL_Widget::Update()
-{
- return ((CFWL_WidgetImp*)m_pData)->Update();
-}
-FWL_ERR IFWL_Widget::LockUpdate()
-{
- return ((CFWL_WidgetImp*)m_pData)->LockUpdate();
-}
-FWL_ERR IFWL_Widget::UnlockUpdate()
-{
- return ((CFWL_WidgetImp*)m_pData)->UnlockUpdate();
-}
-FX_DWORD IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- return ((CFWL_WidgetImp*)m_pData)->HitTest(fx, fy);
-}
-FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy)
-{
- return ((CFWL_WidgetImp*)m_pData)->TransformTo(pWidget, fx, fy);
-}
-FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget *pWidget, CFX_RectF &rt)
-{
- return ((CFWL_WidgetImp*)m_pData)->TransformTo(pWidget, rt);
-}
-FWL_ERR IFWL_Widget::GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal )
-{
- return ((CFWL_WidgetImp*)m_pData)->GetMatrix(matrix, bGlobal);
-}
-FWL_ERR IFWL_Widget::SetMatrix(const CFX_Matrix &matrix)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetMatrix(matrix);
-}
-FWL_ERR IFWL_Widget::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return ((CFWL_WidgetImp*)m_pData)->DrawWidget(pGraphics, pMatrix);
-}
-IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider()
-{
- return ((CFWL_WidgetImp*)m_pData)->GetThemeProvider();
-}
-FWL_ERR IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider *pThemeProvider)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetThemeProvider(pThemeProvider);
-}
-FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider *pDataProvider)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetDataProvider(pDataProvider);
-}
-IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate *pDelegate)
-{
- return ((CFWL_WidgetImp*)m_pData)->SetDelegate(pDelegate);
-}
-IFWL_NoteThread* IFWL_Widget::GetOwnerThread() const
-{
- return ((CFWL_WidgetImp*)m_pData)->GetOwnerThread();
-}
-CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget *pParent)
-{
- return ((CFWL_WidgetImp*)m_pData)->GetOffsetFromParent(pParent);
-}
-FWL_ERR CFWL_WidgetImp::Initialize()
-{
- IFWL_App *pApp = FWL_GetApp();
- _FWL_RETURN_VALUE_IF_FAIL(pApp, FWL_ERR_Indefinite);
- IFWL_AdapterNative *pAdapter = pApp->GetAdapterNative();
- _FWL_RETURN_VALUE_IF_FAIL(pAdapter, FWL_ERR_Indefinite);
- IFWL_AdapterThreadMgr *pAdapterThread = pAdapter->GetThreadMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pAdapterThread, FWL_ERR_Indefinite);
- SetOwnerThread((CFWL_NoteThread*)pAdapterThread->GetCurrentThread());
- IFWL_Widget *pParent = m_pProperties->m_pParent;
- m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
- if (!IsChild()) {
- {
- IFWL_Widget *pOwner = m_pProperties->m_pOwner;
- if (pOwner) {
- m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
- }
- }
- m_pWidgetMgr->CreateWidget_Native(m_pInterface);
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::SetOwner(IFWL_Widget* pOwner) {
+ return ((CFWL_WidgetImp*)m_pData)->SetOwner(pOwner);
}
-FWL_ERR CFWL_WidgetImp::Finalize()
-{
- NotifyDriver();
- IFWL_Form *pForm = (IFWL_Form *)FWL_GetWidgetMgr()->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
- if (pForm && pForm != m_pInterface) {
- IFWL_Content *pContent = pForm->GetContent();
- if (pContent) {
- pContent->RemoveWidget(m_pInterface);
- }
- }
- if (!IsChild()) {
- m_pWidgetMgr->DestroyWidget_Native(m_pInterface);
- }
- m_pWidgetMgr->RemoveWidget(m_pInterface);
- return FWL_ERR_Succeeded;
+IFWL_Widget* IFWL_Widget::GetOuter() {
+ return ((CFWL_WidgetImp*)m_pData)->GetOuter();
}
-FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (bAutoSize) {
- if (HasEdge()) {
- FX_FLOAT fEdge = GetEdgeWidth();
- rect.Inflate(fEdge, fEdge);
- }
- if (HasBorder()) {
- FX_FLOAT fBorder = GetBorderSize();
- rect.Inflate(fBorder, fBorder);
- }
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
+FX_DWORD IFWL_Widget::GetStyles() {
+ return ((CFWL_WidgetImp*)m_pData)->GetStyles();
}
-FWL_ERR CFWL_WidgetImp::GetGlobalRect(CFX_RectF &rect)
-{
- IFWL_Widget *pForm = m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
- _FWL_RETURN_VALUE_IF_FAIL(pForm, FWL_ERR_Indefinite);
- rect.Set(0, 0, m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height);
- if (pForm == m_pInterface) {
- return FWL_ERR_Succeeded;
- }
- return TransformTo(pForm, rect);
-}
-FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF &rect)
-{
- CFX_RectF rtOld = m_pProperties->m_rtWidget;
- m_pProperties->m_rtWidget = rect;
- if (IsChild()) {
- if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || FXSYS_fabs(rtOld.height - rect.height) > 0.5f) {
- CFWL_EvtSizeChanged ev;
- ev.m_pSrcTarget = m_pInterface;
- ev.m_rtOld = rtOld;
- ev.m_rtNew = rect;
- IFWL_WidgetDelegate *pDelegate = SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessEvent(&ev);
- }
- }
- return FWL_ERR_Succeeded;
- }
- m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded,
+ FX_DWORD dwStylesRemoved) {
+ return ((CFWL_WidgetImp*)m_pData)
+ ->ModifyStyles(dwStylesAdded, dwStylesRemoved);
}
-FWL_ERR CFWL_WidgetImp::GetClientRect(CFX_RectF &rect)
-{
- GetEdgeRect(rect);
- if (HasEdge()) {
- FX_FLOAT fEdge = GetEdgeWidth();
- rect.Deflate(fEdge, fEdge);
- }
- return FWL_ERR_Succeeded;
+FX_DWORD IFWL_Widget::GetStylesEx() {
+ return ((CFWL_WidgetImp*)m_pData)->GetStylesEx();
}
-IFWL_Widget* CFWL_WidgetImp::GetParent()
-{
- return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent);
+FWL_ERR IFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ return ((CFWL_WidgetImp*)m_pData)
+ ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
-FWL_ERR CFWL_WidgetImp::SetParent(IFWL_Widget* pParent)
-{
- m_pProperties->m_pParent = pParent;
- m_pWidgetMgr->SetParent(pParent, m_pInterface);
- return FWL_ERR_Succeeded;
+FX_DWORD IFWL_Widget::GetStates() {
+ return ((CFWL_WidgetImp*)m_pData)->GetStates();
}
-IFWL_Widget* CFWL_WidgetImp::GetOwner()
-{
- return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner);
+FWL_ERR IFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ return ((CFWL_WidgetImp*)m_pData)->SetStates(dwStates, bSet);
}
-FWL_ERR CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner)
-{
- m_pProperties->m_pOwner = pOwner;
- m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback) {
+ return ((CFWL_WidgetImp*)m_pData)->SetPrivateData(module_id, pData, callback);
}
-IFWL_Widget* CFWL_WidgetImp::GetOuter()
-{
- return m_pOuter;
+void* IFWL_Widget::GetPrivateData(void* module_id) {
+ return ((CFWL_WidgetImp*)m_pData)->GetPrivateData(module_id);
}
-FX_DWORD CFWL_WidgetImp::GetStyles()
-{
- return m_pProperties->m_dwStyles;
+FWL_ERR IFWL_Widget::Update() {
+ return ((CFWL_WidgetImp*)m_pData)->Update();
}
-FWL_ERR CFWL_WidgetImp::ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved)
-{
- m_pProperties->m_dwStyles = (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded;
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::LockUpdate() {
+ return ((CFWL_WidgetImp*)m_pData)->LockUpdate();
}
-FX_DWORD CFWL_WidgetImp::GetStylesEx()
-{
- return m_pProperties->m_dwStyleExes;
+FWL_ERR IFWL_Widget::UnlockUpdate() {
+ return ((CFWL_WidgetImp*)m_pData)->UnlockUpdate();
}
-FWL_ERR CFWL_WidgetImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- m_pProperties->m_dwStyleExes = (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded;
- return FWL_ERR_Succeeded;
+FX_DWORD IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ return ((CFWL_WidgetImp*)m_pData)->HitTest(fx, fy);
}
-FX_DWORD CFWL_WidgetImp::GetStates()
-{
- return m_pProperties->m_dwStates;
+FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy) {
+ return ((CFWL_WidgetImp*)m_pData)->TransformTo(pWidget, fx, fy);
}
-static void NotifyHideChildWidget(IFWL_WidgetMgr *widgetMgr, IFWL_Widget *widget, CFWL_NoteDriver *noteDriver)
-{
- IFWL_Widget *child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
- while (child) {
- noteDriver->NotifyTargetHide(child);
- NotifyHideChildWidget(widgetMgr, child, noteDriver);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
+FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
+ return ((CFWL_WidgetImp*)m_pData)->TransformTo(pWidget, rt);
}
-FWL_ERR CFWL_WidgetImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
- bSet ? (m_pProperties->m_dwStates |= dwStates) : (m_pProperties->m_dwStates &= ~dwStates);
- FWL_ERR ret = FWL_ERR_Succeeded;
- if (dwStates & FWL_WGTSTATE_Invisible) {
- if (bSet) {
- ret = m_pWidgetMgr->HideWidget_Native(m_pInterface);
- CFWL_NoteDriver *noteDriver = (CFWL_NoteDriver*)GetOwnerThread()->GetNoteDriver();
- IFWL_WidgetMgr *widgetMgr = FWL_GetWidgetMgr();
- noteDriver->NotifyTargetHide(m_pInterface);
- IFWL_Widget *child = widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild);
- while (child) {
- noteDriver->NotifyTargetHide(child);
- NotifyHideChildWidget(widgetMgr, child, noteDriver);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- } else {
- ret = m_pWidgetMgr->ShowWidget_Native(m_pInterface);
- }
- }
- return ret;
+FWL_ERR IFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
+ return ((CFWL_WidgetImp*)m_pData)->GetMatrix(matrix, bGlobal);
}
-FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback)
-{
- if (!m_pPrivateData) {
- m_pPrivateData = new CFX_PrivateData;
- }
- m_pPrivateData->SetPrivateData(module_id, pData, callback);
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
+ return ((CFWL_WidgetImp*)m_pData)->SetMatrix(matrix);
}
-void* CFWL_WidgetImp::GetPrivateData(void* module_id)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pPrivateData, NULL);
- return m_pPrivateData->GetPrivateData(module_id);
+FWL_ERR IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return ((CFWL_WidgetImp*)m_pData)->DrawWidget(pGraphics, pMatrix);
}
-FWL_ERR CFWL_WidgetImp::Update()
-{
- return FWL_ERR_Succeeded;
+IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() {
+ return ((CFWL_WidgetImp*)m_pData)->GetThemeProvider();
}
-FWL_ERR CFWL_WidgetImp::LockUpdate()
-{
- m_iLock++;
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ return ((CFWL_WidgetImp*)m_pData)->SetThemeProvider(pThemeProvider);
}
-FWL_ERR CFWL_WidgetImp::UnlockUpdate()
-{
- if (IsLocked()) {
- m_iLock--;
- }
- return FWL_ERR_Succeeded;
+FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) {
+ return ((CFWL_WidgetImp*)m_pData)->SetDataProvider(pDataProvider);
+}
+IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
+ return ((CFWL_WidgetImp*)m_pData)->SetDelegate(pDelegate);
+}
+IFWL_NoteThread* IFWL_Widget::GetOwnerThread() const {
+ return ((CFWL_WidgetImp*)m_pData)->GetOwnerThread();
+}
+CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
+ return ((CFWL_WidgetImp*)m_pData)->GetOffsetFromParent(pParent);
}
-FX_DWORD CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- if (rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
+FWL_ERR CFWL_WidgetImp::Initialize() {
+ IFWL_App* pApp = FWL_GetApp();
+ _FWL_RETURN_VALUE_IF_FAIL(pApp, FWL_ERR_Indefinite);
+ IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative();
+ _FWL_RETURN_VALUE_IF_FAIL(pAdapter, FWL_ERR_Indefinite);
+ IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pAdapterThread, FWL_ERR_Indefinite);
+ SetOwnerThread((CFWL_NoteThread*)pAdapterThread->GetCurrentThread());
+ IFWL_Widget* pParent = m_pProperties->m_pParent;
+ m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
+ if (!IsChild()) {
+ {
+ IFWL_Widget* pOwner = m_pProperties->m_pOwner;
+ if (pOwner) {
+ m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
+ }
}
+ m_pWidgetMgr->CreateWidget_Native(m_pInterface);
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::Finalize() {
+ NotifyDriver();
+ IFWL_Form* pForm = (IFWL_Form*)FWL_GetWidgetMgr()->GetWidget(
+ m_pInterface, FWL_WGTRELATION_SystemForm);
+ if (pForm && pForm != m_pInterface) {
+ IFWL_Content* pContent = pForm->GetContent();
+ if (pContent) {
+ pContent->RemoveWidget(m_pInterface);
+ }
+ }
+ if (!IsChild()) {
+ m_pWidgetMgr->DestroyWidget_Native(m_pInterface);
+ }
+ m_pWidgetMgr->RemoveWidget(m_pInterface);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (bAutoSize) {
if (HasEdge()) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edge;
- }
+ FX_FLOAT fEdge = GetEdgeWidth();
+ rect.Inflate(fEdge, fEdge);
}
if (HasBorder()) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- if (rtRelative.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Border;
- }
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- CFX_SizeF szOffset;
- if (IsParent(pWidget)) {
- szOffset = GetOffsetFromParent(pWidget);
- } else {
- szOffset = ((IFWL_Widget*)pWidget)->GetOffsetFromParent(m_pInterface);
- szOffset.x = -szOffset.x;
- szOffset.y = -szOffset.y;
- }
- fx += szOffset.x;
- fy += szOffset.y;
- return FWL_ERR_Succeeded;
+ FX_FLOAT fBorder = GetBorderSize();
+ rect.Inflate(fBorder, fBorder);
}
- CFX_RectF r;
- CFX_Matrix m;
- IFWL_Widget * parent = GetParent();
- if (parent) {
- GetWidgetRect(r);
- fx += r.left;
- fy += r.top;
- GetMatrix(m, TRUE);
- m.TransformPoint(fx, fy);
+ } else {
+ rect = m_pProperties->m_rtWidget;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) {
+ IFWL_Widget* pForm =
+ m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
+ _FWL_RETURN_VALUE_IF_FAIL(pForm, FWL_ERR_Indefinite);
+ rect.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ if (pForm == m_pInterface) {
+ return FWL_ERR_Succeeded;
+ }
+ return TransformTo(pForm, rect);
+}
+FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) {
+ CFX_RectF rtOld = m_pProperties->m_rtWidget;
+ m_pProperties->m_rtWidget = rect;
+ if (IsChild()) {
+ if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f ||
+ FXSYS_fabs(rtOld.height - rect.height) > 0.5f) {
+ CFWL_EvtSizeChanged ev;
+ ev.m_pSrcTarget = m_pInterface;
+ ev.m_rtOld = rtOld;
+ ev.m_rtNew = rect;
+ IFWL_WidgetDelegate* pDelegate = SetDelegate(NULL);
+ if (pDelegate) {
+ pDelegate->OnProcessEvent(&ev);
+ }
}
- IFWL_Widget * form1 = m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
- _FWL_RETURN_VALUE_IF_FAIL(form1, FWL_ERR_Indefinite);
- if (!pWidget) {
- form1->GetWidgetRect(r);
- fx += r.left;
- fy += r.top;
-#ifdef FWL_UseMacSystemBorder
- if (form1->GetStyles() & FWL_WGTSTYLE_Caption) {
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
- fy += t;
- }
-#endif
- return FWL_ERR_Succeeded;
+ return FWL_ERR_Succeeded;
+ }
+ m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) {
+ GetEdgeRect(rect);
+ if (HasEdge()) {
+ FX_FLOAT fEdge = GetEdgeWidth();
+ rect.Deflate(fEdge, fEdge);
+ }
+ return FWL_ERR_Succeeded;
+}
+IFWL_Widget* CFWL_WidgetImp::GetParent() {
+ return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent);
+}
+FWL_ERR CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) {
+ m_pProperties->m_pParent = pParent;
+ m_pWidgetMgr->SetParent(pParent, m_pInterface);
+ return FWL_ERR_Succeeded;
+}
+IFWL_Widget* CFWL_WidgetImp::GetOwner() {
+ return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner);
+}
+FWL_ERR CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) {
+ m_pProperties->m_pOwner = pOwner;
+ m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
+ return FWL_ERR_Succeeded;
+}
+IFWL_Widget* CFWL_WidgetImp::GetOuter() {
+ return m_pOuter;
+}
+FX_DWORD CFWL_WidgetImp::GetStyles() {
+ return m_pProperties->m_dwStyles;
+}
+FWL_ERR CFWL_WidgetImp::ModifyStyles(FX_DWORD dwStylesAdded,
+ FX_DWORD dwStylesRemoved) {
+ m_pProperties->m_dwStyles =
+ (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_WidgetImp::GetStylesEx() {
+ return m_pProperties->m_dwStyleExes;
+}
+FWL_ERR CFWL_WidgetImp::ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ m_pProperties->m_dwStyleExes =
+ (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_WidgetImp::GetStates() {
+ return m_pProperties->m_dwStates;
+}
+static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr,
+ IFWL_Widget* widget,
+ CFWL_NoteDriver* noteDriver) {
+ IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ noteDriver->NotifyTargetHide(child);
+ NotifyHideChildWidget(widgetMgr, child, noteDriver);
+ child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
+}
+FWL_ERR CFWL_WidgetImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ bSet ? (m_pProperties->m_dwStates |= dwStates)
+ : (m_pProperties->m_dwStates &= ~dwStates);
+ FWL_ERR ret = FWL_ERR_Succeeded;
+ if (dwStates & FWL_WGTSTATE_Invisible) {
+ if (bSet) {
+ ret = m_pWidgetMgr->HideWidget_Native(m_pInterface);
+ CFWL_NoteDriver* noteDriver =
+ (CFWL_NoteDriver*)GetOwnerThread()->GetNoteDriver();
+ IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
+ noteDriver->NotifyTargetHide(m_pInterface);
+ IFWL_Widget* child =
+ widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ noteDriver->NotifyTargetHide(child);
+ NotifyHideChildWidget(widgetMgr, child, noteDriver);
+ child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
+ } else {
+ ret = m_pWidgetMgr->ShowWidget_Native(m_pInterface);
}
- IFWL_Widget * form2 = m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
- _FWL_RETURN_VALUE_IF_FAIL(form2, FWL_ERR_Indefinite);
- if (form1 != form2) {
- form1->GetWidgetRect(r);
- fx += r.left;
- fy += r.top;
- form2->GetWidgetRect(r);
- fx -= r.left;
- fy -= r.top;
-#ifdef FWL_UseMacSystemBorder
- if ((form1->GetStyles() & FWL_WGTSTYLE_Caption) != (form2->GetStyles() & FWL_WGTSTYLE_Caption)) {
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
- (form1->GetStyles() & FWL_WGTSTYLE_Caption) ? (fy += t) : (fy -= t);
- }
-#endif
+ }
+ return ret;
+}
+FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback) {
+ if (!m_pPrivateData) {
+ m_pPrivateData = new CFX_PrivateData;
+ }
+ m_pPrivateData->SetPrivateData(module_id, pData, callback);
+ return FWL_ERR_Succeeded;
+}
+void* CFWL_WidgetImp::GetPrivateData(void* module_id) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pPrivateData, NULL);
+ return m_pPrivateData->GetPrivateData(module_id);
+}
+FWL_ERR CFWL_WidgetImp::Update() {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::LockUpdate() {
+ m_iLock++;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::UnlockUpdate() {
+ if (IsLocked()) {
+ m_iLock--;
+ }
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ CFX_RectF rtClient;
+ GetClientRect(rtClient);
+ if (rtClient.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Client;
+ }
+ if (HasEdge()) {
+ CFX_RectF rtEdge;
+ GetEdgeRect(rtEdge);
+ if (rtEdge.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Edge;
}
- parent = pWidget->GetParent();
- if (parent) {
- pWidget->GetMatrix(m, TRUE);
- CFX_Matrix m1;
- m1.Reset();
- m1.SetReverse(m);
- m1.TransformPoint(fx, fy);
- pWidget->GetWidgetRect(r);
- fx -= r.left;
- fy -= r.top;
+ }
+ if (HasBorder()) {
+ CFX_RectF rtRelative;
+ GetRelativeRect(rtRelative);
+ if (rtRelative.Contains(fx, fy)) {
+ return FWL_WGTHITTEST_Border;
}
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget *pWidget, CFX_RectF &rt)
-{
- return TransformTo(pWidget, rt.left, rt.top);
-}
-FWL_ERR CFWL_WidgetImp::GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties, FWL_ERR_Indefinite);
- if (bGlobal) {
- IFWL_Widget * parent = GetParent();
- CFX_PtrArray parents;
- while (parent) {
- parents.Add(parent);
- parent = parent->GetParent();
- }
- matrix.Reset();
- CFX_Matrix ctmOnParent;
- CFX_RectF rect;
- int32_t count = parents.GetSize();
- for (int32_t i = count - 2; i >= 0; i--) {
- parent = (IFWL_Widget *) parents.GetAt(i);
- parent->GetMatrix(ctmOnParent, FALSE);
- parent->GetWidgetRect(rect);
- matrix.Concat(ctmOnParent, TRUE);
- matrix.Translate(rect.left, rect.top, TRUE);
- }
- matrix.Concat(m_pProperties->m_ctmOnParent, TRUE);
- parents.RemoveAll();
+ }
+ return FWL_WGTHITTEST_Unknown;
+}
+FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ CFX_SizeF szOffset;
+ if (IsParent(pWidget)) {
+ szOffset = GetOffsetFromParent(pWidget);
} else {
- matrix = m_pProperties->m_ctmOnParent;
+ szOffset = ((IFWL_Widget*)pWidget)->GetOffsetFromParent(m_pInterface);
+ szOffset.x = -szOffset.x;
+ szOffset.y = -szOffset.y;
}
+ fx += szOffset.x;
+ fy += szOffset.y;
return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::SetMatrix(const CFX_Matrix &matrix)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pProperties, FWL_ERR_Indefinite);
- IFWL_Widget * parent = GetParent();
- if (!parent) {
- return FWL_ERR_Indefinite;
+ }
+ CFX_RectF r;
+ CFX_Matrix m;
+ IFWL_Widget* parent = GetParent();
+ if (parent) {
+ GetWidgetRect(r);
+ fx += r.left;
+ fy += r.top;
+ GetMatrix(m, TRUE);
+ m.TransformPoint(fx, fy);
+ }
+ IFWL_Widget* form1 =
+ m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
+ _FWL_RETURN_VALUE_IF_FAIL(form1, FWL_ERR_Indefinite);
+ if (!pWidget) {
+ form1->GetWidgetRect(r);
+ fx += r.left;
+ fy += r.top;
+#ifdef FWL_UseMacSystemBorder
+ if (form1->GetStyles() & FWL_WGTSTYLE_Caption) {
+ FX_FLOAT l, t, r, b;
+ l = t = r = b = 0;
+ FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
+ fy += t;
}
- m_pProperties->m_ctmOnParent = matrix;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return FWL_ERR_Indefinite;
-}
-IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider()
-{
- return m_pProperties->m_pThemeProvider;
-}
-FWL_ERR CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider *pThemeProvider)
-{
- m_pProperties->m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider *pDataProvider)
-{
- m_pProperties->m_pDataProvider = pDataProvider;
+#endif
return FWL_ERR_Succeeded;
-}
-IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate(IFWL_WidgetDelegate *pDelegate)
-{
- if (!m_pCurDelegate) {
- m_pCurDelegate = m_pDelegate;
+ }
+ IFWL_Widget* form2 =
+ m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
+ _FWL_RETURN_VALUE_IF_FAIL(form2, FWL_ERR_Indefinite);
+ if (form1 != form2) {
+ form1->GetWidgetRect(r);
+ fx += r.left;
+ fy += r.top;
+ form2->GetWidgetRect(r);
+ fx -= r.left;
+ fy -= r.top;
+#ifdef FWL_UseMacSystemBorder
+ if ((form1->GetStyles() & FWL_WGTSTYLE_Caption) !=
+ (form2->GetStyles() & FWL_WGTSTYLE_Caption)) {
+ FX_FLOAT l, t, r, b;
+ l = t = r = b = 0;
+ FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
+ (form1->GetStyles() & FWL_WGTSTYLE_Caption) ? (fy += t) : (fy -= t);
}
- if (!pDelegate) {
- return m_pCurDelegate;
+#endif
+ }
+ parent = pWidget->GetParent();
+ if (parent) {
+ pWidget->GetMatrix(m, TRUE);
+ CFX_Matrix m1;
+ m1.Reset();
+ m1.SetReverse(m);
+ m1.TransformPoint(fx, fy);
+ pWidget->GetWidgetRect(r);
+ fx -= r.left;
+ fy -= r.top;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
+ return TransformTo(pWidget, rt.left, rt.top);
+}
+FWL_ERR CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties, FWL_ERR_Indefinite);
+ if (bGlobal) {
+ IFWL_Widget* parent = GetParent();
+ CFX_PtrArray parents;
+ while (parent) {
+ parents.Add(parent);
+ parent = parent->GetParent();
}
- IFWL_WidgetDelegate *pOldDelegate = m_pCurDelegate;
- m_pCurDelegate = pDelegate;
- return pOldDelegate;
-}
-IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const
-{
- return (IFWL_NoteThread*)m_pOwnerThread;
-}
-FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThread *pOwnerThread)
-{
- m_pOwnerThread = pOwnerThread;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::GetProperties(CFWL_WidgetImpProperties &properties)
-{
- properties = *m_pProperties;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::SetProperties(const CFWL_WidgetImpProperties &properties)
-{
- *m_pProperties = properties;
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_WidgetImp::GetInterface()
-{
- return m_pInterface;
-}
-void CFWL_WidgetImp::SetInterface(IFWL_Widget *pInterface)
-{
- m_pInterface = pInterface;
-}
-CFWL_WidgetImp::CFWL_WidgetImp(IFWL_Widget *pOuter )
- : m_pProperties(NULL)
- , m_pPrivateData(NULL)
- , m_pDelegate(NULL)
- , m_pCurDelegate(NULL)
- , m_pOuter(pOuter)
- , m_pInterface(NULL)
- , m_iLock(0)
-{
- m_pProperties = FX_NEW CFWL_WidgetImpProperties;
- m_pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- FXSYS_assert(m_pWidgetMgr != NULL);
-}
-CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : m_pProperties(NULL)
- , m_pPrivateData(NULL)
- , m_pDelegate(NULL)
- , m_pCurDelegate(NULL)
- , m_pOuter(pOuter)
- , m_pInterface(NULL)
- , m_iLock(0)
-{
- if (!m_pProperties) {
- m_pProperties = FX_NEW CFWL_WidgetImpProperties;
+ matrix.Reset();
+ CFX_Matrix ctmOnParent;
+ CFX_RectF rect;
+ int32_t count = parents.GetSize();
+ for (int32_t i = count - 2; i >= 0; i--) {
+ parent = (IFWL_Widget*)parents.GetAt(i);
+ parent->GetMatrix(ctmOnParent, FALSE);
+ parent->GetWidgetRect(rect);
+ matrix.Concat(ctmOnParent, TRUE);
+ matrix.Translate(rect.left, rect.top, TRUE);
}
- *m_pProperties = properties;
- m_pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- FXSYS_assert(m_pWidgetMgr != NULL);
-}
-CFWL_WidgetImp::~CFWL_WidgetImp()
-{
- if (m_pPrivateData) {
- delete m_pPrivateData;
- m_pPrivateData = NULL;
+ matrix.Concat(m_pProperties->m_ctmOnParent, TRUE);
+ parents.RemoveAll();
+ } else {
+ matrix = m_pProperties->m_ctmOnParent;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pProperties, FWL_ERR_Indefinite);
+ IFWL_Widget* parent = GetParent();
+ if (!parent) {
+ return FWL_ERR_Indefinite;
+ }
+ m_pProperties->m_ctmOnParent = matrix;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return FWL_ERR_Indefinite;
+}
+IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider() {
+ return m_pProperties->m_pThemeProvider;
+}
+FWL_ERR CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ m_pProperties->m_pThemeProvider = pThemeProvider;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider* pDataProvider) {
+ m_pProperties->m_pDataProvider = pDataProvider;
+ return FWL_ERR_Succeeded;
+}
+IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate(
+ IFWL_WidgetDelegate* pDelegate) {
+ if (!m_pCurDelegate) {
+ m_pCurDelegate = m_pDelegate;
+ }
+ if (!pDelegate) {
+ return m_pCurDelegate;
+ }
+ IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate;
+ m_pCurDelegate = pDelegate;
+ return pOldDelegate;
+}
+IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const {
+ return (IFWL_NoteThread*)m_pOwnerThread;
+}
+FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThread* pOwnerThread) {
+ m_pOwnerThread = pOwnerThread;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::GetProperties(CFWL_WidgetImpProperties& properties) {
+ properties = *m_pProperties;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImp::SetProperties(
+ const CFWL_WidgetImpProperties& properties) {
+ *m_pProperties = properties;
+ return FWL_ERR_Succeeded;
+}
+IFWL_Widget* CFWL_WidgetImp::GetInterface() {
+ return m_pInterface;
+}
+void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) {
+ m_pInterface = pInterface;
+}
+CFWL_WidgetImp::CFWL_WidgetImp(IFWL_Widget* pOuter)
+ : m_pProperties(NULL),
+ m_pPrivateData(NULL),
+ m_pDelegate(NULL),
+ m_pCurDelegate(NULL),
+ m_pOuter(pOuter),
+ m_pInterface(NULL),
+ m_iLock(0) {
+ m_pProperties = FX_NEW CFWL_WidgetImpProperties;
+ m_pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ FXSYS_assert(m_pWidgetMgr != NULL);
+}
+CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : m_pProperties(NULL),
+ m_pPrivateData(NULL),
+ m_pDelegate(NULL),
+ m_pCurDelegate(NULL),
+ m_pOuter(pOuter),
+ m_pInterface(NULL),
+ m_iLock(0) {
+ if (!m_pProperties) {
+ m_pProperties = FX_NEW CFWL_WidgetImpProperties;
+ }
+ *m_pProperties = properties;
+ m_pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ FXSYS_assert(m_pWidgetMgr != NULL);
+}
+CFWL_WidgetImp::~CFWL_WidgetImp() {
+ if (m_pPrivateData) {
+ delete m_pPrivateData;
+ m_pPrivateData = NULL;
+ }
+ if (m_pProperties) {
+ delete m_pProperties;
+ m_pProperties = NULL;
+ }
+}
+FX_BOOL CFWL_WidgetImp::IsEnabled() {
+ return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
+}
+FX_BOOL CFWL_WidgetImp::IsVisible() {
+ return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
+}
+FX_BOOL CFWL_WidgetImp::IsActive() {
+ return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0;
+}
+FX_BOOL CFWL_WidgetImp::IsOverLapper() {
+ return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
+ FWL_WGTSTYLE_OverLapper;
+}
+FX_BOOL CFWL_WidgetImp::IsPopup() {
+ return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup;
+}
+FX_BOOL CFWL_WidgetImp::IsChild() {
+ return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child;
+}
+FX_BOOL CFWL_WidgetImp::IsLocked() {
+ return m_iLock > 0;
+}
+FX_BOOL CFWL_WidgetImp::IsOffscreen() {
+ return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen;
+}
+FX_BOOL CFWL_WidgetImp::HasBorder() {
+ return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border;
+}
+FX_BOOL CFWL_WidgetImp::HasEdge() {
+ return m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask;
+}
+void CFWL_WidgetImp::GetEdgeRect(CFX_RectF& rtEdge) {
+ rtEdge = m_pProperties->m_rtWidget;
+ rtEdge.left = rtEdge.top = 0;
+ if (HasBorder()) {
+ FX_FLOAT fCX = GetBorderSize();
+ FX_FLOAT fCY = GetBorderSize(FALSE);
+ rtEdge.Deflate(fCX, fCY);
+ }
+}
+FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX) {
+ FX_FLOAT* pfBorder = (FX_FLOAT*)GetThemeCapacity(
+ bCX ? FWL_WGTCAPACITY_CXBorder : FWL_WGTCAPACITY_CYBorder);
+ _FWL_RETURN_VALUE_IF_FAIL(pfBorder, 0);
+ return *pfBorder;
+}
+FX_FLOAT CFWL_WidgetImp::GetEdgeWidth() {
+ FX_DWORD dwCapacity = 0;
+ switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) {
+ case FWL_WGTSTYLE_EdgeFlat: {
+ dwCapacity = FWL_WGTCAPACITY_EdgeFlat;
+ break;
}
- if (m_pProperties) {
- delete m_pProperties;
- m_pProperties = NULL;
+ case FWL_WGTSTYLE_EdgeRaised: {
+ dwCapacity = FWL_WGTCAPACITY_EdgeRaised;
+ break;
}
-}
-FX_BOOL CFWL_WidgetImp::IsEnabled()
-{
- return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
-}
-FX_BOOL CFWL_WidgetImp::IsVisible()
-{
- return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
-}
-FX_BOOL CFWL_WidgetImp::IsActive()
-{
- return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0;
-}
-FX_BOOL CFWL_WidgetImp::IsOverLapper()
-{
- return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == FWL_WGTSTYLE_OverLapper;
-}
-FX_BOOL CFWL_WidgetImp::IsPopup()
-{
- return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup;
-}
-FX_BOOL CFWL_WidgetImp::IsChild()
-{
- return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child;
-}
-FX_BOOL CFWL_WidgetImp::IsLocked()
-{
- return m_iLock > 0;
-}
-FX_BOOL CFWL_WidgetImp::IsOffscreen()
-{
- return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen;
-}
-FX_BOOL CFWL_WidgetImp::HasBorder()
-{
- return m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border;
-}
-FX_BOOL CFWL_WidgetImp::HasEdge()
-{
- return m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask;
-}
-void CFWL_WidgetImp::GetEdgeRect(CFX_RectF &rtEdge)
-{
- rtEdge = m_pProperties->m_rtWidget;
- rtEdge.left = rtEdge.top = 0;
- if (HasBorder()) {
- FX_FLOAT fCX = GetBorderSize();
- FX_FLOAT fCY = GetBorderSize(FALSE);
- rtEdge.Deflate(fCX, fCY);
+ case FWL_WGTSTYLE_EdgeSunken: {
+ dwCapacity = FWL_WGTCAPACITY_EdgeSunken;
+ break;
}
-}
-FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX )
-{
- FX_FLOAT *pfBorder = (FX_FLOAT*)GetThemeCapacity(bCX ? FWL_WGTCAPACITY_CXBorder : FWL_WGTCAPACITY_CYBorder);
- _FWL_RETURN_VALUE_IF_FAIL(pfBorder, 0);
- return *pfBorder;
-}
-FX_FLOAT CFWL_WidgetImp::GetEdgeWidth()
-{
- FX_DWORD dwCapacity = 0;
- switch(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) {
- case FWL_WGTSTYLE_EdgeFlat: {
- dwCapacity = FWL_WGTCAPACITY_EdgeFlat;
- break;
- }
- case FWL_WGTSTYLE_EdgeRaised: {
- dwCapacity = FWL_WGTCAPACITY_EdgeRaised;
- break;
- }
- case FWL_WGTSTYLE_EdgeSunken: {
- dwCapacity = FWL_WGTCAPACITY_EdgeSunken;
- break;
- }
+ }
+ if (dwCapacity > 0) {
+ FX_FLOAT* fRet = (FX_FLOAT*)GetThemeCapacity(dwCapacity);
+ _FWL_RETURN_VALUE_IF_FAIL(fRet, 0);
+ return *fRet;
+ }
+ return 0;
+}
+void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) {
+ rect = m_pProperties->m_rtWidget;
+ rect.left = rect.top = 0;
+}
+void* CFWL_WidgetImp::GetThemeCapacity(FX_DWORD dwCapacity) {
+ IFWL_ThemeProvider* pTheme = GetAvailableTheme();
+ _FWL_RETURN_VALUE_IF_FAIL(pTheme, NULL);
+ CFWL_ThemePart part;
+ part.m_pWidget = m_pInterface;
+ return pTheme->GetCapacity(&part, dwCapacity);
+}
+IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() {
+ if (m_pProperties->m_pThemeProvider) {
+ return m_pProperties->m_pThemeProvider;
+ }
+ IFWL_Widget* pUp = m_pInterface;
+ do {
+ FWL_WGTRELATION relation = (pUp->GetStyles() & FWL_WGTSTYLE_Popup)
+ ? FWL_WGTRELATION_Owner
+ : FWL_WGTRELATION_Parent;
+ pUp = m_pWidgetMgr->GetWidget(pUp, relation);
+ if (pUp) {
+ IFWL_ThemeProvider* pRet = pUp->GetThemeProvider();
+ if (pRet && pRet->IsValidWidget(m_pInterface)) {
+ return pRet;
+ }
}
- if (dwCapacity > 0) {
- FX_FLOAT *fRet = (FX_FLOAT*)GetThemeCapacity(dwCapacity);
- _FWL_RETURN_VALUE_IF_FAIL(fRet, 0);
- return *fRet;
+ } while (pUp);
+ return ((CFWL_AppImp*)FWL_GetApp())->GetThemeProvider();
+}
+CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() {
+ IFWL_Widget* pRet = m_pOuter;
+ IFWL_Widget* pOuter = pRet;
+ while (pOuter) {
+ pRet = pOuter;
+ pOuter = pOuter->GetOuter();
+ }
+ return (CFWL_WidgetImp*)pRet;
+}
+CFWL_WidgetImp* CFWL_WidgetImp::GetSameAncestor(CFWL_WidgetImp* pWidget) {
+ CFX_PtrArray arr1, arr2;
+ CFWL_WidgetImp* pAncestor = pWidget;
+ FWL_WGTRELATION relation;
+ do {
+ arr1.Add(pAncestor);
+ relation =
+ pAncestor->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
+ } while ((pAncestor = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget(
+ pAncestor->m_pInterface, relation)) != NULL);
+ pAncestor = this;
+ do {
+ arr2.Add(pAncestor);
+ relation =
+ pAncestor->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
+ } while ((pAncestor = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget(
+ pAncestor->m_pInterface, relation)) != NULL);
+ for (int32_t i = 0; i < arr1.GetSize(); i++) {
+ void* pVoid = arr1[i];
+ if (arr2.Find(pVoid) < 0) {
+ continue;
+ } else {
+ return (CFWL_WidgetImp*)pVoid;
}
- return 0;
+ }
+ return NULL;
}
-void CFWL_WidgetImp::GetRelativeRect(CFX_RectF &rect)
-{
- rect = m_pProperties->m_rtWidget;
- rect.left = rect.top = 0;
-}
-void* CFWL_WidgetImp::GetThemeCapacity(FX_DWORD dwCapacity)
-{
- IFWL_ThemeProvider *pTheme = GetAvailableTheme();
- _FWL_RETURN_VALUE_IF_FAIL(pTheme, NULL);
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- return pTheme->GetCapacity(&part, dwCapacity);
-}
-IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme()
-{
- if (m_pProperties->m_pThemeProvider) {
- return m_pProperties->m_pThemeProvider;
- }
- IFWL_Widget *pUp = m_pInterface;
- do {
- FWL_WGTRELATION relation = (pUp->GetStyles() & FWL_WGTSTYLE_Popup)
- ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- pUp = m_pWidgetMgr->GetWidget(pUp, relation);
- if (pUp) {
- IFWL_ThemeProvider *pRet = pUp->GetThemeProvider();
- if (pRet && pRet->IsValidWidget(m_pInterface)) {
- return pRet;
- }
- }
- } while (pUp);
- return ((CFWL_AppImp*)FWL_GetApp())->GetThemeProvider();
-}
-CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter()
-{
- IFWL_Widget *pRet = m_pOuter;
- IFWL_Widget *pOuter = pRet;
- while (pOuter) {
- pRet = pOuter;
- pOuter = pOuter->GetOuter();
- }
- return (CFWL_WidgetImp*)pRet;
-}
-CFWL_WidgetImp* CFWL_WidgetImp::GetSameAncestor(CFWL_WidgetImp *pWidget)
-{
- CFX_PtrArray arr1, arr2;
- CFWL_WidgetImp *pAncestor = pWidget;
- FWL_WGTRELATION relation;
- do {
- arr1.Add(pAncestor);
- relation = pAncestor->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- } while ((pAncestor = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget(pAncestor->m_pInterface, relation)) != NULL);
- pAncestor = this;
- do {
- arr2.Add(pAncestor);
- relation = pAncestor->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- } while ((pAncestor = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget(pAncestor->m_pInterface, relation)) != NULL);
- for (int32_t i = 0; i < arr1.GetSize(); i ++) {
- void* pVoid = arr1[i];
- if (arr2.Find(pVoid) < 0) {
- continue;
- } else {
- return (CFWL_WidgetImp*)pVoid;
- }
- }
- return NULL;
-}
-CFX_SizeF CFWL_WidgetImp::GetOffsetFromAncestor(CFWL_WidgetImp *pAncestor)
-{
- CFX_SizeF szRet;
- szRet.Set(0, 0);
- if (pAncestor == this) {
- return szRet;
- }
- CFWL_WidgetImp *pWidget = this;
- do {
- CFX_RectF rect;
- pWidget->GetWidgetRect(rect);
- szRet.x += rect.left;
- szRet.y += rect.top;
- FWL_WGTRELATION relation = pWidget->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- pWidget = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget((IFWL_Widget*)pWidget, relation);
- } while(pWidget && pWidget != pAncestor);
+CFX_SizeF CFWL_WidgetImp::GetOffsetFromAncestor(CFWL_WidgetImp* pAncestor) {
+ CFX_SizeF szRet;
+ szRet.Set(0, 0);
+ if (pAncestor == this) {
return szRet;
-}
-FX_BOOL CFWL_WidgetImp::TransformToOuter(FX_FLOAT &fx, FX_FLOAT &fy)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pOuter, FALSE);
- fx += m_pProperties->m_rtWidget.left;
- fx += m_pProperties->m_rtWidget.top;
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::TransformFromOuter(FX_FLOAT &fx, FX_FLOAT &fy)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pOuter, FALSE);
+ }
+ CFWL_WidgetImp* pWidget = this;
+ do {
CFX_RectF rect;
- m_pOuter->GetWidgetRect(rect);
- fx -= rect.left;
- fx -= rect.top;
- return TRUE;
-}
-#define FWL_WGT_CalcHeight 2048
-#define FWL_WGT_CalcWidth 2048
-#define FWL_WGT_CalcMultiLineDefWidth 120.0f
-CFX_SizeF CFWL_WidgetImp::CalcTextSize(const CFX_WideString &wsText, IFWL_ThemeProvider *pTheme, FX_BOOL bMultiLine , int32_t iLineWidth )
-{
- CFX_SizeF sz;
- sz.Set(0, 0);
- _FWL_RETURN_VALUE_IF_FAIL(pTheme, sz);
- CFWL_ThemeText calPart;
- calPart.m_pWidget = m_pInterface;
- calPart.m_wsText = wsText;
- calPart.m_dwTTOStyles = bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
- calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
- CFX_RectF rect;
- FX_FLOAT fWidth = bMultiLine ?
- (iLineWidth > 0 ? (FX_FLOAT)iLineWidth : FWL_WGT_CalcMultiLineDefWidth) :
- FWL_WGT_CalcWidth;
- rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
- pTheme->CalcTextRect(&calPart, rect);
- sz.x = rect.width;
- sz.y = rect.height;
- return sz;
-}
-void CFWL_WidgetImp::CalcTextRect(const CFX_WideString &wsText, IFWL_ThemeProvider *pTheme, FX_DWORD dwTTOStyles, int32_t iTTOAlign, CFX_RectF &rect)
-{
- CFWL_ThemeText calPart;
- calPart.m_pWidget = m_pInterface;
- calPart.m_wsText = wsText;
- calPart.m_dwTTOStyles = dwTTOStyles;
- calPart.m_iTTOAlign = iTTOAlign;
- pTheme->CalcTextRect(&calPart, rect);
-}
-void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus)
-{
- if (m_pWidgetMgr->IsFormDisabled()) {
- return;
- }
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pDriver);
- IFWL_Widget *curFocus = ((CFWL_NoteDriver*)pDriver)->GetFocus();
- if (bFocus && curFocus != m_pInterface) {
- pDriver->SetFocus(m_pInterface);
- } else if (!bFocus && curFocus == m_pInterface) {
- pDriver->SetFocus(NULL);
- }
-}
-void CFWL_WidgetImp::SetGrab(FX_BOOL bSet)
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- pDriver->SetGrab(m_pInterface, bSet);
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
-{
- if (GetClassID() == FWL_CLASSHASH_Menu) {
- return GetPopupPosMenu(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
+ pWidget->GetWidgetRect(rect);
+ szRet.x += rect.left;
+ szRet.y += rect.top;
+ FWL_WGTRELATION relation =
+ pWidget->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
+ pWidget = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget((IFWL_Widget*)pWidget,
+ relation);
+ } while (pWidget && pWidget != pAncestor);
+ return szRet;
+}
+FX_BOOL CFWL_WidgetImp::TransformToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pOuter, FALSE);
+ fx += m_pProperties->m_rtWidget.left;
+ fx += m_pProperties->m_rtWidget.top;
+ return TRUE;
+}
+FX_BOOL CFWL_WidgetImp::TransformFromOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pOuter, FALSE);
+ CFX_RectF rect;
+ m_pOuter->GetWidgetRect(rect);
+ fx -= rect.left;
+ fx -= rect.top;
+ return TRUE;
+}
+#define FWL_WGT_CalcHeight 2048
+#define FWL_WGT_CalcWidth 2048
+#define FWL_WGT_CalcMultiLineDefWidth 120.0f
+CFX_SizeF CFWL_WidgetImp::CalcTextSize(const CFX_WideString& wsText,
+ IFWL_ThemeProvider* pTheme,
+ FX_BOOL bMultiLine,
+ int32_t iLineWidth) {
+ CFX_SizeF sz;
+ sz.Set(0, 0);
+ _FWL_RETURN_VALUE_IF_FAIL(pTheme, sz);
+ CFWL_ThemeText calPart;
+ calPart.m_pWidget = m_pInterface;
+ calPart.m_wsText = wsText;
+ calPart.m_dwTTOStyles =
+ bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
+ calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
+ CFX_RectF rect;
+ FX_FLOAT fWidth = bMultiLine
+ ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth
+ : FWL_WGT_CalcMultiLineDefWidth)
+ : FWL_WGT_CalcWidth;
+ rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
+ pTheme->CalcTextRect(&calPart, rect);
+ sz.x = rect.width;
+ sz.y = rect.height;
+ return sz;
+}
+void CFWL_WidgetImp::CalcTextRect(const CFX_WideString& wsText,
+ IFWL_ThemeProvider* pTheme,
+ FX_DWORD dwTTOStyles,
+ int32_t iTTOAlign,
+ CFX_RectF& rect) {
+ CFWL_ThemeText calPart;
+ calPart.m_pWidget = m_pInterface;
+ calPart.m_wsText = wsText;
+ calPart.m_dwTTOStyles = dwTTOStyles;
+ calPart.m_iTTOAlign = iTTOAlign;
+ pTheme->CalcTextRect(&calPart, rect);
+}
+void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return;
+ }
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pDriver);
+ IFWL_Widget* curFocus = ((CFWL_NoteDriver*)pDriver)->GetFocus();
+ if (bFocus && curFocus != m_pInterface) {
+ pDriver->SetFocus(m_pInterface);
+ } else if (!bFocus && curFocus == m_pInterface) {
+ pDriver->SetFocus(NULL);
+ }
+}
+void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ pDriver->SetGrab(m_pInterface, bSet);
+}
+FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup) {
+ if (GetClassID() == FWL_CLASSHASH_Menu) {
+ return GetPopupPosMenu(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
+ } else {
+ if (GetClassID() == FWL_CLASSHASH_ComboBox) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
+ fMaxHeight, rtAnchor, rtPopup);
+ } else {
+ return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
+ }
+ } else if (GetClassID() == FWL_CLASSHASH_DateTimePicker &&
+ m_pWidgetMgr->IsFormDisabled()) {
+ return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
+ fMaxHeight, rtAnchor, rtPopup);
} else {
- if (GetClassID() == FWL_CLASSHASH_ComboBox) {
- if (m_pWidgetMgr->IsFormDisabled()) {
- return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- }
- } else if (GetClassID() == FWL_CLASSHASH_DateTimePicker && m_pWidgetMgr->IsFormDisabled()) {
- return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- }
- }
- return FALSE;
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
-{
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
- if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
- FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0;
- FX_FLOAT fRight = rtAnchor.right() + rtPopup.width;
- TransformTo(NULL, fx, fy);
- if (fRight + fx > fScreenWidth || bLeft) {
- rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, rtPopup.height);
- } else {
- rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, rtPopup.height);
- }
- } else {
- FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
- TransformTo(NULL, fx, fy);
- if (fBottom + fy > fScreenHeight) {
- rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, rtPopup.height);
- } else {
- rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, rtPopup.height);
- }
- }
- rtPopup.Offset(fx, fy);
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
-{
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
- FX_FLOAT fPopHeight = rtPopup.height;
- if (rtPopup.height > fMaxHeight) {
- fPopHeight = fMaxHeight;
- } else if (rtPopup.height < fMinHeight) {
- fPopHeight = fMinHeight;
+ return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
- FX_FLOAT fWidth = FX_MAX(rtAnchor.width, rtPopup.width);
- FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight;
+ }
+ return FALSE;
+}
+FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup) {
+ FX_FLOAT fx = 0;
+ FX_FLOAT fy = 0;
+ FX_FLOAT fScreenWidth = 0;
+ FX_FLOAT fScreenHeight = 0;
+ GetScreenSize(fScreenWidth, fScreenHeight);
+ if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
+ FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0;
+ FX_FLOAT fRight = rtAnchor.right() + rtPopup.width;
TransformTo(NULL, fx, fy);
- if (fBottom + fy > fScreenHeight) {
- rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight);
+ if (fRight + fx > fScreenWidth || bLeft) {
+ rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width,
+ rtPopup.height);
} else {
- rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight);
+ rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width,
+ rtPopup.height);
}
- rtPopup.Offset(fx, fy);
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
-{
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
+ } else {
+ FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
TransformTo(NULL, fx, fy);
- if (rtAnchor.bottom() + fy > fScreenHeight) {
- rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, rtPopup.height);
+ if (fBottom + fy > fScreenHeight) {
+ rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width,
+ rtPopup.height);
} else {
- rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, rtPopup.height);
- }
- rtPopup.Offset(fx, fy);
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT &fx, FX_FLOAT &fy)
-{
- IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
- IFWL_AdapterMonitorMgr *pMonitorMgr = pNative->GetMonitorMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pMonitorMgr, FALSE);
- FWL_HMONITOR hMonitor = pMonitorMgr->GetMonitorByPoint(fx, fy);
- pMonitorMgr->GetMonitorSize(hMonitor, fx, fy);
- return TRUE;
-}
-void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget *pEventSource , FX_DWORD dwFilter )
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pNoteDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pNoteDriver);
- pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter);
-}
-void CFWL_WidgetImp::UnregisterEventTarget()
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pNoteDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pNoteDriver);
- pNoteDriver->UnregisterEventTarget(m_pInterface);
-}
-void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey *pNote)
-{
- _FWL_RETURN_IF_FAIL(pNote);
- CFWL_MsgKey *pEvent = (CFWL_MsgKey*)pNote->CloneToEvent();
- pEvent->m_pSrcTarget = m_pInterface;
- pEvent->m_dwCmd = pNote->m_dwCmd;
- pEvent->m_dwKeyCode = pNote->m_dwKeyCode;
- pEvent->m_dwFlags = pNote->m_dwFlags;
- DispatchEvent((CFWL_Event*)pEvent);
- pEvent->Release();
-}
-void CFWL_WidgetImp::DispatchEvent(CFWL_Event *pEvent)
-{
- if (m_pOuter) {
- IFWL_WidgetDelegate *pDelegate = m_pOuter->SetDelegate(NULL);
- pDelegate->OnProcessEvent(pEvent);
- return;
- }
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pNoteDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pNoteDriver);
- pNoteDriver->SendNote(pEvent);
-}
-void CFWL_WidgetImp::Repaint(const CFX_RectF *pRect )
-{
- if (pRect) {
- m_pWidgetMgr->RepaintWidget(m_pInterface, pRect);
- return ;
- }
- CFX_RectF rect;
- rect = m_pProperties->m_rtWidget;
- rect.left = rect.top = 0;
- m_pWidgetMgr->RepaintWidget(m_pInterface, &rect);
-}
-void CFWL_WidgetImp::DrawBackground(CFX_Graphics *pGraphics,
- int32_t iPartBk,
- IFWL_ThemeProvider *pTheme,
- const CFX_Matrix *pMatrix )
-{
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = iPartBk;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix, TRUE);
+ rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
+ rtPopup.height);
}
- param.m_rtPart = rtRelative;
- pTheme->DrawBackground(¶m);
-}
-void CFWL_WidgetImp::DrawBorder(CFX_Graphics *pGraphics,
- int32_t iPartBorder,
- IFWL_ThemeProvider *pTheme,
- const CFX_Matrix *pMatrix )
-{
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = iPartBorder;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix, TRUE);
+ }
+ rtPopup.Offset(fx, fy);
+ return TRUE;
+}
+FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup) {
+ FX_FLOAT fx = 0;
+ FX_FLOAT fy = 0;
+ FX_FLOAT fScreenWidth = 0;
+ FX_FLOAT fScreenHeight = 0;
+ GetScreenSize(fScreenWidth, fScreenHeight);
+ FX_FLOAT fPopHeight = rtPopup.height;
+ if (rtPopup.height > fMaxHeight) {
+ fPopHeight = fMaxHeight;
+ } else if (rtPopup.height < fMinHeight) {
+ fPopHeight = fMinHeight;
+ }
+ FX_FLOAT fWidth = FX_MAX(rtAnchor.width, rtPopup.width);
+ FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight;
+ TransformTo(NULL, fx, fy);
+ if (fBottom + fy > fScreenHeight) {
+ rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight);
+ } else {
+ rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight);
+ }
+ rtPopup.Offset(fx, fy);
+ return TRUE;
+}
+FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup) {
+ FX_FLOAT fx = 0;
+ FX_FLOAT fy = 0;
+ FX_FLOAT fScreenWidth = 0;
+ FX_FLOAT fScreenHeight = 0;
+ GetScreenSize(fScreenWidth, fScreenHeight);
+ TransformTo(NULL, fx, fy);
+ if (rtAnchor.bottom() + fy > fScreenHeight) {
+ rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width,
+ rtPopup.height);
+ } else {
+ rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
+ rtPopup.height);
+ }
+ rtPopup.Offset(fx, fy);
+ return TRUE;
+}
+FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) {
+ IFWL_AdapterNative* pNative = FWL_GetAdapterNative();
+ IFWL_AdapterMonitorMgr* pMonitorMgr = pNative->GetMonitorMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pMonitorMgr, FALSE);
+ FWL_HMONITOR hMonitor = pMonitorMgr->GetMonitorByPoint(fx, fy);
+ pMonitorMgr->GetMonitorSize(hMonitor, fx, fy);
+ return TRUE;
+}
+void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource,
+ FX_DWORD dwFilter) {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pNoteDriver);
+ pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter);
+}
+void CFWL_WidgetImp::UnregisterEventTarget() {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pNoteDriver);
+ pNoteDriver->UnregisterEventTarget(m_pInterface);
+}
+void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) {
+ _FWL_RETURN_IF_FAIL(pNote);
+ CFWL_MsgKey* pEvent = (CFWL_MsgKey*)pNote->CloneToEvent();
+ pEvent->m_pSrcTarget = m_pInterface;
+ pEvent->m_dwCmd = pNote->m_dwCmd;
+ pEvent->m_dwKeyCode = pNote->m_dwKeyCode;
+ pEvent->m_dwFlags = pNote->m_dwFlags;
+ DispatchEvent((CFWL_Event*)pEvent);
+ pEvent->Release();
+}
+void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) {
+ if (m_pOuter) {
+ IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL);
+ pDelegate->OnProcessEvent(pEvent);
+ return;
+ }
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pNoteDriver);
+ pNoteDriver->SendNote(pEvent);
+}
+void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) {
+ if (pRect) {
+ m_pWidgetMgr->RepaintWidget(m_pInterface, pRect);
+ return;
+ }
+ CFX_RectF rect;
+ rect = m_pProperties->m_rtWidget;
+ rect.left = rect.top = 0;
+ m_pWidgetMgr->RepaintWidget(m_pInterface, &rect);
+}
+void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics,
+ int32_t iPartBk,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFX_RectF rtRelative;
+ GetRelativeRect(rtRelative);
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = iPartBk;
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix, TRUE);
+ }
+ param.m_rtPart = rtRelative;
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics,
+ int32_t iPartBorder,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFX_RectF rtRelative;
+ GetRelativeRect(rtRelative);
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = iPartBorder;
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix, TRUE);
+ }
+ param.m_rtPart = rtRelative;
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics,
+ int32_t iPartEdge,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
+ CFX_RectF rtEdge;
+ GetEdgeRect(rtEdge);
+ CFWL_ThemeBackground param;
+ param.m_pWidget = m_pInterface;
+ param.m_iPart = iPartEdge;
+ param.m_pGraphics = pGraphics;
+ if (pMatrix) {
+ param.m_matrix.Concat(*pMatrix, TRUE);
+ }
+ param.m_rtPart = rtEdge;
+ pTheme->DrawBackground(¶m);
+}
+void CFWL_WidgetImp::NotifyDriver() {
+ IFWL_NoteThread* pThread = GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pDriver);
+ pDriver->NotifyTargetDestroy(m_pInterface);
+}
+CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) {
+ CFX_SizeF szRet;
+ szRet.Set(0, 0);
+ if (pParent == (IFWL_Widget*)this) {
+ return szRet;
+ }
+ IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
+ _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, szRet);
+ szRet.x += m_pProperties->m_rtWidget.left;
+ szRet.y += m_pProperties->m_rtWidget.top;
+ IFWL_Widget* pDstWidget = GetParent();
+ while (pDstWidget && pDstWidget != pParent) {
+ CFX_RectF rtDst;
+ pDstWidget->GetWidgetRect(rtDst);
+ szRet.x += rtDst.left;
+ szRet.y += rtDst.top;
+ pDstWidget = pWidgetMgr->GetWidget(pDstWidget, FWL_WGTRELATION_Parent);
+ }
+ return szRet;
+}
+FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) {
+ if (pParent == (IFWL_Widget*)this) {
+ return FALSE;
+ }
+ IFWL_Widget* pUpWidget = GetParent();
+ while (pUpWidget) {
+ if (pUpWidget == pParent) {
+ return TRUE;
}
- param.m_rtPart = rtRelative;
- pTheme->DrawBackground(¶m);
-}
-void CFWL_WidgetImp::DrawEdge(CFX_Graphics *pGraphics,
- int32_t iPartEdge,
- IFWL_ThemeProvider *pTheme,
- const CFX_Matrix *pMatrix )
-{
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = iPartEdge;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix, TRUE);
+ pUpWidget = pUpWidget->GetParent();
+ }
+ return FALSE;
+}
+CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {}
+int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage->m_pDstTarget, 0);
+ CFWL_WidgetImp* pWidget =
+ (CFWL_WidgetImp*)((IFWL_TargetData*)pMessage->m_pDstTarget)->GetData();
+ FX_DWORD dwMsgCode = pMessage->GetClassID();
+ switch (dwMsgCode) {
+ case FWL_MSGHASH_Mouse: {
+ CFWL_EvtMouse evt;
+ evt.m_pSrcTarget = pWidget->m_pInterface;
+ evt.m_pDstTarget = pWidget->m_pInterface;
+ evt.m_dwCmd = ((CFWL_MsgMouse*)pMessage)->m_dwCmd;
+ evt.m_dwFlags = ((CFWL_MsgMouse*)pMessage)->m_dwFlags;
+ evt.m_fx = ((CFWL_MsgMouse*)pMessage)->m_fx;
+ evt.m_fy = ((CFWL_MsgMouse*)pMessage)->m_fy;
+ pWidget->DispatchEvent(&evt);
+ break;
}
- param.m_rtPart = rtEdge;
- pTheme->DrawBackground(¶m);
-}
-void CFWL_WidgetImp::NotifyDriver()
-{
- IFWL_NoteThread *pThread = GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pDriver);
- pDriver->NotifyTargetDestroy(m_pInterface);
-}
-CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget *pParent)
-{
- CFX_SizeF szRet;
- szRet.Set(0, 0);
- if (pParent == (IFWL_Widget*)this) {
- return szRet;
+ case FWL_MSGHASH_MouseWheel: {
+ CFWL_EvtMouseWheel evt;
+ evt.m_pSrcTarget = pWidget->m_pInterface;
+ evt.m_pDstTarget = pWidget->m_pInterface;
+ evt.m_dwFlags = ((CFWL_MsgMouseWheel*)pMessage)->m_dwFlags;
+ evt.m_fDeltaX = ((CFWL_MsgMouseWheel*)pMessage)->m_fDeltaX;
+ evt.m_fDeltaY = ((CFWL_MsgMouseWheel*)pMessage)->m_fDeltaY;
+ evt.m_fx = ((CFWL_MsgMouseWheel*)pMessage)->m_fx;
+ evt.m_fy = ((CFWL_MsgMouseWheel*)pMessage)->m_fy;
+ pWidget->DispatchEvent(&evt);
+ break;
}
- IFWL_WidgetMgr *pWidgetMgr = FWL_GetWidgetMgr();
- _FWL_RETURN_VALUE_IF_FAIL(pWidgetMgr, szRet);
- szRet.x += m_pProperties->m_rtWidget.left;
- szRet.y += m_pProperties->m_rtWidget.top;
- IFWL_Widget *pDstWidget = GetParent();
- while (pDstWidget && pDstWidget != pParent) {
- CFX_RectF rtDst;
- pDstWidget->GetWidgetRect(rtDst);
- szRet.x += rtDst.left;
- szRet.y += rtDst.top;
- pDstWidget = pWidgetMgr->GetWidget(pDstWidget, FWL_WGTRELATION_Parent);
+ case FWL_MSGHASH_Key: {
+ CFWL_EvtKey evt;
+ evt.m_pSrcTarget = pWidget->m_pInterface;
+ ;
+ evt.m_pDstTarget = pWidget->m_pInterface;
+ ;
+ evt.m_dwKeyCode = ((CFWL_MsgKey*)pMessage)->m_dwKeyCode;
+ evt.m_dwFlags = ((CFWL_MsgKey*)pMessage)->m_dwFlags;
+ evt.m_dwCmd = ((CFWL_MsgKey*)pMessage)->m_dwCmd;
+ pWidget->DispatchEvent(&evt);
+ break;
}
- return szRet;
-}
-FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget *pParent)
-{
- if (pParent == (IFWL_Widget*)this) {
- return FALSE;
+ case FWL_MSGHASH_SetFocus: {
+ CFWL_EvtSetFocus evt;
+ evt.m_pSrcTarget = ((CFWL_MsgSetFocus*)pMessage)->m_pDstTarget;
+ evt.m_pDstTarget = ((CFWL_MsgSetFocus*)pMessage)->m_pDstTarget;
+ evt.m_pSetFocus = pWidget->m_pInterface;
+ pWidget->DispatchEvent(&evt);
+ break;
}
- IFWL_Widget *pUpWidget = GetParent();
- while (pUpWidget) {
- if (pUpWidget == pParent) {
- return TRUE;
- }
- pUpWidget = pUpWidget->GetParent();
+ case FWL_MSGHASH_KillFocus: {
+ CFWL_EvtKillFocus evt;
+ evt.m_pSrcTarget = ((CFWL_MsgKillFocus*)pMessage)->m_pDstTarget;
+ evt.m_pDstTarget = ((CFWL_MsgKillFocus*)pMessage)->m_pDstTarget;
+ evt.m_pKillFocus = pWidget->m_pInterface;
+ pWidget->DispatchEvent(&evt);
+ break;
}
- return FALSE;
-}
-CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate()
-{
-}
-int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage->m_pDstTarget, 0);
- CFWL_WidgetImp *pWidget = (CFWL_WidgetImp*)((IFWL_TargetData*)pMessage->m_pDstTarget)->GetData();
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_Mouse: {
- CFWL_EvtMouse evt;
- evt.m_pSrcTarget = pWidget->m_pInterface;
- evt.m_pDstTarget = pWidget->m_pInterface;
- evt.m_dwCmd = ((CFWL_MsgMouse*)pMessage)->m_dwCmd;
- evt.m_dwFlags = ((CFWL_MsgMouse*)pMessage)->m_dwFlags;
- evt.m_fx = ((CFWL_MsgMouse*)pMessage)->m_fx;
- evt.m_fy = ((CFWL_MsgMouse*)pMessage)->m_fy;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_MouseWheel: {
- CFWL_EvtMouseWheel evt;
- evt.m_pSrcTarget = pWidget->m_pInterface;
- evt.m_pDstTarget = pWidget->m_pInterface;
- evt.m_dwFlags = ((CFWL_MsgMouseWheel*)pMessage)->m_dwFlags;
- evt.m_fDeltaX = ((CFWL_MsgMouseWheel*)pMessage)->m_fDeltaX;
- evt.m_fDeltaY = ((CFWL_MsgMouseWheel*)pMessage)->m_fDeltaY;
- evt.m_fx = ((CFWL_MsgMouseWheel*)pMessage)->m_fx;
- evt.m_fy = ((CFWL_MsgMouseWheel*)pMessage)->m_fy;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_EvtKey evt;
- evt.m_pSrcTarget = pWidget->m_pInterface;;
- evt.m_pDstTarget = pWidget->m_pInterface;;
- evt.m_dwKeyCode = ((CFWL_MsgKey*)pMessage)->m_dwKeyCode;
- evt.m_dwFlags = ((CFWL_MsgKey*)pMessage)->m_dwFlags;
- evt.m_dwCmd = ((CFWL_MsgKey*)pMessage)->m_dwCmd;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_SetFocus: {
- CFWL_EvtSetFocus evt;
- evt.m_pSrcTarget = ((CFWL_MsgSetFocus*)pMessage)->m_pDstTarget;
- evt.m_pDstTarget = ((CFWL_MsgSetFocus*)pMessage)->m_pDstTarget;
- evt.m_pSetFocus = pWidget->m_pInterface;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_KillFocus: {
- CFWL_EvtKillFocus evt;
- evt.m_pSrcTarget = ((CFWL_MsgKillFocus*)pMessage)->m_pDstTarget;
- evt.m_pDstTarget = ((CFWL_MsgKillFocus*)pMessage)->m_pDstTarget;
- evt.m_pKillFocus = pWidget->m_pInterface;
- pWidget->DispatchEvent(&evt);
- break;
- }
- default: {
- }
- }
- return 1;
-}
-FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
+ default: {}
+ }
+ return 1;
+}
+FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ CFWL_EvtDraw evt;
+ evt.m_pGraphics = pGraphics;
+ return FWL_ERR_Succeeded;
+}
+class CFWL_Custom : public CFWL_WidgetImp {
+ public:
+ CFWL_Custom(IFWL_Widget* pOuter = NULL);
+ CFWL_Custom(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR SetProxy(IFWL_Proxy* pProxy);
+
+ protected:
+ IFWL_Proxy* m_pProxy;
+};
+CFWL_Custom::CFWL_Custom(IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(pOuter), m_pProxy(NULL) {}
+CFWL_Custom::CFWL_Custom(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : CFWL_WidgetImp(properties, pOuter), m_pProxy(NULL) {}
+FWL_ERR CFWL_Custom::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ if (m_pProxy &&
+ (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
return FWL_ERR_Succeeded;
+ }
+ return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
}
-FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- CFWL_EvtDraw evt;
- evt.m_pGraphics = pGraphics;
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_Custom::Update() {
+ if (m_pProxy) {
+ return m_pProxy->Update();
+ }
+ return CFWL_WidgetImp::Update();
}
-class CFWL_Custom : public CFWL_WidgetImp
-{
-public:
- CFWL_Custom(IFWL_Widget *pOuter = NULL);
- CFWL_Custom(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR SetProxy(IFWL_Proxy *pProxy);
-protected:
- IFWL_Proxy *m_pProxy;
-};
-CFWL_Custom::CFWL_Custom(IFWL_Widget *pOuter )
- : CFWL_WidgetImp(pOuter)
- , m_pProxy(NULL)
-{
-}
-CFWL_Custom::CFWL_Custom(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
- : CFWL_WidgetImp(properties, pOuter)
- , m_pProxy(NULL)
-{
-}
-FWL_ERR CFWL_Custom::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- if (m_pProxy && (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
+FWL_ERR CFWL_Custom::SetProxy(IFWL_Proxy* pProxy) {
+ m_pProxy = pProxy;
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_Custom::Update()
-{
- if (m_pProxy) {
- return m_pProxy->Update();
- }
- return CFWL_WidgetImp::Update();
+IFWL_Custom* IFWL_Custom::Create() {
+ return new IFWL_Custom;
}
-FWL_ERR CFWL_Custom::SetProxy(IFWL_Proxy *pProxy)
-{
- m_pProxy = pProxy;
- return FWL_ERR_Succeeded;
-}
-IFWL_Custom* IFWL_Custom::Create()
-{
- return new IFWL_Custom;
+IFWL_Custom::IFWL_Custom() {
+ m_pData = NULL;
}
-IFWL_Custom::IFWL_Custom()
-{
+IFWL_Custom::~IFWL_Custom() {
+ if (m_pData) {
+ delete (CFWL_Custom*)m_pData;
m_pData = NULL;
-}
-IFWL_Custom::~IFWL_Custom()
-{
- if (m_pData) {
- delete (CFWL_Custom*)m_pData;
- m_pData = NULL;
- }
-}
-FWL_ERR IFWL_Custom::Initialize(IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_Custom(pOuter);
- ((CFWL_Custom*)m_pData)->SetInterface(this);
- return ((CFWL_Custom*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Custom::Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter )
-{
- m_pData = FX_NEW CFWL_Custom(properties, pOuter);
- ((CFWL_Custom*)m_pData)->SetInterface(this);
- return ((CFWL_Custom*)m_pData)->Initialize();
-}
-FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy *pProxy)
-{
- return ((CFWL_Custom*)m_pData)->SetProxy(pProxy);
-}
-void FWL_SetWidgetRect(IFWL_Widget *widget, const CFX_RectF &rect)
-{
- ((CFWL_WidgetImp*)((IFWL_TargetData*)widget)->GetData())->m_pProperties->m_rtWidget = rect;
-}
-void FWL_SetWidgetStates(IFWL_Widget *widget, FX_DWORD dwStates)
-{
- ((CFWL_WidgetImp*)((IFWL_TargetData*)widget)->GetData())->m_pProperties->m_dwStates = dwStates;
-}
-void FWL_SetWidgetStyles(IFWL_Widget *widget, FX_DWORD dwStyles)
-{
- ((CFWL_WidgetImp*)((IFWL_TargetData*)widget)->GetData())->m_pProperties->m_dwStyles = dwStyles;
-}
-FWL_ERR FWL_EnabelWidget(IFWL_Widget *widget, FX_BOOL bEnable)
-{
- widget->SetStates(FWL_WGTSTATE_Disabled, !bEnable);
- IFWL_WidgetMgr *widgetMgr = FWL_GetWidgetMgr();
- IFWL_Widget *child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
- while (child) {
- FWL_EnabelWidget(child, bEnable);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return FWL_ERR_Succeeded;
+ }
+}
+FWL_ERR IFWL_Custom::Initialize(IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_Custom(pOuter);
+ ((CFWL_Custom*)m_pData)->SetInterface(this);
+ return ((CFWL_Custom*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Custom::Initialize(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter) {
+ m_pData = FX_NEW CFWL_Custom(properties, pOuter);
+ ((CFWL_Custom*)m_pData)->SetInterface(this);
+ return ((CFWL_Custom*)m_pData)->Initialize();
+}
+FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy* pProxy) {
+ return ((CFWL_Custom*)m_pData)->SetProxy(pProxy);
+}
+void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect) {
+ ((CFWL_WidgetImp*)((IFWL_TargetData*)widget)->GetData())
+ ->m_pProperties->m_rtWidget = rect;
+}
+void FWL_SetWidgetStates(IFWL_Widget* widget, FX_DWORD dwStates) {
+ ((CFWL_WidgetImp*)((IFWL_TargetData*)widget)->GetData())
+ ->m_pProperties->m_dwStates = dwStates;
+}
+void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD dwStyles) {
+ ((CFWL_WidgetImp*)((IFWL_TargetData*)widget)->GetData())
+ ->m_pProperties->m_dwStyles = dwStyles;
+}
+FWL_ERR FWL_EnabelWidget(IFWL_Widget* widget, FX_BOOL bEnable) {
+ widget->SetStates(FWL_WGTSTATE_Disabled, !bEnable);
+ IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
+ IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ FWL_EnabelWidget(child, bEnable);
+ child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp b/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp index 51988dd9cd..2719ff96ec 100644 --- a/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp +++ b/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp @@ -11,1044 +11,1052 @@ #include "include/fwl_threadimp.h"
#include "include/fwl_appimp.h"
#define FWL_NORMALMATRIX
-FX_BOOL FWL_UseOffscreen(IFWL_Widget * pWidget)
-{
-#if (_FX_OS_==_FX_MACOSX_)
- return FALSE;
+FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) {
+#if (_FX_OS_ == _FX_MACOSX_)
+ return FALSE;
#else
- return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen;
+ return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen;
#endif
}
-IFWL_WidgetMgr* FWL_GetWidgetMgr()
-{
- IFWL_App *pApp = FWL_GetApp();
- _FWL_RETURN_VALUE_IF_FAIL(pApp, NULL);
- return pApp->GetWidgetMgr();
+IFWL_WidgetMgr* FWL_GetWidgetMgr() {
+ IFWL_App* pApp = FWL_GetApp();
+ _FWL_RETURN_VALUE_IF_FAIL(pApp, NULL);
+ return pApp->GetWidgetMgr();
}
-CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative *pAdapterNative)
- : m_dwCapability(0)
-{
- m_pDelegate = FX_NEW CFWL_WidgetMgrDelegate(this);
- m_pAdapter = pAdapterNative->GetWidgetMgr((IFWL_WidgetMgrDelegate*)m_pDelegate);
- FXSYS_assert(m_pAdapter);
- CFWL_WidgetMgrItem *pRoot = FX_NEW CFWL_WidgetMgrItem;
- m_mapWidgetItem.SetAt(NULL, pRoot);
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)
- m_rtScreen.Reset();
- IFWL_AdapterMonitorMgr* pMonitorMgr = pAdapterNative->GetMonitorMgr();
- if (pMonitorMgr) {
- FWL_HMONITOR monitor = pMonitorMgr->GetCurrentMonitor();
- if (monitor) {
- pMonitorMgr->GetMonitorSize(monitor, m_rtScreen.width, m_rtScreen.height);
- }
- }
+CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative)
+ : m_dwCapability(0) {
+ m_pDelegate = FX_NEW CFWL_WidgetMgrDelegate(this);
+ m_pAdapter =
+ pAdapterNative->GetWidgetMgr((IFWL_WidgetMgrDelegate*)m_pDelegate);
+ FXSYS_assert(m_pAdapter);
+ CFWL_WidgetMgrItem* pRoot = FX_NEW CFWL_WidgetMgrItem;
+ m_mapWidgetItem.SetAt(NULL, pRoot);
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
+ m_rtScreen.Reset();
+ IFWL_AdapterMonitorMgr* pMonitorMgr = pAdapterNative->GetMonitorMgr();
+ if (pMonitorMgr) {
+ FWL_HMONITOR monitor = pMonitorMgr->GetCurrentMonitor();
+ if (monitor) {
+ pMonitorMgr->GetMonitorSize(monitor, m_rtScreen.width, m_rtScreen.height);
+ }
+ }
#endif
}
-CFWL_WidgetMgr::~CFWL_WidgetMgr()
-{
- FX_POSITION ps = m_mapWidgetItem.GetStartPosition();
- while (ps) {
- void* pWidget;
- CFWL_WidgetMgrItem *pItem;
- m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem);
- delete pItem;
- }
- m_mapWidgetItem.RemoveAll();
- if (m_pDelegate) {
- delete m_pDelegate;
- m_pDelegate = NULL;
- }
+CFWL_WidgetMgr::~CFWL_WidgetMgr() {
+ FX_POSITION ps = m_mapWidgetItem.GetStartPosition();
+ while (ps) {
+ void* pWidget;
+ CFWL_WidgetMgrItem* pItem;
+ m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem);
+ delete pItem;
+ }
+ m_mapWidgetItem.RemoveAll();
+ if (m_pDelegate) {
+ delete m_pDelegate;
+ m_pDelegate = NULL;
+ }
}
-int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget *pParent )
-{
- CFWL_WidgetMgrItem *pParentItem = GetWidgetMgrItem(pParent);
- return TravelWidgetMgr(pParentItem, NULL, NULL);
+int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) {
+ CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
+ return TravelWidgetMgr(pParentItem, NULL, NULL);
}
-IFWL_Widget* CFWL_WidgetMgr::GetWidget(int32_t nIndex, IFWL_Widget *pParent )
-{
- CFWL_WidgetMgrItem *pParentItem = GetWidgetMgrItem(pParent);
- IFWL_Widget *pWidget = NULL;
- TravelWidgetMgr(pParentItem, &nIndex, NULL, &pWidget);
- return pWidget;
+IFWL_Widget* CFWL_WidgetMgr::GetWidget(int32_t nIndex, IFWL_Widget* pParent) {
+ CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
+ IFWL_Widget* pWidget = NULL;
+ TravelWidgetMgr(pParentItem, &nIndex, NULL, &pWidget);
+ return pWidget;
}
-IFWL_Widget* CFWL_WidgetMgr::GetWidget(IFWL_Widget *pWidget, FWL_WGTRELATION eRelation)
-{
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- if (!pItem) {
- return NULL;
- }
- IFWL_Widget *pRet = NULL;
- switch (eRelation) {
- case FWL_WGTRELATION_Parent: {
- pRet = pItem->pParent ? pItem->pParent->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_Owner: {
- pRet = pItem->pOwner ? pItem->pOwner->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_FirstSibling: {
- pItem = pItem->pPrevious;
- while (pItem && pItem->pPrevious) {
- pItem = pItem->pPrevious;
- }
- pRet = pItem ? pItem->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_PriorSibling: {
- pRet = pItem->pPrevious ? pItem->pPrevious->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_NextSibling: {
- pRet = pItem->pNext ? pItem->pNext->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_LastSibling: {
- pItem = pItem->pNext;
- while (pItem && pItem->pNext) {
- pItem = pItem->pNext;
- }
- pRet = pItem ? pItem->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_FirstChild: {
- pRet = pItem->pChild ? pItem->pChild->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_LastChild: {
- pItem = pItem->pChild;
- while (pItem && pItem->pNext) {
- pItem = pItem->pNext;
- }
- pRet = pItem ? pItem->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_SystemForm: {
- while (pItem) {
- if (IsAbleNative(pItem->pWidget)) {
- pRet = pItem->pWidget;
- break;
- }
- pItem = pItem->pParent;
- }
- break;
- }
- default: {
- }
+IFWL_Widget* CFWL_WidgetMgr::GetWidget(IFWL_Widget* pWidget,
+ FWL_WGTRELATION eRelation) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ if (!pItem) {
+ return NULL;
+ }
+ IFWL_Widget* pRet = NULL;
+ switch (eRelation) {
+ case FWL_WGTRELATION_Parent: {
+ pRet = pItem->pParent ? pItem->pParent->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_Owner: {
+ pRet = pItem->pOwner ? pItem->pOwner->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_FirstSibling: {
+ pItem = pItem->pPrevious;
+ while (pItem && pItem->pPrevious) {
+ pItem = pItem->pPrevious;
+ }
+ pRet = pItem ? pItem->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_PriorSibling: {
+ pRet = pItem->pPrevious ? pItem->pPrevious->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_NextSibling: {
+ pRet = pItem->pNext ? pItem->pNext->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_LastSibling: {
+ pItem = pItem->pNext;
+ while (pItem && pItem->pNext) {
+ pItem = pItem->pNext;
+ }
+ pRet = pItem ? pItem->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_FirstChild: {
+ pRet = pItem->pChild ? pItem->pChild->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_LastChild: {
+ pItem = pItem->pChild;
+ while (pItem && pItem->pNext) {
+ pItem = pItem->pNext;
+ }
+ pRet = pItem ? pItem->pWidget : NULL;
+ break;
+ }
+ case FWL_WGTRELATION_SystemForm: {
+ while (pItem) {
+ if (IsAbleNative(pItem->pWidget)) {
+ pRet = pItem->pWidget;
+ break;
+ }
+ pItem = pItem->pParent;
+ }
+ break;
}
- return pRet;
+ default: {}
+ }
+ return pRet;
}
-int32_t CFWL_WidgetMgr::GetWidgetIndex(IFWL_Widget *pWidget)
-{
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- _FWL_RETURN_VALUE_IF_FAIL(pItem, -1);
- return TravelWidgetMgr(pItem->pParent, NULL, pItem);
+int32_t CFWL_WidgetMgr::GetWidgetIndex(IFWL_Widget* pWidget) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ _FWL_RETURN_VALUE_IF_FAIL(pItem, -1);
+ return TravelWidgetMgr(pItem->pParent, NULL, pItem);
}
-FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget *pWidget, int32_t nIndex)
-{
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- _FWL_RETURN_VALUE_IF_FAIL(pItem, FALSE);
- _FWL_RETURN_VALUE_IF_FAIL(pItem->pParent, FALSE);
- CFWL_WidgetMgrItem *pChild = pItem->pParent->pChild;
- int32_t i = 0;
- while (pChild) {
- if (pChild == pItem) {
- if (i == nIndex) {
- return TRUE;
- }
- if (pChild->pPrevious) {
- pChild->pPrevious->pNext = pChild->pNext;
- }
- if (pChild->pNext) {
- pChild->pNext->pPrevious = pChild->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- pItem->pNext = NULL;
- pItem->pPrevious = NULL;
- break;
- }
- if(!pChild->pNext) {
- break;
- }
+FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ _FWL_RETURN_VALUE_IF_FAIL(pItem, FALSE);
+ _FWL_RETURN_VALUE_IF_FAIL(pItem->pParent, FALSE);
+ CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild;
+ int32_t i = 0;
+ while (pChild) {
+ if (pChild == pItem) {
+ if (i == nIndex) {
+ return TRUE;
+ }
+ if (pChild->pPrevious) {
+ pChild->pPrevious->pNext = pChild->pNext;
+ }
+ if (pChild->pNext) {
+ pChild->pNext->pPrevious = pChild->pPrevious;
+ }
+ if (pItem->pParent->pChild == pItem) {
+ pItem->pParent->pChild = pItem->pNext;
+ }
+ pItem->pNext = NULL;
+ pItem->pPrevious = NULL;
+ break;
+ }
+ if (!pChild->pNext) {
+ break;
+ }
+ pChild = pChild->pNext;
+ ++i;
+ }
+ pChild = pItem->pParent->pChild;
+ if (pChild) {
+ if (nIndex < 0) {
+ while (pChild->pNext) {
pChild = pChild->pNext;
- ++i;
- }
- pChild = pItem->pParent->pChild;
- if (pChild) {
- if (nIndex < 0) {
- while(pChild->pNext) {
- pChild = pChild->pNext;
- }
- pChild->pNext = pItem;
- pItem->pPrevious = pChild;
- pItem->pNext = NULL;
- return TRUE;
- }
- i = 0;
- while(i < nIndex && pChild->pNext ) {
- pChild = pChild->pNext;
- ++i;
- }
- if (!pChild->pNext) {
- pChild->pNext = pItem;
- pItem->pPrevious = pChild;
- pItem->pNext = NULL;
- return TRUE;
- }
- if (pChild->pPrevious) {
- pItem->pPrevious = pChild->pPrevious;
- pChild->pPrevious->pNext = pItem;
- }
- pChild->pPrevious = pItem;
- pItem->pNext = pChild;
- if (pItem->pParent->pChild == pChild) {
- pItem->pParent->pChild = pItem;
- }
- } else {
- pItem->pParent->pChild = pItem;
- pItem->pPrevious = NULL;
- pItem->pNext = NULL;
- }
- return TRUE;
+ }
+ pChild->pNext = pItem;
+ pItem->pPrevious = pChild;
+ pItem->pNext = NULL;
+ return TRUE;
+ }
+ i = 0;
+ while (i < nIndex && pChild->pNext) {
+ pChild = pChild->pNext;
+ ++i;
+ }
+ if (!pChild->pNext) {
+ pChild->pNext = pItem;
+ pItem->pPrevious = pChild;
+ pItem->pNext = NULL;
+ return TRUE;
+ }
+ if (pChild->pPrevious) {
+ pItem->pPrevious = pChild->pPrevious;
+ pChild->pPrevious->pNext = pItem;
+ }
+ pChild->pPrevious = pItem;
+ pItem->pNext = pChild;
+ if (pItem->pParent->pChild == pChild) {
+ pItem->pParent->pChild = pItem;
+ }
+ } else {
+ pItem->pParent->pChild = pItem;
+ pItem->pPrevious = NULL;
+ pItem->pNext = NULL;
+ }
+ return TRUE;
}
-FX_BOOL CFWL_WidgetMgr::IsWidget(void* pObj)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pObj, FALSE);
- return GetWidgetMgrItem((IFWL_Widget*)pObj) != NULL;
+FX_BOOL CFWL_WidgetMgr::IsWidget(void* pObj) {
+ _FWL_RETURN_VALUE_IF_FAIL(pObj, FALSE);
+ return GetWidgetMgrItem((IFWL_Widget*)pObj) != NULL;
}
-FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget *pWidget, const CFX_RectF *pRect )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pAdapter, FWL_ERR_Indefinite);
- IFWL_Widget *pNative = pWidget;
- CFX_RectF rect(*pRect);
- if (IsFormDisabled()) {
- IFWL_Widget *pOuter = pWidget->GetOuter();
- while (pOuter) {
- CFX_RectF rtTemp;
- pNative->GetWidgetRect(rtTemp);
- rect.left += rtTemp.left;
- rect.top += rtTemp.top;
- pNative = pOuter;
- pOuter = pOuter->GetOuter();
- }
- } else if (!IsAbleNative(pWidget)) {
- pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
- _FWL_RETURN_VALUE_IF_FAIL(pNative, FWL_ERR_Indefinite);
- pWidget->TransformTo(pNative, rect.left, rect.top);
- }
- AddRedrawCounts(pNative);
- return m_pAdapter->RepaintWidget(pNative, &rect);
+FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pAdapter, FWL_ERR_Indefinite);
+ IFWL_Widget* pNative = pWidget;
+ CFX_RectF rect(*pRect);
+ if (IsFormDisabled()) {
+ IFWL_Widget* pOuter = pWidget->GetOuter();
+ while (pOuter) {
+ CFX_RectF rtTemp;
+ pNative->GetWidgetRect(rtTemp);
+ rect.left += rtTemp.left;
+ rect.top += rtTemp.top;
+ pNative = pOuter;
+ pOuter = pOuter->GetOuter();
+ }
+ } else if (!IsAbleNative(pWidget)) {
+ pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
+ _FWL_RETURN_VALUE_IF_FAIL(pNative, FWL_ERR_Indefinite);
+ pWidget->TransformTo(pNative, rect.left, rect.top);
+ }
+ AddRedrawCounts(pNative);
+ return m_pAdapter->RepaintWidget(pNative, &rect);
}
-void CFWL_WidgetMgr::AddWidget(IFWL_Widget *pWidget)
-{
- CFWL_WidgetMgrItem *pParentItem = GetWidgetMgrItem(NULL);
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- if (!pItem) {
- pItem = FX_NEW CFWL_WidgetMgrItem;
- pItem->pWidget = pWidget;
- m_mapWidgetItem.SetAt(pWidget, pItem);
- }
- if (pItem->pParent && pItem->pParent != pParentItem) {
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
+void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) {
+ CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL);
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ if (!pItem) {
+ pItem = FX_NEW CFWL_WidgetMgrItem;
+ pItem->pWidget = pWidget;
+ m_mapWidgetItem.SetAt(pWidget, pItem);
+ }
+ if (pItem->pParent && pItem->pParent != pParentItem) {
+ if (pItem->pPrevious) {
+ pItem->pPrevious->pNext = pItem->pNext;
}
- pItem->pParent = pParentItem;
- SetWidgetIndex(pWidget, -1);
-}
-void CFWL_WidgetMgr::InsertWidget(IFWL_Widget *pParent, IFWL_Widget *pChild, int32_t nIndex )
-{
- CFWL_WidgetMgrItem *pParentItem = GetWidgetMgrItem(pParent);
- if (!pParentItem) {
- pParentItem = FX_NEW CFWL_WidgetMgrItem;
- pParentItem->pWidget = pParent;
- m_mapWidgetItem.SetAt(pParent, pParentItem);
- CFWL_WidgetMgrItem *pRoot = GetWidgetMgrItem(NULL);
- pParentItem->pParent = pRoot;
- SetWidgetIndex(pParent, -1);
+ if (pItem->pNext) {
+ pItem->pNext->pPrevious = pItem->pPrevious;
}
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pChild);
- if (!pItem) {
- pItem = FX_NEW CFWL_WidgetMgrItem;
- pItem->pWidget = pChild;
- m_mapWidgetItem.SetAt(pChild, pItem);
+ if (pItem->pParent->pChild == pItem) {
+ pItem->pParent->pChild = pItem->pNext;
}
- if (pItem->pParent && pItem->pParent != pParentItem) {
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- }
- pItem->pParent = pParentItem;
- SetWidgetIndex(pChild, nIndex);
+ }
+ pItem->pParent = pParentItem;
+ SetWidgetIndex(pWidget, -1);
}
-void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget *pWidget)
-{
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- if (!pItem) {
- return;
- }
+void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent,
+ IFWL_Widget* pChild,
+ int32_t nIndex) {
+ CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
+ if (!pParentItem) {
+ pParentItem = FX_NEW CFWL_WidgetMgrItem;
+ pParentItem->pWidget = pParent;
+ m_mapWidgetItem.SetAt(pParent, pParentItem);
+ CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL);
+ pParentItem->pParent = pRoot;
+ SetWidgetIndex(pParent, -1);
+ }
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild);
+ if (!pItem) {
+ pItem = FX_NEW CFWL_WidgetMgrItem;
+ pItem->pWidget = pChild;
+ m_mapWidgetItem.SetAt(pChild, pItem);
+ }
+ if (pItem->pParent && pItem->pParent != pParentItem) {
if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
+ pItem->pPrevious->pNext = pItem->pNext;
}
if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent && pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
+ pItem->pNext->pPrevious = pItem->pPrevious;
}
- CFWL_WidgetMgrItem *pChild = pItem->pChild;
- while (pChild) {
- CFWL_WidgetMgrItem *pNext = pChild->pNext;
- RemoveWidget(pChild->pWidget);
- pChild = pNext;
+ if (pItem->pParent->pChild == pItem) {
+ pItem->pParent->pChild = pItem->pNext;
}
- m_mapWidgetItem.RemoveKey(pWidget);
- delete pItem;
+ }
+ pItem->pParent = pParentItem;
+ SetWidgetIndex(pChild, nIndex);
}
-void CFWL_WidgetMgr::SetOwner(IFWL_Widget *pOwner, IFWL_Widget *pOwned)
-{
- CFWL_WidgetMgrItem *pParentItem = GetWidgetMgrItem(pOwner);
- if (!pParentItem) {
- pParentItem = FX_NEW CFWL_WidgetMgrItem;
- pParentItem->pWidget = pOwner;
- m_mapWidgetItem.SetAt(pOwner, pParentItem);
- CFWL_WidgetMgrItem *pRoot = GetWidgetMgrItem(NULL);
- pParentItem->pParent = pRoot;
- SetWidgetIndex(pOwner, -1);
- }
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pOwned);
- if (!pItem) {
- pItem = FX_NEW CFWL_WidgetMgrItem;
- pItem->pWidget = pOwned;
- m_mapWidgetItem.SetAt(pOwned, pItem);
- }
- pItem->pOwner = pParentItem;
+void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ if (!pItem) {
+ return;
+ }
+ if (pItem->pPrevious) {
+ pItem->pPrevious->pNext = pItem->pNext;
+ }
+ if (pItem->pNext) {
+ pItem->pNext->pPrevious = pItem->pPrevious;
+ }
+ if (pItem->pParent && pItem->pParent->pChild == pItem) {
+ pItem->pParent->pChild = pItem->pNext;
+ }
+ CFWL_WidgetMgrItem* pChild = pItem->pChild;
+ while (pChild) {
+ CFWL_WidgetMgrItem* pNext = pChild->pNext;
+ RemoveWidget(pChild->pWidget);
+ pChild = pNext;
+ }
+ m_mapWidgetItem.RemoveKey(pWidget);
+ delete pItem;
}
-void CFWL_WidgetMgr::SetParent(IFWL_Widget *pParent, IFWL_Widget *pChild)
-{
- CFWL_WidgetMgrItem *pParentItem = GetWidgetMgrItem(pParent);
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pChild);
- _FWL_RETURN_IF_FAIL(pItem);
- if (pItem->pParent && pItem->pParent != pParentItem) {
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- pItem->pNext = NULL;
- pItem->pPrevious = NULL;
+void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) {
+ CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner);
+ if (!pParentItem) {
+ pParentItem = FX_NEW CFWL_WidgetMgrItem;
+ pParentItem->pWidget = pOwner;
+ m_mapWidgetItem.SetAt(pOwner, pParentItem);
+ CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL);
+ pParentItem->pParent = pRoot;
+ SetWidgetIndex(pOwner, -1);
+ }
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned);
+ if (!pItem) {
+ pItem = FX_NEW CFWL_WidgetMgrItem;
+ pItem->pWidget = pOwned;
+ m_mapWidgetItem.SetAt(pOwned, pItem);
+ }
+ pItem->pOwner = pParentItem;
+}
+void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) {
+ CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild);
+ _FWL_RETURN_IF_FAIL(pItem);
+ if (pItem->pParent && pItem->pParent != pParentItem) {
+ if (pItem->pPrevious) {
+ pItem->pPrevious->pNext = pItem->pNext;
}
- pItem->pParent = pParentItem;
- SetWidgetIndex(pChild, -1);
- _FWL_RETURN_IF_FAIL(m_pAdapter);
- m_pAdapter->SetParentWidget(pChild, pParent);
+ if (pItem->pNext) {
+ pItem->pNext->pPrevious = pItem->pPrevious;
+ }
+ if (pItem->pParent->pChild == pItem) {
+ pItem->pParent->pChild = pItem->pNext;
+ }
+ pItem->pNext = NULL;
+ pItem->pPrevious = NULL;
+ }
+ pItem->pParent = pParentItem;
+ SetWidgetIndex(pChild, -1);
+ _FWL_RETURN_IF_FAIL(m_pAdapter);
+ m_pAdapter->SetParentWidget(pChild, pParent);
}
-FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget *pChild, IFWL_Widget *pParent)
-{
- IFWL_Widget *pTemp = pChild;
- do {
- if (pTemp == pParent) {
- return TRUE;
- }
- pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent);
- } while (pTemp);
- return FALSE;
+FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) {
+ IFWL_Widget* pTemp = pChild;
+ do {
+ if (pTemp == pParent) {
+ return TRUE;
+ }
+ pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent);
+ } while (pTemp);
+ return FALSE;
}
-FWL_ERR CFWL_WidgetMgr::CreateWidget_Native(IFWL_Widget *pWidget)
-{
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->CreateWidget(pWidget, pWidget->GetOwner());
+FWL_ERR CFWL_WidgetMgr::CreateWidget_Native(IFWL_Widget* pWidget) {
+ if (!IsAbleNative(pWidget)) {
+ return FWL_ERR_Succeeded;
+ }
+ return m_pAdapter->CreateWidget(pWidget, pWidget->GetOwner());
}
-FWL_ERR CFWL_WidgetMgr::DestroyWidget_Native(IFWL_Widget *pWidget)
-{
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->DestroyWidget(pWidget);
+FWL_ERR CFWL_WidgetMgr::DestroyWidget_Native(IFWL_Widget* pWidget) {
+ if (!IsAbleNative(pWidget)) {
+ return FWL_ERR_Succeeded;
+ }
+ return m_pAdapter->DestroyWidget(pWidget);
}
-FWL_ERR CFWL_WidgetMgr::GetWidgetRect_Native(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->GetWidgetRect(pWidget, rect);
+FWL_ERR CFWL_WidgetMgr::GetWidgetRect_Native(IFWL_Widget* pWidget,
+ CFX_RectF& rect) {
+ if (!IsAbleNative(pWidget)) {
+ return FWL_ERR_Succeeded;
+ }
+ return m_pAdapter->GetWidgetRect(pWidget, rect);
}
-FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget *pWidget, const CFX_RectF &rect)
-{
- if (FWL_UseOffscreen(pWidget)) {
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- pItem->iRedrawCounter ++;
- if (pItem->pOffscreen) {
- CFX_RenderDevice *pDevice = pItem->pOffscreen->GetRenderDevice();
- if (pDevice && pDevice->GetBitmap()) {
- CFX_DIBitmap *pBitmap = pDevice->GetBitmap();
- if (pBitmap->GetWidth() - rect.width > 1 || pBitmap->GetHeight() - rect.height > 1) {
- delete pItem->pOffscreen;
- pItem->pOffscreen = NULL;
- }
- }
+FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget,
+ const CFX_RectF& rect) {
+ if (FWL_UseOffscreen(pWidget)) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ pItem->iRedrawCounter++;
+ if (pItem->pOffscreen) {
+ CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice();
+ if (pDevice && pDevice->GetBitmap()) {
+ CFX_DIBitmap* pBitmap = pDevice->GetBitmap();
+ if (pBitmap->GetWidth() - rect.width > 1 ||
+ pBitmap->GetHeight() - rect.height > 1) {
+ delete pItem->pOffscreen;
+ pItem->pOffscreen = NULL;
}
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)
- pItem->bOutsideChanged = !m_rtScreen.Contains(rect);
-#endif
+ }
}
- return m_pAdapter->SetWidgetRect(pWidget, rect);
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
+ pItem->bOutsideChanged = !m_rtScreen.Contains(rect);
+#endif
+ }
+ return m_pAdapter->SetWidgetRect(pWidget, rect);
}
-FWL_ERR CFWL_WidgetMgr::SetWidgetPosition_Native(IFWL_Widget *pWidget, FX_FLOAT fx, FX_FLOAT fy)
-{
- return m_pAdapter->SetWidgetPosition(pWidget, fx, fy);
+FWL_ERR CFWL_WidgetMgr::SetWidgetPosition_Native(IFWL_Widget* pWidget,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ return m_pAdapter->SetWidgetPosition(pWidget, fx, fy);
}
-FWL_ERR CFWL_WidgetMgr::SetWidgetIcon_Native(IFWL_Widget *pWidget, const CFX_DIBitmap *pIcon, FX_BOOL bBig)
-{
- return m_pAdapter->SetWidgetIcon(pWidget, pIcon, bBig);
+FWL_ERR CFWL_WidgetMgr::SetWidgetIcon_Native(IFWL_Widget* pWidget,
+ const CFX_DIBitmap* pIcon,
+ FX_BOOL bBig) {
+ return m_pAdapter->SetWidgetIcon(pWidget, pIcon, bBig);
}
-FWL_ERR CFWL_WidgetMgr::SetWidgetCaption_Native(IFWL_Widget *pWidget, const CFX_WideStringC& wsCaption)
-{
- return m_pAdapter->SetWidgetCaption(pWidget, wsCaption);
+FWL_ERR CFWL_WidgetMgr::SetWidgetCaption_Native(
+ IFWL_Widget* pWidget,
+ const CFX_WideStringC& wsCaption) {
+ return m_pAdapter->SetWidgetCaption(pWidget, wsCaption);
}
-FWL_ERR CFWL_WidgetMgr::SetBorderRegion_Native(IFWL_Widget *pWidget, CFX_Path *pPath)
-{
- return m_pAdapter->SetBorderRegion(pWidget, pPath);
+FWL_ERR CFWL_WidgetMgr::SetBorderRegion_Native(IFWL_Widget* pWidget,
+ CFX_Path* pPath) {
+ return m_pAdapter->SetBorderRegion(pWidget, pPath);
}
-FWL_ERR CFWL_WidgetMgr::ShowWidget_Native(IFWL_Widget *pWidget)
-{
- return m_pAdapter->ShowWidget(pWidget);
+FWL_ERR CFWL_WidgetMgr::ShowWidget_Native(IFWL_Widget* pWidget) {
+ return m_pAdapter->ShowWidget(pWidget);
}
-FWL_ERR CFWL_WidgetMgr::HideWidget_Native(IFWL_Widget *pWidget)
-{
- return m_pAdapter->HideWidget(pWidget);
+FWL_ERR CFWL_WidgetMgr::HideWidget_Native(IFWL_Widget* pWidget) {
+ return m_pAdapter->HideWidget(pWidget);
}
-FWL_ERR CFWL_WidgetMgr::SetNormal_Native(IFWL_Widget *pWidget)
-{
- return m_pAdapter->SetNormal(pWidget);
+FWL_ERR CFWL_WidgetMgr::SetNormal_Native(IFWL_Widget* pWidget) {
+ return m_pAdapter->SetNormal(pWidget);
}
-FWL_ERR CFWL_WidgetMgr::SetMaximize_Native(IFWL_Widget *pWidget)
-{
- return m_pAdapter->SetMaximize(pWidget);
+FWL_ERR CFWL_WidgetMgr::SetMaximize_Native(IFWL_Widget* pWidget) {
+ return m_pAdapter->SetMaximize(pWidget);
}
-FWL_ERR CFWL_WidgetMgr::SetMinimize_Native(IFWL_Widget *pWidget)
-{
- return m_pAdapter->SetMinimize(pWidget);
+FWL_ERR CFWL_WidgetMgr::SetMinimize_Native(IFWL_Widget* pWidget) {
+ return m_pAdapter->SetMinimize(pWidget);
}
-FX_BOOL CFWL_WidgetMgr::CheckMessage_Native()
-{
- return m_pAdapter->CheckMessage();
+FX_BOOL CFWL_WidgetMgr::CheckMessage_Native() {
+ return m_pAdapter->CheckMessage();
}
-FWL_ERR CFWL_WidgetMgr::DispatchMessage_Native()
-{
- return m_pAdapter->DispatchMessage();
+FWL_ERR CFWL_WidgetMgr::DispatchMessage_Native() {
+ return m_pAdapter->DispatchMessage();
}
-FX_BOOL CFWL_WidgetMgr::IsIdleMessage_Native()
-{
- return m_pAdapter->IsIdleMessage();
+FX_BOOL CFWL_WidgetMgr::IsIdleMessage_Native() {
+ return m_pAdapter->IsIdleMessage();
}
-FWL_ERR CFWL_WidgetMgr::Exit_Native(int32_t iExitCode)
-{
- return m_pAdapter->Exit(iExitCode);
+FWL_ERR CFWL_WidgetMgr::Exit_Native(int32_t iExitCode) {
+ return m_pAdapter->Exit(iExitCode);
}
-FWL_ERR CFWL_WidgetMgr::CreateWidgetWithNativeId_Native(IFWL_Widget *pWidget, void *vp)
-{
- return m_pAdapter->CreateWidgetWithNativeId(pWidget, vp);
+FWL_ERR CFWL_WidgetMgr::CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget,
+ void* vp) {
+ return m_pAdapter->CreateWidgetWithNativeId(pWidget, vp);
}
-IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget * parent, FX_FLOAT x, FX_FLOAT y)
-{
- _FWL_RETURN_VALUE_IF_FAIL(parent, NULL);
- FX_FLOAT x1;
- FX_FLOAT y1;
- IFWL_Widget * child = GetWidget(parent, FWL_WGTRELATION_LastChild);
- while (child) {
- if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
- x1 = x;
- y1 = y;
- CFX_Matrix matrixOnParent;
- child->GetMatrix(matrixOnParent);
- CFX_Matrix m;
- m.Reset();
- m.SetReverse(matrixOnParent);
- m.TransformPoint(x1, y1);
- CFX_RectF bounds;
- child->GetWidgetRect(bounds);
- if (bounds.Contains(x1, y1)) {
- x1 -= bounds.left;
- y1 -= bounds.top;
- return GetWidgetAtPoint(child, x1, y1);
- }
- }
- child = GetWidget(child, FWL_WGTRELATION_PriorSibling);
- }
- return parent;
+IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent,
+ FX_FLOAT x,
+ FX_FLOAT y) {
+ _FWL_RETURN_VALUE_IF_FAIL(parent, NULL);
+ FX_FLOAT x1;
+ FX_FLOAT y1;
+ IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild);
+ while (child) {
+ if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
+ x1 = x;
+ y1 = y;
+ CFX_Matrix matrixOnParent;
+ child->GetMatrix(matrixOnParent);
+ CFX_Matrix m;
+ m.Reset();
+ m.SetReverse(matrixOnParent);
+ m.TransformPoint(x1, y1);
+ CFX_RectF bounds;
+ child->GetWidgetRect(bounds);
+ if (bounds.Contains(x1, y1)) {
+ x1 -= bounds.left;
+ y1 -= bounds.top;
+ return GetWidgetAtPoint(child, x1, y1);
+ }
+ }
+ child = GetWidget(child, FWL_WGTRELATION_PriorSibling);
+ }
+ return parent;
}
-void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget *pForm, FX_FLOAT fx, FX_FLOAT fy)
-{
- if (!FWL_UseOffscreen(pForm)) {
- return;
- }
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pForm);
- if (pItem->pOffscreen) {
- delete pItem->pOffscreen;
- pItem->pOffscreen = NULL;
- }
+void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!FWL_UseOffscreen(pForm)) {
+ return;
+ }
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pForm);
+ if (pItem->pOffscreen) {
+ delete pItem->pOffscreen;
+ pItem->pOffscreen = NULL;
+ }
}
-IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget *parent, IFWL_Widget *focus, FX_BOOL &bFind)
-{
- IFWL_Widget *child = FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if (focus == child) {
- bFind = TRUE;
- }
- if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && (!focus || (focus != child && bFind))) {
- return child;
- }
- IFWL_Widget *bRet = nextTab(child, focus, bFind);
- if (bRet) {
- return bRet;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return NULL;
+IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent,
+ IFWL_Widget* focus,
+ FX_BOOL& bFind) {
+ IFWL_Widget* child =
+ FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ if (focus == child) {
+ bFind = TRUE;
+ }
+ if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) &&
+ (!focus || (focus != child && bFind))) {
+ return child;
+ }
+ IFWL_Widget* bRet = nextTab(child, focus, bFind);
+ if (bRet) {
+ return bRet;
+ }
+ child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
+ return NULL;
}
-int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget *pFirst)
-{
- int32_t iRet = 0;
- IFWL_Widget *pChild = pFirst;
- while (pChild) {
- if ((pChild->GetStyles() & FWL_WGTSTYLE_Group) && pChild->GetClassID() == 3811304691) {
- iRet ++;
- }
- pChild = GetWidget(pChild, FWL_WGTRELATION_NextSibling);
- }
- return iRet;
+int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) {
+ int32_t iRet = 0;
+ IFWL_Widget* pChild = pFirst;
+ while (pChild) {
+ if ((pChild->GetStyles() & FWL_WGTSTYLE_Group) &&
+ pChild->GetClassID() == 3811304691) {
+ iRet++;
+ }
+ pChild = GetWidget(pChild, FWL_WGTRELATION_NextSibling);
+ }
+ return iRet;
}
-IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget *pWidget, FX_BOOL bNext)
-{
- while ((pWidget = GetWidget(pWidget, bNext ? FWL_WGTRELATION_NextSibling : FWL_WGTRELATION_PriorSibling)) != NULL) {
- if (pWidget->GetClassID() == 3811304691) {
- return pWidget;
- }
- }
- return NULL;
+IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget,
+ FX_BOOL bNext) {
+ while ((pWidget = GetWidget(pWidget, bNext ? FWL_WGTRELATION_NextSibling
+ : FWL_WGTRELATION_PriorSibling)) !=
+ NULL) {
+ if (pWidget->GetClassID() == 3811304691) {
+ return pWidget;
+ }
+ }
+ return NULL;
}
-IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(IFWL_Widget *pRadioButton)
-{
- if (pRadioButton->GetStyles() & FWL_WGTSTYLE_Group) {
- return pRadioButton;
- }
- IFWL_Widget *pNext = pRadioButton;
- while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != NULL) {
- if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
- return pNext;
- }
- }
- pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling);
- if ((pNext->GetStyles() & FWL_WGTSTYLE_Group) && pNext->GetClassID() == 3811304691) {
- return pNext;
- }
- while ((pNext = GetSiblingRadioButton(pNext, FALSE)) && pNext && pNext != pRadioButton) {
- if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
- return pNext;
- }
- }
- pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
- if (pNext && (pNext->GetStyles() == FWL_WGTSTYLE_Group) && pNext->GetClassID() == 3811304691) {
- return pNext;
- }
- return GetSiblingRadioButton(pNext, TRUE);
+IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
+ IFWL_Widget* pRadioButton) {
+ if (pRadioButton->GetStyles() & FWL_WGTSTYLE_Group) {
+ return pRadioButton;
+ }
+ IFWL_Widget* pNext = pRadioButton;
+ while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != NULL) {
+ if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
+ return pNext;
+ }
+ }
+ pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling);
+ if ((pNext->GetStyles() & FWL_WGTSTYLE_Group) &&
+ pNext->GetClassID() == 3811304691) {
+ return pNext;
+ }
+ while ((pNext = GetSiblingRadioButton(pNext, FALSE)) && pNext &&
+ pNext != pRadioButton) {
+ if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
+ return pNext;
+ }
+ }
+ pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
+ if (pNext && (pNext->GetStyles() == FWL_WGTSTYLE_Group) &&
+ pNext->GetClassID() == 3811304691) {
+ return pNext;
+ }
+ return GetSiblingRadioButton(pNext, TRUE);
}
-void CFWL_WidgetMgr::GetSameGroupRadioButton(IFWL_Widget *pRadioButton, CFX_PtrArray &group)
-{
- IFWL_Widget *pFirst = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
- if (!pFirst) {
- pFirst = pRadioButton;
- }
- int32_t iGroup = CountRadioButtonGroup(pFirst);
- if (iGroup < 2) {
- if (pFirst->GetClassID() == 3811304691) {
- group.Add(pFirst);
- }
- IFWL_Widget *pNext = pFirst;
- while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != NULL) {
- group.Add(pNext);
- }
- return;
- }
- IFWL_Widget *pNext = GetRadioButtonGroupHeader(pRadioButton);
- do {
- group.Add(pNext);
- pNext = GetSiblingRadioButton(pNext, TRUE);
- if (!pNext) {
- if (pFirst->GetClassID() == 3811304691) {
- pNext = pFirst;
- } else {
- pNext = GetSiblingRadioButton(pFirst, TRUE);
- }
- }
- } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0));
+void CFWL_WidgetMgr::GetSameGroupRadioButton(IFWL_Widget* pRadioButton,
+ CFX_PtrArray& group) {
+ IFWL_Widget* pFirst = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
+ if (!pFirst) {
+ pFirst = pRadioButton;
+ }
+ int32_t iGroup = CountRadioButtonGroup(pFirst);
+ if (iGroup < 2) {
+ if (pFirst->GetClassID() == 3811304691) {
+ group.Add(pFirst);
+ }
+ IFWL_Widget* pNext = pFirst;
+ while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != NULL) {
+ group.Add(pNext);
+ }
+ return;
+ }
+ IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton);
+ do {
+ group.Add(pNext);
+ pNext = GetSiblingRadioButton(pNext, TRUE);
+ if (!pNext) {
+ if (pFirst->GetClassID() == 3811304691) {
+ pNext = pFirst;
+ } else {
+ pNext = GetSiblingRadioButton(pFirst, TRUE);
+ }
+ }
+ } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0));
}
-IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget *pParent)
-{
- if ((pParent->GetClassID() == 3521614244) && (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
- return pParent;
- }
- IFWL_Widget *child = FWL_GetWidgetMgr()->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if ((child->GetClassID() == 3521614244) && (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
- return child;
- }
- IFWL_Widget *find = GetDefaultButton(child);
- if (find) {
- return find;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return NULL;
+IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) {
+ if ((pParent->GetClassID() == 3521614244) &&
+ (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
+ return pParent;
+ }
+ IFWL_Widget* child =
+ FWL_GetWidgetMgr()->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ if ((child->GetClassID() == 3521614244) &&
+ (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
+ return child;
+ }
+ IFWL_Widget* find = GetDefaultButton(child);
+ if (find) {
+ return find;
+ }
+ child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
+ return NULL;
}
-void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget *pWidget)
-{
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- (pItem->iRedrawCounter)++;
+void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ (pItem->iRedrawCounter)++;
}
-void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget *pWidget)
-{
- CFWL_WidgetMgrItem *pItem = GetWidgetMgrItem(pWidget);
- pItem->iRedrawCounter = 0;
+void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) {
+ CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
+ pItem->iRedrawCounter = 0;
}
-CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(IFWL_Widget *pWidget)
-{
- return (CFWL_WidgetMgrItem*)m_mapWidgetItem.GetValueAt(pWidget);
+CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(IFWL_Widget* pWidget) {
+ return (CFWL_WidgetMgrItem*)m_mapWidgetItem.GetValueAt(pWidget);
}
-int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem *pParent, int32_t *pIndex, CFWL_WidgetMgrItem *pItem, IFWL_Widget **pWidget )
-{
- if (!pParent) {
- return 0;
- }
- int32_t iCount = 0;
- CFWL_WidgetMgrItem *pChild = pParent->pChild;
- while (pChild) {
- iCount ++;
- if (pIndex) {
- if (*pIndex == 0) {
- *pWidget = pChild->pWidget;
- return iCount;
- }
- pIndex --;
- }
- if (pItem && pItem == pChild) {
- return iCount - 1;
- }
- pChild = pChild->pNext;
- }
+int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent,
+ int32_t* pIndex,
+ CFWL_WidgetMgrItem* pItem,
+ IFWL_Widget** pWidget) {
+ if (!pParent) {
+ return 0;
+ }
+ int32_t iCount = 0;
+ CFWL_WidgetMgrItem* pChild = pParent->pChild;
+ while (pChild) {
+ iCount++;
if (pIndex) {
- return 0;
- } else if (pItem) {
- return -1;
- }
- return iCount - 1;
-}
-FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) {
- return FALSE;
- }
- FX_DWORD dwStyles = pWidget->GetStyles();
- return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == FWL_WGTSTYLE_OverLapper) || (dwStyles & FWL_WGTSTYLE_Popup);
+ if (*pIndex == 0) {
+ *pWidget = pChild->pWidget;
+ return iCount;
+ }
+ pIndex--;
+ }
+ if (pItem && pItem == pChild) {
+ return iCount - 1;
+ }
+ pChild = pChild->pNext;
+ }
+ if (pIndex) {
+ return 0;
+ } else if (pItem) {
+ return -1;
+ }
+ return iCount - 1;
}
-FX_BOOL CFWL_WidgetMgr::IsThreadEnabled()
-{
- return !(m_dwCapability & FWL_WGTMGR_DisableThread);
+FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) {
+ return FALSE;
+ }
+ FX_DWORD dwStyles = pWidget->GetStyles();
+ return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
+ FWL_WGTSTYLE_OverLapper) ||
+ (dwStyles & FWL_WGTSTYLE_Popup);
}
-FX_BOOL CFWL_WidgetMgr::IsFormDisabled()
-{
- return m_dwCapability & FWL_WGTMGR_DisableForm;
+FX_BOOL CFWL_WidgetMgr::IsThreadEnabled() {
+ return !(m_dwCapability & FWL_WGTMGR_DisableThread);
}
-FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup)
-{
- IFWL_AdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr();
- return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, rtPopup);
+FX_BOOL CFWL_WidgetMgr::IsFormDisabled() {
+ return m_dwCapability & FWL_WGTMGR_DisableForm;
}
-CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr *pWidgetMgr)
- : m_pWidgetMgr(pWidgetMgr)
-{
+FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget,
+ FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup) {
+ IFWL_AdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr();
+ return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor,
+ rtPopup);
}
-FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(FX_DWORD dwCapability )
-{
- m_pWidgetMgr->m_dwCapability = dwCapability;
- return FWL_ERR_Succeeded;
+CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr)
+ : m_pWidgetMgr(pWidgetMgr) {}
+FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(FX_DWORD dwCapability) {
+ m_pWidgetMgr->m_dwCapability = dwCapability;
+ return FWL_ERR_Succeeded;
}
-int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message *pMessage)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
- _FWL_RETURN_VALUE_IF_FAIL(pMessage->m_pDstTarget, 0);
- IFWL_Widget *pDstWidget = (IFWL_Widget*)pMessage->m_pDstTarget;
- IFWL_NoteThread *pNoteThread = pDstWidget->GetOwnerThread();
- _FWL_RETURN_VALUE_IF_FAIL(pNoteThread, 0);
- CFWL_NoteDriver *pNoteDriver = (CFWL_NoteDriver*)pNoteThread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(pNoteDriver, 0);
- if (m_pWidgetMgr->IsThreadEnabled()) {
- pMessage = (CFWL_Message*)pMessage->Clone();
- }
- if (m_pWidgetMgr->IsFormDisabled()) {
- pNoteDriver->ProcessMessage(pMessage);
- } else {
- pNoteDriver->QueueMessage(pMessage);
- }
-#if (_FX_OS_==_FX_MACOSX_)
- CFWL_NoteLoop *pTopLoop = pNoteDriver->GetTopLoop();
- if (pTopLoop) {
- pNoteDriver->UnqueueMessage(pTopLoop);
- }
+int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) {
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage, 0);
+ _FWL_RETURN_VALUE_IF_FAIL(pMessage->m_pDstTarget, 0);
+ IFWL_Widget* pDstWidget = (IFWL_Widget*)pMessage->m_pDstTarget;
+ IFWL_NoteThread* pNoteThread = pDstWidget->GetOwnerThread();
+ _FWL_RETURN_VALUE_IF_FAIL(pNoteThread, 0);
+ CFWL_NoteDriver* pNoteDriver = (CFWL_NoteDriver*)pNoteThread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(pNoteDriver, 0);
+ if (m_pWidgetMgr->IsThreadEnabled()) {
+ pMessage = (CFWL_Message*)pMessage->Clone();
+ }
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ pNoteDriver->ProcessMessage(pMessage);
+ } else {
+ pNoteDriver->QueueMessage(pMessage);
+ }
+#if (_FX_OS_ == _FX_MACOSX_)
+ CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop();
+ if (pTopLoop) {
+ pNoteDriver->UnqueueMessage(pTopLoop);
+ }
#endif
- if (m_pWidgetMgr->IsThreadEnabled()) {
- pMessage->Release();
- }
- return FWL_ERR_Succeeded;
+ if (m_pWidgetMgr->IsThreadEnabled()) {
+ pMessage->Release();
+ }
+ return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget * pWidget,
- CFX_Graphics * pGraphics,
- const CFX_Matrix * pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);
- _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
- CFX_Graphics *pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
- CFX_RectF clipCopy;
- pWidget->GetWidgetRect(clipCopy);
- clipCopy.left = clipCopy.top = 0;
- if (bUseOffscreenDirect(pWidget)) {
- DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
- return FWL_ERR_Succeeded;
- }
- CFX_RectF clipBounds;
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_) || (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_)
- IFWL_WidgetDelegate *pDelegate = pWidget->SetDelegate(NULL);
+FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Indefinite);
+ _FWL_RETURN_VALUE_IF_FAIL(pGraphics, FWL_ERR_Indefinite);
+ CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
+ CFX_RectF clipCopy;
+ pWidget->GetWidgetRect(clipCopy);
+ clipCopy.left = clipCopy.top = 0;
+ if (bUseOffscreenDirect(pWidget)) {
+ DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
+ return FWL_ERR_Succeeded;
+ }
+ CFX_RectF clipBounds;
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \
+ (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_)
+ IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
+ pDelegate->OnDrawWidget(pTemp, pMatrix);
+ pGraphics->GetClipRect(clipBounds);
+ clipCopy = clipBounds;
+#elif(_FX_OS_ == _FX_MACOSX_)
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
pDelegate->OnDrawWidget(pTemp, pMatrix);
pGraphics->GetClipRect(clipBounds);
clipCopy = clipBounds;
-#elif (_FX_OS_==_FX_MACOSX_)
- if (m_pWidgetMgr->IsFormDisabled()) {
- IFWL_WidgetDelegate *pDelegate = pWidget->SetDelegate(NULL);
- pDelegate->OnDrawWidget(pTemp, pMatrix);
- pGraphics->GetClipRect(clipBounds);
- clipCopy = clipBounds;
- } else {
- clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
- ((CFX_Matrix*)pMatrix)->Reset();
+ } else {
+ clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
+ ((CFX_Matrix*)pMatrix)->Reset();
#ifdef FWL_UseMacSystemBorder
#else
#endif
- {
- IFWL_WidgetDelegate *pDelegate = pWidget->SetDelegate(NULL);
- pDelegate->OnDrawWidget(pTemp, pMatrix);
- }
+ {
+ IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
+ pDelegate->OnDrawWidget(pTemp, pMatrix);
}
+ }
#endif
- if (!m_pWidgetMgr->IsFormDisabled()) {
- CFX_RectF rtClient;
- pWidget->GetClientRect(rtClient);
- clipBounds.Intersect(rtClient);
- }
- if (!clipBounds.IsEmpty()) {
- DrawChild(pWidget, clipBounds, pTemp, pMatrix);
- }
- DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
- m_pWidgetMgr->ResetRedrawCounts(pWidget);
- return FWL_ERR_Succeeded;
+ if (!m_pWidgetMgr->IsFormDisabled()) {
+ CFX_RectF rtClient;
+ pWidget->GetClientRect(rtClient);
+ clipBounds.Intersect(rtClient);
+ }
+ if (!clipBounds.IsEmpty()) {
+ DrawChild(pWidget, clipBounds, pTemp, pMatrix);
+ }
+ DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
+ m_pWidgetMgr->ResetRedrawCounts(pWidget);
+ return FWL_ERR_Succeeded;
}
-void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
- const CFX_RectF& rtClip,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix )
-{
- _FWL_RETURN_IF_FAIL(parent);
- FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled();
- IFWL_Widget* pNextChild = m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (pNextChild) {
- IFWL_Widget* child = pNextChild;
- pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- if (child->GetStates() & FWL_WGTSTATE_Invisible) {
- continue;
- }
- CFX_RectF rtWidget;
- child->GetWidgetRect(rtWidget);
- if (rtWidget.IsEmpty()) {
- continue;
- }
- CFX_Matrix widgetMatrix;
- CFX_RectF clipBounds(rtWidget);
- if(!bFormDisable) {
- child->GetMatrix(widgetMatrix, TRUE);
- }
- if (pMatrix) {
- widgetMatrix.Concat(*pMatrix);
- }
- if (!bFormDisable) {
- widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
- clipBounds.Intersect(rtClip);
- if (clipBounds.IsEmpty()) {
- continue;
- }
- pGraphics->SaveGraphState();
- pGraphics->SetClipRect(clipBounds);
- }
- widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE);
- IFWL_WidgetDelegate *pDelegate = child->SetDelegate(NULL);
- if (pDelegate) {
- if (m_pWidgetMgr->IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip)) {
- pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
- }
- }
- if (!bFormDisable) {
- pGraphics->RestoreGraphState();
- }
- DrawChild(child, clipBounds, pGraphics, bFormDisable ? &widgetMatrix : pMatrix);
- child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
+void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
+ const CFX_RectF& rtClip,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(parent);
+ FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled();
+ IFWL_Widget* pNextChild =
+ m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild);
+ while (pNextChild) {
+ IFWL_Widget* child = pNextChild;
+ pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ if (child->GetStates() & FWL_WGTSTATE_Invisible) {
+ continue;
}
+ CFX_RectF rtWidget;
+ child->GetWidgetRect(rtWidget);
+ if (rtWidget.IsEmpty()) {
+ continue;
+ }
+ CFX_Matrix widgetMatrix;
+ CFX_RectF clipBounds(rtWidget);
+ if (!bFormDisable) {
+ child->GetMatrix(widgetMatrix, TRUE);
+ }
+ if (pMatrix) {
+ widgetMatrix.Concat(*pMatrix);
+ }
+ if (!bFormDisable) {
+ widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
+ clipBounds.Intersect(rtClip);
+ if (clipBounds.IsEmpty()) {
+ continue;
+ }
+ pGraphics->SaveGraphState();
+ pGraphics->SetClipRect(clipBounds);
+ }
+ widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE);
+ IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL);
+ if (pDelegate) {
+ if (m_pWidgetMgr->IsFormDisabled() ||
+ IsNeedRepaint(child, &widgetMatrix, rtClip)) {
+ pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
+ }
+ }
+ if (!bFormDisable) {
+ pGraphics->RestoreGraphState();
+ }
+ DrawChild(child, clipBounds, pGraphics,
+ bFormDisable ? &widgetMatrix : pMatrix);
+ child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
}
-CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix)
-{
- if (!FWL_UseOffscreen(pWidget)) {
- return pGraphics;
- }
- CFWL_WidgetMgrItem *pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (!pItem->pOffscreen) {
- pItem->pOffscreen = FX_NEW CFX_Graphics;
- CFX_RectF rect;
- pWidget->GetWidgetRect(rect);
- pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, FXDIB_Argb);
- }
+CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore(
+ IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ if (!FWL_UseOffscreen(pWidget)) {
+ return pGraphics;
+ }
+ CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
+ if (!pItem->pOffscreen) {
+ pItem->pOffscreen = FX_NEW CFX_Graphics;
CFX_RectF rect;
- pGraphics->GetClipRect(rect);
- pItem->pOffscreen->SetClipRect(rect);
- return pItem->pOffscreen;
+ pWidget->GetWidgetRect(rect);
+ pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height,
+ FXDIB_Argb);
+ }
+ CFX_RectF rect;
+ pGraphics->GetClipRect(rect);
+ pItem->pOffscreen->SetClipRect(rect);
+ return pItem->pOffscreen;
}
-void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, CFX_RectF &rtClip, const CFX_Matrix *pMatrix)
-{
- if (FWL_UseOffscreen(pWidget)) {
- CFWL_WidgetMgrItem *pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, (CFX_Matrix*)pMatrix);
+void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ CFX_RectF& rtClip,
+ const CFX_Matrix* pMatrix) {
+ if (FWL_UseOffscreen(pWidget)) {
+ CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
+ pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip,
+ (CFX_Matrix*)pMatrix);
#ifdef _WIN32
- pItem->pOffscreen->ClearClip();
+ pItem->pOffscreen->ClearClip();
#endif
- }
- CFWL_WidgetMgrItem *pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- pItem->iRedrawCounter = 0;
+ }
+ CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
+ pItem->iRedrawCounter = 0;
}
-#define FWL_NEEDREPAINTHIT_Point 12
-#define FWL_NEEDREPAINTHIT_Piece 3
+#define FWL_NEEDREPAINTHIT_Point 12
+#define FWL_NEEDREPAINTHIT_Piece 3
typedef struct _FWL_NeedRepaintHitData {
- CFX_PointF hitPoint;
- FX_BOOL bNotNeedRepaint;
- FX_BOOL bNotContainByDirty;
+ CFX_PointF hitPoint;
+ FX_BOOL bNotNeedRepaint;
+ FX_BOOL bNotContainByDirty;
} FWL_NeedRepaintHitData;
-FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget *pWidget, CFX_Matrix *pMatrix, const CFX_RectF &rtDirty)
-{
- CFWL_WidgetMgrItem * pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (pItem && pItem->iRedrawCounter > 0) {
- pItem->iRedrawCounter = 0;
- return TRUE;
- }
- CFX_RectF rtWidget;
- pWidget->GetWidgetRect(rtWidget);
- rtWidget.left = rtWidget.top = 0;
- pMatrix->TransformRect(rtWidget);
- if (!rtWidget.IntersectWith(rtDirty)) {
- return FALSE;
- }
- IFWL_Widget * pChild = FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild);
- if (!pChild) {
+FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
+ CFX_Matrix* pMatrix,
+ const CFX_RectF& rtDirty) {
+ CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
+ if (pItem && pItem->iRedrawCounter > 0) {
+ pItem->iRedrawCounter = 0;
+ return TRUE;
+ }
+ CFX_RectF rtWidget;
+ pWidget->GetWidgetRect(rtWidget);
+ rtWidget.left = rtWidget.top = 0;
+ pMatrix->TransformRect(rtWidget);
+ if (!rtWidget.IntersectWith(rtDirty)) {
+ return FALSE;
+ }
+ IFWL_Widget* pChild =
+ FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild);
+ if (!pChild) {
+ return TRUE;
+ }
+ if (pChild->GetClassID() == 3150298670) {
+ CFX_RectF rtTemp;
+ pChild->GetWidgetRect(rtTemp);
+ if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) {
+ pChild =
+ FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild);
+ if (!pChild) {
return TRUE;
+ }
+ }
+ }
+ CFX_RectF rtChilds;
+ rtChilds.Empty();
+ FX_BOOL bChildIntersectWithDirty = FALSE;
+ FX_BOOL bOrginPtIntersectWidthChild = FALSE;
+ FX_BOOL bOrginPtIntersectWidthDirty =
+ rtDirty.Contains(rtWidget.left, rtWidget.top);
+ static FWL_NeedRepaintHitData hitPoint[FWL_NEEDREPAINTHIT_Point];
+ static int32_t iSize = sizeof(FWL_NeedRepaintHitData);
+ FXSYS_memset(hitPoint, 0, iSize);
+ FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece;
+ FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece;
+ hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left;
+ hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x =
+ hitPoint[10].hitPoint.x = fxPiece + rtWidget.left;
+ hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x =
+ hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left;
+ hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x =
+ rtWidget.width + rtWidget.left;
+ hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top;
+ hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y =
+ hitPoint[5].hitPoint.y = fyPiece + rtWidget.top;
+ hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y =
+ hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top;
+ hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y =
+ rtWidget.height + rtWidget.top;
+ do {
+ CFX_RectF rect;
+ pChild->GetWidgetRect(rect);
+ CFX_RectF r = rect;
+ r.left += rtWidget.left;
+ r.top += rtWidget.top;
+ if (r.IsEmpty()) {
+ continue;
}
- if (pChild->GetClassID() == 3150298670) {
- CFX_RectF rtTemp;
- pChild->GetWidgetRect(rtTemp);
- if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) {
- pChild = FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild);
- if (!pChild) {
- return TRUE;
- }
- }
+ if (r.Contains(rtDirty)) {
+ return FALSE;
}
- CFX_RectF rtChilds;
- rtChilds.Empty();
- FX_BOOL bChildIntersectWithDirty = FALSE;
- FX_BOOL bOrginPtIntersectWidthChild = FALSE;
- FX_BOOL bOrginPtIntersectWidthDirty = rtDirty.Contains(rtWidget.left, rtWidget.top);
- static FWL_NeedRepaintHitData hitPoint[FWL_NEEDREPAINTHIT_Point];
- static int32_t iSize = sizeof(FWL_NeedRepaintHitData);
- FXSYS_memset(hitPoint, 0, iSize);
- FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece;
- FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece;
- hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left;
- hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = hitPoint[10].hitPoint.x = fxPiece + rtWidget.left;
- hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left;
- hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = rtWidget.width + rtWidget.left;
- hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top;
- hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = hitPoint[5].hitPoint.y = fyPiece + rtWidget.top;
- hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top;
- hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = rtWidget.height + rtWidget.top;
- do {
- CFX_RectF rect;
- pChild->GetWidgetRect(rect);
- CFX_RectF r = rect;
- r.left += rtWidget.left;
- r.top += rtWidget.top;
- if (r.IsEmpty()) {
- continue;
- }
- if (r.Contains(rtDirty)) {
- return FALSE;
- }
- if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) {
- bChildIntersectWithDirty = TRUE;
- }
- if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
- bOrginPtIntersectWidthChild = rect.Contains(0, 0);
- }
- if (rtChilds.IsEmpty()) {
- rtChilds = rect;
- } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) {
- rtChilds.Union(rect);
- }
- for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i ++) {
- if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) {
- continue;
- }
- if (!rtDirty.Contains(hitPoint[i].hitPoint)) {
- hitPoint[i].bNotContainByDirty = TRUE;
- continue;
- }
- if (r.Contains(hitPoint[i].hitPoint)) {
- hitPoint[i].bNotNeedRepaint = TRUE;
- }
- }
- } while ((pChild = FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_NextSibling)) != NULL);
- if (!bChildIntersectWithDirty) {
- return TRUE;
+ if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) {
+ bChildIntersectWithDirty = TRUE;
}
if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
- return TRUE;
+ bOrginPtIntersectWidthChild = rect.Contains(0, 0);
}
if (rtChilds.IsEmpty()) {
- return TRUE;
- }
- int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point;
- for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i ++) {
- if (hitPoint[i].bNotNeedRepaint) {
- repaintPoint --;
- }
- }
- if (repaintPoint > 0) {
- return TRUE;
- }
- pMatrix->TransformRect(rtChilds);
- if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) {
- return FALSE;
- }
+ rtChilds = rect;
+ } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) {
+ rtChilds.Union(rect);
+ }
+ for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) {
+ if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) {
+ continue;
+ }
+ if (!rtDirty.Contains(hitPoint[i].hitPoint)) {
+ hitPoint[i].bNotContainByDirty = TRUE;
+ continue;
+ }
+ if (r.Contains(hitPoint[i].hitPoint)) {
+ hitPoint[i].bNotNeedRepaint = TRUE;
+ }
+ }
+ } while ((pChild = FWL_GetWidgetMgr()->GetWidget(
+ pChild, FWL_WGTRELATION_NextSibling)) != NULL);
+ if (!bChildIntersectWithDirty) {
+ return TRUE;
+ }
+ if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
+ return TRUE;
+ }
+ if (rtChilds.IsEmpty()) {
+ return TRUE;
+ }
+ int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point;
+ for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) {
+ if (hitPoint[i].bNotNeedRepaint) {
+ repaintPoint--;
+ }
+ }
+ if (repaintPoint > 0) {
return TRUE;
+ }
+ pMatrix->TransformRect(rtChilds);
+ if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) {
+ return FALSE;
+ }
+ return TRUE;
}
-FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget *pWidget)
-{
- CFWL_WidgetMgrItem *pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) {
- return FALSE;
- }
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)
- if (pItem->bOutsideChanged) {
- CFX_RectF r;
- pWidget->GetWidgetRect(r);
- CFX_RectF temp(m_pWidgetMgr->m_rtScreen);
- temp.Deflate(50, 50);
- if (!temp.Contains(r)) {
- return FALSE;
- }
- pItem->bOutsideChanged = FALSE;
+FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) {
+ CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
+ if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) {
+ return FALSE;
+ }
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
+ if (pItem->bOutsideChanged) {
+ CFX_RectF r;
+ pWidget->GetWidgetRect(r);
+ CFX_RectF temp(m_pWidgetMgr->m_rtScreen);
+ temp.Deflate(50, 50);
+ if (!temp.Contains(r)) {
+ return FALSE;
}
+ pItem->bOutsideChanged = FALSE;
+ }
#endif
- return pItem->iRedrawCounter == 0;
+ return pItem->iRedrawCounter == 0;
}
-static void FWL_WriteBMP(CFX_DIBitmap* pBitmap, const FX_CHAR* filename)
-{
- FILE* file = fopen(filename, "wb");
- if (file == NULL) {
- return;
- }
- int size = 14 + 40 + pBitmap->GetPitch() * pBitmap->GetHeight();
- unsigned char buffer[40];
- buffer[0] = 'B';
- buffer[1] = 'M';
- buffer[2] = (unsigned char)size;
- buffer[3] = (unsigned char)(size >> 8);
- buffer[4] = (unsigned char)(size >> 16);
- buffer[5] = (unsigned char)(size >> 24);
- buffer[6] = buffer[7] = buffer[8] = buffer[9] = 0;
- buffer[10] = 54;
- buffer[11] = buffer[12] = buffer[13] = 0;
- fwrite(buffer, 14, 1, file);
- memset(buffer, 0, 40);
- buffer[0] = 40;
- buffer[4] = (unsigned char)pBitmap->GetWidth();
- buffer[5] = (unsigned char)(pBitmap->GetWidth() >> 8);
- buffer[6] = (unsigned char)(pBitmap->GetWidth() >> 16);
- buffer[7] = (unsigned char)(pBitmap->GetWidth() >> 24);
- buffer[8] = (unsigned char)(-pBitmap->GetHeight());
- buffer[9] = (unsigned char)((-pBitmap->GetHeight()) >> 8);
- buffer[10] = (unsigned char)((-pBitmap->GetHeight()) >> 16);
- buffer[11] = (unsigned char)((-pBitmap->GetHeight()) >> 24);
- buffer[12] = 1;
- buffer[14] = pBitmap->GetBPP();
- fwrite(buffer, 40, 1, file);
- for (int row = 0; row < pBitmap->GetHeight(); row ++) {
- uint8_t* scan_line = pBitmap->GetBuffer() + row * pBitmap->GetPitch();
- fwrite(scan_line, pBitmap->GetPitch(), 1, file);
- }
- fclose(file);
+static void FWL_WriteBMP(CFX_DIBitmap* pBitmap, const FX_CHAR* filename) {
+ FILE* file = fopen(filename, "wb");
+ if (file == NULL) {
+ return;
+ }
+ int size = 14 + 40 + pBitmap->GetPitch() * pBitmap->GetHeight();
+ unsigned char buffer[40];
+ buffer[0] = 'B';
+ buffer[1] = 'M';
+ buffer[2] = (unsigned char)size;
+ buffer[3] = (unsigned char)(size >> 8);
+ buffer[4] = (unsigned char)(size >> 16);
+ buffer[5] = (unsigned char)(size >> 24);
+ buffer[6] = buffer[7] = buffer[8] = buffer[9] = 0;
+ buffer[10] = 54;
+ buffer[11] = buffer[12] = buffer[13] = 0;
+ fwrite(buffer, 14, 1, file);
+ memset(buffer, 0, 40);
+ buffer[0] = 40;
+ buffer[4] = (unsigned char)pBitmap->GetWidth();
+ buffer[5] = (unsigned char)(pBitmap->GetWidth() >> 8);
+ buffer[6] = (unsigned char)(pBitmap->GetWidth() >> 16);
+ buffer[7] = (unsigned char)(pBitmap->GetWidth() >> 24);
+ buffer[8] = (unsigned char)(-pBitmap->GetHeight());
+ buffer[9] = (unsigned char)((-pBitmap->GetHeight()) >> 8);
+ buffer[10] = (unsigned char)((-pBitmap->GetHeight()) >> 16);
+ buffer[11] = (unsigned char)((-pBitmap->GetHeight()) >> 24);
+ buffer[12] = 1;
+ buffer[14] = pBitmap->GetBPP();
+ fwrite(buffer, 40, 1, file);
+ for (int row = 0; row < pBitmap->GetHeight(); row++) {
+ uint8_t* scan_line = pBitmap->GetBuffer() + row * pBitmap->GetPitch();
+ fwrite(scan_line, pBitmap->GetPitch(), 1, file);
+ }
+ fclose(file);
}
-FWL_ERR FWL_WidgetMgrSnapshot(IFWL_Widget *pWidget, const CFX_WideString *saveFile, const CFX_Matrix *pMatrix)
-{
- CFX_RectF r;
- pWidget->GetWidgetRect(r);
- CFX_Graphics gs;
- gs.Create((int32_t)r.width, (int32_t)r.height, FXDIB_Argb);
- CFWL_WidgetMgr *widgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- CFWL_WidgetMgrDelegate *delegate = widgetMgr->GetDelegate();
- delegate->OnDrawWidget(pWidget, &gs, pMatrix);
- CFX_DIBitmap *dib = gs.GetRenderDevice()->GetBitmap();
- FWL_WriteBMP(dib, saveFile->UTF8Encode());
- return FWL_ERR_Succeeded;
+FWL_ERR FWL_WidgetMgrSnapshot(IFWL_Widget* pWidget,
+ const CFX_WideString* saveFile,
+ const CFX_Matrix* pMatrix) {
+ CFX_RectF r;
+ pWidget->GetWidgetRect(r);
+ CFX_Graphics gs;
+ gs.Create((int32_t)r.width, (int32_t)r.height, FXDIB_Argb);
+ CFWL_WidgetMgr* widgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ CFWL_WidgetMgrDelegate* delegate = widgetMgr->GetDelegate();
+ delegate->OnDrawWidget(pWidget, &gs, pMatrix);
+ CFX_DIBitmap* dib = gs.GetRenderDevice()->GetBitmap();
+ FWL_WriteBMP(dib, saveFile->UTF8Encode());
+ return FWL_ERR_Succeeded;
}
-FX_BOOL FWL_WidgetIsChild(IFWL_Widget *parent, IFWL_Widget *find)
-{
- if (!find) {
- return FALSE;
- }
- IFWL_Widget *child = FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if (child == find) {
- return TRUE;
- }
- if (FWL_WidgetIsChild(child, find)) {
- return TRUE;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
+FX_BOOL FWL_WidgetIsChild(IFWL_Widget* parent, IFWL_Widget* find) {
+ if (!find) {
return FALSE;
+ }
+ IFWL_Widget* child =
+ FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ if (child == find) {
+ return TRUE;
+ }
+ if (FWL_WidgetIsChild(child, find)) {
+ return TRUE;
+ }
+ child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
+ }
+ return FALSE;
}
diff --git a/xfa/src/fwl/src/core/include/fwl_appimp.h b/xfa/src/fwl/src/core/include/fwl_appimp.h index e0f1f5977a..ec23febb32 100644 --- a/xfa/src/fwl/src/core/include/fwl_appimp.h +++ b/xfa/src/fwl/src/core/include/fwl_appimp.h @@ -13,22 +13,22 @@ class IFWL_WidgetMgr; class IFWL_ThemeProvider;
class IFWL_App;
class CFWL_AppImp;
-class CFWL_AppImp : public CFWL_NoteThread
-{
-public:
- CFWL_AppImp(IFWL_AdapterNative *pAdapter);
- virtual ~CFWL_AppImp();
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual IFWL_AdapterNative* GetAdapterNative();
- virtual IFWL_WidgetMgr* GetWidgetMgr();
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual FWL_ERR Exit(int32_t iExitCode = 0);
- IFWL_ThemeProvider* GetThemeProvider();
-protected:
- CFWL_WidgetMgr *m_pWidgetMgr;
- IFWL_AdapterNative *m_pAdapterNative;
- IFWL_ThemeProvider *m_pThemeProvider;
- FX_BOOL m_bFuelAdapter;
+class CFWL_AppImp : public CFWL_NoteThread {
+ public:
+ CFWL_AppImp(IFWL_AdapterNative* pAdapter);
+ virtual ~CFWL_AppImp();
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual IFWL_AdapterNative* GetAdapterNative();
+ virtual IFWL_WidgetMgr* GetWidgetMgr();
+ virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ virtual FWL_ERR Exit(int32_t iExitCode = 0);
+ IFWL_ThemeProvider* GetThemeProvider();
+
+ protected:
+ CFWL_WidgetMgr* m_pWidgetMgr;
+ IFWL_AdapterNative* m_pAdapterNative;
+ IFWL_ThemeProvider* m_pThemeProvider;
+ FX_BOOL m_bFuelAdapter;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_contentimp.h b/xfa/src/fwl/src/core/include/fwl_contentimp.h index 95a47a3796..0bfc77cd58 100644 --- a/xfa/src/fwl/src/core/include/fwl_contentimp.h +++ b/xfa/src/fwl/src/core/include/fwl_contentimp.h @@ -9,23 +9,23 @@ class CFWL_WidgetImp;
class IFWL_Widget;
class CFWL_ContentImp;
-class CFWL_ContentImp : public CFWL_WidgetImp
-{
-public:
- CFWL_ContentImp();
- CFWL_ContentImp(const CFWL_WidgetImpProperties &properties);
- virtual ~CFWL_ContentImp();
- virtual FWL_ERR InsertWidget(IFWL_Widget *pChild, int32_t nIndex = -1);
- virtual FWL_ERR RemoveWidget(IFWL_Widget *pWidget);
- virtual FWL_ERR RemoveAllWidgets();
- virtual FWL_ERR GetMinSize(FX_FLOAT &fWidth, FX_FLOAT &fHeight);
- virtual FWL_ERR SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
- virtual FWL_ERR GetMaxSize(FX_FLOAT &fWidth, FX_FLOAT &fHeight);
- virtual FWL_ERR SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
-protected:
- FX_FLOAT m_fWidthMin;
- FX_FLOAT m_fWidthMax;
- FX_FLOAT m_fHeightMax;
- FX_FLOAT m_fHeightMin;
+class CFWL_ContentImp : public CFWL_WidgetImp {
+ public:
+ CFWL_ContentImp();
+ CFWL_ContentImp(const CFWL_WidgetImpProperties& properties);
+ virtual ~CFWL_ContentImp();
+ virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
+ virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
+ virtual FWL_ERR RemoveAllWidgets();
+ virtual FWL_ERR GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
+ virtual FWL_ERR SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
+ virtual FWL_ERR GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
+ virtual FWL_ERR SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
+
+ protected:
+ FX_FLOAT m_fWidthMin;
+ FX_FLOAT m_fWidthMax;
+ FX_FLOAT m_fHeightMax;
+ FX_FLOAT m_fHeightMin;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_formimp.h b/xfa/src/fwl/src/core/include/fwl_formimp.h index f0cee13000..16d626461e 100644 --- a/xfa/src/fwl/src/core/include/fwl_formimp.h +++ b/xfa/src/fwl/src/core/include/fwl_formimp.h @@ -16,172 +16,175 @@ class IFWL_ThemeProvider; class CFWL_SysBtn;
class CFWL_FormImp;
class CFWL_FormDelegate;
-#define FWL_SYSBUTTONSTATE_Hover 0x0001
-#define FWL_SYSBUTTONSTATE_Pressed 0x0002
-#define FWL_SYSBUTTONSTATE_Disabled 0x0010
-class CFWL_SysBtn
-{
-public:
- CFWL_SysBtn()
- {
- m_rtBtn.Set(0, 0, 0, 0);
- m_dwState = 0;
- }
+#define FWL_SYSBUTTONSTATE_Hover 0x0001
+#define FWL_SYSBUTTONSTATE_Pressed 0x0002
+#define FWL_SYSBUTTONSTATE_Disabled 0x0010
+class CFWL_SysBtn {
+ public:
+ CFWL_SysBtn() {
+ m_rtBtn.Set(0, 0, 0, 0);
+ m_dwState = 0;
+ }
- FX_BOOL IsHover()
- {
- return m_dwState & FWL_SYSBUTTONSTATE_Hover;
- }
- FX_BOOL IsPressed()
- {
- return m_dwState & FWL_SYSBUTTONSTATE_Pressed;
- }
- FX_BOOL IsDisabled()
- {
- return m_dwState & FWL_SYSBUTTONSTATE_Disabled;
- }
- void SetNormal()
- {
- m_dwState &= 0xFFF0;
- }
- void SetPressed()
- {
- SetNormal();
- m_dwState |= FWL_SYSBUTTONSTATE_Pressed;
- }
- void SetHover()
- {
- SetNormal();
- m_dwState |= FWL_SYSBUTTONSTATE_Hover;
- }
- void SetDisabled(FX_BOOL bDisabled)
- {
- bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled;
- }
- int32_t GetPartState()
- {
- return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1));
- }
+ FX_BOOL IsHover() { return m_dwState & FWL_SYSBUTTONSTATE_Hover; }
+ FX_BOOL IsPressed() { return m_dwState & FWL_SYSBUTTONSTATE_Pressed; }
+ FX_BOOL IsDisabled() { return m_dwState & FWL_SYSBUTTONSTATE_Disabled; }
+ void SetNormal() { m_dwState &= 0xFFF0; }
+ void SetPressed() {
+ SetNormal();
+ m_dwState |= FWL_SYSBUTTONSTATE_Pressed;
+ }
+ void SetHover() {
+ SetNormal();
+ m_dwState |= FWL_SYSBUTTONSTATE_Hover;
+ }
+ void SetDisabled(FX_BOOL bDisabled) {
+ bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled
+ : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled;
+ }
+ int32_t GetPartState() {
+ return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1));
+ }
- CFX_RectF m_rtBtn;
- FX_DWORD m_dwState;
+ CFX_RectF m_rtBtn;
+ FX_DWORD m_dwState;
};
enum FORM_RESIZETYPE {
- FORM_RESIZETYPE_None = 0,
- FORM_RESIZETYPE_Cap,
- FORM_RESIZETYPE_Left,
- FORM_RESIZETYPE_Top,
- FORM_RESIZETYPE_Right,
- FORM_RESIZETYPE_Bottom,
- FORM_RESIZETYPE_LeftTop,
- FORM_RESIZETYPE_LeftBottom,
- FORM_RESIZETYPE_RightTop,
- FORM_RESIZETYPE_RightBottom
+ FORM_RESIZETYPE_None = 0,
+ FORM_RESIZETYPE_Cap,
+ FORM_RESIZETYPE_Left,
+ FORM_RESIZETYPE_Top,
+ FORM_RESIZETYPE_Right,
+ FORM_RESIZETYPE_Bottom,
+ FORM_RESIZETYPE_LeftTop,
+ FORM_RESIZETYPE_LeftBottom,
+ FORM_RESIZETYPE_RightTop,
+ FORM_RESIZETYPE_RightBottom
};
typedef struct RestoreResizeInfo {
- CFX_PointF m_ptStart;
- CFX_SizeF m_szStart;
+ CFX_PointF m_ptStart;
+ CFX_SizeF m_szStart;
} RestoreInfo;
-class CFWL_FormImp : public CFWL_PanelImp
-{
-public:
- CFWL_FormImp(IFWL_Widget *pOuter = NULL);
- CFWL_FormImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_FormImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+class CFWL_FormImp : public CFWL_PanelImp {
+ public:
+ CFWL_FormImp(IFWL_Widget* pOuter = NULL);
+ CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_FormImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR GetClientRect(CFX_RectF &rect);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual FWL_FORMSIZE GetFormSize();
- virtual FWL_ERR SetFormSize(FWL_FORMSIZE eFormSize);
- virtual IFWL_Widget* DoModal();
- virtual IFWL_Widget* DoModal(FX_DWORD &dwCommandID);
- virtual FWL_ERR EndDoModal();
- virtual FWL_ERR SetBorderRegion(CFX_Path *pPath);
- virtual void DrawBackground(CFX_Graphics *pGraphics, IFWL_ThemeProvider *pTheme);
- CFWL_WidgetImp* GetSubFocus();
- void SetSubFocus(CFWL_WidgetImp *pWidget);
- CFX_MapAccelerators& GetAccelerator();
- void SetAccelerator(CFX_MapAccelerators *pAccelerators);
-protected:
- void ShowChildWidget(IFWL_Widget *pParent);
- void RemoveSysButtons();
- void CalcContentRect(CFX_RectF &rtContent);
- CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy);
- CFWL_SysBtn* GetSysBtnByState(FX_DWORD dwState);
- CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex);
- int32_t GetSysBtnIndex(CFWL_SysBtn *pBtn);
- FX_FLOAT GetCaptionHeight();
- void DrawCaptionText(CFX_Graphics *pGs, IFWL_ThemeProvider *pTheme, const CFX_Matrix* pMatrix = NULL);
- void DrawIconImage(CFX_Graphics *pGs, IFWL_ThemeProvider *pTheme, const CFX_Matrix* pMatrix = NULL);
- void GetEdgeRect(CFX_RectF &rtEdge);
- void SetWorkAreaRect();
- void SetCursor(FX_FLOAT fx, FX_FLOAT fy);
- void Layout();
- void ReSetSysBtn();
- void RegisterForm();
- void UnRegisterForm();
- FX_BOOL IsDoModal();
- void SetThemeData();
- FX_BOOL HasIcon();
- void UpdateIcon();
- void UpdateCaption();
- void DoWidthLimit(FX_FLOAT &fLeft, FX_FLOAT &fWidth, FX_FLOAT fCurX, FX_FLOAT fSpace, FX_FLOAT fLimitMin, FX_FLOAT fLimitMax, FX_BOOL bLeft);
- void DoHeightLimit(FX_FLOAT &fTop, FX_FLOAT &fHeight, FX_FLOAT fCurY, FX_FLOAT fSpace, FX_FLOAT fLimitMin, FX_FLOAT fLimitMax, FX_BOOL bTop);
- CFX_MapAccelerators m_mapAccelerators;
- CFX_RectF m_rtRestore;
- CFX_RectF m_rtCaptionText;
- CFX_RectF m_rtRelative;
- CFX_RectF m_rtCaption;
- CFX_RectF m_rtIcon;
- CFWL_SysBtn *m_pCloseBox;
- CFWL_SysBtn *m_pMinBox;
- CFWL_SysBtn *m_pMaxBox;
- CFWL_SysBtn *m_pCaptionBox;
- CFWL_NoteLoop *m_pNoteLoop;
- CFWL_WidgetImp *m_pSubFocus;
- RestoreInfo m_InfoStart;
- FX_FLOAT m_fCXBorder;
- FX_FLOAT m_fCYBorder;
- int32_t m_iCaptureBtn;
- int32_t m_iSysBox;
- int32_t m_eResizeType;
- FX_BOOL m_bLButtonDown;
- FX_BOOL m_bMaximized;
- FX_BOOL m_bSetMaximize;
- FX_BOOL m_bCustomizeLayout;
- FWL_FORMSIZE m_eFormSize;
- FX_BOOL m_bDoModalFlag;
- FX_FLOAT m_fSmallIconSz;
- FX_FLOAT m_fBigIconSz;
- CFX_DIBitmap *m_pBigIcon;
- CFX_DIBitmap *m_pSmallIcon;
- FX_BOOL m_bMouseIn;
- friend class CFWL_FormDelegate;
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR GetClientRect(CFX_RectF& rect);
+ virtual FWL_ERR Update();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_FORMSIZE GetFormSize();
+ virtual FWL_ERR SetFormSize(FWL_FORMSIZE eFormSize);
+ virtual IFWL_Widget* DoModal();
+ virtual IFWL_Widget* DoModal(FX_DWORD& dwCommandID);
+ virtual FWL_ERR EndDoModal();
+ virtual FWL_ERR SetBorderRegion(CFX_Path* pPath);
+ virtual void DrawBackground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme);
+ CFWL_WidgetImp* GetSubFocus();
+ void SetSubFocus(CFWL_WidgetImp* pWidget);
+ CFX_MapAccelerators& GetAccelerator();
+ void SetAccelerator(CFX_MapAccelerators* pAccelerators);
+
+ protected:
+ void ShowChildWidget(IFWL_Widget* pParent);
+ void RemoveSysButtons();
+ void CalcContentRect(CFX_RectF& rtContent);
+ CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy);
+ CFWL_SysBtn* GetSysBtnByState(FX_DWORD dwState);
+ CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex);
+ int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn);
+ FX_FLOAT GetCaptionHeight();
+ void DrawCaptionText(CFX_Graphics* pGs,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawIconImage(CFX_Graphics* pGs,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void GetEdgeRect(CFX_RectF& rtEdge);
+ void SetWorkAreaRect();
+ void SetCursor(FX_FLOAT fx, FX_FLOAT fy);
+ void Layout();
+ void ReSetSysBtn();
+ void RegisterForm();
+ void UnRegisterForm();
+ FX_BOOL IsDoModal();
+ void SetThemeData();
+ FX_BOOL HasIcon();
+ void UpdateIcon();
+ void UpdateCaption();
+ void DoWidthLimit(FX_FLOAT& fLeft,
+ FX_FLOAT& fWidth,
+ FX_FLOAT fCurX,
+ FX_FLOAT fSpace,
+ FX_FLOAT fLimitMin,
+ FX_FLOAT fLimitMax,
+ FX_BOOL bLeft);
+ void DoHeightLimit(FX_FLOAT& fTop,
+ FX_FLOAT& fHeight,
+ FX_FLOAT fCurY,
+ FX_FLOAT fSpace,
+ FX_FLOAT fLimitMin,
+ FX_FLOAT fLimitMax,
+ FX_BOOL bTop);
+ CFX_MapAccelerators m_mapAccelerators;
+ CFX_RectF m_rtRestore;
+ CFX_RectF m_rtCaptionText;
+ CFX_RectF m_rtRelative;
+ CFX_RectF m_rtCaption;
+ CFX_RectF m_rtIcon;
+ CFWL_SysBtn* m_pCloseBox;
+ CFWL_SysBtn* m_pMinBox;
+ CFWL_SysBtn* m_pMaxBox;
+ CFWL_SysBtn* m_pCaptionBox;
+ CFWL_NoteLoop* m_pNoteLoop;
+ CFWL_WidgetImp* m_pSubFocus;
+ RestoreInfo m_InfoStart;
+ FX_FLOAT m_fCXBorder;
+ FX_FLOAT m_fCYBorder;
+ int32_t m_iCaptureBtn;
+ int32_t m_iSysBox;
+ int32_t m_eResizeType;
+ FX_BOOL m_bLButtonDown;
+ FX_BOOL m_bMaximized;
+ FX_BOOL m_bSetMaximize;
+ FX_BOOL m_bCustomizeLayout;
+ FWL_FORMSIZE m_eFormSize;
+ FX_BOOL m_bDoModalFlag;
+ FX_FLOAT m_fSmallIconSz;
+ FX_FLOAT m_fBigIconSz;
+ CFX_DIBitmap* m_pBigIcon;
+ CFX_DIBitmap* m_pSmallIcon;
+ FX_BOOL m_bMouseIn;
+ friend class CFWL_FormDelegate;
};
-class CFWL_FormDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_FormDelegate(CFWL_FormImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- void OnLButtonDown(CFWL_MsgMouse *pMsg);
- void OnLButtonUp(CFWL_MsgMouse *pMsg);
- void OnMouseMove(CFWL_MsgMouse *pMsg);
- void OnMouseHover(CFWL_MsgMouse *pMsg);
- void OnMouseLeave(CFWL_MsgMouse *pMsg);
- void OnLButtonDblClk(CFWL_MsgMouse *pMsg);
- void OnWindowMove(CFWL_MsgWindowMove *pMsg);
- void OnClose(CFWL_MsgClose *pMsg);
- CFWL_FormImp *m_pOwner;
+class CFWL_FormDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_FormDelegate(CFWL_FormImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseHover(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
+ void OnLButtonDblClk(CFWL_MsgMouse* pMsg);
+ void OnWindowMove(CFWL_MsgWindowMove* pMsg);
+ void OnClose(CFWL_MsgClose* pMsg);
+ CFWL_FormImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_gridimp.h b/xfa/src/fwl/src/core/include/fwl_gridimp.h index 82aeb7ecdc..693aac24f9 100644 --- a/xfa/src/fwl/src/core/include/fwl_gridimp.h +++ b/xfa/src/fwl/src/core/include/fwl_gridimp.h @@ -12,150 +12,182 @@ class CFWL_GridLength; class CFWL_GridColRow;
class CFWL_GridWidgetInfo;
class CFWL_GridImp;
-class CFWL_GridLength
-{
-public:
- CFWL_GridLength()
- : fLength(0)
- , eUnit(FWL_GRIDUNIT_Fixed)
- {
- }
- CFWL_GridLength(FX_FLOAT fValue, FWL_GRIDUNIT e)
- : fLength(fValue)
- , eUnit(e)
- {
- }
- FX_FLOAT fLength;
- FWL_GRIDUNIT eUnit;
+class CFWL_GridLength {
+ public:
+ CFWL_GridLength() : fLength(0), eUnit(FWL_GRIDUNIT_Fixed) {}
+ CFWL_GridLength(FX_FLOAT fValue, FWL_GRIDUNIT e)
+ : fLength(fValue), eUnit(e) {}
+ FX_FLOAT fLength;
+ FWL_GRIDUNIT eUnit;
};
-class CFWL_GridColRow
-{
-public:
- CFWL_GridColRow()
- : m_Size (1, FWL_GRIDUNIT_Scaled)
- , m_MinSize(0, FWL_GRIDUNIT_Fixed)
- , m_MaxSize(0, FWL_GRIDUNIT_Infinity)
- , m_fActualSize(0)
- , m_fActualPos(0)
- {
- }
- CFWL_GridLength m_Size;
- CFWL_GridLength m_MinSize;
- CFWL_GridLength m_MaxSize;
- FX_FLOAT m_fActualSize;
- FX_FLOAT m_fActualPos;
+class CFWL_GridColRow {
+ public:
+ CFWL_GridColRow()
+ : m_Size(1, FWL_GRIDUNIT_Scaled),
+ m_MinSize(0, FWL_GRIDUNIT_Fixed),
+ m_MaxSize(0, FWL_GRIDUNIT_Infinity),
+ m_fActualSize(0),
+ m_fActualPos(0) {}
+ CFWL_GridLength m_Size;
+ CFWL_GridLength m_MinSize;
+ CFWL_GridLength m_MaxSize;
+ FX_FLOAT m_fActualSize;
+ FX_FLOAT m_fActualPos;
};
-class CFWL_GridWidgetInfo
-{
-public:
- CFWL_GridWidgetInfo()
- : m_iColumn (0)
- , m_iColumnSpan(1)
- , m_iRow(0)
- , m_iRowSpan(1)
- , m_dwMarginFlag(0)
- , m_fActualWidth(0)
- , m_fActualHeight(0)
- {
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
- m_Margin[0] = m_Margin[1] = m_Margin[2] = m_Margin[3] = 0;
- }
- int32_t m_iColumn;
- int32_t m_iColumnSpan;
- int32_t m_iRow;
- int32_t m_iRowSpan;
- CFWL_GridLength m_Size[6];
- FX_DWORD m_dwMarginFlag;
- FX_FLOAT m_Margin[4];
- FX_FLOAT m_fActualWidth;
- FX_FLOAT m_fActualHeight;
+class CFWL_GridWidgetInfo {
+ public:
+ CFWL_GridWidgetInfo()
+ : m_iColumn(0),
+ m_iColumnSpan(1),
+ m_iRow(0),
+ m_iRowSpan(1),
+ m_dwMarginFlag(0),
+ m_fActualWidth(0),
+ m_fActualHeight(0) {
+ m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
+ m_Size[FWL_GRIDSIZE_Width].fLength = 0;
+ m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
+ m_Size[FWL_GRIDSIZE_Height].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
+ m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
+ m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
+ m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
+ m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
+ m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
+ m_Margin[0] = m_Margin[1] = m_Margin[2] = m_Margin[3] = 0;
+ }
+ int32_t m_iColumn;
+ int32_t m_iColumnSpan;
+ int32_t m_iRow;
+ int32_t m_iRowSpan;
+ CFWL_GridLength m_Size[6];
+ FX_DWORD m_dwMarginFlag;
+ FX_FLOAT m_Margin[4];
+ FX_FLOAT m_fActualWidth;
+ FX_FLOAT m_fActualHeight;
};
-class CFWL_GridImp : public CFWL_ContentImp
-{
-public:
- CFWL_GridImp();
- CFWL_GridImp(const CFWL_WidgetImpProperties &properties);
- virtual ~CFWL_GridImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF &rect);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
+class CFWL_GridImp : public CFWL_ContentImp {
+ public:
+ CFWL_GridImp();
+ CFWL_GridImp(const CFWL_WidgetImpProperties& properties);
+ virtual ~CFWL_GridImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR InsertWidget(IFWL_Widget *pChild, int32_t nIndex = -1);
- virtual FWL_ERR RemoveWidget(IFWL_Widget *pWidget);
- virtual FWL_HGRIDCOLROW InsertColRow(FX_BOOL bColumn, int32_t nIndex = -1);
- virtual int32_t CountColRows(FX_BOOL bColumn);
- virtual FWL_HGRIDCOLROW GetColRow(FX_BOOL bColumn, int32_t nIndex);
- virtual int32_t GetIndex(FWL_HGRIDCOLROW hColRow);
- virtual FX_FLOAT GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit);
- virtual FWL_ERR SetSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit);
- virtual FX_FLOAT GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit);
- virtual FWL_ERR SetMinSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit);
- virtual FX_FLOAT GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT &eUnit);
- virtual FWL_ERR SetMaxSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit);
- virtual FX_BOOL DeleteColRow(FWL_HGRIDCOLROW hColRow);
- virtual FX_BOOL IsColumn(FWL_HGRIDCOLROW hColRow);
- virtual int32_t GetWidgetPos(IFWL_Widget *pWidget, FX_BOOL bColumn);
- virtual FWL_ERR SetWidgetPos(IFWL_Widget *pWidget, int32_t iPos, FX_BOOL bColumn);
- virtual int32_t GetWidgetSpan(IFWL_Widget *pWidget, FX_BOOL bColumn);
- virtual FWL_ERR SetWidgetSpan(IFWL_Widget *pWidget, int32_t iSpan, FX_BOOL bColumn);
- virtual FX_FLOAT GetWidgetSize(IFWL_Widget *pWidget, FWL_GRIDSIZE eSize, FWL_GRIDUNIT &eUnit);
- virtual FWL_ERR SetWidgetSize(IFWL_Widget *pWidget, FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit);
- virtual FX_BOOL GetWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin, FX_FLOAT &fMargin);
- virtual FWL_ERR SetWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin, FX_FLOAT fMargin);
- virtual FWL_ERR RemoveWidgetMargin(IFWL_Widget *pWidget, FWL_GRIDMARGIN eMargin);
- virtual FX_FLOAT GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT &eUnit);
- virtual FWL_ERR SetGridSize(FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit);
-protected:
- CFWL_GridWidgetInfo* GetWidgetInfo(IFWL_Widget* pWidget);
- void ProcFixedColRow(CFWL_GridColRow *pColRow, int32_t nIndex, FX_FLOAT fColRowSize, FX_BOOL bColumn);
- void ProcAutoColRow(CFWL_GridColRow *pColRow, int32_t nIndex, FX_BOOL bColumn);
- void ProcScaledColRow(CFWL_GridColRow *pColRow, int32_t nIndex, FX_FLOAT fColRowSize, FX_BOOL bColumn);
- void CalcWidgetWidth(IFWL_Widget *pWidget, CFWL_GridWidgetInfo *pInfo, FX_FLOAT fColunmWidth);
- void CalcWidgetHeigt(IFWL_Widget *pWidget, CFWL_GridWidgetInfo *pInfo, FX_FLOAT fRowHeigt);
- FX_FLOAT CalcAutoColumnWidgetWidth(IFWL_Widget *pWidget, CFWL_GridWidgetInfo* pInfo);
- FX_FLOAT CalcAutoColumnWidgetHeight(IFWL_Widget *pWidget, CFWL_GridWidgetInfo* pInfo);
- FX_FLOAT ProcessColumns(FX_FLOAT fWidth);
- FX_FLOAT ProcessRows(FX_FLOAT fHeight);
- FX_FLOAT ProcessUnCertainColumns();
- FX_FLOAT ProcessUnCertainRows();
- FX_BOOL SetColRowActualSize(CFWL_GridColRow *pColRow, FX_FLOAT fSize, FX_BOOL bSetBeyond = FALSE);
- FX_FLOAT SetWidgetActualWidth(CFWL_GridWidgetInfo *pInfo, FX_FLOAT fWidth);
- FX_FLOAT SetWidgetActualHeight(CFWL_GridWidgetInfo *pInfo, FX_FLOAT fHeight);
- void SetAllWidgetsRect();
- FX_BOOL IsGrid(IFWL_Widget *pWidget);
- void SetSpanAutoColRowSize(const CFX_PtrArray &spanAutos, FX_FLOAT fTotalSize);
- void SetSpanScaledColRowSize(const CFX_PtrArray &spanScaleds, FX_FLOAT fTotalSize, FX_FLOAT fTotalScaledNum);
- void SetScaledColRowsSize(const CFX_PtrArray &spanScaleds, FX_FLOAT fTotalSize, FX_FLOAT fTotalScaledNum);
- CFX_PtrArray m_Rows;
- CFX_PtrArray m_Columns;
- CFX_PtrArray m_Widgets;
- CFX_MapPtrToPtr m_mapWidgetInfo;
- CFWL_GridLength m_Size[6];
- friend class CFWL_GridDelegate;
+ virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
+ virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
+ virtual FWL_HGRIDCOLROW InsertColRow(FX_BOOL bColumn, int32_t nIndex = -1);
+ virtual int32_t CountColRows(FX_BOOL bColumn);
+ virtual FWL_HGRIDCOLROW GetColRow(FX_BOOL bColumn, int32_t nIndex);
+ virtual int32_t GetIndex(FWL_HGRIDCOLROW hColRow);
+ virtual FX_FLOAT GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
+ virtual FWL_ERR SetSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit);
+ virtual FX_FLOAT GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
+ virtual FWL_ERR SetMinSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit);
+ virtual FX_FLOAT GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
+ virtual FWL_ERR SetMaxSize(FWL_HGRIDCOLROW hColRow,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUnit);
+ virtual FX_BOOL DeleteColRow(FWL_HGRIDCOLROW hColRow);
+ virtual FX_BOOL IsColumn(FWL_HGRIDCOLROW hColRow);
+ virtual int32_t GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn);
+ virtual FWL_ERR SetWidgetPos(IFWL_Widget* pWidget,
+ int32_t iPos,
+ FX_BOOL bColumn);
+ virtual int32_t GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn);
+ virtual FWL_ERR SetWidgetSpan(IFWL_Widget* pWidget,
+ int32_t iSpan,
+ FX_BOOL bColumn);
+ virtual FX_FLOAT GetWidgetSize(IFWL_Widget* pWidget,
+ FWL_GRIDSIZE eSize,
+ FWL_GRIDUNIT& eUnit);
+ virtual FWL_ERR SetWidgetSize(IFWL_Widget* pWidget,
+ FWL_GRIDSIZE eSize,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUit);
+ virtual FX_BOOL GetWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin,
+ FX_FLOAT& fMargin);
+ virtual FWL_ERR SetWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin,
+ FX_FLOAT fMargin);
+ virtual FWL_ERR RemoveWidgetMargin(IFWL_Widget* pWidget,
+ FWL_GRIDMARGIN eMargin);
+ virtual FX_FLOAT GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit);
+ virtual FWL_ERR SetGridSize(FWL_GRIDSIZE eSize,
+ FX_FLOAT fSize,
+ FWL_GRIDUNIT eUit);
+
+ protected:
+ CFWL_GridWidgetInfo* GetWidgetInfo(IFWL_Widget* pWidget);
+ void ProcFixedColRow(CFWL_GridColRow* pColRow,
+ int32_t nIndex,
+ FX_FLOAT fColRowSize,
+ FX_BOOL bColumn);
+ void ProcAutoColRow(CFWL_GridColRow* pColRow,
+ int32_t nIndex,
+ FX_BOOL bColumn);
+ void ProcScaledColRow(CFWL_GridColRow* pColRow,
+ int32_t nIndex,
+ FX_FLOAT fColRowSize,
+ FX_BOOL bColumn);
+ void CalcWidgetWidth(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo,
+ FX_FLOAT fColunmWidth);
+ void CalcWidgetHeigt(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo,
+ FX_FLOAT fRowHeigt);
+ FX_FLOAT CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo);
+ FX_FLOAT CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
+ CFWL_GridWidgetInfo* pInfo);
+ FX_FLOAT ProcessColumns(FX_FLOAT fWidth);
+ FX_FLOAT ProcessRows(FX_FLOAT fHeight);
+ FX_FLOAT ProcessUnCertainColumns();
+ FX_FLOAT ProcessUnCertainRows();
+ FX_BOOL SetColRowActualSize(CFWL_GridColRow* pColRow,
+ FX_FLOAT fSize,
+ FX_BOOL bSetBeyond = FALSE);
+ FX_FLOAT SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fWidth);
+ FX_FLOAT SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fHeight);
+ void SetAllWidgetsRect();
+ FX_BOOL IsGrid(IFWL_Widget* pWidget);
+ void SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
+ FX_FLOAT fTotalSize);
+ void SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
+ FX_FLOAT fTotalSize,
+ FX_FLOAT fTotalScaledNum);
+ void SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
+ FX_FLOAT fTotalSize,
+ FX_FLOAT fTotalScaledNum);
+ CFX_PtrArray m_Rows;
+ CFX_PtrArray m_Columns;
+ CFX_PtrArray m_Widgets;
+ CFX_MapPtrToPtr m_mapWidgetInfo;
+ CFWL_GridLength m_Size[6];
+ friend class CFWL_GridDelegate;
};
-class CFWL_GridDelegate : public CFWL_WidgetImpDelegate
-{
-public:
- CFWL_GridDelegate(CFWL_GridImp *pOwner);
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
-protected:
- CFWL_GridImp *m_pOwner;
+class CFWL_GridDelegate : public CFWL_WidgetImpDelegate {
+ public:
+ CFWL_GridDelegate(CFWL_GridImp* pOwner);
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+
+ protected:
+ CFWL_GridImp* m_pOwner;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_noteimp.h b/xfa/src/fwl/src/core/include/fwl_noteimp.h index cc94b37fa4..1c0e922470 100644 --- a/xfa/src/fwl/src/core/include/fwl_noteimp.h +++ b/xfa/src/fwl/src/core/include/fwl_noteimp.h @@ -17,143 +17,135 @@ class CFWL_NoteDriver; class CFWL_EventTarget;
class CFWL_ToolTipContainer;
-class CFWL_NoteLoop
-{
-public:
- CFWL_NoteLoop(CFWL_WidgetImp *pForm = NULL);
- virtual ~CFWL_NoteLoop() {}
- virtual FX_BOOL PreProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR Idle(int32_t count);
- CFWL_WidgetImp* GetForm();
- FX_BOOL ContinueModal();
- FWL_ERR EndModalLoop();
- FX_BOOL TranslateAccelerator(CFWL_Message *pMessage);
- FWL_ERR SetMainForm(CFWL_WidgetImp *pForm);
-protected:
- void GenerateCommondEvent(FX_DWORD dwCommand);
+class CFWL_NoteLoop {
+ public:
+ CFWL_NoteLoop(CFWL_WidgetImp* pForm = NULL);
+ virtual ~CFWL_NoteLoop() {}
+ virtual FX_BOOL PreProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR Idle(int32_t count);
+ CFWL_WidgetImp* GetForm();
+ FX_BOOL ContinueModal();
+ FWL_ERR EndModalLoop();
+ FX_BOOL TranslateAccelerator(CFWL_Message* pMessage);
+ FWL_ERR SetMainForm(CFWL_WidgetImp* pForm);
- CFWL_WidgetImp *m_pForm;
- FX_BOOL m_bContinueModal;
+ protected:
+ void GenerateCommondEvent(FX_DWORD dwCommand);
+
+ CFWL_WidgetImp* m_pForm;
+ FX_BOOL m_bContinueModal;
};
-class CFWL_NoteDriver
-{
-public:
- CFWL_NoteDriver();
- virtual ~CFWL_NoteDriver();
- virtual FX_BOOL SendNote(CFWL_Note *pNote);
- virtual FX_BOOL PostMessage(CFWL_Message *pMessage);
- virtual FWL_ERR RegisterEventTarget(IFWL_Widget *pListener, IFWL_Widget *pEventSource = NULL, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
- virtual FWL_ERR UnregisterEventTarget(IFWL_Widget *pListener);
- virtual void ClearEventTargets(FX_BOOL bRemoveAll);
- virtual int32_t GetQueueMaxSize() const;
- virtual FWL_ERR SetQueueMaxSize(const int32_t size);
- virtual IFWL_NoteThread* GetOwnerThread() const;
- virtual FWL_ERR PushNoteLoop(IFWL_NoteLoop *pNoteLoop);
- virtual IFWL_NoteLoop* PopNoteLoop();
- virtual FX_BOOL SetFocus(IFWL_Widget *pFocus, FX_BOOL bNotify = FALSE);
- virtual FWL_ERR Run();
- IFWL_Widget* GetFocus();
- IFWL_Widget* GetHover();
- void SetHover(IFWL_Widget *pHover);
- void SetGrab(IFWL_Widget *pGrab, FX_BOOL bSet);
- void NotifyTargetHide(IFWL_Widget *pNoteTarget);
- void NotifyTargetDestroy(IFWL_Widget *pNoteTarget);
- void NotifyFullScreenMode(IFWL_Widget *pNoteTarget, FX_BOOL bFullScreen);
- FWL_ERR RegisterForm(CFWL_WidgetImp *pForm);
- FWL_ERR UnRegisterForm(CFWL_WidgetImp *pForm);
- FX_BOOL QueueMessage(CFWL_Message *pMessage);
- FX_BOOL UnqueueMessage(CFWL_NoteLoop *pNoteLoop);
- CFWL_NoteLoop* GetTopLoop();
- int32_t CountLoop();
- void SetHook(FWLMessageHookCallback callback, void* info);
- FX_BOOL ProcessMessage(CFWL_Message *pMessage);
-protected:
- FX_BOOL DispatchMessage(CFWL_Message *pMessage, IFWL_Widget *pMessageForm);
- FX_BOOL DoActivate(CFWL_MsgActivate *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoDeactivate(CFWL_MsgDeactivate *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoSetFocus(CFWL_MsgSetFocus *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoKillFocus(CFWL_MsgKillFocus *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoKey(CFWL_MsgKey *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoMouse(CFWL_MsgMouse *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoWheel(CFWL_MsgMouseWheel *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoSize(CFWL_MsgSize *pMsg);
- FX_BOOL DoWindowMove(CFWL_MsgWindowMove *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoDragFiles(CFWL_MsgDropFiles *pMsg, IFWL_Widget *pMessageForm);
- FX_BOOL DoMouseEx(CFWL_MsgMouse *pMsg, IFWL_Widget *pMessageForm);
- void MouseSecondary(CFWL_MsgMouse *pMsg);
- FX_BOOL IsValidMessage(CFWL_Message *pMessage);
- IFWL_Widget* GetMessageForm(IFWL_Widget *pDstTarget);
- void ClearInvalidEventTargets(FX_BOOL bRemoveAll);
- CFX_PtrArray m_forms;
- CFX_PtrArray m_noteQueue;
- CFX_PtrArray m_noteLoopQueue;
- CFX_MapPtrToPtr m_eventTargets;
- int32_t m_sendEventCalled;
- int32_t m_maxSize;
- FX_BOOL m_bFullScreen;
- IFWL_Widget *m_pHover;
- IFWL_Widget *m_pFocus;
- IFWL_Widget *m_pGrab;
- CFWL_NoteLoop *m_pNoteLoop;
- FWLMessageHookCallback m_hook;
- void* m_hookInfo;
+class CFWL_NoteDriver {
+ public:
+ CFWL_NoteDriver();
+ virtual ~CFWL_NoteDriver();
+ virtual FX_BOOL SendNote(CFWL_Note* pNote);
+ virtual FX_BOOL PostMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR RegisterEventTarget(IFWL_Widget* pListener,
+ IFWL_Widget* pEventSource = NULL,
+ FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
+ virtual FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener);
+ virtual void ClearEventTargets(FX_BOOL bRemoveAll);
+ virtual int32_t GetQueueMaxSize() const;
+ virtual FWL_ERR SetQueueMaxSize(const int32_t size);
+ virtual IFWL_NoteThread* GetOwnerThread() const;
+ virtual FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop);
+ virtual IFWL_NoteLoop* PopNoteLoop();
+ virtual FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE);
+ virtual FWL_ERR Run();
+ IFWL_Widget* GetFocus();
+ IFWL_Widget* GetHover();
+ void SetHover(IFWL_Widget* pHover);
+ void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet);
+ void NotifyTargetHide(IFWL_Widget* pNoteTarget);
+ void NotifyTargetDestroy(IFWL_Widget* pNoteTarget);
+ void NotifyFullScreenMode(IFWL_Widget* pNoteTarget, FX_BOOL bFullScreen);
+ FWL_ERR RegisterForm(CFWL_WidgetImp* pForm);
+ FWL_ERR UnRegisterForm(CFWL_WidgetImp* pForm);
+ FX_BOOL QueueMessage(CFWL_Message* pMessage);
+ FX_BOOL UnqueueMessage(CFWL_NoteLoop* pNoteLoop);
+ CFWL_NoteLoop* GetTopLoop();
+ int32_t CountLoop();
+ void SetHook(FWLMessageHookCallback callback, void* info);
+ FX_BOOL ProcessMessage(CFWL_Message* pMessage);
+
+ protected:
+ FX_BOOL DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm);
+ FX_BOOL DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoSize(CFWL_MsgSize* pMsg);
+ FX_BOOL DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm);
+ FX_BOOL DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm);
+ void MouseSecondary(CFWL_MsgMouse* pMsg);
+ FX_BOOL IsValidMessage(CFWL_Message* pMessage);
+ IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget);
+ void ClearInvalidEventTargets(FX_BOOL bRemoveAll);
+ CFX_PtrArray m_forms;
+ CFX_PtrArray m_noteQueue;
+ CFX_PtrArray m_noteLoopQueue;
+ CFX_MapPtrToPtr m_eventTargets;
+ int32_t m_sendEventCalled;
+ int32_t m_maxSize;
+ FX_BOOL m_bFullScreen;
+ IFWL_Widget* m_pHover;
+ IFWL_Widget* m_pFocus;
+ IFWL_Widget* m_pGrab;
+ CFWL_NoteLoop* m_pNoteLoop;
+ FWLMessageHookCallback m_hook;
+ void* m_hookInfo;
};
typedef CFX_MapPtrTemplate<void*, FX_DWORD> CFWL_EventSource;
-class CFWL_EventTarget
-{
-public:
- CFWL_EventTarget(CFWL_NoteDriver *pNoteDriver, IFWL_Widget *pListener)
- : m_pNoteDriver(pNoteDriver)
- , m_pListener(pListener)
- , m_bInvalid(FALSE)
- {
- }
- ~CFWL_EventTarget();
- int32_t SetEventSource(IFWL_Widget *pSource, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
- FX_BOOL ProcessEvent(CFWL_Event *pEvent);
- FX_BOOL IsFilterEvent(CFWL_Event *pEvent, FX_DWORD dwFilter);
- FX_BOOL IsInvalid()
- {
- return m_bInvalid;
- }
- void FlagInvalid()
- {
- m_bInvalid = TRUE;
- }
-protected:
- CFWL_EventSource m_eventSources;
- IFWL_Widget *m_pListener;
- CFWL_NoteDriver *m_pNoteDriver;
- FX_BOOL m_bInvalid;
+class CFWL_EventTarget {
+ public:
+ CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener)
+ : m_pNoteDriver(pNoteDriver), m_pListener(pListener), m_bInvalid(FALSE) {}
+ ~CFWL_EventTarget();
+ int32_t SetEventSource(IFWL_Widget* pSource,
+ FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
+ FX_BOOL ProcessEvent(CFWL_Event* pEvent);
+ FX_BOOL IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter);
+ FX_BOOL IsInvalid() { return m_bInvalid; }
+ void FlagInvalid() { m_bInvalid = TRUE; }
+
+ protected:
+ CFWL_EventSource m_eventSources;
+ IFWL_Widget* m_pListener;
+ CFWL_NoteDriver* m_pNoteDriver;
+ FX_BOOL m_bInvalid;
};
-class CFWL_ToolTipContainer
-{
-public:
- static CFWL_ToolTipContainer* getInstance();
- static void DeleteInstance();
+class CFWL_ToolTipContainer {
+ public:
+ static CFWL_ToolTipContainer* getInstance();
+ static void DeleteInstance();
- FX_ERR AddToolTipTarget(IFWL_ToolTipTarget *pTarget);
- FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget *pTarget);
- IFWL_ToolTipTarget* GetCurrentToolTipTarget();
+ FX_ERR AddToolTipTarget(IFWL_ToolTipTarget* pTarget);
+ FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget);
+ IFWL_ToolTipTarget* GetCurrentToolTipTarget();
- FX_BOOL HasToolTip(IFWL_Widget *pWidget);
+ FX_BOOL HasToolTip(IFWL_Widget* pWidget);
- FX_BOOL ProcessEnter(CFWL_EvtMouse *pEvt, IFWL_Widget *pOwner);
- FX_BOOL ProcessLeave(CFWL_EvtMouse *pEvt);
+ FX_BOOL ProcessEnter(CFWL_EvtMouse* pEvt, IFWL_Widget* pOwner);
+ FX_BOOL ProcessLeave(CFWL_EvtMouse* pEvt);
- FX_ERR SetToolTipInitialDelay(int32_t iDelayTime);
- FX_ERR SetToolTipAutoPopDelay(int32_t iDelayTime);
+ FX_ERR SetToolTipInitialDelay(int32_t iDelayTime);
+ FX_ERR SetToolTipAutoPopDelay(int32_t iDelayTime);
-protected:
- CFWL_ToolTipContainer();
- virtual ~CFWL_ToolTipContainer();
+ protected:
+ CFWL_ToolTipContainer();
+ virtual ~CFWL_ToolTipContainer();
- IFWL_ToolTipTarget *pCurTarget;
- CFWL_ToolTipImp *m_pToolTipImp;
- CFWL_CoreToopTipDP *m_ToolTipDp;
- CFX_PtrArray m_arrWidget;
+ IFWL_ToolTipTarget* pCurTarget;
+ CFWL_ToolTipImp* m_pToolTipImp;
+ CFWL_CoreToopTipDP* m_ToolTipDp;
+ CFX_PtrArray m_arrWidget;
-private:
- static CFWL_ToolTipContainer* s_pInstance;
+ private:
+ static CFWL_ToolTipContainer* s_pInstance;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_panelimp.h b/xfa/src/fwl/src/core/include/fwl_panelimp.h index bdaf8bd2a8..508c4bb767 100644 --- a/xfa/src/fwl/src/core/include/fwl_panelimp.h +++ b/xfa/src/fwl/src/core/include/fwl_panelimp.h @@ -11,19 +11,20 @@ class CFWL_WidgetImpProperties; class IFWL_Widget;
class IFWL_Content;
class CFWL_PanelImp;
-class CFWL_PanelImp : public CFWL_WidgetImp
-{
-public:
- CFWL_PanelImp(IFWL_Widget *pOuter = NULL);
- CFWL_PanelImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_PanelImp();
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual IFWL_Content* GetContent();
- virtual FWL_ERR SetContent(IFWL_Content *pContent);
-protected:
- IFWL_Content *m_pContent;
+class CFWL_PanelImp : public CFWL_WidgetImp {
+ public:
+ CFWL_PanelImp(IFWL_Widget* pOuter = NULL);
+ CFWL_PanelImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_PanelImp();
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR Update();
+ virtual IFWL_Content* GetContent();
+ virtual FWL_ERR SetContent(IFWL_Content* pContent);
+
+ protected:
+ IFWL_Content* m_pContent;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_targetimp.h b/xfa/src/fwl/src/core/include/fwl_targetimp.h index 3b0b7c38a6..3dd3f6aeb8 100644 --- a/xfa/src/fwl/src/core/include/fwl_targetimp.h +++ b/xfa/src/fwl/src/core/include/fwl_targetimp.h @@ -7,26 +7,25 @@ #ifndef _FWL_TARGET_IMP_H
#define _FWL_TARGET_IMP_H
class IFWL_Target;
-class CFWL_Target
-{
-public:
- virtual FX_DWORD Release();
- virtual IFWL_Target* Retain();
- virtual FX_DWORD GetRefCount() const;
- virtual FWL_ERR GetClassName(CFX_WideString &wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-protected:
- CFWL_Target();
- virtual ~CFWL_Target();
- FX_DWORD m_dwRefCount;
+class CFWL_Target {
+ public:
+ virtual FX_DWORD Release();
+ virtual IFWL_Target* Retain();
+ virtual FX_DWORD GetRefCount() const;
+ virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+ virtual FX_DWORD GetClassID() const;
+ virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
+
+ protected:
+ CFWL_Target();
+ virtual ~CFWL_Target();
+ FX_DWORD m_dwRefCount;
};
-class IFWL_TargetData : public IFWL_Target
-{
-public:
- void* GetData();
- void SetData(void* pData);
+class IFWL_TargetData : public IFWL_Target {
+ public:
+ void* GetData();
+ void SetData(void* pData);
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_threadimp.h b/xfa/src/fwl/src/core/include/fwl_threadimp.h index 26acc54006..735708d98c 100644 --- a/xfa/src/fwl/src/core/include/fwl_threadimp.h +++ b/xfa/src/fwl/src/core/include/fwl_threadimp.h @@ -13,41 +13,34 @@ class IFWL_NoteDriver; class CFWL_Thread;
class CFWL_NoteThread;
class CFWL_ControlThread;
-class CFWL_Thread
-{
-public:
- CFWL_Thread();
- virtual ~CFWL_Thread();
- virtual void Release()
- {
- delete this;
- }
- virtual FWL_ERR Run(FWL_HTHREAD hThread);
+class CFWL_Thread {
+ public:
+ CFWL_Thread();
+ virtual ~CFWL_Thread();
+ virtual void Release() { delete this; }
+ virtual FWL_ERR Run(FWL_HTHREAD hThread);
};
-class CFWL_ControlThread : public CFWL_Thread
-{
-public:
- CFWL_ControlThread(IFWL_Thread * defHandler)
- {
- _defHandler = defHandler;
- }
- virtual ~CFWL_ControlThread();
- virtual FWL_ERR Run(FWL_HTHREAD hThread);
-protected:
- IFWL_Thread * _defHandler;
+class CFWL_ControlThread : public CFWL_Thread {
+ public:
+ CFWL_ControlThread(IFWL_Thread* defHandler) { _defHandler = defHandler; }
+ virtual ~CFWL_ControlThread();
+ virtual FWL_ERR Run(FWL_HTHREAD hThread);
+
+ protected:
+ IFWL_Thread* _defHandler;
};
-class CFWL_NoteThread : public CFWL_Thread
-{
-public:
- CFWL_NoteThread();
- virtual ~CFWL_NoteThread();
- virtual FWL_ERR Run(FWL_HTHREAD hThread);
- virtual IFWL_NoteDriver* GetNoteDriver();
-protected:
- CFWL_NoteDriver *m_pNoteDriver;
- FWL_HTHREAD m_hThread;
- static CFWL_ControlThread * _assistantThreadHandler;
- static FWL_HTHREAD _assistantThread;
- static int32_t _refCount;
+class CFWL_NoteThread : public CFWL_Thread {
+ public:
+ CFWL_NoteThread();
+ virtual ~CFWL_NoteThread();
+ virtual FWL_ERR Run(FWL_HTHREAD hThread);
+ virtual IFWL_NoteDriver* GetNoteDriver();
+
+ protected:
+ CFWL_NoteDriver* m_pNoteDriver;
+ FWL_HTHREAD m_hThread;
+ static CFWL_ControlThread* _assistantThreadHandler;
+ static FWL_HTHREAD _assistantThread;
+ static int32_t _refCount;
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_widgetimp.h b/xfa/src/fwl/src/core/include/fwl_widgetimp.h index fa523f390c..f32f7e1ad0 100644 --- a/xfa/src/fwl/src/core/include/fwl_widgetimp.h +++ b/xfa/src/fwl/src/core/include/fwl_widgetimp.h @@ -15,115 +15,150 @@ class IFWL_ThemeProvider; class IFWL_DataProvider;
class IFWL_WidgetDelegate;
class CFWL_WidgetImp;
-class CFWL_WidgetImp : public CFWL_Target
-{
-public:
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+class CFWL_WidgetImp : public CFWL_Target {
+ public:
+ virtual FWL_ERR Initialize();
+ virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR GetGlobalRect(CFX_RectF &rect);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF &rect);
- virtual FWL_ERR GetClientRect(CFX_RectF &rect);
- virtual IFWL_Widget* GetParent();
- virtual FWL_ERR SetParent(IFWL_Widget *pParent);
- virtual IFWL_Widget* GetOwner();
- virtual FWL_ERR SetOwner(IFWL_Widget *pOwner);
- virtual IFWL_Widget* GetOuter();
- virtual FX_DWORD GetStyles();
- virtual FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved);
- virtual FX_DWORD GetStylesEx();
- virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved);
- virtual FX_DWORD GetStates();
- virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback);
- virtual void* GetPrivateData(void* module_id);
- virtual FWL_ERR Update();
- virtual FWL_ERR LockUpdate();
- virtual FWL_ERR UnlockUpdate();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR TransformTo(IFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy);
- virtual FWL_ERR TransformTo(IFWL_Widget *pWidget, CFX_RectF &rt);
- virtual FWL_ERR GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal = FALSE);
- virtual FWL_ERR SetMatrix(const CFX_Matrix &matrix);
- virtual FWL_ERR DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
- virtual IFWL_ThemeProvider* GetThemeProvider();
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider *pThemeProvider);
- virtual FWL_ERR SetDataProvider(IFWL_DataProvider *pDataProvider);
- virtual IFWL_WidgetDelegate*SetDelegate(IFWL_WidgetDelegate *pDelegate);
- virtual IFWL_NoteThread* GetOwnerThread() const;
- FWL_ERR SetOwnerThread(CFWL_NoteThread *pOwnerThread);
- FWL_ERR GetProperties(CFWL_WidgetImpProperties &properties);
- FWL_ERR SetProperties(const CFWL_WidgetImpProperties &properties);
- IFWL_Widget* GetInterface();
- void SetInterface(IFWL_Widget *pInterface);
- CFX_SizeF GetOffsetFromParent(IFWL_Widget *pParent);
-protected:
- CFWL_WidgetImp(IFWL_Widget *pOuter = NULL);
- CFWL_WidgetImp(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);
- virtual ~CFWL_WidgetImp();
- FX_BOOL IsEnabled();
- FX_BOOL IsVisible();
- FX_BOOL IsActive();
- FX_BOOL IsOverLapper();
- FX_BOOL IsPopup();
- FX_BOOL IsChild();
- FX_BOOL IsLocked();
- FX_BOOL IsOffscreen();
- FX_BOOL HasBorder();
- FX_BOOL HasEdge();
- void GetEdgeRect(CFX_RectF &rtEdge);
- FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE);
- FX_FLOAT GetEdgeWidth();
- void GetRelativeRect(CFX_RectF &rect);
- void* GetThemeCapacity(FX_DWORD dwCapacity);
- IFWL_ThemeProvider* GetAvailableTheme();
- CFWL_WidgetImp* GetRootOuter();
- CFWL_WidgetImp* GetSameAncestor(CFWL_WidgetImp *pWidget);
- CFX_SizeF GetOffsetFromAncestor(CFWL_WidgetImp *pAncestor);
- FX_BOOL TransformToOuter(FX_FLOAT &fx, FX_FLOAT &fy);
- FX_BOOL TransformFromOuter(FX_FLOAT &fx, FX_FLOAT &fy);
- CFX_SizeF CalcTextSize(const CFX_WideString &wsText, IFWL_ThemeProvider *pTheme, FX_BOOL bMultiLine = FALSE, int32_t iLineWidth = -1);
- void CalcTextRect(const CFX_WideString &wsText, IFWL_ThemeProvider *pTheme, FX_DWORD dwTTOStyles, int32_t iTTOAlign, CFX_RectF &rect);
- void SetFocus(FX_BOOL bFocus);
- void SetGrab(FX_BOOL bSet);
- FX_BOOL GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);
- FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);
- FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);
- FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);
- FX_BOOL GetScreenSize(FX_FLOAT &fx, FX_FLOAT &fy);
- void RegisterEventTarget(IFWL_Widget *pEventSource = NULL, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
- void UnregisterEventTarget();
- void DispatchKeyEvent(CFWL_MsgKey *pNote);
- void DispatchEvent(CFWL_Event *pEvent);
- void Repaint(const CFX_RectF *pRect = NULL);
- void DrawBackground(CFX_Graphics *pGraphics, int32_t iPartBk, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void DrawBorder(CFX_Graphics *pGraphics, int32_t iPartBorder, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void DrawEdge(CFX_Graphics *pGraphics, int32_t iPartEdge, IFWL_ThemeProvider *pTheme, const CFX_Matrix *pMatrix = NULL);
- void NotifyDriver();
+ virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_ERR GetGlobalRect(CFX_RectF& rect);
+ virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
+ virtual FWL_ERR GetClientRect(CFX_RectF& rect);
+ virtual IFWL_Widget* GetParent();
+ virtual FWL_ERR SetParent(IFWL_Widget* pParent);
+ virtual IFWL_Widget* GetOwner();
+ virtual FWL_ERR SetOwner(IFWL_Widget* pOwner);
+ virtual IFWL_Widget* GetOuter();
+ virtual FX_DWORD GetStyles();
+ virtual FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded,
+ FX_DWORD dwStylesRemoved);
+ virtual FX_DWORD GetStylesEx();
+ virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved);
+ virtual FX_DWORD GetStates();
+ virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
+ virtual FWL_ERR SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback);
+ virtual void* GetPrivateData(void* module_id);
+ virtual FWL_ERR Update();
+ virtual FWL_ERR LockUpdate();
+ virtual FWL_ERR UnlockUpdate();
+ virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
+ virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
+ virtual FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
+ virtual FWL_ERR SetMatrix(const CFX_Matrix& matrix);
+ virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ virtual IFWL_ThemeProvider* GetThemeProvider();
+ virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
+ virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
+ virtual IFWL_NoteThread* GetOwnerThread() const;
+ FWL_ERR SetOwnerThread(CFWL_NoteThread* pOwnerThread);
+ FWL_ERR GetProperties(CFWL_WidgetImpProperties& properties);
+ FWL_ERR SetProperties(const CFWL_WidgetImpProperties& properties);
+ IFWL_Widget* GetInterface();
+ void SetInterface(IFWL_Widget* pInterface);
+ CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
- FX_BOOL IsParent(IFWL_Widget *pParent);
- CFWL_WidgetMgr *m_pWidgetMgr;
- CFWL_NoteThread *m_pOwnerThread;
- CFWL_WidgetImpProperties *m_pProperties;
- CFX_PrivateData *m_pPrivateData;
- IFWL_WidgetDelegate *m_pDelegate;
- IFWL_WidgetDelegate *m_pCurDelegate;
- IFWL_Widget *m_pOuter;
- IFWL_Widget *m_pInterface;
- int32_t m_iLock;
- friend class CFWL_WidgetImpDelegate;
- friend void FWL_SetWidgetRect(IFWL_Widget *widget, const CFX_RectF &rect);
- friend void FWL_SetWidgetStates(IFWL_Widget *widget, FX_DWORD dwStates);
- friend void FWL_SetWidgetStyles(IFWL_Widget *widget, FX_DWORD dwStyles);
+ protected:
+ CFWL_WidgetImp(IFWL_Widget* pOuter = NULL);
+ CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter = NULL);
+ virtual ~CFWL_WidgetImp();
+ FX_BOOL IsEnabled();
+ FX_BOOL IsVisible();
+ FX_BOOL IsActive();
+ FX_BOOL IsOverLapper();
+ FX_BOOL IsPopup();
+ FX_BOOL IsChild();
+ FX_BOOL IsLocked();
+ FX_BOOL IsOffscreen();
+ FX_BOOL HasBorder();
+ FX_BOOL HasEdge();
+ void GetEdgeRect(CFX_RectF& rtEdge);
+ FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE);
+ FX_FLOAT GetEdgeWidth();
+ void GetRelativeRect(CFX_RectF& rect);
+ void* GetThemeCapacity(FX_DWORD dwCapacity);
+ IFWL_ThemeProvider* GetAvailableTheme();
+ CFWL_WidgetImp* GetRootOuter();
+ CFWL_WidgetImp* GetSameAncestor(CFWL_WidgetImp* pWidget);
+ CFX_SizeF GetOffsetFromAncestor(CFWL_WidgetImp* pAncestor);
+ FX_BOOL TransformToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
+ FX_BOOL TransformFromOuter(FX_FLOAT& fx, FX_FLOAT& fy);
+ CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
+ IFWL_ThemeProvider* pTheme,
+ FX_BOOL bMultiLine = FALSE,
+ int32_t iLineWidth = -1);
+ void CalcTextRect(const CFX_WideString& wsText,
+ IFWL_ThemeProvider* pTheme,
+ FX_DWORD dwTTOStyles,
+ int32_t iTTOAlign,
+ CFX_RectF& rect);
+ void SetFocus(FX_BOOL bFocus);
+ void SetGrab(FX_BOOL bSet);
+ FX_BOOL GetPopupPos(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
+ FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
+ FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
+ FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
+ FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy);
+ void RegisterEventTarget(IFWL_Widget* pEventSource = NULL,
+ FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
+ void UnregisterEventTarget();
+ void DispatchKeyEvent(CFWL_MsgKey* pNote);
+ void DispatchEvent(CFWL_Event* pEvent);
+ void Repaint(const CFX_RectF* pRect = NULL);
+ void DrawBackground(CFX_Graphics* pGraphics,
+ int32_t iPartBk,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawBorder(CFX_Graphics* pGraphics,
+ int32_t iPartBorder,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void DrawEdge(CFX_Graphics* pGraphics,
+ int32_t iPartEdge,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix = NULL);
+ void NotifyDriver();
+
+ FX_BOOL IsParent(IFWL_Widget* pParent);
+ CFWL_WidgetMgr* m_pWidgetMgr;
+ CFWL_NoteThread* m_pOwnerThread;
+ CFWL_WidgetImpProperties* m_pProperties;
+ CFX_PrivateData* m_pPrivateData;
+ IFWL_WidgetDelegate* m_pDelegate;
+ IFWL_WidgetDelegate* m_pCurDelegate;
+ IFWL_Widget* m_pOuter;
+ IFWL_Widget* m_pInterface;
+ int32_t m_iLock;
+ friend class CFWL_WidgetImpDelegate;
+ friend void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect);
+ friend void FWL_SetWidgetStates(IFWL_Widget* widget, FX_DWORD dwStates);
+ friend void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD dwStyles);
};
-class CFWL_WidgetImpDelegate
-{
-public:
- CFWL_WidgetImpDelegate();
- virtual ~CFWL_WidgetImpDelegate() {}
- virtual int32_t OnProcessMessage(CFWL_Message *pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event *pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix = NULL);
+class CFWL_WidgetImpDelegate {
+ public:
+ CFWL_WidgetImpDelegate();
+ virtual ~CFWL_WidgetImpDelegate() {}
+ virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
+ virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
};
#endif
diff --git a/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h b/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h index 31b978ec97..5cd8510105 100644 --- a/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h +++ b/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h @@ -13,132 +13,151 @@ class CFWL_WidgetMgrItem; class CFWL_WidgetMgr;
class CFWL_WidgetMgrDelegate;
class IFWL_AdapterNative;
-class CFWL_WidgetMgrItem
-{
-public:
- CFWL_WidgetMgrItem()
- : pParent(NULL)
- , pOwner(NULL)
- , pChild(NULL)
- , pPrevious(NULL)
- , pNext(NULL)
- , pWidget(NULL)
- , pOffscreen(NULL)
- , iRedrawCounter(0)
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)
- , bOutsideChanged(FALSE)
+class CFWL_WidgetMgrItem {
+ public:
+ CFWL_WidgetMgrItem()
+ : pParent(NULL),
+ pOwner(NULL),
+ pChild(NULL),
+ pPrevious(NULL),
+ pNext(NULL),
+ pWidget(NULL),
+ pOffscreen(NULL),
+ iRedrawCounter(0)
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
+ ,
+ bOutsideChanged(FALSE)
#endif
- {
+ {
+ }
+ ~CFWL_WidgetMgrItem() {
+ if (pOffscreen) {
+ delete pOffscreen;
+ pOffscreen = NULL;
}
- ~CFWL_WidgetMgrItem()
- {
- if (pOffscreen) {
- delete pOffscreen;
- pOffscreen = NULL;
- }
- }
- CFWL_WidgetMgrItem *pParent;
- CFWL_WidgetMgrItem *pOwner;
- CFWL_WidgetMgrItem *pChild;
- CFWL_WidgetMgrItem *pPrevious;
- CFWL_WidgetMgrItem *pNext;
- IFWL_Widget *pWidget;
- CFX_Graphics *pOffscreen;
- int32_t iRedrawCounter;
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)
- FX_BOOL bOutsideChanged;
+ }
+ CFWL_WidgetMgrItem* pParent;
+ CFWL_WidgetMgrItem* pOwner;
+ CFWL_WidgetMgrItem* pChild;
+ CFWL_WidgetMgrItem* pPrevious;
+ CFWL_WidgetMgrItem* pNext;
+ IFWL_Widget* pWidget;
+ CFX_Graphics* pOffscreen;
+ int32_t iRedrawCounter;
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
+ FX_BOOL bOutsideChanged;
#endif
};
-class CFWL_WidgetMgr
-{
-public:
- CFWL_WidgetMgr(IFWL_AdapterNative *pAdapterNative);
- virtual ~CFWL_WidgetMgr();
- virtual int32_t CountWidgets(IFWL_Widget *pParent = NULL);
- virtual IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget *pParent = NULL);
- virtual IFWL_Widget* GetWidget(IFWL_Widget *pWidget, FWL_WGTRELATION eRelation);
- virtual int32_t GetWidgetIndex(IFWL_Widget *pWidget);
- virtual FX_BOOL SetWidgetIndex(IFWL_Widget *pWidget, int32_t nIndex);
- virtual FX_BOOL IsWidget(void* pObj);
- virtual FWL_ERR RepaintWidget(IFWL_Widget *pWidget, const CFX_RectF *pRect = NULL);
- virtual FX_DWORD GetCapability()
- {
- return m_dwCapability;
- }
- void AddWidget(IFWL_Widget *pWidget);
- void InsertWidget(IFWL_Widget *pParent, IFWL_Widget *pChild, int32_t nIndex = -1);
- void RemoveWidget(IFWL_Widget *pWidget);
- void SetOwner(IFWL_Widget *pOwner, IFWL_Widget *pOwned);
- void SetParent(IFWL_Widget *pParent, IFWL_Widget *pChild);
- FX_BOOL IsChild(IFWL_Widget *pChild, IFWL_Widget *pParent);
- FWL_ERR CreateWidget_Native(IFWL_Widget *pWidget);
- FWL_ERR DestroyWidget_Native(IFWL_Widget *pWidget);
- FWL_ERR GetWidgetRect_Native(IFWL_Widget *pWidget, CFX_RectF &rect);
- FWL_ERR SetWidgetRect_Native(IFWL_Widget *pWidget, const CFX_RectF &rect);
- FWL_ERR SetWidgetPosition_Native(IFWL_Widget *pWidget, FX_FLOAT fx, FX_FLOAT fy);
- FWL_ERR SetWidgetIcon_Native(IFWL_Widget *pWidget, const CFX_DIBitmap *pIcon, FX_BOOL bBig);
- FWL_ERR SetWidgetCaption_Native(IFWL_Widget *pWidget, const CFX_WideStringC& wsCaption);
- FWL_ERR SetBorderRegion_Native(IFWL_Widget *pWidget, CFX_Path *pPath);
- FWL_ERR ShowWidget_Native(IFWL_Widget *pWidget);
- FWL_ERR HideWidget_Native(IFWL_Widget *pWidget);
- FWL_ERR SetNormal_Native(IFWL_Widget *pWidget);
- FWL_ERR SetMaximize_Native(IFWL_Widget *pWidget);
- FWL_ERR SetMinimize_Native(IFWL_Widget *pWidget);
- FX_BOOL CheckMessage_Native();
- FWL_ERR DispatchMessage_Native();
- FX_BOOL IsIdleMessage_Native();
- FWL_ERR Exit_Native(int32_t iExitCode);
- FWL_ERR CreateWidgetWithNativeId_Native(IFWL_Widget *pWidget, void *vp);
- IFWL_Widget* GetWidgetAtPoint(IFWL_Widget *pParent, FX_FLOAT fx, FX_FLOAT fy);
- void NotifySizeChanged(IFWL_Widget *pForm, FX_FLOAT fx, FX_FLOAT fy);
- IFWL_Widget* nextTab(IFWL_Widget *parent, IFWL_Widget *focus, FX_BOOL &bFind);
- int32_t CountRadioButtonGroup(IFWL_Widget *pFirst);
- IFWL_Widget* GetSiblingRadioButton(IFWL_Widget *pWidget, FX_BOOL bNext);
- IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget *pRadioButton);
- void GetSameGroupRadioButton(IFWL_Widget *pRadioButton, CFX_PtrArray &group);
- IFWL_Widget* GetDefaultButton(IFWL_Widget *pParent);
- void AddRedrawCounts(IFWL_Widget *pWidget);
- void ResetRedrawCounts(IFWL_Widget *pWidget);
- IFWL_AdapterWidgetMgr* GetAdapterWidgetMgr()
- {
- return m_pAdapter;
- }
- CFWL_WidgetMgrDelegate* GetDelegate()
- {
- return m_pDelegate;
- }
- CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget *pWidget);
- FX_BOOL IsThreadEnabled();
- FX_BOOL IsFormDisabled();
- FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF &rtAnchor, CFX_RectF &rtPopup);
-protected:
- int32_t TravelWidgetMgr(CFWL_WidgetMgrItem *pParent, int32_t *pIndex, CFWL_WidgetMgrItem *pItem, IFWL_Widget **pWidget = NULL);
- FX_BOOL IsAbleNative(IFWL_Widget *pWidget);
- CFX_MapPtrToPtr m_mapWidgetItem;
- IFWL_AdapterWidgetMgr *m_pAdapter;
- CFWL_WidgetMgrDelegate *m_pDelegate;
- friend class CFWL_WidgetMgrDelegate;
- FX_DWORD m_dwCapability;
-#if (_FX_OS_==_FX_WIN32_DESKTOP_) || (_FX_OS_==_FX_WIN64_)
- CFX_RectF m_rtScreen;
+class CFWL_WidgetMgr {
+ public:
+ CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative);
+ virtual ~CFWL_WidgetMgr();
+ virtual int32_t CountWidgets(IFWL_Widget* pParent = NULL);
+ virtual IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL);
+ virtual IFWL_Widget* GetWidget(IFWL_Widget* pWidget,
+ FWL_WGTRELATION eRelation);
+ virtual int32_t GetWidgetIndex(IFWL_Widget* pWidget);
+ virtual FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex);
+ virtual FX_BOOL IsWidget(void* pObj);
+ virtual FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect = NULL);
+ virtual FX_DWORD GetCapability() { return m_dwCapability; }
+ void AddWidget(IFWL_Widget* pWidget);
+ void InsertWidget(IFWL_Widget* pParent,
+ IFWL_Widget* pChild,
+ int32_t nIndex = -1);
+ void RemoveWidget(IFWL_Widget* pWidget);
+ void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned);
+ void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild);
+ FX_BOOL IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent);
+ FWL_ERR CreateWidget_Native(IFWL_Widget* pWidget);
+ FWL_ERR DestroyWidget_Native(IFWL_Widget* pWidget);
+ FWL_ERR GetWidgetRect_Native(IFWL_Widget* pWidget, CFX_RectF& rect);
+ FWL_ERR SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect);
+ FWL_ERR SetWidgetPosition_Native(IFWL_Widget* pWidget,
+ FX_FLOAT fx,
+ FX_FLOAT fy);
+ FWL_ERR SetWidgetIcon_Native(IFWL_Widget* pWidget,
+ const CFX_DIBitmap* pIcon,
+ FX_BOOL bBig);
+ FWL_ERR SetWidgetCaption_Native(IFWL_Widget* pWidget,
+ const CFX_WideStringC& wsCaption);
+ FWL_ERR SetBorderRegion_Native(IFWL_Widget* pWidget, CFX_Path* pPath);
+ FWL_ERR ShowWidget_Native(IFWL_Widget* pWidget);
+ FWL_ERR HideWidget_Native(IFWL_Widget* pWidget);
+ FWL_ERR SetNormal_Native(IFWL_Widget* pWidget);
+ FWL_ERR SetMaximize_Native(IFWL_Widget* pWidget);
+ FWL_ERR SetMinimize_Native(IFWL_Widget* pWidget);
+ FX_BOOL CheckMessage_Native();
+ FWL_ERR DispatchMessage_Native();
+ FX_BOOL IsIdleMessage_Native();
+ FWL_ERR Exit_Native(int32_t iExitCode);
+ FWL_ERR CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget, void* vp);
+ IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy);
+ void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy);
+ IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind);
+ int32_t CountRadioButtonGroup(IFWL_Widget* pFirst);
+ IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, FX_BOOL bNext);
+ IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton);
+ void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, CFX_PtrArray& group);
+ IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent);
+ void AddRedrawCounts(IFWL_Widget* pWidget);
+ void ResetRedrawCounts(IFWL_Widget* pWidget);
+ IFWL_AdapterWidgetMgr* GetAdapterWidgetMgr() { return m_pAdapter; }
+ CFWL_WidgetMgrDelegate* GetDelegate() { return m_pDelegate; }
+ CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget);
+ FX_BOOL IsThreadEnabled();
+ FX_BOOL IsFormDisabled();
+ FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget,
+ FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
+
+ protected:
+ int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent,
+ int32_t* pIndex,
+ CFWL_WidgetMgrItem* pItem,
+ IFWL_Widget** pWidget = NULL);
+ FX_BOOL IsAbleNative(IFWL_Widget* pWidget);
+ CFX_MapPtrToPtr m_mapWidgetItem;
+ IFWL_AdapterWidgetMgr* m_pAdapter;
+ CFWL_WidgetMgrDelegate* m_pDelegate;
+ friend class CFWL_WidgetMgrDelegate;
+ FX_DWORD m_dwCapability;
+#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
+ CFX_RectF m_rtScreen;
#endif
};
-class CFWL_WidgetMgrDelegate
-{
-public:
- CFWL_WidgetMgrDelegate(CFWL_WidgetMgr *pWidgetMgr);
- virtual ~CFWL_WidgetMgrDelegate() {}
- virtual FWL_ERR OnSetCapability(FX_DWORD dwCapability = FWL_WGTMGR_DisableThread);
- virtual int32_t OnProcessMessageToForm(CFWL_Message *pMessage);
- virtual FWL_ERR OnDrawWidget(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix );
-protected:
- void DrawChild(IFWL_Widget *pParent, const CFX_RectF &rtClip, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix );
- CFX_Graphics* DrawWidgetBefore(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix);
- void DrawWidgetAfter(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, CFX_RectF &rtClip, const CFX_Matrix *pMatrix);
- FX_BOOL IsNeedRepaint(IFWL_Widget *pWidget, CFX_Matrix *pMatrix, const CFX_RectF &rtDirty);
- FX_BOOL bUseOffscreenDirect(IFWL_Widget *pWidget);
+class CFWL_WidgetMgrDelegate {
+ public:
+ CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr);
+ virtual ~CFWL_WidgetMgrDelegate() {}
+ virtual FWL_ERR OnSetCapability(
+ FX_DWORD dwCapability = FWL_WGTMGR_DisableThread);
+ virtual int32_t OnProcessMessageToForm(CFWL_Message* pMessage);
+ virtual FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix);
+
+ protected:
+ void DrawChild(IFWL_Widget* pParent,
+ const CFX_RectF& rtClip,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix);
+ CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix);
+ void DrawWidgetAfter(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ CFX_RectF& rtClip,
+ const CFX_Matrix* pMatrix);
+ FX_BOOL IsNeedRepaint(IFWL_Widget* pWidget,
+ CFX_Matrix* pMatrix,
+ const CFX_RectF& rtDirty);
+ FX_BOOL bUseOffscreenDirect(IFWL_Widget* pWidget);
- CFWL_WidgetMgr *m_pWidgetMgr;
+ CFWL_WidgetMgr* m_pWidgetMgr;
};
#endif
diff --git a/xfa/src/fwl/src/lightwidget/app.cpp b/xfa/src/fwl/src/lightwidget/app.cpp index 54327c8cbc..9441b8f2f4 100644 --- a/xfa/src/fwl/src/lightwidget/app.cpp +++ b/xfa/src/fwl/src/lightwidget/app.cpp @@ -5,38 +5,30 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_App::CFWL_App()
- : m_pAppImp(NULL)
- , m_pThemeProvider(NULL)
-{
- m_pAppImp = IFWL_App::Create(NULL);
+CFWL_App::CFWL_App() : m_pAppImp(NULL), m_pThemeProvider(NULL) {
+ m_pAppImp = IFWL_App::Create(NULL);
}
-CFWL_App::~CFWL_App()
-{
- if (m_pThemeProvider) {
- m_pThemeProvider->Finalize();
- delete m_pThemeProvider;
- m_pThemeProvider = NULL;
- }
- m_pAppImp->Release();
+CFWL_App::~CFWL_App() {
+ if (m_pThemeProvider) {
+ m_pThemeProvider->Finalize();
+ delete m_pThemeProvider;
+ m_pThemeProvider = NULL;
+ }
+ m_pAppImp->Release();
}
-FWL_ERR CFWL_App::Initialize()
-{
- m_pThemeProvider = FX_NEW CFWL_Theme;
- m_pThemeProvider->Initialize();
- m_pAppImp->SetThemeProvider((IFWL_ThemeProvider*)m_pThemeProvider);
- return m_pAppImp->Initialize();
+FWL_ERR CFWL_App::Initialize() {
+ m_pThemeProvider = FX_NEW CFWL_Theme;
+ m_pThemeProvider->Initialize();
+ m_pAppImp->SetThemeProvider((IFWL_ThemeProvider*)m_pThemeProvider);
+ return m_pAppImp->Initialize();
}
-CFWL_Theme* CFWL_App::GetTheme()
-{
- return m_pThemeProvider;
+CFWL_Theme* CFWL_App::GetTheme() {
+ return m_pThemeProvider;
}
-FWL_ERR CFWL_App::Exit(int32_t iExitCode )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pAppImp, FWL_ERR_Indefinite);
- return m_pAppImp->Exit(iExitCode);
+FWL_ERR CFWL_App::Exit(int32_t iExitCode) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pAppImp, FWL_ERR_Indefinite);
+ return m_pAppImp->Exit(iExitCode);
}
-IFWL_App* CFWL_App::GetApp()
-{
- return m_pAppImp;
+IFWL_App* CFWL_App::GetApp() {
+ return m_pAppImp;
}
diff --git a/xfa/src/fwl/src/lightwidget/barcode.cpp b/xfa/src/fwl/src/lightwidget/barcode.cpp index 6c770c3b2c..f71a00d2ca 100644 --- a/xfa/src/fwl/src/lightwidget/barcode.cpp +++ b/xfa/src/fwl/src/lightwidget/barcode.cpp @@ -5,53 +5,45 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_Barcode* CFWL_Barcode::Create()
-{
- return FX_NEW CFWL_Barcode;
+CFWL_Barcode* CFWL_Barcode::Create() {
+ return FX_NEW CFWL_Barcode;
}
-FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_pDataProvider = &m_barcodeData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- m_pImp = IFWL_Barcode::Create();
- FWL_ERR ret = ((IFWL_Barcode*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
+FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_pDataProvider = &m_barcodeData;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ m_pImp = IFWL_Barcode::Create();
+ FWL_ERR ret = ((IFWL_Barcode*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
}
-CFWL_Barcode::CFWL_Barcode()
-{
+CFWL_Barcode::CFWL_Barcode() {}
+CFWL_Barcode::~CFWL_Barcode() {}
+void CFWL_Barcode::SetType(BC_TYPE type) {
+ _FWL_RETURN_IF_FAIL(m_pImp);
+ ((IFWL_Barcode*)m_pImp)->SetType(type);
}
-CFWL_Barcode::~CFWL_Barcode()
-{
+FX_BOOL CFWL_Barcode::IsProtectedType() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_Barcode*)m_pImp)->IsProtectedType();
}
-void CFWL_Barcode::SetType(BC_TYPE type)
-{
- _FWL_RETURN_IF_FAIL(m_pImp);
- ((IFWL_Barcode*)m_pImp)->SetType(type);
-}
-FX_BOOL CFWL_Barcode::IsProtectedType()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_Barcode*)m_pImp)->IsProtectedType();
-}
-FWL_ERR CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- return FWL_ERR_Succeeded;
+FWL_ERR CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/lightwidget/caret.cpp b/xfa/src/fwl/src/lightwidget/caret.cpp index a93e5d9dc5..a09ce40ffb 100644 --- a/xfa/src/fwl/src/lightwidget/caret.cpp +++ b/xfa/src/fwl/src/lightwidget/caret.cpp @@ -5,54 +5,44 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_Caret* CFWL_Caret::Create()
-{
- return FX_NEW CFWL_Caret;
-}
-FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- m_pImp = IFWL_Caret::Create();
- FWL_ERR ret = ((IFWL_Caret*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_Caret::ShowCaret(FX_BOOL bFlag)
-{
- return ((IFWL_Caret*)m_pImp)->ShowCaret(bFlag);
-}
-FWL_ERR CFWL_Caret::GetFrequency(FX_DWORD &elapse)
-{
- return ((IFWL_Caret*)m_pImp)->GetFrequency(elapse);
-}
-FWL_ERR CFWL_Caret::SetFrequency(FX_DWORD elapse)
-{
- return ((IFWL_Caret*)m_pImp)->SetFrequency(elapse);
-}
-FWL_ERR CFWL_Caret::SetColor(CFX_Color crFill)
-{
- return ((IFWL_Caret*)m_pImp)->SetColor(crFill);
-}
-CFWL_Caret::CFWL_Caret()
-{
-}
-CFWL_Caret::~CFWL_Caret()
-{
-}
+CFWL_Caret* CFWL_Caret::Create() {
+ return FX_NEW CFWL_Caret;
+}
+FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ m_pImp = IFWL_Caret::Create();
+ FWL_ERR ret = ((IFWL_Caret*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_Caret::ShowCaret(FX_BOOL bFlag) {
+ return ((IFWL_Caret*)m_pImp)->ShowCaret(bFlag);
+}
+FWL_ERR CFWL_Caret::GetFrequency(FX_DWORD& elapse) {
+ return ((IFWL_Caret*)m_pImp)->GetFrequency(elapse);
+}
+FWL_ERR CFWL_Caret::SetFrequency(FX_DWORD elapse) {
+ return ((IFWL_Caret*)m_pImp)->SetFrequency(elapse);
+}
+FWL_ERR CFWL_Caret::SetColor(CFX_Color crFill) {
+ return ((IFWL_Caret*)m_pImp)->SetColor(crFill);
+}
+CFWL_Caret::CFWL_Caret() {}
+CFWL_Caret::~CFWL_Caret() {}
diff --git a/xfa/src/fwl/src/lightwidget/checkbox.cpp b/xfa/src/fwl/src/lightwidget/checkbox.cpp index 5079159d48..79d4886fdf 100644 --- a/xfa/src/fwl/src/lightwidget/checkbox.cpp +++ b/xfa/src/fwl/src/lightwidget/checkbox.cpp @@ -5,71 +5,57 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_CheckBox* CFWL_CheckBox::Create()
-{
- return FX_NEW CFWL_CheckBox;
-}
-FWL_ERR CFWL_CheckBox::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_pDataProvider = &m_checkboxData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- m_pImp = IFWL_CheckBox::Create();
- FWL_ERR ret = ((IFWL_CheckBox*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption)
-{
- m_checkboxData.m_wsCaption = wsCaption;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight)
-{
- m_checkboxData.m_fBoxHeight = fHeight;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_CheckBox::GetCheckState()
-{
- return ((IFWL_CheckBox*)m_pImp)->GetCheckState();
-}
-FWL_ERR CFWL_CheckBox::SetCheckState(int32_t iCheck)
-{
- return ((IFWL_CheckBox*)m_pImp)->SetCheckState(iCheck);
-}
-CFWL_CheckBox::CFWL_CheckBox()
-{
-}
-CFWL_CheckBox::~CFWL_CheckBox()
-{
-}
+CFWL_CheckBox* CFWL_CheckBox::Create() {
+ return FX_NEW CFWL_CheckBox;
+}
+FWL_ERR CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_pDataProvider = &m_checkboxData;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ m_pImp = IFWL_CheckBox::Create();
+ FWL_ERR ret = ((IFWL_CheckBox*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) {
+ m_checkboxData.m_wsCaption = wsCaption;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) {
+ m_checkboxData.m_fBoxHeight = fHeight;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_CheckBox::GetCheckState() {
+ return ((IFWL_CheckBox*)m_pImp)->GetCheckState();
+}
+FWL_ERR CFWL_CheckBox::SetCheckState(int32_t iCheck) {
+ return ((IFWL_CheckBox*)m_pImp)->SetCheckState(iCheck);
+}
+CFWL_CheckBox::CFWL_CheckBox() {}
+CFWL_CheckBox::~CFWL_CheckBox() {}
CFWL_CheckBox::CFWL_CheckBoxDP::CFWL_CheckBoxDP()
- : m_fBoxHeight(16.0f)
- , m_wsCaption(L"Check box")
-{
-}
-FWL_ERR CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget *pWidget)
-{
- return m_fBoxHeight;
+ : m_fBoxHeight(16.0f), m_wsCaption(L"Check box") {}
+FWL_ERR CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsCaption;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) {
+ return m_fBoxHeight;
}
diff --git a/xfa/src/fwl/src/lightwidget/combobox.cpp b/xfa/src/fwl/src/lightwidget/combobox.cpp index 20211caa72..aec2403ae3 100644 --- a/xfa/src/fwl/src/lightwidget/combobox.cpp +++ b/xfa/src/fwl/src/lightwidget/combobox.cpp @@ -5,357 +5,324 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_ComboBox* CFWL_ComboBox::Create()
-{
- return FX_NEW CFWL_ComboBox;
-}
-FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
+CFWL_ComboBox* CFWL_ComboBox::Create() {
+ return FX_NEW CFWL_ComboBox;
+}
+FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_pDataProvider = &m_comboBoxData;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ m_pImp = IFWL_ComboBox::Create();
+ FWL_ERR ret = ((IFWL_ComboBox*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
+ CFWL_ComboBoxItem* pItem = FX_NEW CFWL_ComboBoxItem;
+ pItem->m_wsText = wsText;
+ pItem->m_dwStyles = 0;
+ return m_comboBoxData.m_arrItem.Add(pItem);
+}
+int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText,
+ CFX_DIBitmap* pIcon) {
+ CFWL_ComboBoxItem* pItem = FX_NEW CFWL_ComboBoxItem;
+ pItem->m_wsText = wsText;
+ pItem->m_dwStyles = 0;
+ pItem->m_pDIB = pIcon;
+ return m_comboBoxData.m_arrItem.Add(pItem);
+}
+int32_t CFWL_ComboBox::RemoveAt(int32_t iIndex) {
+ return m_comboBoxData.m_arrItem.RemoveAt(iIndex);
+}
+int32_t CFWL_ComboBox::RemoveAll() {
+ m_comboBoxData.m_arrItem.RemoveAll();
+ return 0;
+}
+int32_t CFWL_ComboBox::CountItems() {
+ return m_comboBoxData.CountItems(GetWidget());
+}
+FWL_ERR CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) {
+ CFWL_ComboBoxItem* pItem =
+ (CFWL_ComboBoxItem*)(m_comboBoxData.GetItem((IFWL_Widget*)this, iIndex));
+ _FWL_RETURN_VALUE_IF_FAIL(pItem, FWL_ERR_Indefinite);
+ wsText = pItem->m_wsText;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ComboBox::GetCurSel() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
+ return ((IFWL_ComboBox*)m_pImp)->GetCurSel();
+}
+FWL_ERR CFWL_ComboBox::SetCurSel(int32_t iSel) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ComboBox*)m_pImp)->SetCurSel(iSel);
+}
+FWL_ERR CFWL_ComboBox::SetEditText(const CFX_WideStringC& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ComboBox*)m_pImp)->SetEditText(wsText);
+}
+int32_t CFWL_ComboBox::GetEditTextLength() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ComboBox*)m_pImp)->GetEditTextLength();
+}
+FWL_ERR CFWL_ComboBox::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ComboBox*)m_pImp)->GetEditText(wsText, nStart, nCount);
+}
+FWL_ERR CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ComboBox*)m_pImp)->SetEditSelRange(nStart, nCount);
+}
+int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ComboBox*)m_pImp)->GetEditSelRange(nIndex, nStart);
+}
+int32_t CFWL_ComboBox::GetEditLimit() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ComboBox*)m_pImp)->GetEditLimit();
+}
+FWL_ERR CFWL_ComboBox::SetEditLimit(int32_t nLimit) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ComboBox*)m_pImp)->SetEditLimit(nLimit);
+}
+FWL_ERR CFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ComboBox*)m_pImp)->EditDoClipboard(iCmd);
+}
+FX_BOOL CFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditRedo(bsRecord);
+}
+FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditUndo(bsRecord);
+}
+FWL_ERR CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
+ m_comboBoxData.m_fMaxListHeight = fMaxHeight;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
+ CFWL_ComboBoxItem* pItem =
+ (CFWL_ComboBoxItem*)(m_comboBoxData.GetItem((IFWL_Widget*)this, iIndex));
+ _FWL_RETURN_VALUE_IF_FAIL(pItem, FWL_ERR_Indefinite);
+ pItem->m_pData = pData;
+ return FWL_ERR_Succeeded;
+}
+void* CFWL_ComboBox::GetItemData(int32_t iIndex) {
+ CFWL_ComboBoxItem* pItem =
+ (CFWL_ComboBoxItem*)(m_comboBoxData.GetItem((IFWL_Widget*)this, iIndex));
+ _FWL_RETURN_VALUE_IF_FAIL(pItem, NULL);
+ return pItem->m_pData;
+}
+FWL_ERR CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) {
+ return ((IFWL_ComboBox*)m_pImp)->GetListBoxt()->SetThemeProvider(pTheme);
+}
+FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() {
+ return ((IFWL_ComboBox*)m_pImp)->AfterFocusShowDropList();
+}
+FWL_ERR CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
+ return ((IFWL_ComboBox*)m_pImp)->OpenDropDownList(bActivate);
+}
+FX_BOOL CFWL_ComboBox::EditCanUndo() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCanUndo();
+}
+FX_BOOL CFWL_ComboBox::EditCanRedo() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCanRedo();
+}
+FX_BOOL CFWL_ComboBox::EditUndo() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditUndo();
+}
+FX_BOOL CFWL_ComboBox::EditRedo() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditRedo();
+}
+FX_BOOL CFWL_ComboBox::EditCanCopy() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCanCopy();
+}
+FX_BOOL CFWL_ComboBox::EditCanCut() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCanCut();
+}
+FX_BOOL CFWL_ComboBox::EditCanSelectAll() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCanSelectAll();
+}
+FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCopy(wsCopy);
+}
+FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditCut(wsCut);
+}
+FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditPaste(wsPaste);
+}
+FX_BOOL CFWL_ComboBox::EditSelectAll() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditSelectAll();
+}
+FX_BOOL CFWL_ComboBox::EditDelete() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditDelete();
+}
+FX_BOOL CFWL_ComboBox::EditDeSelect() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->EditDeSelect();
+}
+FWL_ERR CFWL_ComboBox::GetBBox(CFX_RectF& rect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)->GetBBox(rect);
+}
+FWL_ERR CFWL_ComboBox::EditModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ComboBox*)m_pImp)
+ ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+CFWL_ComboBox::CFWL_ComboBox() {}
+CFWL_ComboBox::~CFWL_ComboBox() {}
+CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP() {
+ m_fItemHeight = 0;
+ m_fMaxListHeight = 0;
+}
+CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {
+ int32_t nCount = m_arrItem.GetSize();
+ for (int32_t i = 0; i < nCount; i++) {
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)m_arrItem[i];
+ if (pItem) {
+ delete pItem;
}
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_pDataProvider = &m_comboBoxData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- m_pImp = IFWL_ComboBox::Create();
- FWL_ERR ret = ((IFWL_ComboBox*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText)
-{
- CFWL_ComboBoxItem *pItem = FX_NEW CFWL_ComboBoxItem;
- pItem->m_wsText = wsText;
- pItem->m_dwStyles = 0;
- return m_comboBoxData.m_arrItem.Add(pItem);
-}
-int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText, CFX_DIBitmap *pIcon)
-{
- CFWL_ComboBoxItem *pItem = FX_NEW CFWL_ComboBoxItem;
- pItem->m_wsText = wsText;
- pItem->m_dwStyles = 0;
- pItem->m_pDIB = pIcon;
- return m_comboBoxData.m_arrItem.Add(pItem);
-}
-int32_t CFWL_ComboBox::RemoveAt(int32_t iIndex)
-{
- return m_comboBoxData.m_arrItem.RemoveAt(iIndex);
-}
-int32_t CFWL_ComboBox::RemoveAll()
-{
- m_comboBoxData.m_arrItem.RemoveAll();
- return 0;
-}
-int32_t CFWL_ComboBox::CountItems()
-{
- return m_comboBoxData.CountItems(GetWidget());
-}
-FWL_ERR CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString &wsText)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)(m_comboBoxData.GetItem((IFWL_Widget *)this, iIndex));
- _FWL_RETURN_VALUE_IF_FAIL(pItem, FWL_ERR_Indefinite);
- wsText = pItem->m_wsText;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ComboBox::GetCurSel()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
- return ((IFWL_ComboBox*)m_pImp)->GetCurSel();
-}
-FWL_ERR CFWL_ComboBox::SetCurSel(int32_t iSel)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ComboBox*)m_pImp)->SetCurSel(iSel);
-}
-FWL_ERR CFWL_ComboBox::SetEditText(const CFX_WideStringC& wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ComboBox*)m_pImp)->SetEditText(wsText);
-}
-int32_t CFWL_ComboBox::GetEditTextLength() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ComboBox*)m_pImp)->GetEditTextLength();
-}
-FWL_ERR CFWL_ComboBox::GetEditText(CFX_WideString &wsText, int32_t nStart, int32_t nCount) const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ComboBox*)m_pImp)->GetEditText(wsText, nStart, nCount);
-}
-FWL_ERR CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ComboBox*)m_pImp)->SetEditSelRange(nStart, nCount);
-}
-int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t &nStart)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ComboBox*)m_pImp)->GetEditSelRange(nIndex, nStart);
-}
-int32_t CFWL_ComboBox::GetEditLimit()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ComboBox*)m_pImp)->GetEditLimit();
-}
-FWL_ERR CFWL_ComboBox::SetEditLimit(int32_t nLimit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ComboBox*)m_pImp)->SetEditLimit(nLimit);
-}
-FWL_ERR CFWL_ComboBox::EditDoClipboard(int32_t iCmd)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ComboBox*)m_pImp)->EditDoClipboard(iCmd);
-}
-FX_BOOL CFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditRedo(bsRecord);
-}
-FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditUndo(bsRecord);
-}
-FWL_ERR CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight)
-{
- m_comboBoxData.m_fMaxListHeight = fMaxHeight;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)(m_comboBoxData.GetItem((IFWL_Widget *)this, iIndex));
- _FWL_RETURN_VALUE_IF_FAIL(pItem, FWL_ERR_Indefinite);
- pItem->m_pData = pData;
- return FWL_ERR_Succeeded;
-}
-void* CFWL_ComboBox::GetItemData(int32_t iIndex)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)(m_comboBoxData.GetItem((IFWL_Widget *)this, iIndex));
- _FWL_RETURN_VALUE_IF_FAIL(pItem, NULL);
- return pItem->m_pData;
-}
-FWL_ERR CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider *pTheme)
-{
- return ((IFWL_ComboBox*)m_pImp)->GetListBoxt()->SetThemeProvider(pTheme);
-}
-FX_BOOL CFWL_ComboBox::AfterFocusShowDropList()
-{
- return ((IFWL_ComboBox*)m_pImp)->AfterFocusShowDropList();
-}
-FWL_ERR CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate)
-{
- return ((IFWL_ComboBox*)m_pImp)->OpenDropDownList(bActivate);
-}
-FX_BOOL CFWL_ComboBox::EditCanUndo()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCanUndo();
-}
-FX_BOOL CFWL_ComboBox::EditCanRedo()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCanRedo();
-}
-FX_BOOL CFWL_ComboBox::EditUndo()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditUndo();
-}
-FX_BOOL CFWL_ComboBox::EditRedo()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditRedo();
-}
-FX_BOOL CFWL_ComboBox::EditCanCopy()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCanCopy();
-}
-FX_BOOL CFWL_ComboBox::EditCanCut()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCanCut();
-}
-FX_BOOL CFWL_ComboBox::EditCanSelectAll()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCanSelectAll();
-}
-FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString &wsCopy)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCopy(wsCopy);
-}
-FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString &wsCut)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditCut(wsCut);
-}
-FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString &wsPaste)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditPaste(wsPaste);
-}
-FX_BOOL CFWL_ComboBox::EditSelectAll()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditSelectAll();
-}
-FX_BOOL CFWL_ComboBox::EditDelete()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditDelete();
-}
-FX_BOOL CFWL_ComboBox::EditDeSelect()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditDeSelect();
-}
-FWL_ERR CFWL_ComboBox::GetBBox(CFX_RectF &rect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->GetBBox(rect);
-}
-FWL_ERR CFWL_ComboBox::EditModifyStylesEx(FX_DWORD dwStylesExAdded,
- FX_DWORD dwStylesExRemoved)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ComboBox*)m_pImp)->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-CFWL_ComboBox::CFWL_ComboBox()
-{
-}
-CFWL_ComboBox::~CFWL_ComboBox()
-{
-}
-CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP()
-{
- m_fItemHeight = 0;
- m_fMaxListHeight = 0;
-}
-CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP()
-{
- int32_t nCount = m_arrItem.GetSize();
- for (int32_t i = 0; i < nCount; i ++) {
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)m_arrItem[i];
- if (pItem) {
- delete pItem;
- }
- }
- m_arrItem.RemoveAll();
-}
-int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget *pWidget)
-{
- return m_arrItem.GetSize();
-}
-FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget *pWidget, int32_t nIndex)
-{
- int32_t iCount = m_arrItem.GetSize();
- if (nIndex >= iCount || nIndex < 0) {
- return NULL;
- }
- return (FWL_HLISTITEM)m_arrItem[nIndex];
-}
-int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- return m_arrItem.Find(hItem);
-}
-FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, int32_t nIndex)
-{
- return m_arrItem.SetAt(nIndex, hItem);
-}
-FX_DWORD CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, 0);
- return ((CFWL_ComboBoxItem*)hItem)->m_dwStyles;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- wsText = ((CFWL_ComboBoxItem*)hItem)->m_wsText;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_RectF& rtItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)hItem;
- rtItem.Set(pItem->m_rtItem.left,
- pItem->m_rtItem.top,
- pItem->m_rtItem.width,
- pItem->m_rtItem.height);
- return FWL_ERR_Succeeded;
-}
-void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)hItem;
- return pItem->m_pData;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_DWORD dwStyle)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- ((CFWL_ComboBoxItem*)hItem)->m_dwStyles = dwStyle;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const FX_WCHAR* pszText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- ((CFWL_ComboBoxItem*)hItem)->m_wsText = pszText;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const CFX_RectF& rtItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- ((CFWL_ComboBoxItem*)hItem)->m_rtItem = rtItem;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget *pWidget)
-{
- return m_fItemHeight;
-}
-CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
- return ((CFWL_ComboBoxItem*)hItem)->m_pDIB;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_RectF& rtCheck)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)hItem;
- rtCheck = pItem->m_rtCheckBox;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const CFX_RectF& rtCheck)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)hItem;
- pItem->m_rtCheckBox = rtCheck;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)hItem;
- return pItem->m_dwCheckState;
-}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_DWORD dwCheckState)
-{
- CFWL_ComboBoxItem *pItem = (CFWL_ComboBoxItem*)hItem;
- pItem->m_dwCheckState = dwCheckState;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget *pWidget)
-{
- return m_fMaxListHeight;
+ }
+ m_arrItem.RemoveAll();
+}
+int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) {
+ return m_arrItem.GetSize();
+}
+FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget,
+ int32_t nIndex) {
+ int32_t iCount = m_arrItem.GetSize();
+ if (nIndex >= iCount || nIndex < 0) {
+ return NULL;
+ }
+ return (FWL_HLISTITEM)m_arrItem[nIndex];
+}
+int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ return m_arrItem.Find(hItem);
+}
+FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ int32_t nIndex) {
+ return m_arrItem.SetAt(nIndex, hItem);
+}
+FX_DWORD CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, 0);
+ return ((CFWL_ComboBoxItem*)hItem)->m_dwStyles;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ wsText = ((CFWL_ComboBoxItem*)hItem)->m_wsText;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)hItem;
+ rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width,
+ pItem->m_rtItem.height);
+ return FWL_ERR_Succeeded;
+}
+void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)hItem;
+ return pItem->m_pData;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ FX_DWORD dwStyle) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ ((CFWL_ComboBoxItem*)hItem)->m_dwStyles = dwStyle;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ ((CFWL_ComboBoxItem*)hItem)->m_wsText = pszText;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ ((CFWL_ComboBoxItem*)hItem)->m_rtItem = rtItem;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
+ return m_fItemHeight;
+}
+CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
+ return ((CFWL_ComboBoxItem*)hItem)->m_pDIB;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) {
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)hItem;
+ rtCheck = pItem->m_rtCheckBox;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect(
+ IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtCheck) {
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)hItem;
+ pItem->m_rtCheckBox = rtCheck;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState(
+ IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)hItem;
+ return pItem->m_dwCheckState;
+}
+FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState(
+ IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ FX_DWORD dwCheckState) {
+ CFWL_ComboBoxItem* pItem = (CFWL_ComboBoxItem*)hItem;
+ pItem->m_dwCheckState = dwCheckState;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) {
+ return m_fMaxListHeight;
}
diff --git a/xfa/src/fwl/src/lightwidget/datetimepicker.cpp b/xfa/src/fwl/src/lightwidget/datetimepicker.cpp index ee64d09d7c..008a22179d 100644 --- a/xfa/src/fwl/src/lightwidget/datetimepicker.cpp +++ b/xfa/src/fwl/src/lightwidget/datetimepicker.cpp @@ -5,152 +5,135 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_DateTimePicker* CFWL_DateTimePicker::Create()
-{
- return FX_NEW CFWL_DateTimePicker;
-}
-FWL_ERR CFWL_DateTimePicker::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_DateTimePickerDP;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_DateTimePicker::Create();
- FWL_ERR ret = ((IFWL_DateTimePicker*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_DateTimePicker::SetToday(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- m_DateTimePickerDP.m_iYear = iYear;
- m_DateTimePickerDP.m_iMonth = iMonth;
- m_DateTimePickerDP.m_iDay = iDay;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_DateTimePicker::CountSelRanges()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->CountSelRanges();
-}
-int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t &nStart)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->GetSelRange(nIndex, nStart);
-}
-FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString &wsText)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->GetEditText(wsText);
-}
-FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->SetEditText(wsText);
-}
-FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t &iYear, int32_t &iMonth, int32_t &iDay)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->GetCurSel(iYear, iMonth, iDay);
-}
-FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->SetCurSel(iYear, iMonth, iDay);
-}
-CFWL_DateTimePicker::CFWL_DateTimePicker()
-{
-}
-CFWL_DateTimePicker::~CFWL_DateTimePicker()
-{
-}
-CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP()
-{
- m_iYear = 2011;
- m_iMonth = 1;
- m_iDay = 1;
-}
-FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- wsCaption = m_wsData;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(IFWL_Widget *pWidget, int32_t &iYear, int32_t &iMonth, int32_t &iDay)
-{
- iYear = m_iYear;
- iMonth = m_iMonth;
- iDay = m_iDay;
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_DateTimePicker::CanUndo()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->CanUndo();
-}
-FX_BOOL CFWL_DateTimePicker::CanRedo()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->CanRedo();
-}
-FX_BOOL CFWL_DateTimePicker::Undo()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->Undo();
-}
-FX_BOOL CFWL_DateTimePicker::Redo()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->Redo();
-}
-FX_BOOL CFWL_DateTimePicker::CanCopy()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->CanCopy();
-}
-FX_BOOL CFWL_DateTimePicker::CanCut()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->CanCut();
-}
-FX_BOOL CFWL_DateTimePicker::CanSelectAll()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->CanSelectAll();
-}
-FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString &wsCopy)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->Copy(wsCopy);
-}
-FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString &wsCut)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->Copy(wsCut);
-}
-FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString &wsPaste)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->Paste(wsPaste);
-}
-FX_BOOL CFWL_DateTimePicker::SelectAll()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->SelectAll();
-}
-FX_BOOL CFWL_DateTimePicker::Delete()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->Delete();
-}
-FX_BOOL CFWL_DateTimePicker::DeSelect()
-{
- return ((IFWL_DateTimePicker*)m_pImp)->DeSelect();
-}
-FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF &rect)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->GetBBox(rect);
-}
-FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->SetEditLimit(nLimit);
-}
-FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- return ((IFWL_DateTimePicker*)m_pImp)->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
+CFWL_DateTimePicker* CFWL_DateTimePicker::Create() {
+ return FX_NEW CFWL_DateTimePicker;
+}
+FWL_ERR CFWL_DateTimePicker::Initialize(
+ const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_pDataProvider = &m_DateTimePickerDP;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_DateTimePicker::Create();
+ FWL_ERR ret = ((IFWL_DateTimePicker*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_DateTimePicker::SetToday(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ m_DateTimePickerDP.m_iYear = iYear;
+ m_DateTimePickerDP.m_iMonth = iMonth;
+ m_DateTimePickerDP.m_iDay = iDay;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_DateTimePicker::CountSelRanges() {
+ return ((IFWL_DateTimePicker*)m_pImp)->CountSelRanges();
+}
+int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ return ((IFWL_DateTimePicker*)m_pImp)->GetSelRange(nIndex, nStart);
+}
+FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) {
+ return ((IFWL_DateTimePicker*)m_pImp)->GetEditText(wsText);
+}
+FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) {
+ return ((IFWL_DateTimePicker*)m_pImp)->SetEditText(wsText);
+}
+FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ return ((IFWL_DateTimePicker*)m_pImp)->GetCurSel(iYear, iMonth, iDay);
+}
+FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ return ((IFWL_DateTimePicker*)m_pImp)->SetCurSel(iYear, iMonth, iDay);
+}
+CFWL_DateTimePicker::CFWL_DateTimePicker() {}
+CFWL_DateTimePicker::~CFWL_DateTimePicker() {}
+CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() {
+ m_iYear = 2011;
+ m_iMonth = 1;
+ m_iDay = 1;
+}
+FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsData;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(
+ IFWL_Widget* pWidget,
+ int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ iYear = m_iYear;
+ iMonth = m_iMonth;
+ iDay = m_iDay;
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_DateTimePicker::CanUndo() {
+ return ((IFWL_DateTimePicker*)m_pImp)->CanUndo();
+}
+FX_BOOL CFWL_DateTimePicker::CanRedo() {
+ return ((IFWL_DateTimePicker*)m_pImp)->CanRedo();
+}
+FX_BOOL CFWL_DateTimePicker::Undo() {
+ return ((IFWL_DateTimePicker*)m_pImp)->Undo();
+}
+FX_BOOL CFWL_DateTimePicker::Redo() {
+ return ((IFWL_DateTimePicker*)m_pImp)->Redo();
+}
+FX_BOOL CFWL_DateTimePicker::CanCopy() {
+ return ((IFWL_DateTimePicker*)m_pImp)->CanCopy();
+}
+FX_BOOL CFWL_DateTimePicker::CanCut() {
+ return ((IFWL_DateTimePicker*)m_pImp)->CanCut();
+}
+FX_BOOL CFWL_DateTimePicker::CanSelectAll() {
+ return ((IFWL_DateTimePicker*)m_pImp)->CanSelectAll();
+}
+FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) {
+ return ((IFWL_DateTimePicker*)m_pImp)->Copy(wsCopy);
+}
+FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) {
+ return ((IFWL_DateTimePicker*)m_pImp)->Copy(wsCut);
+}
+FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) {
+ return ((IFWL_DateTimePicker*)m_pImp)->Paste(wsPaste);
+}
+FX_BOOL CFWL_DateTimePicker::SelectAll() {
+ return ((IFWL_DateTimePicker*)m_pImp)->SelectAll();
+}
+FX_BOOL CFWL_DateTimePicker::Delete() {
+ return ((IFWL_DateTimePicker*)m_pImp)->Delete();
+}
+FX_BOOL CFWL_DateTimePicker::DeSelect() {
+ return ((IFWL_DateTimePicker*)m_pImp)->DeSelect();
+}
+FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
+ return ((IFWL_DateTimePicker*)m_pImp)->GetBBox(rect);
+}
+FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
+ return ((IFWL_DateTimePicker*)m_pImp)->SetEditLimit(nLimit);
+}
+FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ return ((IFWL_DateTimePicker*)m_pImp)
+ ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
diff --git a/xfa/src/fwl/src/lightwidget/edit.cpp b/xfa/src/fwl/src/lightwidget/edit.cpp index 310e68ba2f..8447d1494e 100644 --- a/xfa/src/fwl/src/lightwidget/edit.cpp +++ b/xfa/src/fwl/src/lightwidget/edit.cpp @@ -5,222 +5,187 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_Edit* CFWL_Edit::Create()
-{
- return FX_NEW CFWL_Edit;
-}
-FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_Edit::Create();
- FWL_ERR ret = ((IFWL_Edit*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_Edit::SetText(const CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetText(wsText);
-}
-int32_t CFWL_Edit::GetTextLength() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_Edit*)m_pImp)->GetTextLength();
-}
-FWL_ERR CFWL_Edit::GetText(CFX_WideString &wsText, int32_t nStart, int32_t nCount) const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->GetText(wsText, nStart, nCount);
-}
-FWL_ERR CFWL_Edit::ClearText()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->ClearText();
-}
-int32_t CFWL_Edit::GetCaretPos() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
- return ((IFWL_Edit*)m_pImp)->GetCaretPos();
-}
-int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
- return ((IFWL_Edit*)m_pImp)->SetCaretPos(nIndex, bBefore);
-}
-FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- ((IFWL_Edit*)m_pImp)->AddSelRange(nStart, nCount);
- int32_t pos = 0;
- int32_t sum = ((IFWL_Edit*)m_pImp)->GetTextLength();
- if (nCount == -1) {
- pos = sum;
- } else {
- pos = nStart + nCount;
- }
- return ((IFWL_Edit*)m_pImp)->SetCaretPos(pos);
-}
-int32_t CFWL_Edit::CountSelRanges()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_Edit*)m_pImp)->CountSelRanges();
-}
-int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t &nStart)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_Edit*)m_pImp)->GetSelRange(nIndex, nStart);
-}
-FWL_ERR CFWL_Edit::ClearSelections()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->ClearSelections();
-}
-int32_t CFWL_Edit::GetLimit()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
- return ((IFWL_Edit*)m_pImp)->GetLimit();
-}
-FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetLimit(nLimit);
-}
-FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetAliasChar(wAlias);
-}
-FWL_ERR CFWL_Edit::SetFormatString(const CFX_WideString &wsFormat)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetFormatString(wsFormat);
-}
-FWL_ERR CFWL_Edit::Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->Insert(nStart, lpText, nLen);
-}
-FWL_ERR CFWL_Edit::DeleteSelections()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->DeleteSelections();
-}
-FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->DeleteRange(nStart, nCount);
-}
-FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC &wsReplace)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->ReplaceSelections(wsReplace);
-}
-FWL_ERR CFWL_Edit::Replace(int32_t nStart, int32_t nLen, const CFX_WideStringC &wsReplace)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->Replace(nStart, nLen, wsReplace);
-}
-FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->DoClipboard(iCmd);
-}
-FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_Edit*)m_pImp)->Redo(bsRecord);
-}
-FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_Edit*)m_pImp)->Undo(bsRecord);
-}
-FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetTabWidth(fTabWidth, bEquidistant);
-}
-FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax)
-{
- if (iMin > iMax) {
- return FWL_ERR_Parameter_Invalid;
- }
- return ((IFWL_Edit*)m_pImp)->SetNumberRange(iMin, iMax);
-}
-FWL_ERR CFWL_Edit::SetBackColor(FX_DWORD dwColor)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetBackColor(dwColor);
-}
-FWL_ERR CFWL_Edit::SetFont(const CFX_WideString &wsFont, FX_FLOAT fSize)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_Edit*)m_pImp)->SetFont(wsFont, fSize);
-}
-FX_BOOL CFWL_Edit::CanUndo()
-{
- return ((IFWL_Edit*)m_pImp)->CanUndo();
-}
-FX_BOOL CFWL_Edit::CanRedo()
-{
- return ((IFWL_Edit*)m_pImp)->CanRedo();
-}
-FX_BOOL CFWL_Edit::Undo()
-{
- return ((IFWL_Edit*)m_pImp)->Undo();
-}
-FX_BOOL CFWL_Edit::Redo()
-{
- return ((IFWL_Edit*)m_pImp)->Undo();
-}
-FX_BOOL CFWL_Edit::Copy(CFX_WideString &wsCopy)
-{
- return ((IFWL_Edit*)m_pImp)->Copy(wsCopy);
-}
-FX_BOOL CFWL_Edit::Cut(CFX_WideString &wsCut)
-{
- return ((IFWL_Edit*)m_pImp)->Cut(wsCut);
-}
-FX_BOOL CFWL_Edit::Paste(const CFX_WideString &wsPaste)
-{
- return ((IFWL_Edit*)m_pImp)->Paste(wsPaste);
-}
-FX_BOOL CFWL_Edit::Delete()
-{
- return ((IFWL_Edit*)m_pImp)->Delete();
-}
-void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset)
-{
- return ((IFWL_Edit*)m_pImp)->SetScrollOffset(fScrollOffset);
-}
-FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray &sSuggest)
-{
- return ((IFWL_Edit*)m_pImp)->GetSuggestWords(pointf, sSuggest);
-}
-FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, const CFX_ByteStringC& bsReplace)
-{
- return ((IFWL_Edit*)m_pImp)->ReplaceSpellCheckWord(pointf, bsReplace);
-}
-CFWL_Edit::CFWL_Edit()
-{
-}
-CFWL_Edit::~CFWL_Edit()
-{
+CFWL_Edit* CFWL_Edit::Create() {
+ return FX_NEW CFWL_Edit;
+}
+FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_Edit::Create();
+ FWL_ERR ret = ((IFWL_Edit*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetText(wsText);
+}
+int32_t CFWL_Edit::GetTextLength() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_Edit*)m_pImp)->GetTextLength();
+}
+FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->GetText(wsText, nStart, nCount);
+}
+FWL_ERR CFWL_Edit::ClearText() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->ClearText();
+}
+int32_t CFWL_Edit::GetCaretPos() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
+ return ((IFWL_Edit*)m_pImp)->GetCaretPos();
+}
+int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
+ return ((IFWL_Edit*)m_pImp)->SetCaretPos(nIndex, bBefore);
+}
+FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ ((IFWL_Edit*)m_pImp)->AddSelRange(nStart, nCount);
+ int32_t pos = 0;
+ int32_t sum = ((IFWL_Edit*)m_pImp)->GetTextLength();
+ if (nCount == -1) {
+ pos = sum;
+ } else {
+ pos = nStart + nCount;
+ }
+ return ((IFWL_Edit*)m_pImp)->SetCaretPos(pos);
+}
+int32_t CFWL_Edit::CountSelRanges() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_Edit*)m_pImp)->CountSelRanges();
+}
+int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_Edit*)m_pImp)->GetSelRange(nIndex, nStart);
+}
+FWL_ERR CFWL_Edit::ClearSelections() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->ClearSelections();
+}
+int32_t CFWL_Edit::GetLimit() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
+ return ((IFWL_Edit*)m_pImp)->GetLimit();
+}
+FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetLimit(nLimit);
+}
+FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetAliasChar(wAlias);
+}
+FWL_ERR CFWL_Edit::SetFormatString(const CFX_WideString& wsFormat) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetFormatString(wsFormat);
+}
+FWL_ERR CFWL_Edit::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->Insert(nStart, lpText, nLen);
+}
+FWL_ERR CFWL_Edit::DeleteSelections() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->DeleteSelections();
+}
+FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->DeleteRange(nStart, nCount);
+}
+FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->ReplaceSelections(wsReplace);
+}
+FWL_ERR CFWL_Edit::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->Replace(nStart, nLen, wsReplace);
+}
+FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->DoClipboard(iCmd);
+}
+FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_Edit*)m_pImp)->Redo(bsRecord);
+}
+FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_Edit*)m_pImp)->Undo(bsRecord);
+}
+FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetTabWidth(fTabWidth, bEquidistant);
+}
+FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
+ if (iMin > iMax) {
+ return FWL_ERR_Parameter_Invalid;
+ }
+ return ((IFWL_Edit*)m_pImp)->SetNumberRange(iMin, iMax);
+}
+FWL_ERR CFWL_Edit::SetBackColor(FX_DWORD dwColor) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetBackColor(dwColor);
+}
+FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_Edit*)m_pImp)->SetFont(wsFont, fSize);
+}
+FX_BOOL CFWL_Edit::CanUndo() {
+ return ((IFWL_Edit*)m_pImp)->CanUndo();
+}
+FX_BOOL CFWL_Edit::CanRedo() {
+ return ((IFWL_Edit*)m_pImp)->CanRedo();
+}
+FX_BOOL CFWL_Edit::Undo() {
+ return ((IFWL_Edit*)m_pImp)->Undo();
+}
+FX_BOOL CFWL_Edit::Redo() {
+ return ((IFWL_Edit*)m_pImp)->Undo();
}
+FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) {
+ return ((IFWL_Edit*)m_pImp)->Copy(wsCopy);
+}
+FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) {
+ return ((IFWL_Edit*)m_pImp)->Cut(wsCut);
+}
+FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) {
+ return ((IFWL_Edit*)m_pImp)->Paste(wsPaste);
+}
+FX_BOOL CFWL_Edit::Delete() {
+ return ((IFWL_Edit*)m_pImp)->Delete();
+}
+void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
+ return ((IFWL_Edit*)m_pImp)->SetScrollOffset(fScrollOffset);
+}
+FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf,
+ CFX_ByteStringArray& sSuggest) {
+ return ((IFWL_Edit*)m_pImp)->GetSuggestWords(pointf, sSuggest);
+}
+FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
+ const CFX_ByteStringC& bsReplace) {
+ return ((IFWL_Edit*)m_pImp)->ReplaceSpellCheckWord(pointf, bsReplace);
+}
+CFWL_Edit::CFWL_Edit() {}
+CFWL_Edit::~CFWL_Edit() {}
diff --git a/xfa/src/fwl/src/lightwidget/listbox.cpp b/xfa/src/fwl/src/lightwidget/listbox.cpp index c96e368ca4..2bfd10c173 100644 --- a/xfa/src/fwl/src/lightwidget/listbox.cpp +++ b/xfa/src/fwl/src/lightwidget/listbox.cpp @@ -5,323 +5,307 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_ListBox* CFWL_ListBox::Create()
-{
- return FX_NEW CFWL_ListBox;
-}
-FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
+CFWL_ListBox* CFWL_ListBox::Create() {
+ return FX_NEW CFWL_ListBox;
+}
+FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_pDataProvider = &m_ListBoxDP;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_ListBox::Create();
+ FWL_ERR ret = ((IFWL_ListBox*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) {
+ ((CFWL_ListItem*)hItem)->m_pDIB = pDIB;
+ return FWL_ERR_Succeeded;
+}
+FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd,
+ FX_BOOL bSelect) {
+ CFWL_ListItem* pItem = FX_NEW CFWL_ListItem;
+ pItem->m_dwStates = 0;
+ pItem->m_wsText = wsAdd;
+ pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0;
+ m_ListBoxDP.m_arrItem.Add(pItem);
+ return (FWL_HLISTITEM)pItem;
+}
+FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) {
+ int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
+ if (nIndex < 0 || nIndex >= m_ListBoxDP.m_arrItem.GetSize()) {
+ return FALSE;
+ }
+ CFWL_ListItem* pDelItem =
+ (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, nIndex);
+ int32_t iCount = m_ListBoxDP.CountItems((IFWL_ListBox*)this);
+ int32_t iSel = nIndex + 1;
+ if (iSel >= iCount) {
+ iSel = nIndex - 1;
+ if (iSel < 0) {
+ iSel = -1;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_ListBoxDP;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (iSel >= 0) {
+ CFWL_ListItem* pSel =
+ (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, iSel);
+ pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected;
+ }
+ m_ListBoxDP.m_arrItem.RemoveAt(nIndex);
+ delete pDelItem;
+ return TRUE;
+}
+FX_BOOL CFWL_ListBox::DeleteAll() {
+ int32_t iCount = m_ListBoxDP.CountItems((IFWL_ListBox*)this);
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_ListItem* pItem =
+ (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, i);
+ delete pItem;
+ }
+ m_ListBoxDP.m_arrItem.RemoveAll();
+ return TRUE;
+}
+int32_t CFWL_ListBox::CountSelItems() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ListBox*)m_pImp)->CountSelItems();
+}
+FWL_HLISTITEM CFWL_ListBox::GetSelItem(int32_t nIndexSel) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
+ return ((IFWL_ListBox*)m_pImp)->GetSelItem(nIndexSel);
+}
+int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ListBox*)m_pImp)->GetSelIndex(nIndex);
+}
+FWL_ERR CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ListBox*)m_pImp)->SetSelItem(hItem, bSelect);
+}
+FWL_ERR CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ListBox*)m_pImp)->GetItemText(hItem, wsText);
+}
+FWL_ERR CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ListBox*)m_pImp)->GetScrollPos(fPos, bVert);
+}
+FWL_ERR CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) {
+ m_ListBoxDP.m_fItemHeight = fItemHeight;
+ return FWL_ERR_Succeeded;
+}
+FWL_HLISTITEM CFWL_ListBox::GetFocusItem() {
+ for (int32_t i = 0; i < m_ListBoxDP.m_arrItem.GetSize(); i++) {
+ CFWL_ListItem* hItem = (CFWL_ListItem*)(m_ListBoxDP.m_arrItem[i]);
+ if (hItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) {
+ return (FWL_HLISTITEM)hItem;
}
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_ListBox::Create();
- FWL_ERR ret = ((IFWL_ListBox*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_ListBox::AddDIBitmap(CFX_DIBitmap *pDIB, FWL_HLISTITEM hItem)
-{
- ((CFWL_ListItem*)hItem)->m_pDIB = pDIB;
- return FWL_ERR_Succeeded;
-}
-FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, FX_BOOL bSelect)
-{
- CFWL_ListItem * pItem = FX_NEW CFWL_ListItem;
- pItem->m_dwStates = 0;
- pItem->m_wsText = wsAdd;
- pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0;
- m_ListBoxDP.m_arrItem.Add(pItem);
- return (FWL_HLISTITEM)pItem;
-}
-FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem)
-{
- int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
- if (nIndex < 0 || nIndex >= m_ListBoxDP.m_arrItem.GetSize()) {
- return FALSE;
- }
- CFWL_ListItem *pDelItem = (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, nIndex);
- int32_t iCount = m_ListBoxDP.CountItems((IFWL_ListBox*)this);
- int32_t iSel = nIndex + 1;
- if (iSel >= iCount) {
- iSel = nIndex - 1;
- if (iSel < 0) {
- iSel = -1;
- }
- }
- if (iSel >= 0) {
- CFWL_ListItem *pSel = (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, iSel);
- pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected;
+ }
+ return NULL;
+}
+FWL_ERR CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) {
+ int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
+ ((CFWL_ListItem*)(m_ListBoxDP.m_arrItem[nIndex]))->m_dwStates |=
+ FWL_ITEMSTATE_LTB_Focused;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR* CFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) {
+ return ((IFWL_ListBox*)m_pImp)->Sort(pCom);
+}
+int32_t CFWL_ListBox::CountItems() {
+ return m_ListBoxDP.m_arrItem.GetSize();
+}
+FWL_HLISTITEM CFWL_ListBox::GetItem(int32_t nIndex) {
+ int32_t nCount = m_ListBoxDP.m_arrItem.GetSize();
+ if (nIndex > nCount - 1 && nIndex < 0) {
+ return NULL;
+ }
+ return (FWL_HLISTITEM)m_ListBoxDP.m_arrItem[nIndex];
+}
+FWL_ERR CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem,
+ const CFX_WideStringC& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ pItem->m_wsText = wsText;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ wsText = pItem->m_wsText;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ pItem->m_pData = pData;
+ return FWL_ERR_Succeeded;
+}
+void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ return pItem->m_pData;
+}
+FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
+ CFX_RectF rtClient;
+ m_pImp->GetClientRect(rtClient);
+ fx -= rtClient.left;
+ fy -= rtClient.top;
+ FX_FLOAT fPosX = 0;
+ FX_FLOAT fPosY = 0;
+ ((IFWL_ListBox*)m_pImp)->GetScrollPos(fx);
+ ((IFWL_ListBox*)m_pImp)->GetScrollPos(fy, FALSE);
+ int32_t nCount = m_ListBoxDP.CountItems(NULL);
+ for (int32_t i = 0; i < nCount; i++) {
+ FWL_HLISTITEM hItem = m_ListBoxDP.GetItem(NULL, i);
+ if (!hItem) {
+ continue;
}
- m_ListBoxDP.m_arrItem.RemoveAt(nIndex);
- delete pDelItem;
- return TRUE;
-}
-FX_BOOL CFWL_ListBox::DeleteAll()
-{
- int32_t iCount = m_ListBoxDP.CountItems((IFWL_ListBox*)this);
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_ListItem *pItem = (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, i);
- delete pItem;
+ CFX_RectF rtItem;
+ m_ListBoxDP.GetItemRect(NULL, hItem, rtItem);
+ rtItem.Offset(-fPosX, -fPosY);
+ if (rtItem.Contains(fx, fy)) {
+ return hItem;
}
- m_ListBoxDP.m_arrItem.RemoveAll();
- return TRUE;
-}
-int32_t CFWL_ListBox::CountSelItems()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ListBox*)m_pImp)->CountSelItems();
-}
-FWL_HLISTITEM CFWL_ListBox::GetSelItem(int32_t nIndexSel)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
- return ((IFWL_ListBox*)m_pImp)->GetSelItem(nIndexSel);
-}
-int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ListBox*)m_pImp)->GetSelIndex(nIndex);
-}
-FWL_ERR CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ListBox*)m_pImp)->SetSelItem(hItem, bSelect);
-}
-FWL_ERR CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ListBox*)m_pImp)->GetItemText(hItem, wsText);
-}
-FWL_ERR CFWL_ListBox::GetScrollPos(FX_FLOAT &fPos, FX_BOOL bVert)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ListBox*)m_pImp)->GetScrollPos(fPos, bVert);
-}
-FWL_ERR CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight)
-{
- m_ListBoxDP.m_fItemHeight = fItemHeight;
- return FWL_ERR_Succeeded;
-}
-FWL_HLISTITEM CFWL_ListBox::GetFocusItem()
-{
- for (int32_t i = 0; i < m_ListBoxDP.m_arrItem.GetSize(); i++) {
- CFWL_ListItem * hItem = (CFWL_ListItem *)(m_ListBoxDP.m_arrItem[i]);
- if (hItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) {
- return (FWL_HLISTITEM)hItem;
- }
+ }
+ return NULL;
+}
+FX_DWORD CFWL_ListBox::GetItemStates(FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, 0);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ return pItem->m_dwStates | pItem->m_dwCheckState;
+}
+CFWL_ListBox::CFWL_ListBox() {}
+CFWL_ListBox::~CFWL_ListBox() {}
+CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {}
+CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {
+ int32_t nCount = m_arrItem.GetSize();
+ for (int32_t i = 0; i < nCount; i++) {
+ CFWL_ListItem* pItem = (CFWL_ListItem*)m_arrItem[i];
+ if (pItem != NULL) {
+ delete pItem;
}
- return NULL;
+ }
+ m_arrItem.RemoveAll();
}
-FWL_ERR CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem)
-{
- int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
- ((CFWL_ListItem *)(m_ListBoxDP.m_arrItem[nIndex]))->m_dwStates |= FWL_ITEMSTATE_LTB_Focused;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR* CFWL_ListBox::Sort(IFWL_ListBoxCompare *pCom)
-{
- return ((IFWL_ListBox*)m_pImp)->Sort(pCom);
-}
-int32_t CFWL_ListBox::CountItems()
-{
- return m_ListBoxDP.m_arrItem.GetSize();
-}
-FWL_HLISTITEM CFWL_ListBox::GetItem(int32_t nIndex)
-{
- int32_t nCount = m_ListBoxDP.m_arrItem.GetSize();
- if (nIndex > nCount - 1 && nIndex < 0) {
- return NULL;
- }
- return (FWL_HLISTITEM)m_ListBoxDP.m_arrItem[nIndex];
-}
-FWL_ERR CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- pItem->m_wsText = wsText;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem, CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- wsText = pItem->m_wsText;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- pItem->m_pData = pData;
- return FWL_ERR_Succeeded;
-}
-void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- return pItem->m_pData;
-}
-FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy)
-{
- CFX_RectF rtClient;
- m_pImp->GetClientRect(rtClient);
- fx -= rtClient.left;
- fy -= rtClient.top;
- FX_FLOAT fPosX = 0;
- FX_FLOAT fPosY = 0;
- ((IFWL_ListBox*)m_pImp)->GetScrollPos(fx);
- ((IFWL_ListBox*)m_pImp)->GetScrollPos(fy, FALSE);
- int32_t nCount = m_ListBoxDP.CountItems(NULL);
- for (int32_t i = 0; i < nCount; i ++) {
- FWL_HLISTITEM hItem = m_ListBoxDP.GetItem(NULL, i);
- if (!hItem) {
- continue;
- }
- CFX_RectF rtItem;
- m_ListBoxDP.GetItemRect(NULL, hItem, rtItem);
- rtItem.Offset(-fPosX, -fPosY);
- if (rtItem.Contains(fx, fy)) {
- return hItem;
- }
- }
- return NULL;
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsData;
+ return FWL_ERR_Succeeded;
}
-FX_DWORD CFWL_ListBox::GetItemStates(FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, 0);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- return pItem->m_dwStates | pItem->m_dwCheckState;
-}
-CFWL_ListBox::CFWL_ListBox()
-{
-}
-CFWL_ListBox::~CFWL_ListBox()
-{
-}
-CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP()
-{
-}
-CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP()
-{
- int32_t nCount = m_arrItem.GetSize();
- for (int32_t i = 0; i < nCount; i ++) {
- CFWL_ListItem *pItem = (CFWL_ListItem*)m_arrItem[i];
- if (pItem != NULL) {
- delete pItem;
- }
- }
- m_arrItem.RemoveAll();
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- wsCaption = m_wsData;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(IFWL_Widget *pWidget)
-{
- return m_arrItem.GetSize();
-}
-FWL_HLISTITEM CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget *pWidget, int32_t nIndex)
-{
- if (nIndex >= m_arrItem.GetSize() || nIndex < 0) {
- return NULL;
- } else {
- return (FWL_HLISTITEM)m_arrItem[nIndex];
- }
+int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(IFWL_Widget* pWidget) {
+ return m_arrItem.GetSize();
}
-int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- return m_arrItem.Find(hItem);
-}
-FX_BOOL CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, int32_t nIndex)
-{
- return m_arrItem.SetAt(nIndex, hItem);
-}
-FX_DWORD CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, -1);
- return ((CFWL_ListItem*)hItem)->m_dwStates;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_WideString &wsText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- wsText = ((CFWL_ListItem*)hItem)->m_wsText;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_RectF &rtItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- rtItem = pItem->m_rtItem;
- return FWL_ERR_Succeeded;
-}
-void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- return pItem->m_pData;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_DWORD dwStyle)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- ((CFWL_ListItem*)hItem)->m_dwStates = dwStyle;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const FX_WCHAR* pszText)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- ((CFWL_ListItem*)hItem)->m_wsText = pszText;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const CFX_RectF &rtItem)
-{
- _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
- ((CFWL_ListItem*)hItem)->m_rtItem = rtItem;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget *pWidget)
-{
- return m_fItemHeight;
-}
-CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- return ((CFWL_ListItem*)hItem)->m_pDIB;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_RectF& rtCheck)
-{
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- rtCheck = pItem->m_rtCheckBox;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const CFX_RectF& rtCheck)
-{
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- pItem->m_rtCheckBox = rtCheck;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget *pWidget, FWL_HLISTITEM hItem)
-{
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- return pItem->m_dwCheckState;
-}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_DWORD dwCheckState)
-{
- CFWL_ListItem *pItem = (CFWL_ListItem*)hItem;
- pItem->m_dwCheckState = dwCheckState;
- return FWL_ERR_Succeeded;
+FWL_HLISTITEM CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget* pWidget,
+ int32_t nIndex) {
+ if (nIndex >= m_arrItem.GetSize() || nIndex < 0) {
+ return NULL;
+ } else {
+ return (FWL_HLISTITEM)m_arrItem[nIndex];
+ }
+}
+int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ return m_arrItem.Find(hItem);
+}
+FX_BOOL CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ int32_t nIndex) {
+ return m_arrItem.SetAt(nIndex, hItem);
+}
+FX_DWORD CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, -1);
+ return ((CFWL_ListItem*)hItem)->m_dwStates;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ wsText = ((CFWL_ListItem*)hItem)->m_wsText;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ rtItem = pItem->m_rtItem;
+ return FWL_ERR_Succeeded;
+}
+void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, NULL);
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ return pItem->m_pData;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ FX_DWORD dwStyle) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ ((CFWL_ListItem*)hItem)->m_dwStates = dwStyle;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ ((CFWL_ListItem*)hItem)->m_wsText = pszText;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtItem) {
+ _FWL_RETURN_VALUE_IF_FAIL(hItem, FWL_ERR_Indefinite);
+ ((CFWL_ListItem*)hItem)->m_rtItem = rtItem;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
+ return m_fItemHeight;
+}
+CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ return ((CFWL_ListItem*)hItem)->m_pDIB;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) {
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ rtCheck = pItem->m_rtCheckBox;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect(
+ IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtCheck) {
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ pItem->m_rtCheckBox = rtCheck;
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem) {
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ return pItem->m_dwCheckState;
+}
+FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ FX_DWORD dwCheckState) {
+ CFWL_ListItem* pItem = (CFWL_ListItem*)hItem;
+ pItem->m_dwCheckState = dwCheckState;
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/lightwidget/picturebox.cpp b/xfa/src/fwl/src/lightwidget/picturebox.cpp index 619a473c21..dd7fe16eef 100644 --- a/xfa/src/fwl/src/lightwidget/picturebox.cpp +++ b/xfa/src/fwl/src/lightwidget/picturebox.cpp @@ -5,140 +5,121 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_PictureBox* CFWL_PictureBox::Create()
-{
- return FX_NEW CFWL_PictureBox;
-}
-FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_PictureBoxDP;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_PictureBox::Create();
- FWL_ERR ret = ((IFWL_PictureBox*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-CFX_DIBitmap* CFWL_PictureBox::GetPicture()
-{
- return m_PictureBoxDP.m_pBitmap;
-}
-FWL_ERR CFWL_PictureBox::SetPicture(CFX_DIBitmap *pBitmap)
-{
- m_PictureBoxDP.m_pBitmap = pBitmap;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_PictureBox::GetRotation()
-{
- return m_PictureBoxDP.m_fRotation;
-}
-FWL_ERR CFWL_PictureBox::SetRotation(FX_FLOAT fRotation)
-{
- m_PictureBoxDP.m_fRotation = fRotation;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_PictureBox::GetFlipMode()
-{
- return m_PictureBoxDP.GetFlipMode((IFWL_Widget*)this);
-}
-FWL_ERR CFWL_PictureBox::SetFlipMode(int32_t iFlipMode)
-{
- m_PictureBoxDP.m_iFlipMode = iFlipMode;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_PictureBox::GetOpacity()
-{
- return m_PictureBoxDP.GetOpacity((IFWL_Widget*)this);
-}
-FWL_ERR CFWL_PictureBox::SetOpacity(int32_t iOpacity)
-{
- m_PictureBoxDP.m_iOpacity = iOpacity;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PictureBox::GetScale(FX_FLOAT &fScaleX, FX_FLOAT &fScaleY)
-{
- CFX_Matrix matrix;
- m_PictureBoxDP.GetMatrix((IFWL_Widget*)this, matrix);
- matrix.Scale(fScaleX, fScaleY);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY)
-{
- m_PictureBoxDP.m_fScaleX = fScaleX;
- m_PictureBoxDP.m_fScaleY = fScaleY;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PictureBox::GetOffset(FX_FLOAT &fx, FX_FLOAT &fy)
-{
- CFX_Matrix matrix;
- m_PictureBoxDP.GetMatrix((IFWL_Widget*)this, matrix);
- fx = matrix.e;
- fy = matrix.f;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy)
-{
- m_PictureBoxDP.m_fOffSetX = fx;
- m_PictureBoxDP.m_fOffSetY = fy;
- return FWL_ERR_Succeeded;
-}
-CFWL_PictureBox::CFWL_PictureBox()
-{
-}
-CFWL_PictureBox::~CFWL_PictureBox()
-{
-}
-FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- return FWL_ERR_Succeeded;
-}
-CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture(IFWL_Widget *pWidget)
-{
- return m_pBitmap;
-}
-CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetErrorPicture(IFWL_Widget *pWidget)
-{
- return m_pBitmap;
-}
-CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetInitialPicture(IFWL_Widget *pWidget)
-{
- return m_pBitmap;
-}
-int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget *pWidget)
-{
- return m_iOpacity;
-}
-FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget *pWidget, CFX_Matrix &matrix)
-{
- CFX_RectF rect;
- pWidget->GetClientRect(rect);
- FX_FLOAT fLen = rect.width / 2;
- FX_FLOAT fWid = rect.height / 2;
- matrix.Reset();
- matrix.Translate(-fLen, -fWid);
- matrix.Rotate(m_fRotation);
- matrix.Translate(fLen, fWid);
- matrix.Scale(m_fScaleX, m_fScaleY);
- matrix.Translate(m_fOffSetX, m_fOffSetY);
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget *pWidget)
-{
- return m_iFlipMode;
+CFWL_PictureBox* CFWL_PictureBox::Create() {
+ return FX_NEW CFWL_PictureBox;
+}
+FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_pDataProvider = &m_PictureBoxDP;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_PictureBox::Create();
+ FWL_ERR ret = ((IFWL_PictureBox*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+CFX_DIBitmap* CFWL_PictureBox::GetPicture() {
+ return m_PictureBoxDP.m_pBitmap;
+}
+FWL_ERR CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) {
+ m_PictureBoxDP.m_pBitmap = pBitmap;
+ return FWL_ERR_Succeeded;
+}
+FX_FLOAT CFWL_PictureBox::GetRotation() {
+ return m_PictureBoxDP.m_fRotation;
+}
+FWL_ERR CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) {
+ m_PictureBoxDP.m_fRotation = fRotation;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_PictureBox::GetFlipMode() {
+ return m_PictureBoxDP.GetFlipMode((IFWL_Widget*)this);
+}
+FWL_ERR CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) {
+ m_PictureBoxDP.m_iFlipMode = iFlipMode;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_PictureBox::GetOpacity() {
+ return m_PictureBoxDP.GetOpacity((IFWL_Widget*)this);
+}
+FWL_ERR CFWL_PictureBox::SetOpacity(int32_t iOpacity) {
+ m_PictureBoxDP.m_iOpacity = iOpacity;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) {
+ CFX_Matrix matrix;
+ m_PictureBoxDP.GetMatrix((IFWL_Widget*)this, matrix);
+ matrix.Scale(fScaleX, fScaleY);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) {
+ m_PictureBoxDP.m_fScaleX = fScaleX;
+ m_PictureBoxDP.m_fScaleY = fScaleY;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) {
+ CFX_Matrix matrix;
+ m_PictureBoxDP.GetMatrix((IFWL_Widget*)this, matrix);
+ fx = matrix.e;
+ fy = matrix.f;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
+ m_PictureBoxDP.m_fOffSetX = fx;
+ m_PictureBoxDP.m_fOffSetY = fy;
+ return FWL_ERR_Succeeded;
+}
+CFWL_PictureBox::CFWL_PictureBox() {}
+CFWL_PictureBox::~CFWL_PictureBox() {}
+FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_ERR_Succeeded;
+}
+CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetErrorPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetInitialPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget* pWidget) {
+ return m_iOpacity;
+}
+FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget,
+ CFX_Matrix& matrix) {
+ CFX_RectF rect;
+ pWidget->GetClientRect(rect);
+ FX_FLOAT fLen = rect.width / 2;
+ FX_FLOAT fWid = rect.height / 2;
+ matrix.Reset();
+ matrix.Translate(-fLen, -fWid);
+ matrix.Rotate(m_fRotation);
+ matrix.Translate(fLen, fWid);
+ matrix.Scale(m_fScaleX, m_fScaleY);
+ matrix.Translate(m_fOffSetX, m_fOffSetY);
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) {
+ return m_iFlipMode;
}
diff --git a/xfa/src/fwl/src/lightwidget/pushbutton.cpp b/xfa/src/fwl/src/lightwidget/pushbutton.cpp index f09c3cd2fe..e0df77f502 100644 --- a/xfa/src/fwl/src/lightwidget/pushbutton.cpp +++ b/xfa/src/fwl/src/lightwidget/pushbutton.cpp @@ -5,67 +5,58 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_PushButton* CFWL_PushButton::Create()
-{
- return FX_NEW CFWL_PushButton;
-}
-FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_buttonData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_PushButton::Create();
- FWL_ERR ret = ((IFWL_PushButton*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_PushButton::GetCaption(CFX_WideString &wsCaption)
-{
- wsCaption = m_buttonData.m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption)
-{
- m_buttonData.m_wsCaption = wsCaption;
- return FWL_ERR_Succeeded;
-}
-CFX_DIBitmap* CFWL_PushButton::GetPicture()
-{
- return m_buttonData.m_pBitmap;
-}
-FWL_ERR CFWL_PushButton::SetPicture(CFX_DIBitmap *pBitmap)
-{
- m_buttonData.m_pBitmap = pBitmap;
- return FWL_ERR_Succeeded;
-}
-CFWL_PushButton::CFWL_PushButton()
-{
-}
-CFWL_PushButton::~CFWL_PushButton()
-{
-}
-FWL_ERR CFWL_PushButton::CFWL_PushButtonDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture(IFWL_Widget *pWidget)
-{
- return m_pBitmap;
+CFWL_PushButton* CFWL_PushButton::Create() {
+ return FX_NEW CFWL_PushButton;
+}
+FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_pDataProvider = &m_buttonData;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_PushButton::Create();
+ FWL_ERR ret = ((IFWL_PushButton*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) {
+ wsCaption = m_buttonData.m_wsCaption;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) {
+ m_buttonData.m_wsCaption = wsCaption;
+ return FWL_ERR_Succeeded;
+}
+CFX_DIBitmap* CFWL_PushButton::GetPicture() {
+ return m_buttonData.m_pBitmap;
+}
+FWL_ERR CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) {
+ m_buttonData.m_pBitmap = pBitmap;
+ return FWL_ERR_Succeeded;
+}
+CFWL_PushButton::CFWL_PushButton() {}
+CFWL_PushButton::~CFWL_PushButton() {}
+FWL_ERR CFWL_PushButton::CFWL_PushButtonDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsCaption;
+ return FWL_ERR_Succeeded;
+}
+CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
}
diff --git a/xfa/src/fwl/src/lightwidget/scrollbar.cpp b/xfa/src/fwl/src/lightwidget/scrollbar.cpp index 492b0f91f5..6b4e326d2a 100644 --- a/xfa/src/fwl/src/lightwidget/scrollbar.cpp +++ b/xfa/src/fwl/src/lightwidget/scrollbar.cpp @@ -5,98 +5,80 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_ScrollBar* CFWL_ScrollBar::Create()
-{
- return FX_NEW CFWL_ScrollBar;
-}
-FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_ScrollBar::Create();
- FWL_ERR ret = ((IFWL_ScrollBar*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FX_BOOL CFWL_ScrollBar::IsVertical()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ScrollBar*)m_pImp)->IsVertical();
-}
-FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT &fMin, FX_FLOAT &fMax)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ScrollBar*)m_pImp)->GetRange(fMin, fMax);
-}
-FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ScrollBar*)m_pImp)->SetRange(fMin, fMax);
-}
-FX_FLOAT CFWL_ScrollBar::GetPageSize()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ScrollBar*)m_pImp)->GetPageSize();
-}
-FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ScrollBar*)m_pImp)->SetPageSize(fPageSize);
-}
-FX_FLOAT CFWL_ScrollBar::GetStepSize()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return ((IFWL_ScrollBar*)m_pImp)->GetStepSize();
-}
-FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ScrollBar*)m_pImp)->SetStepSize(fStepSize);
-}
-FX_FLOAT CFWL_ScrollBar::GetPos()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
- return ((IFWL_ScrollBar*)m_pImp)->GetPos();
-}
-FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ScrollBar*)m_pImp)->SetPos(fPos);
-}
-FX_FLOAT CFWL_ScrollBar::GetTrackPos()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
- return ((IFWL_ScrollBar*)m_pImp)->GetTrackPos();
-}
-FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return ((IFWL_ScrollBar*)m_pImp)->SetTrackPos(fTrackPos);
-}
-FX_BOOL CFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return ((IFWL_ScrollBar*)m_pImp)->DoScroll(dwCode, fPos);
-}
-CFWL_ScrollBar::CFWL_ScrollBar()
-{
-}
-CFWL_ScrollBar::~CFWL_ScrollBar()
-{
-}
+CFWL_ScrollBar* CFWL_ScrollBar::Create() {
+ return FX_NEW CFWL_ScrollBar;
+}
+FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_ScrollBar::Create();
+ FWL_ERR ret = ((IFWL_ScrollBar*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FX_BOOL CFWL_ScrollBar::IsVertical() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ScrollBar*)m_pImp)->IsVertical();
+}
+FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ScrollBar*)m_pImp)->GetRange(fMin, fMax);
+}
+FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ScrollBar*)m_pImp)->SetRange(fMin, fMax);
+}
+FX_FLOAT CFWL_ScrollBar::GetPageSize() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ScrollBar*)m_pImp)->GetPageSize();
+}
+FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ScrollBar*)m_pImp)->SetPageSize(fPageSize);
+}
+FX_FLOAT CFWL_ScrollBar::GetStepSize() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return ((IFWL_ScrollBar*)m_pImp)->GetStepSize();
+}
+FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ScrollBar*)m_pImp)->SetStepSize(fStepSize);
+}
+FX_FLOAT CFWL_ScrollBar::GetPos() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
+ return ((IFWL_ScrollBar*)m_pImp)->GetPos();
+}
+FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ScrollBar*)m_pImp)->SetPos(fPos);
+}
+FX_FLOAT CFWL_ScrollBar::GetTrackPos() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, -1);
+ return ((IFWL_ScrollBar*)m_pImp)->GetTrackPos();
+}
+FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return ((IFWL_ScrollBar*)m_pImp)->SetTrackPos(fTrackPos);
+}
+FX_BOOL CFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return ((IFWL_ScrollBar*)m_pImp)->DoScroll(dwCode, fPos);
+}
+CFWL_ScrollBar::CFWL_ScrollBar() {}
+CFWL_ScrollBar::~CFWL_ScrollBar() {}
diff --git a/xfa/src/fwl/src/lightwidget/theme.cpp b/xfa/src/fwl/src/lightwidget/theme.cpp index f9a2bab6a2..e8fb41de69 100644 --- a/xfa/src/fwl/src/lightwidget/theme.cpp +++ b/xfa/src/fwl/src/lightwidget/theme.cpp @@ -5,151 +5,141 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget *pWidget)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pWidget);
- return pTheme != NULL;
-}
-FX_DWORD CFWL_Theme::GetThemeID(IFWL_Widget *pWidget)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pWidget);
- FXSYS_assert(pTheme);
- return pTheme->GetThemeID(pWidget);
-}
-FX_DWORD CFWL_Theme::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- int32_t iCount = m_arrThemes.GetSize();
- FX_DWORD dwID;
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_WidgetTP *pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
- dwID = pTheme->GetThemeID(pWidget);
- pTheme->SetThemeID(pWidget, dwThemeID, FALSE);
+FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) {
+ CFWL_WidgetTP* pTheme = GetTheme(pWidget);
+ return pTheme != NULL;
+}
+FX_DWORD CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) {
+ CFWL_WidgetTP* pTheme = GetTheme(pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->GetThemeID(pWidget);
+}
+FX_DWORD CFWL_Theme::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ int32_t iCount = m_arrThemes.GetSize();
+ FX_DWORD dwID;
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_WidgetTP* pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
+ dwID = pTheme->GetThemeID(pWidget);
+ pTheme->SetThemeID(pWidget, dwThemeID, FALSE);
+ }
+ return dwID;
+}
+FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) {
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) {
+ CFWL_WidgetTP* pTheme = GetTheme(pParams->m_pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->DrawBackground(pParams);
+}
+FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) {
+ CFWL_WidgetTP* pTheme = GetTheme(pParams->m_pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->DrawText(pParams);
+}
+void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, FX_DWORD dwCapacity) {
+ CFWL_WidgetTP* pTheme = GetTheme(pThemePart->m_pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->GetCapacity(pThemePart, dwCapacity);
+}
+FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) {
+ CFWL_WidgetTP* pTheme = GetTheme(pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->IsCustomizedLayout(pWidget);
+}
+FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) {
+ CFWL_WidgetTP* pTheme = GetTheme(pThemePart->m_pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->GetPartRect(pThemePart, rtPart);
+}
+FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ CFWL_WidgetTP* pTheme = GetTheme(pThemePart->m_pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->IsInPart(pThemePart, fx, fy);
+}
+FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
+ CFWL_WidgetTP* pTheme = GetTheme(pParams->m_pWidget);
+ FXSYS_assert(pTheme);
+ return pTheme->CalcTextRect(pParams, rect);
+}
+FWL_ERR CFWL_Theme::Initialize() {
+ int32_t iCount = m_arrThemes.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_WidgetTP* pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
+ pTheme->Initialize();
+ }
+ FWLTHEME_Init();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_Theme::Finalize() {
+ int32_t iCount = m_arrThemes.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_WidgetTP* pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
+ pTheme->Finalize();
+ }
+ FWLTHEME_Release();
+ return FWL_ERR_Succeeded;
+}
+CFWL_Theme::CFWL_Theme() {
+ CFWL_FormTP* pFormTP = FX_NEW CFWL_FormTP;
+ CFWL_PushButtonTP* pPushButtonTP = FX_NEW CFWL_PushButtonTP;
+ CFWL_CheckBoxTP* pCheckBoxTP = FX_NEW CFWL_CheckBoxTP;
+ CFWL_ListBoxTP* pListBoxTP = FX_NEW CFWL_ListBoxTP;
+ CFWL_PictureBoxTP* pPictureBoxTP = FX_NEW CFWL_PictureBoxTP;
+ CFWL_ScrollBarTP* pSrollBarTP = FX_NEW CFWL_ScrollBarTP;
+ CFWL_EditTP* pEditTP = FX_NEW CFWL_EditTP;
+ CFWL_ComboBoxTP* pComboBoxTP = FX_NEW CFWL_ComboBoxTP;
+ CFWL_BarcodeTP* pBarcodeTP = FX_NEW CFWL_BarcodeTP;
+ CFWL_DateTimePickerTP* pDateTimePickerTP = FX_NEW CFWL_DateTimePickerTP;
+ CFWL_MonthCalendarTP* pMonthCalendarTP = FX_NEW CFWL_MonthCalendarTP;
+ CFWL_CaretTP* pCaretTP = FX_NEW CFWL_CaretTP;
+ m_arrThemes.Add(pFormTP);
+ m_arrThemes.Add(pPushButtonTP);
+ m_arrThemes.Add(pCheckBoxTP);
+ m_arrThemes.Add(pListBoxTP);
+ m_arrThemes.Add(pPictureBoxTP);
+ m_arrThemes.Add(pSrollBarTP);
+ m_arrThemes.Add(pEditTP);
+ m_arrThemes.Add(pComboBoxTP);
+ m_arrThemes.Add(pBarcodeTP);
+ m_arrThemes.Add(pDateTimePickerTP);
+ m_arrThemes.Add(pMonthCalendarTP);
+ m_arrThemes.Add(pCaretTP);
+}
+CFWL_Theme::~CFWL_Theme() {
+ int32_t iCount = m_arrThemes.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_WidgetTP* pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
+ delete pTheme;
+ }
+ m_arrThemes.RemoveAll();
+}
+FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget,
+ const FX_WCHAR* strFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont) {
+ int32_t iCount = m_arrThemes.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_WidgetTP* pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
+ pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont);
+ }
+ return FWL_ERR_Succeeded;
+}
+CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) {
+ int32_t iCount = m_arrThemes.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ CFWL_WidgetTP* pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
+ if (pTheme->IsValidWidget(pWidget)) {
+ return pTheme;
}
- return dwID;
-}
-FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget *pWidget, CFX_Matrix &matrix)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget *pWidget, const CFX_Matrix &matrix)
-{
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pParams->m_pWidget);
- FXSYS_assert(pTheme);
- return pTheme->DrawBackground(pParams);
-}
-FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText *pParams)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pParams->m_pWidget);
- FXSYS_assert(pTheme);
- return pTheme->DrawText(pParams);
-}
-void* CFWL_Theme::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pThemePart->m_pWidget);
- FXSYS_assert(pTheme);
- return pTheme->GetCapacity(pThemePart, dwCapacity);
-}
-FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget *pWidget)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pWidget);
- FXSYS_assert(pTheme);
- return pTheme->IsCustomizedLayout(pWidget);
-}
-FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF &rtPart)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pThemePart->m_pWidget);
- FXSYS_assert(pTheme);
- return pTheme->GetPartRect(pThemePart, rtPart);
-}
-FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart, FX_FLOAT fx, FX_FLOAT fy)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pThemePart->m_pWidget);
- FXSYS_assert(pTheme);
- return pTheme->IsInPart(pThemePart, fx, fy);
-}
-FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText *pParams, CFX_RectF &rect)
-{
- CFWL_WidgetTP *pTheme = GetTheme(pParams->m_pWidget);
- FXSYS_assert(pTheme);
- return pTheme->CalcTextRect(pParams, rect);
-}
-FWL_ERR CFWL_Theme::Initialize()
-{
- int32_t iCount = m_arrThemes.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_WidgetTP *pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
- pTheme->Initialize();
- }
- FWLTHEME_Init();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_Theme::Finalize()
-{
- int32_t iCount = m_arrThemes.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_WidgetTP *pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
- pTheme->Finalize();
- }
- FWLTHEME_Release();
- return FWL_ERR_Succeeded;
-}
-CFWL_Theme::CFWL_Theme()
-{
- CFWL_FormTP *pFormTP = FX_NEW CFWL_FormTP;
- CFWL_PushButtonTP *pPushButtonTP = FX_NEW CFWL_PushButtonTP;
- CFWL_CheckBoxTP *pCheckBoxTP = FX_NEW CFWL_CheckBoxTP;
- CFWL_ListBoxTP *pListBoxTP = FX_NEW CFWL_ListBoxTP;
- CFWL_PictureBoxTP *pPictureBoxTP = FX_NEW CFWL_PictureBoxTP;
- CFWL_ScrollBarTP *pSrollBarTP = FX_NEW CFWL_ScrollBarTP;
- CFWL_EditTP *pEditTP = FX_NEW CFWL_EditTP;
- CFWL_ComboBoxTP *pComboBoxTP = FX_NEW CFWL_ComboBoxTP;
- CFWL_BarcodeTP *pBarcodeTP = FX_NEW CFWL_BarcodeTP;
- CFWL_DateTimePickerTP *pDateTimePickerTP = FX_NEW CFWL_DateTimePickerTP;
- CFWL_MonthCalendarTP *pMonthCalendarTP = FX_NEW CFWL_MonthCalendarTP;
- CFWL_CaretTP *pCaretTP = FX_NEW CFWL_CaretTP;
- m_arrThemes.Add(pFormTP);
- m_arrThemes.Add(pPushButtonTP);
- m_arrThemes.Add(pCheckBoxTP);
- m_arrThemes.Add(pListBoxTP);
- m_arrThemes.Add(pPictureBoxTP);
- m_arrThemes.Add(pSrollBarTP);
- m_arrThemes.Add(pEditTP);
- m_arrThemes.Add(pComboBoxTP);
- m_arrThemes.Add(pBarcodeTP);
- m_arrThemes.Add(pDateTimePickerTP);
- m_arrThemes.Add(pMonthCalendarTP);
- m_arrThemes.Add(pCaretTP);
-}
-CFWL_Theme::~CFWL_Theme()
-{
- int32_t iCount = m_arrThemes.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_WidgetTP *pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
- delete pTheme;
- }
- m_arrThemes.RemoveAll();
-}
-FWL_ERR CFWL_Theme::SetFont(IFWL_Widget *pWidget, const FX_WCHAR* strFont, FX_FLOAT fFontSize, FX_ARGB rgbFont)
-{
- int32_t iCount = m_arrThemes.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_WidgetTP *pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
- pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont);
- }
- return FWL_ERR_Succeeded;
-}
-CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget)
-{
- int32_t iCount = m_arrThemes.GetSize();
- for (int32_t i = 0; i < iCount; i ++) {
- CFWL_WidgetTP *pTheme = (CFWL_WidgetTP*)m_arrThemes[i];
- if (pTheme->IsValidWidget(pWidget)) {
- return pTheme;
- }
- }
- return NULL;
+ }
+ return NULL;
}
diff --git a/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp b/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp index 7491e6be38..1864c288fc 100644 --- a/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp +++ b/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp @@ -11,131 +11,107 @@ #include "../core/include/fwl_panelimp.h"
#include "../core/include/fwl_formimp.h"
#include "../core/include/fwl_threadimp.h"
-CFWL_ToolTip* CFWL_ToolTip::Create()
-{
- return FX_NEW CFWL_ToolTip;
-}
-FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_tooltipData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- m_pImp = IFWL_ToolTip::Create();
- FWL_ERR ret = ((IFWL_ToolTip*)m_pImp)->Initialize(prop);
- if (ret == FWL_ERR_Succeeded) {
- CFWL_Widget::Initialize();
- }
- return ret;
-}
-FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString &wsCaption)
-{
- wsCaption = m_tooltipData.m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption)
-{
- m_tooltipData.m_wsCaption = wsCaption;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ToolTip::GetInitialDelay()
-{
- return m_tooltipData.m_nInitDelayTime;
-}
-int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime)
-{
- m_tooltipData.m_nInitDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ToolTip::GetAutoPopDelay()
-{
- return m_tooltipData.m_nAutoPopDelayTime;
-}
-int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime)
-{
- m_tooltipData.m_nAutoPopDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
-}
-CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon()
-{
- return m_tooltipData.m_pBitmap;
-}
-FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap *pBitmap)
-{
- m_tooltipData.m_pBitmap = pBitmap;
- return FWL_ERR_Succeeded;
-}
-CFX_SizeF CFWL_ToolTip::GetToolTipIconSize()
-{
- return m_tooltipData.m_fIconSize;
-}
-FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize)
-{
- m_tooltipData.m_fIconSize = fSize;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF &rtAnchor)
-{
- return ((IFWL_ToolTip*)m_pImp)->SetAnchor(rtAnchor);
-}
-FWL_ERR CFWL_ToolTip::Show()
-{
- return ((IFWL_ToolTip*)m_pImp)->Show();
-}
-FWL_ERR CFWL_ToolTip::Hide()
-{
- return ((IFWL_ToolTip*)m_pImp)->Hide();
-}
-CFWL_ToolTip::CFWL_ToolTip()
-{
-}
-CFWL_ToolTip::~CFWL_ToolTip()
-{
-}
-CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP()
- : m_pBitmap(NULL)
-{
- m_wsCaption = L"";
- m_nInitDelayTime = 500;
- m_nAutoPopDelayTime = 50000;
- m_fIconSize.Set( 0.0, 0.0);
- m_fAnchor.Set( 0.0, 0.0, 0.0, 0.0);
-}
-FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget *pWidget, CFX_WideString &wsCaption)
-{
- wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget *pWidget)
-{
- return m_nInitDelayTime;
-}
-int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget *pWidget)
-{
- return m_nAutoPopDelayTime;
-}
-CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon(IFWL_Widget *pWidget)
-{
- return m_pBitmap;
-}
-CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize(IFWL_Widget *pWidget)
-{
- return m_fIconSize;
-}
-CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor()
-{
- return m_fAnchor;
+CFWL_ToolTip* CFWL_ToolTip::Create() {
+ return FX_NEW CFWL_ToolTip;
+}
+FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(!m_pImp, FWL_ERR_Indefinite);
+ if (pProperties) {
+ *m_pProperties = *pProperties;
+ }
+ CFWL_WidgetImpProperties prop;
+ prop.m_dwStyles = m_pProperties->m_dwStyles;
+ prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ prop.m_dwStates = m_pProperties->m_dwStates;
+ prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ prop.m_pDataProvider = &m_tooltipData;
+ if (m_pProperties->m_pParent) {
+ prop.m_pParent = m_pProperties->m_pParent->GetWidget();
+ }
+ if (m_pProperties->m_pOwner) {
+ prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
+ }
+ prop.m_rtWidget = m_pProperties->m_rtWidget;
+ m_pImp = IFWL_ToolTip::Create();
+ FWL_ERR ret = ((IFWL_ToolTip*)m_pImp)->Initialize(prop);
+ if (ret == FWL_ERR_Succeeded) {
+ CFWL_Widget::Initialize();
+ }
+ return ret;
+}
+FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) {
+ wsCaption = m_tooltipData.m_wsCaption;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) {
+ m_tooltipData.m_wsCaption = wsCaption;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ToolTip::GetInitialDelay() {
+ return m_tooltipData.m_nInitDelayTime;
+}
+int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) {
+ m_tooltipData.m_nInitDelayTime = nDelayTime;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ToolTip::GetAutoPopDelay() {
+ return m_tooltipData.m_nAutoPopDelayTime;
+}
+int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) {
+ m_tooltipData.m_nAutoPopDelayTime = nDelayTime;
+ return FWL_ERR_Succeeded;
+}
+CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() {
+ return m_tooltipData.m_pBitmap;
+}
+FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) {
+ m_tooltipData.m_pBitmap = pBitmap;
+ return FWL_ERR_Succeeded;
+}
+CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() {
+ return m_tooltipData.m_fIconSize;
+}
+FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) {
+ m_tooltipData.m_fIconSize = fSize;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
+ return ((IFWL_ToolTip*)m_pImp)->SetAnchor(rtAnchor);
+}
+FWL_ERR CFWL_ToolTip::Show() {
+ return ((IFWL_ToolTip*)m_pImp)->Show();
+}
+FWL_ERR CFWL_ToolTip::Hide() {
+ return ((IFWL_ToolTip*)m_pImp)->Hide();
+}
+CFWL_ToolTip::CFWL_ToolTip() {}
+CFWL_ToolTip::~CFWL_ToolTip() {}
+CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) {
+ m_wsCaption = L"";
+ m_nInitDelayTime = 500;
+ m_nAutoPopDelayTime = 50000;
+ m_fIconSize.Set(0.0, 0.0);
+ m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
+}
+FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsCaption;
+ return FWL_ERR_Succeeded;
+}
+int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
+ return m_nInitDelayTime;
+}
+int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) {
+ return m_nAutoPopDelayTime;
+}
+CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize(
+ IFWL_Widget* pWidget) {
+ return m_fIconSize;
+}
+CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() {
+ return m_fAnchor;
}
diff --git a/xfa/src/fwl/src/lightwidget/widget.cpp b/xfa/src/fwl/src/lightwidget/widget.cpp index be6c728e2c..85bb710bd6 100644 --- a/xfa/src/fwl/src/lightwidget/widget.cpp +++ b/xfa/src/fwl/src/lightwidget/widget.cpp @@ -10,335 +10,296 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "../core/include/fwl_widgetmgrimp.h"
-IFWL_Widget* CFWL_Widget::GetWidget()
-{
- return m_pImp;
-}
-FX_DWORD CFWL_Widget::Release()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- FX_DWORD dwRef = m_pImp->GetRefCount();
- if (dwRef == 1) {
- m_pImp->Finalize();
- }
- m_pImp->Release();
- if (dwRef == 1) {
- m_pImp = NULL;
- delete this;
- }
- return dwRef - 1;
-}
-CFWL_Widget* CFWL_Widget::Retain()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
- m_pImp->Retain();
- return this;
-}
-FX_DWORD CFWL_Widget::GetRefCount() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 1);
- return m_pImp->GetRefCount();
-}
-FWL_ERR CFWL_Widget::GetClassName(CFX_WideString &wsClass) const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->GetClassName(wsClass);
-}
-FX_DWORD CFWL_Widget::GetClassID() const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return m_pImp->GetClassID();
-}
-FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
- return m_pImp->IsInstance(wsClass);
+IFWL_Widget* CFWL_Widget::GetWidget() {
+ return m_pImp;
+}
+FX_DWORD CFWL_Widget::Release() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ FX_DWORD dwRef = m_pImp->GetRefCount();
+ if (dwRef == 1) {
+ m_pImp->Finalize();
+ }
+ m_pImp->Release();
+ if (dwRef == 1) {
+ m_pImp = NULL;
+ delete this;
+ }
+ return dwRef - 1;
+}
+CFWL_Widget* CFWL_Widget::Retain() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
+ m_pImp->Retain();
+ return this;
+}
+FX_DWORD CFWL_Widget::GetRefCount() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 1);
+ return m_pImp->GetRefCount();
+}
+FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->GetClassName(wsClass);
+}
+FX_DWORD CFWL_Widget::GetClassID() const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return m_pImp->GetClassID();
+}
+FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FALSE);
+ return m_pImp->IsInstance(wsClass);
}
static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't');
-FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties *pProperties )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->SetPrivateData(gs_pFWLWidget, this, NULL);
-}
-FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF &rect, FX_BOOL bAutoSize )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->GetWidgetRect(rect, bAutoSize);
-}
-FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF &rect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->GetGlobalRect(rect);
-}
-FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF &rect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->SetWidgetRect(rect);
-}
-FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF &rect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->GetClientRect(rect);
-}
-CFWL_Widget* CFWL_Widget::GetParent()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
- IFWL_Widget *parent = m_pImp->GetParent();
- if (parent) {
- return (CFWL_Widget*)parent->GetPrivateData(gs_pFWLWidget);
- }
- return NULL;
-}
-FWL_ERR CFWL_Widget::SetParent(CFWL_Widget *pParent)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->SetParent(pParent ? pParent->GetWidget() : NULL);
-}
-CFWL_Widget* CFWL_Widget::GetOwner()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
- return NULL;
-}
-FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget *pOwner)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_Widget::GetStyles()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return m_pImp->GetStyles();
-}
-FWL_ERR CFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded, FX_DWORD dwStylesRemoved)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->ModifyStyles(dwStylesAdded, dwStylesRemoved);
-}
-FX_DWORD CFWL_Widget::GetStylesEx()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return m_pImp->GetStylesEx();
-}
-FWL_ERR CFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved)
-{
- return m_pImp->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-FX_DWORD CFWL_Widget::GetStates()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->GetStates();
-}
-FWL_ERR CFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->SetStates(dwStates, bSet);
-}
-FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->SetPrivateData(module_id, pData, callback);
-}
-void* CFWL_Widget::GetPrivateData(void* module_id)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
- return m_pImp->GetPrivateData(module_id);
-}
-FWL_ERR CFWL_Widget::Update()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->Update();
-}
-FWL_ERR CFWL_Widget::LockUpdate()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->LockUpdate();
-}
-FWL_ERR CFWL_Widget::UnlockUpdate()
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->UnlockUpdate();
-}
-FX_DWORD CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
- return m_pImp->HitTest(fx, fy);
-}
-FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget *pWidget, FX_FLOAT &fx, FX_FLOAT &fy)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy);
-}
-FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget *pWidget, CFX_RectF &rt)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt);
-}
-FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix &matrix, FX_BOOL bGlobal )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->GetMatrix(matrix, bGlobal);
-}
-FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix &matrix)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->SetMatrix(matrix);
-}
-FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- return m_pImp->DrawWidget(pGraphics, pMatrix);
-}
-FWL_ERR CFWL_Widget::GetProperties(CFWL_WidgetProperties &properties)
-{
- properties.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- properties.m_rtWidget = m_pProperties->m_rtWidget;
- properties.m_dwStyles = m_pProperties->m_dwStyles;
- properties.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- properties.m_dwStates = m_pProperties->m_dwStates;
- properties.m_pParent = m_pProperties->m_pParent;
- properties.m_pOwner = m_pProperties->m_pOwner;
- properties.m_wsWindowclass = m_pProperties->m_wsWindowclass;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_Widget::SetProperties(const CFWL_WidgetProperties &properties)
-{
- m_pProperties->m_ctmOnParent = properties.m_ctmOnParent;
- m_pProperties->m_rtWidget = properties.m_rtWidget;
- m_pProperties->m_dwStyles = properties.m_dwStyles;
- m_pProperties->m_dwStyleExes = properties.m_dwStyleExes;
- m_pProperties->m_dwStates = properties.m_dwStates;
- m_pProperties->m_pParent = properties.m_pParent;
- m_pProperties->m_pOwner = properties.m_pOwner;
- m_pProperties->m_wsWindowclass = properties.m_wsWindowclass;
- return FWL_ERR_Succeeded;
-}
-IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
- m_pDelegate = m_pImp->SetDelegate(pDelegate);
- return m_pDelegate;
+FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->SetPrivateData(gs_pFWLWidget, this, NULL);
+}
+FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->GetWidgetRect(rect, bAutoSize);
+}
+FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->GetGlobalRect(rect);
+}
+FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->SetWidgetRect(rect);
+}
+FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->GetClientRect(rect);
+}
+CFWL_Widget* CFWL_Widget::GetParent() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
+ IFWL_Widget* parent = m_pImp->GetParent();
+ if (parent) {
+ return (CFWL_Widget*)parent->GetPrivateData(gs_pFWLWidget);
+ }
+ return NULL;
+}
+FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->SetParent(pParent ? pParent->GetWidget() : NULL);
+}
+CFWL_Widget* CFWL_Widget::GetOwner() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
+ return NULL;
+}
+FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return FWL_ERR_Succeeded;
+}
+FX_DWORD CFWL_Widget::GetStyles() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return m_pImp->GetStyles();
+}
+FWL_ERR CFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded,
+ FX_DWORD dwStylesRemoved) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->ModifyStyles(dwStylesAdded, dwStylesRemoved);
+}
+FX_DWORD CFWL_Widget::GetStylesEx() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return m_pImp->GetStylesEx();
+}
+FWL_ERR CFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded,
+ FX_DWORD dwStylesExRemoved) {
+ return m_pImp->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+FX_DWORD CFWL_Widget::GetStates() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->GetStates();
+}
+FWL_ERR CFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->SetStates(dwStates, bSet);
+}
+FWL_ERR CFWL_Widget::SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->SetPrivateData(module_id, pData, callback);
+}
+void* CFWL_Widget::GetPrivateData(void* module_id) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
+ return m_pImp->GetPrivateData(module_id);
+}
+FWL_ERR CFWL_Widget::Update() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->Update();
+}
+FWL_ERR CFWL_Widget::LockUpdate() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->LockUpdate();
+}
+FWL_ERR CFWL_Widget::UnlockUpdate() {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->UnlockUpdate();
+}
+FX_DWORD CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, 0);
+ return m_pImp->HitTest(fx, fy);
+}
+FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy);
+}
+FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt);
+}
+FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->GetMatrix(matrix, bGlobal);
+}
+FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->SetMatrix(matrix);
+}
+FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ return m_pImp->DrawWidget(pGraphics, pMatrix);
+}
+FWL_ERR CFWL_Widget::GetProperties(CFWL_WidgetProperties& properties) {
+ properties.m_ctmOnParent = m_pProperties->m_ctmOnParent;
+ properties.m_rtWidget = m_pProperties->m_rtWidget;
+ properties.m_dwStyles = m_pProperties->m_dwStyles;
+ properties.m_dwStyleExes = m_pProperties->m_dwStyleExes;
+ properties.m_dwStates = m_pProperties->m_dwStates;
+ properties.m_pParent = m_pProperties->m_pParent;
+ properties.m_pOwner = m_pProperties->m_pOwner;
+ properties.m_wsWindowclass = m_pProperties->m_wsWindowclass;
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_Widget::SetProperties(const CFWL_WidgetProperties& properties) {
+ m_pProperties->m_ctmOnParent = properties.m_ctmOnParent;
+ m_pProperties->m_rtWidget = properties.m_rtWidget;
+ m_pProperties->m_dwStyles = properties.m_dwStyles;
+ m_pProperties->m_dwStyleExes = properties.m_dwStyleExes;
+ m_pProperties->m_dwStates = properties.m_dwStates;
+ m_pProperties->m_pParent = properties.m_pParent;
+ m_pProperties->m_pOwner = properties.m_pOwner;
+ m_pProperties->m_wsWindowclass = properties.m_wsWindowclass;
+ return FWL_ERR_Succeeded;
+}
+IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, NULL);
+ m_pDelegate = m_pImp->SetDelegate(pDelegate);
+ return m_pDelegate;
}
CFWL_Widget::CFWL_Widget()
- : m_pImp(NULL)
- , m_pDelegate(NULL)
- , m_pProperties(NULL)
-{
- m_pProperties = FX_NEW CFWL_WidgetProperties;
- m_pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
- FXSYS_assert(m_pWidgetMgr != NULL);
-}
-CFWL_Widget::~CFWL_Widget()
-{
- if (m_pProperties) {
- delete m_pProperties;
- m_pProperties = NULL;
- }
- if (m_pImp) {
- m_pImp->Finalize();
- m_pImp->Release();
- m_pImp = NULL;
- }
-}
-FWL_ERR CFWL_Widget::Repaint(const CFX_RectF *pRect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- CFX_RectF rect;
- if (pRect) {
- rect = *pRect;
- } else {
- m_pImp->GetWidgetRect(rect);
- rect.left = rect.top = 0;
- }
- return m_pWidgetMgr->RepaintWidget(m_pImp, &rect);
-}
-FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- IFWL_NoteThread *pThread = m_pImp->GetOwnerThread();
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- IFWL_NoteDriver *pDriver = pThread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- if (bFocus) {
- pDriver->SetFocus(m_pImp);
- } else {
- if (((CFWL_NoteDriver*)pDriver)->GetFocus() == m_pImp) {
- pDriver->SetFocus(NULL);
- }
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- IFWL_NoteThread *pThread = m_pImp->GetOwnerThread();
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- CFWL_NoteDriver *pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
- pDriver->SetGrab(m_pImp, bSet);
- return FWL_ERR_Succeeded;
-}
-void CFWL_Widget::RegisterEventTarget(CFWL_Widget *pEventSource , FX_DWORD dwFilter )
-{
- _FWL_RETURN_IF_FAIL(m_pImp);
- IFWL_NoteThread *pThread = m_pImp->GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pNoteDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pNoteDriver);
- IFWL_Widget *pEventSourceImp = !pEventSource ? NULL : pEventSource->GetWidget();
- pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
-}
-void CFWL_Widget::DispatchEvent(CFWL_Event *pEvent)
-{
- _FWL_RETURN_IF_FAIL(m_pImp);
- if (m_pImp->GetOuter()) {
- return;
+ : m_pImp(NULL), m_pDelegate(NULL), m_pProperties(NULL) {
+ m_pProperties = FX_NEW CFWL_WidgetProperties;
+ m_pWidgetMgr = (CFWL_WidgetMgr*)FWL_GetWidgetMgr();
+ FXSYS_assert(m_pWidgetMgr != NULL);
+}
+CFWL_Widget::~CFWL_Widget() {
+ if (m_pProperties) {
+ delete m_pProperties;
+ m_pProperties = NULL;
+ }
+ if (m_pImp) {
+ m_pImp->Finalize();
+ m_pImp->Release();
+ m_pImp = NULL;
+ }
+}
+FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ CFX_RectF rect;
+ if (pRect) {
+ rect = *pRect;
+ } else {
+ m_pImp->GetWidgetRect(rect);
+ rect.left = rect.top = 0;
+ }
+ return m_pWidgetMgr->RepaintWidget(m_pImp, &rect);
+}
+FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ IFWL_NoteThread* pThread = m_pImp->GetOwnerThread();
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ if (bFocus) {
+ pDriver->SetFocus(m_pImp);
+ } else {
+ if (((CFWL_NoteDriver*)pDriver)->GetFocus() == m_pImp) {
+ pDriver->SetFocus(NULL);
}
- IFWL_NoteThread *pThread = m_pImp->GetOwnerThread();
- _FWL_RETURN_IF_FAIL(pThread);
- IFWL_NoteDriver *pNoteDriver = pThread->GetNoteDriver();
- _FWL_RETURN_IF_FAIL(pNoteDriver);
- pNoteDriver->SendNote(pEvent);
-}
-#define FWL_WGT_CalcHeight 2048
-#define FWL_WGT_CalcWidth 2048
-#define FWL_WGT_CalcMultiLineDefWidth 120.0f
-CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString &wsText, FX_BOOL bMultiLine , int32_t iLineWidth )
-{
- CFX_SizeF sz;
- sz.Set(0, 0);
- _FWL_RETURN_VALUE_IF_FAIL(m_pImp, sz);
- IFWL_ThemeProvider *pTheme = m_pImp->GetThemeProvider();
- _FWL_RETURN_VALUE_IF_FAIL(pTheme, sz);
- CFWL_ThemeText calPart;
- calPart.m_pWidget = m_pImp;
- calPart.m_wsText = wsText;
- calPart.m_dwTTOStyles = bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
- calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
- CFX_RectF rect;
- FX_FLOAT fWidth = bMultiLine ?
- (iLineWidth > 0 ? (FX_FLOAT)iLineWidth : FWL_WGT_CalcMultiLineDefWidth) :
- FWL_WGT_CalcWidth;
- rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
- pTheme->CalcTextRect(&calPart, rect);
- sz.x = rect.width;
- sz.y = rect.height;
- return sz;
-}
-CFWL_WidgetDelegate::CFWL_WidgetDelegate()
-{
-}
-CFWL_WidgetDelegate::~CFWL_WidgetDelegate()
-{
-}
-int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message *pMessage)
-{
- return 1;
-}
-FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event *pEvent)
-{
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics *pGraphics, const CFX_Matrix *pMatrix )
-{
- return FWL_ERR_Succeeded;
+ }
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ IFWL_NoteThread* pThread = m_pImp->GetOwnerThread();
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ CFWL_NoteDriver* pDriver = (CFWL_NoteDriver*)pThread->GetNoteDriver();
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, FWL_ERR_Indefinite);
+ pDriver->SetGrab(m_pImp, bSet);
+ return FWL_ERR_Succeeded;
+}
+void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource,
+ FX_DWORD dwFilter) {
+ _FWL_RETURN_IF_FAIL(m_pImp);
+ IFWL_NoteThread* pThread = m_pImp->GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pNoteDriver);
+ IFWL_Widget* pEventSourceImp =
+ !pEventSource ? NULL : pEventSource->GetWidget();
+ pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
+}
+void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
+ _FWL_RETURN_IF_FAIL(m_pImp);
+ if (m_pImp->GetOuter()) {
+ return;
+ }
+ IFWL_NoteThread* pThread = m_pImp->GetOwnerThread();
+ _FWL_RETURN_IF_FAIL(pThread);
+ IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+ _FWL_RETURN_IF_FAIL(pNoteDriver);
+ pNoteDriver->SendNote(pEvent);
+}
+#define FWL_WGT_CalcHeight 2048
+#define FWL_WGT_CalcWidth 2048
+#define FWL_WGT_CalcMultiLineDefWidth 120.0f
+CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
+ FX_BOOL bMultiLine,
+ int32_t iLineWidth) {
+ CFX_SizeF sz;
+ sz.Set(0, 0);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pImp, sz);
+ IFWL_ThemeProvider* pTheme = m_pImp->GetThemeProvider();
+ _FWL_RETURN_VALUE_IF_FAIL(pTheme, sz);
+ CFWL_ThemeText calPart;
+ calPart.m_pWidget = m_pImp;
+ calPart.m_wsText = wsText;
+ calPart.m_dwTTOStyles =
+ bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
+ calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
+ CFX_RectF rect;
+ FX_FLOAT fWidth = bMultiLine
+ ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth
+ : FWL_WGT_CalcMultiLineDefWidth)
+ : FWL_WGT_CalcWidth;
+ rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
+ pTheme->CalcTextRect(&calPart, rect);
+ sz.x = rect.width;
+ sz.y = rect.height;
+ return sz;
+}
+CFWL_WidgetDelegate::CFWL_WidgetDelegate() {}
+CFWL_WidgetDelegate::~CFWL_WidgetDelegate() {}
+int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ return 1;
+}
+FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return FWL_ERR_Succeeded;
}
diff --git a/xfa/src/fwl/src/theme/barcodetp.cpp b/xfa/src/fwl/src/theme/barcodetp.cpp index 86bbf92c4a..fa9ced035f 100644 --- a/xfa/src/fwl/src/theme/barcodetp.cpp +++ b/xfa/src/fwl/src/theme/barcodetp.cpp @@ -5,35 +5,30 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_BarcodeTP::CFWL_BarcodeTP()
-{
+CFWL_BarcodeTP::CFWL_BarcodeTP() {}
+CFWL_BarcodeTP::~CFWL_BarcodeTP() {}
+FX_BOOL CFWL_BarcodeTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_Barcode;
}
-CFWL_BarcodeTP::~CFWL_BarcodeTP()
-{
-}
-FX_BOOL CFWL_BarcodeTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_Barcode;
-}
-FX_BOOL CFWL_BarcodeTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_BCD_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_BCD_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_BCD_Background: {
- FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- default: {
- }
+FX_BOOL CFWL_BarcodeTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_BCD_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_BCD_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_BCD_Background: {
+ FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
+ &pParams->m_matrix);
+ break;
}
- return TRUE;
+ default: {}
+ }
+ return TRUE;
}
diff --git a/xfa/src/fwl/src/theme/carettp.cpp b/xfa/src/fwl/src/theme/carettp.cpp index b33a97da25..c7602b04ef 100644 --- a/xfa/src/fwl/src/theme/carettp.cpp +++ b/xfa/src/fwl/src/theme/carettp.cpp @@ -5,39 +5,38 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_CaretTP::CFWL_CaretTP()
-{
+CFWL_CaretTP::CFWL_CaretTP() {}
+CFWL_CaretTP::~CFWL_CaretTP() {}
+FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_Caret;
}
-CFWL_CaretTP::~CFWL_CaretTP()
-{
-}
-FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_Caret;
-}
-FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_CAT_Background: {
- if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) {
- return TRUE;
- }
- DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, &(pParams->m_rtPart), (CFX_Color *)pParams->m_pData, &(pParams->m_matrix));
- break;
- }
+FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_CAT_Background: {
+ if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) {
+ return TRUE;
+ }
+ DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates,
+ &(pParams->m_rtPart), (CFX_Color*)pParams->m_pData,
+ &(pParams->m_matrix));
+ break;
}
- return TRUE;
+ }
+ return TRUE;
}
-void CFWL_CaretTP::DrawCaretBK(CFX_Graphics *pGraphics, FX_DWORD dwStates, const CFX_RectF *pRect, CFX_Color *crFill, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_Color crFilltemp;
- crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0);
- CFX_RectF rect = *pRect;
- path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
- pGraphics->SetFillColor(&crFilltemp);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics,
+ FX_DWORD dwStates,
+ const CFX_RectF* pRect,
+ CFX_Color* crFill,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_Color crFilltemp;
+ crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0);
+ CFX_RectF rect = *pRect;
+ path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
+ pGraphics->SetFillColor(&crFilltemp);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
}
diff --git a/xfa/src/fwl/src/theme/checkboxtp.cpp b/xfa/src/fwl/src/theme/checkboxtp.cpp index bba56e69ed..d86f1886a6 100644 --- a/xfa/src/fwl/src/theme/checkboxtp.cpp +++ b/xfa/src/fwl/src/theme/checkboxtp.cpp @@ -5,496 +5,539 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define CHECKBOX_SIZE_SIGNMARGIN 3
-#define CHECKBOX_SIZE_SIGNBORDER 2
-#define CHECKBOX_SIZE_SIGNPATH 100
-#define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153))
-#define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100))
-#define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226))
-#define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255))
-#define CHECKBOX_FXGE_CoordinatesAdjust
-CFWL_CheckBoxTP::CFWL_CheckBoxTP()
- : m_pCheckPath(NULL)
-{
- m_pThemeData = FX_NEW CKBThemeData;
- SetThemeData(0);
+#define CHECKBOX_SIZE_SIGNMARGIN 3
+#define CHECKBOX_SIZE_SIGNBORDER 2
+#define CHECKBOX_SIZE_SIGNPATH 100
+#define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153))
+#define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100))
+#define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226))
+#define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255))
+#define CHECKBOX_FXGE_CoordinatesAdjust
+CFWL_CheckBoxTP::CFWL_CheckBoxTP() : m_pCheckPath(NULL) {
+ m_pThemeData = FX_NEW CKBThemeData;
+ SetThemeData(0);
}
-CFWL_CheckBoxTP::~CFWL_CheckBoxTP()
-{
- if (m_pThemeData) {
- delete m_pThemeData;
- m_pThemeData = NULL;
- }
- if (m_pCheckPath) {
- m_pCheckPath->Clear();
- delete m_pCheckPath;
- m_pCheckPath = NULL;
- }
+CFWL_CheckBoxTP::~CFWL_CheckBoxTP() {
+ if (m_pThemeData) {
+ delete m_pThemeData;
+ m_pThemeData = NULL;
+ }
+ if (m_pCheckPath) {
+ m_pCheckPath->Clear();
+ delete m_pCheckPath;
+ m_pCheckPath = NULL;
+ }
}
-FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- FX_DWORD dwHash = pWidget->GetClassID();
- return dwHash == FWL_CLASSHASH_CheckBox || dwHash == FWL_CLASSHASH_RadioButton;
+FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ FX_DWORD dwHash = pWidget->GetClassID();
+ return dwHash == FWL_CLASSHASH_CheckBox ||
+ dwHash == FWL_CLASSHASH_RadioButton;
}
-FX_DWORD CFWL_CheckBoxTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- if (m_pThemeData) {
- SetThemeData(FWL_GetThemeColor(dwThemeID));
- }
- return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
+FX_DWORD CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ if (m_pThemeData) {
+ SetThemeData(FWL_GetThemeColor(dwThemeID));
+ }
+ return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
}
-FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
- FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled;
- FX_ARGB argText = bDisable ? FWLTHEME_CAPACITY_TextDisColor : FWLTHEME_CAPACITY_TextColor;
- m_pTextOut->SetTextColor(argText);
- return CFWL_WidgetTP::DrawText(pParams);
+FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
+ FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) ==
+ FWL_PARTSTATE_CKB_Disabled;
+ FX_ARGB argText =
+ bDisable ? FWLTHEME_CAPACITY_TextDisColor : FWLTHEME_CAPACITY_TextColor;
+ m_pTextOut->SetTextColor(argText);
+ return CFWL_WidgetTP::DrawText(pParams);
}
-FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_CKB_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_CKB_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_CKB_Background: {
- FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- if (pParams->m_dwStates & FWL_PARTSTATE_CKB_Focused) {
- pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData;
- DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- }
- break;
- }
- case FWL_PART_CKB_CheckBox: {
- DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, pParams->m_dwStates, &pParams->m_matrix);
- if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) |
- ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral)) {
- DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, pParams->m_dwStates, &pParams->m_matrix);
- }
- FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled;
- DrawSignBorder(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, bDisable, &pParams->m_matrix);
- break;
- }
- default: {
- return FALSE;
- }
+FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_CKB_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_CKB_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
}
- return TRUE;
+ case FWL_PART_CKB_Background: {
+ FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
+ &pParams->m_matrix);
+ if (pParams->m_dwStates & FWL_PARTSTATE_CKB_Focused) {
+ pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData;
+ DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ }
+ break;
+ }
+ case FWL_PART_CKB_CheckBox: {
+ DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart,
+ pParams->m_dwStates, &pParams->m_matrix);
+ if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) ==
+ FWL_PARTSTATE_CKB_Checked) |
+ ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) ==
+ FWL_PARTSTATE_CKB_Neutral)) {
+ DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart,
+ pParams->m_dwStates, &pParams->m_matrix);
+ }
+ FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) ==
+ FWL_PARTSTATE_CKB_Disabled;
+ DrawSignBorder(pParams->m_pWidget, pParams->m_pGraphics,
+ &pParams->m_rtPart, bDisable, &pParams->m_matrix);
+ break;
+ }
+ default: { return FALSE; }
+ }
+ return TRUE;
}
-FWL_ERR CFWL_CheckBoxTP::Initialize()
-{
- InitTTO();
- return CFWL_WidgetTP::Initialize();
+FWL_ERR CFWL_CheckBoxTP::Initialize() {
+ InitTTO();
+ return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_CheckBoxTP::Finalize()
-{
- FinalizeTTO();
- return CFWL_WidgetTP::Finalize();
+FWL_ERR CFWL_CheckBoxTP::Finalize() {
+ FinalizeTTO();
+ return CFWL_WidgetTP::Finalize();
}
-void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_DWORD dwStates, CFX_Matrix *pMatrix )
-{
- dwStates &= 0x03;
- int32_t fillMode = FXFILL_WINDING;
- FX_DWORD dwStyleEx = pWidget->GetStylesEx();
- dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask;
- CFX_Path path;
- path.Create();
- FX_FLOAT fRight = pRect->right();
- FX_FLOAT fBottom = pRect->bottom();
- FX_BOOL bClipSign = (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered;
- if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) || (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) {
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
- if (bClipSign) {
- fillMode = FXFILL_ALTERNATE;
- path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN,
- pRect->top + CHECKBOX_SIZE_SIGNMARGIN,
- pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2,
- pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2);
- }
- } else {
+void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FX_DWORD dwStates,
+ CFX_Matrix* pMatrix) {
+ dwStates &= 0x03;
+ int32_t fillMode = FXFILL_WINDING;
+ FX_DWORD dwStyleEx = pWidget->GetStylesEx();
+ dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask;
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fBottom = pRect->bottom();
+ FX_BOOL bClipSign =
+ (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered;
+ if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) ||
+ (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) {
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ if (bClipSign) {
+ fillMode = FXFILL_ALTERNATE;
+ path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN,
+ pRect->top + CHECKBOX_SIZE_SIGNMARGIN,
+ pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2,
+ pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2);
+ }
+ } else {
#ifdef CHECKBOX_FXGE_CoordinatesAdjust
- CFX_RectF rect(*pRect);
- rect.Deflate(0, 0, 1, 1);
- path.AddEllipse(rect);
+ CFX_RectF rect(*pRect);
+ rect.Deflate(0, 0, 1, 1);
+ path.AddEllipse(rect);
#else
- path.AddEllipse(*pRect);
+ path.AddEllipse(*pRect);
#endif
- if (bClipSign) {
- fillMode = FXFILL_ALTERNATE;
+ if (bClipSign) {
+ fillMode = FXFILL_ALTERNATE;
#ifdef CHECKBOX_FXGE_CoordinatesAdjust
- CFX_RectF rtClip(rect);
+ CFX_RectF rtClip(rect);
#else
- CFX_RectF rtClip(*pRect);
+ CFX_RectF rtClip(*pRect);
#endif
- rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1, CHECKBOX_SIZE_SIGNMARGIN - 1);
- path.AddEllipse(rtClip);
- }
- }
- int32_t iTheme = 1;
- if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) {
- iTheme = 2;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Pressed) {
- iTheme = 3;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) {
- iTheme = 4;
+ rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1,
+ CHECKBOX_SIZE_SIGNMARGIN - 1);
+ path.AddEllipse(rtClip);
}
- if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) {
- iTheme += 4;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) {
- iTheme += 8;
- }
- DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight,
- fBottom, m_pThemeData->clrBoxBk[iTheme][0],
- m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix);
+ }
+ int32_t iTheme = 1;
+ if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) {
+ iTheme = 2;
+ } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) ==
+ FWL_PARTSTATE_CKB_Pressed) {
+ iTheme = 3;
+ } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) ==
+ FWL_PARTSTATE_CKB_Disabled) {
+ iTheme = 4;
+ }
+ if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) {
+ iTheme += 4;
+ } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) ==
+ FWL_PARTSTATE_CKB_Neutral) {
+ iTheme += 8;
+ }
+ DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom,
+ m_pThemeData->clrBoxBk[iTheme][0],
+ m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix);
}
-void CFWL_CheckBoxTP::DrawSign(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_RectF *pRtBox, FX_DWORD dwStates, CFX_Matrix *pMatrix )
-{
- CFX_RectF rtSign(*pRtBox);
- rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN);
- FX_DWORD dwColor = m_pThemeData->clrSignCheck;
- FX_BOOL bCheck = TRUE;
- if (((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) &&
- ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked)) {
- dwColor = m_pThemeData->clrSignBorderDisable;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) {
- switch (dwStates & FWL_PARTSTATE_CKB_Mask1) {
- case FWL_PARTSTATE_CKB_Normal: {
- bCheck = FALSE;
- dwColor = m_pThemeData->clrSignNeutralNormal;
- break;
- }
- case FWL_PARTSTATE_CKB_Hovered: {
- bCheck = FALSE;
- dwColor = m_pThemeData->clrSignNeutralHover;
- break;
- }
- case FWL_PARTSTATE_CKB_Pressed: {
- bCheck = FALSE, dwColor = m_pThemeData->clrSignNeutralPressed;
- break;
- }
- case FWL_PARTSTATE_CKB_Disabled: {
- bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable;
- break;
- }
- }
+void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtBox,
+ FX_DWORD dwStates,
+ CFX_Matrix* pMatrix) {
+ CFX_RectF rtSign(*pRtBox);
+ rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN);
+ FX_DWORD dwColor = m_pThemeData->clrSignCheck;
+ FX_BOOL bCheck = TRUE;
+ if (((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) &&
+ ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked)) {
+ dwColor = m_pThemeData->clrSignBorderDisable;
+ } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) ==
+ FWL_PARTSTATE_CKB_Neutral) {
+ switch (dwStates & FWL_PARTSTATE_CKB_Mask1) {
+ case FWL_PARTSTATE_CKB_Normal: {
+ bCheck = FALSE;
+ dwColor = m_pThemeData->clrSignNeutralNormal;
+ break;
+ }
+ case FWL_PARTSTATE_CKB_Hovered: {
+ bCheck = FALSE;
+ dwColor = m_pThemeData->clrSignNeutralHover;
+ break;
+ }
+ case FWL_PARTSTATE_CKB_Pressed: {
+ bCheck = FALSE, dwColor = m_pThemeData->clrSignNeutralPressed;
+ break;
+ }
+ case FWL_PARTSTATE_CKB_Disabled: {
+ bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable;
+ break;
+ }
}
- if (bCheck) {
- FX_DWORD dwStyle = pWidget->GetStylesEx();
- switch(dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) {
- case FWL_STYLEEXT_CKB_SignShapeCheck: {
- DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_SignShapeCircle: {
- rtSign.Deflate(1, 1);
- DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_SignShapeCross: {
- DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_SignShapeDiamond: {
- DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_SignShapeSquare: {
- DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_SignShapeStar: {
- DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix);
- break;
- }
- }
- } else {
- FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix);
+ }
+ if (bCheck) {
+ FX_DWORD dwStyle = pWidget->GetStylesEx();
+ switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) {
+ case FWL_STYLEEXT_CKB_SignShapeCheck: {
+ DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix);
+ break;
+ }
+ case FWL_STYLEEXT_CKB_SignShapeCircle: {
+ rtSign.Deflate(1, 1);
+ DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix);
+ break;
+ }
+ case FWL_STYLEEXT_CKB_SignShapeCross: {
+ DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix);
+ break;
+ }
+ case FWL_STYLEEXT_CKB_SignShapeDiamond: {
+ DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix);
+ break;
+ }
+ case FWL_STYLEEXT_CKB_SignShapeSquare: {
+ DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix);
+ break;
+ }
+ case FWL_STYLEEXT_CKB_SignShapeStar: {
+ DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix);
+ break;
+ }
}
+ } else {
+ FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix);
+ }
}
-void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, CFX_Matrix *pMatrix )
-{
- ((CFX_RectF*)pRtSign)->Inflate(-3, -3);
- FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix);
+void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ CFX_Matrix* pMatrix) {
+ ((CFX_RectF*)pRtSign)->Inflate(-3, -3);
+ FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix);
}
-void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )
-{
- if (!m_pCheckPath) {
- initCheckPath(pRtSign->width);
- }
- CFX_Matrix mt;
- mt.Reset();
- mt.Translate(pRtSign->left, pRtSign->top);
- mt.Concat(*pMatrix);
- CFX_Color crFill(argbFill);
- pGraphics->SaveGraphState();
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt);
- pGraphics->RestoreGraphState();
+void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ FX_ARGB argbFill,
+ CFX_Matrix* pMatrix) {
+ if (!m_pCheckPath) {
+ initCheckPath(pRtSign->width);
+ }
+ CFX_Matrix mt;
+ mt.Reset();
+ mt.Translate(pRtSign->left, pRtSign->top);
+ mt.Concat(*pMatrix);
+ CFX_Color crFill(argbFill);
+ pGraphics->SaveGraphState();
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt);
+ pGraphics->RestoreGraphState();
}
-void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- path.AddEllipse(*pRtSign);
- CFX_Color crFill(argbFill);
- pGraphics->SaveGraphState();
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
+void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ FX_ARGB argbFill,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ path.AddEllipse(*pRtSign);
+ CFX_Color crFill(argbFill);
+ pGraphics->SaveGraphState();
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
}
-void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- FX_FLOAT fRight = pRtSign->right();
- FX_FLOAT fBottom = pRtSign->bottom();
- path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom);
- path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top);
- CFX_Color crFill(argbFill);
- pGraphics->SaveGraphState();
- pGraphics->SetStrokeColor(&crFill);
- pGraphics->SetLineWidth(1.0f);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
+void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ FX_ARGB argbFill,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fRight = pRtSign->right();
+ FX_FLOAT fBottom = pRtSign->bottom();
+ path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom);
+ path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top);
+ CFX_Color crFill(argbFill);
+ pGraphics->SaveGraphState();
+ pGraphics->SetStrokeColor(&crFill);
+ pGraphics->SetLineWidth(1.0f);
+ pGraphics->StrokePath(&path, pMatrix);
+ pGraphics->RestoreGraphState();
}
-void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- FX_FLOAT fWidth = pRtSign->width;
- FX_FLOAT fHeight = pRtSign->height;
- FX_FLOAT fBottom = pRtSign->bottom();
- path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top);
- path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2);
- path.LineTo(pRtSign->left + fWidth / 2, fBottom);
- path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2);
- path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top);
- CFX_Color crFill(argbFill);
- pGraphics->SaveGraphState();
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
+void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ FX_ARGB argbFill,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fWidth = pRtSign->width;
+ FX_FLOAT fHeight = pRtSign->height;
+ FX_FLOAT fBottom = pRtSign->bottom();
+ path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top);
+ path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2);
+ path.LineTo(pRtSign->left + fWidth / 2, fBottom);
+ path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2);
+ path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top);
+ CFX_Color crFill(argbFill);
+ pGraphics->SaveGraphState();
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
}
-void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, pRtSign->height);
- CFX_Color crFill(argbFill);
- pGraphics->SaveGraphState();
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
+void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ FX_ARGB argbFill,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width,
+ pRtSign->height);
+ CFX_Color crFill(argbFill);
+ pGraphics->SaveGraphState();
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
}
-void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics *pGraphics, const CFX_RectF *pRtSign, FX_ARGB argbFill, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- FX_FLOAT fBottom = pRtSign->bottom();
- FX_FLOAT fRadius = (pRtSign->top - fBottom) / ( 1 + (FX_FLOAT)cos(FX_PI / 5.0f));
- CFX_PointF ptCenter;
- ptCenter.Set((pRtSign->left + pRtSign->right()) / 2.0f, (pRtSign->top + fBottom) / 2.0f);
- FX_FLOAT px[5], py[5];
- FX_FLOAT fAngel = FX_PI / 10.0f;
- for (int32_t i = 0; i < 5; i++) {
- px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
- py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
- fAngel += FX_PI * 2 / 5.0f;
+void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtSign,
+ FX_ARGB argbFill,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fBottom = pRtSign->bottom();
+ FX_FLOAT fRadius =
+ (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f));
+ CFX_PointF ptCenter;
+ ptCenter.Set((pRtSign->left + pRtSign->right()) / 2.0f,
+ (pRtSign->top + fBottom) / 2.0f);
+ FX_FLOAT px[5], py[5];
+ FX_FLOAT fAngel = FX_PI / 10.0f;
+ for (int32_t i = 0; i < 5; i++) {
+ px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
+ py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
+ fAngel += FX_PI * 2 / 5.0f;
+ }
+ path.MoveTo(px[0], py[0]);
+ int32_t nNext = 0;
+ for (int32_t j = 0; j < 5; j++) {
+ nNext += 2;
+ if (nNext >= 5) {
+ nNext -= 5;
}
- path.MoveTo(px[0], py[0]);
- int32_t nNext = 0;
- for (int32_t j = 0; j < 5; j++) {
- nNext += 2;
- if (nNext >= 5) {
- nNext -= 5;
- }
- path.LineTo(px[nNext], py[nNext]);
- }
- CFX_Color crFill(argbFill);
- pGraphics->SaveGraphState();
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
+ path.LineTo(px[nNext], py[nNext]);
+ }
+ CFX_Color crFill(argbFill);
+ pGraphics->SaveGraphState();
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
}
-void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget *pWidget, CFX_Graphics *pGraphics, const CFX_RectF *pRtBox, FX_BOOL bDisable , CFX_Matrix *pMatrix )
-{
- switch(pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) {
- case FWL_STYLEEXT_CKB_ShapeSolidSquare: {
- DrawAnnulusRect(pGraphics,
- bDisable ? m_pThemeData->clrSignBorderDisable : m_pThemeData->clrSignBorderNormal,
- pRtBox,
- 1,
- pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_ShapeSunkenSquare: {
- Draw3DRect(pGraphics,
- FWLTHEME_EDGE_Sunken,
- CHECKBOX_SIZE_SIGNBORDER,
- pRtBox,
- CHECKBOX_COLOR_BOXLT1,
- CHECKBOX_COLOR_BOXLT2,
- CHECKBOX_COLOR_BOXRB1,
- CHECKBOX_COLOR_BOXRB2,
- pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_ShapeSolidCircle: {
- DrawAnnulusCircle(pGraphics,
- bDisable ? m_pThemeData->clrSignBorderDisable : m_pThemeData->clrSignBorderNormal,
- pRtBox,
- 1,
- pMatrix);
- break;
- }
- case FWL_STYLEEXT_CKB_ShapeSunkenCircle: {
- Draw3DCircle(pGraphics,
- FWLTHEME_EDGE_Sunken,
- CHECKBOX_SIZE_SIGNBORDER,
- pRtBox,
- CHECKBOX_COLOR_BOXLT1,
- CHECKBOX_COLOR_BOXLT2,
- CHECKBOX_COLOR_BOXRB1,
- CHECKBOX_COLOR_BOXRB2,
- pMatrix);
- break;
- }
+void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_RectF* pRtBox,
+ FX_BOOL bDisable,
+ CFX_Matrix* pMatrix) {
+ switch (pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) {
+ case FWL_STYLEEXT_CKB_ShapeSolidSquare: {
+ DrawAnnulusRect(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable
+ : m_pThemeData->clrSignBorderNormal,
+ pRtBox, 1, pMatrix);
+ break;
}
-}
-void CFWL_CheckBoxTP::SetThemeData(FX_DWORD dwID)
-{
- FX_DWORD *pData = (FX_DWORD*)&m_pThemeData->clrBoxBk;
- if (dwID) {
- *pData++ = 0, *pData++ = 0, \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114);
- m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187);
- m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138);
- m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26);
- m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113);
- m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33);
- m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26);
- } else {
- *pData++ = 0, *pData++ = 0, \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128);
- m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187);
- m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128);
- m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26);
- m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113);
- m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33);
- m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26);
+ case FWL_STYLEEXT_CKB_ShapeSunkenSquare: {
+ Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER,
+ pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
+ CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix);
+ break;
}
-}
-void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen)
-{
- if (!m_pCheckPath) {
- m_pCheckPath = FX_NEW CFX_Path;
- m_pCheckPath->Create();
- FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT px1, py1, px2, py2;
- CFX_PointF pt1;
- pt1.Set(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);
- CFX_PointF pt2;
- pt2.Set(fWidth / 4.5f, fBottom + fHeight / 16.0f);
- CFX_PointF pt3;
- pt3.Set(fWidth / 3.0f, fBottom);
- CFX_PointF pt4;
- pt4.Set(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f);
- CFX_PointF pt5;
- pt5.Set(fWidth / 3.6f, fBottom + fHeight / 3.5f);
- CFX_PointF pt12;
- pt12.Set(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f);
- CFX_PointF pt21;
- pt21.Set(fWidth / 5.0f, fBottom + fHeight / 5.0f);
- CFX_PointF pt23;
- pt23.Set(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f);
- CFX_PointF pt32;
- pt32.Set(fWidth / 4.0f, fBottom);
- CFX_PointF pt34;
- pt34.Set(fWidth * (1 / 7.0f + 7 / 15.0f), fBottom + fHeight * 4 / 5.0f);
- CFX_PointF pt43;
- pt43.Set(fWidth * (1 / 7.0f + 7 / 15.0f), fBottom + fHeight * 4 / 5.0f);
- CFX_PointF pt45;
- pt45.Set(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f);
- CFX_PointF pt54;
- pt54.Set(fWidth / 3.4f, fBottom + fHeight / 3.5f);
- CFX_PointF pt51;
- pt51.Set(fWidth / 3.6f, fBottom + fHeight / 4.0f);
- CFX_PointF pt15;
- pt15.Set(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f);
- m_pCheckPath->MoveTo(pt1.x, pt1.y);
- px1 = pt12.x - pt1.x;
- py1 = pt12.y - pt1.y;
- px2 = pt21.x - pt2.x;
- py2 = pt21.y - pt2.y;
- m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER, pt1.y + py1 * FWLTHEME_BEZIER,
- pt2.x + px2 * FWLTHEME_BEZIER, pt2.y + py2 * FWLTHEME_BEZIER,
- pt2.x, pt2.y);
- px1 = pt23.x - pt2.x;
- py1 = pt23.y - pt2.y;
- px2 = pt32.x - pt3.x;
- py2 = pt32.y - pt3.y;
- m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER, pt2.y + py1 * FWLTHEME_BEZIER,
- pt3.x + px2 * FWLTHEME_BEZIER, pt3.y + py2 * FWLTHEME_BEZIER,
- pt3.x, pt3.y);
- px1 = pt34.x - pt3.x;
- py1 = pt34.y - pt3.y;
- px2 = pt43.x - pt4.x;
- py2 = pt43.y - pt4.y;
- m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER, pt3.y + py1 * FWLTHEME_BEZIER,
- pt4.x + px2 * FWLTHEME_BEZIER, pt4.y + py2 * FWLTHEME_BEZIER,
- pt4.x, pt4.y);
- px1 = pt45.x - pt4.x;
- py1 = pt45.y - pt4.y;
- px2 = pt54.x - pt5.x;
- py2 = pt54.y - pt5.y;
- m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER, pt4.y + py1 * FWLTHEME_BEZIER,
- pt5.x + px2 * FWLTHEME_BEZIER, pt5.y + py2 * FWLTHEME_BEZIER,
- pt5.x, pt5.y);
- px1 = pt51.x - pt5.x;
- py1 = pt51.y - pt5.y;
- px2 = pt15.x - pt1.x;
- py2 = pt15.y - pt1.y;
- m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER, pt5.y + py1 * FWLTHEME_BEZIER,
- pt1.x + px2 * FWLTHEME_BEZIER, pt1.y + py2 * FWLTHEME_BEZIER,
- pt1.x, pt1.y);
- FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH;
- CFX_AffineMatrix mt;
- mt.Set(1, 0, 0, 1, 0, 0);
- mt.Scale(fScale, fScale);
- CFX_PathData *pData = m_pCheckPath->GetPathData();
- pData->Transform(&mt);
+ case FWL_STYLEEXT_CKB_ShapeSolidCircle: {
+ DrawAnnulusCircle(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable
+ : m_pThemeData->clrSignBorderNormal,
+ pRtBox, 1, pMatrix);
+ break;
+ }
+ case FWL_STYLEEXT_CKB_ShapeSunkenCircle: {
+ Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER,
+ pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
+ CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix);
+ break;
}
+ }
+}
+void CFWL_CheckBoxTP::SetThemeData(FX_DWORD dwID) {
+ FX_DWORD* pData = (FX_DWORD*)&m_pThemeData->clrBoxBk;
+ if (dwID) {
+ *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114);
+ m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187);
+ m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138);
+ m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26);
+ m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113);
+ m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33);
+ m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26);
+ } else {
+ *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128);
+ m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187);
+ m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128);
+ m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26);
+ m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113);
+ m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33);
+ m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26);
+ }
+}
+void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) {
+ if (!m_pCheckPath) {
+ m_pCheckPath = FX_NEW CFX_Path;
+ m_pCheckPath->Create();
+ FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH;
+ FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH;
+ FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH;
+ FX_FLOAT px1, py1, px2, py2;
+ CFX_PointF pt1;
+ pt1.Set(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);
+ CFX_PointF pt2;
+ pt2.Set(fWidth / 4.5f, fBottom + fHeight / 16.0f);
+ CFX_PointF pt3;
+ pt3.Set(fWidth / 3.0f, fBottom);
+ CFX_PointF pt4;
+ pt4.Set(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f);
+ CFX_PointF pt5;
+ pt5.Set(fWidth / 3.6f, fBottom + fHeight / 3.5f);
+ CFX_PointF pt12;
+ pt12.Set(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f);
+ CFX_PointF pt21;
+ pt21.Set(fWidth / 5.0f, fBottom + fHeight / 5.0f);
+ CFX_PointF pt23;
+ pt23.Set(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f);
+ CFX_PointF pt32;
+ pt32.Set(fWidth / 4.0f, fBottom);
+ CFX_PointF pt34;
+ pt34.Set(fWidth * (1 / 7.0f + 7 / 15.0f), fBottom + fHeight * 4 / 5.0f);
+ CFX_PointF pt43;
+ pt43.Set(fWidth * (1 / 7.0f + 7 / 15.0f), fBottom + fHeight * 4 / 5.0f);
+ CFX_PointF pt45;
+ pt45.Set(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f);
+ CFX_PointF pt54;
+ pt54.Set(fWidth / 3.4f, fBottom + fHeight / 3.5f);
+ CFX_PointF pt51;
+ pt51.Set(fWidth / 3.6f, fBottom + fHeight / 4.0f);
+ CFX_PointF pt15;
+ pt15.Set(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f);
+ m_pCheckPath->MoveTo(pt1.x, pt1.y);
+ px1 = pt12.x - pt1.x;
+ py1 = pt12.y - pt1.y;
+ px2 = pt21.x - pt2.x;
+ py2 = pt21.y - pt2.y;
+ m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER,
+ pt1.y + py1 * FWLTHEME_BEZIER,
+ pt2.x + px2 * FWLTHEME_BEZIER,
+ pt2.y + py2 * FWLTHEME_BEZIER, pt2.x, pt2.y);
+ px1 = pt23.x - pt2.x;
+ py1 = pt23.y - pt2.y;
+ px2 = pt32.x - pt3.x;
+ py2 = pt32.y - pt3.y;
+ m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER,
+ pt2.y + py1 * FWLTHEME_BEZIER,
+ pt3.x + px2 * FWLTHEME_BEZIER,
+ pt3.y + py2 * FWLTHEME_BEZIER, pt3.x, pt3.y);
+ px1 = pt34.x - pt3.x;
+ py1 = pt34.y - pt3.y;
+ px2 = pt43.x - pt4.x;
+ py2 = pt43.y - pt4.y;
+ m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER,
+ pt3.y + py1 * FWLTHEME_BEZIER,
+ pt4.x + px2 * FWLTHEME_BEZIER,
+ pt4.y + py2 * FWLTHEME_BEZIER, pt4.x, pt4.y);
+ px1 = pt45.x - pt4.x;
+ py1 = pt45.y - pt4.y;
+ px2 = pt54.x - pt5.x;
+ py2 = pt54.y - pt5.y;
+ m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER,
+ pt4.y + py1 * FWLTHEME_BEZIER,
+ pt5.x + px2 * FWLTHEME_BEZIER,
+ pt5.y + py2 * FWLTHEME_BEZIER, pt5.x, pt5.y);
+ px1 = pt51.x - pt5.x;
+ py1 = pt51.y - pt5.y;
+ px2 = pt15.x - pt1.x;
+ py2 = pt15.y - pt1.y;
+ m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER,
+ pt5.y + py1 * FWLTHEME_BEZIER,
+ pt1.x + px2 * FWLTHEME_BEZIER,
+ pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y);
+ FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH;
+ CFX_AffineMatrix mt;
+ mt.Set(1, 0, 0, 1, 0, 0);
+ mt.Scale(fScale, fScale);
+ CFX_PathData* pData = m_pCheckPath->GetPathData();
+ pData->Transform(&mt);
+ }
}
diff --git a/xfa/src/fwl/src/theme/comboboxtp.cpp b/xfa/src/fwl/src/theme/comboboxtp.cpp index 28a1958f58..e60ab476a4 100644 --- a/xfa/src/fwl/src/theme/comboboxtp.cpp +++ b/xfa/src/fwl/src/theme/comboboxtp.cpp @@ -5,143 +5,145 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define FWLTHEME_CAPACITY_ComboFormHandler 8.0f
-CFWL_ComboBoxTP::CFWL_ComboBoxTP()
-{
- m_dwThemeID = 0;
+#define FWLTHEME_CAPACITY_ComboFormHandler 8.0f
+CFWL_ComboBoxTP::CFWL_ComboBoxTP() {
+ m_dwThemeID = 0;
}
-CFWL_ComboBoxTP::~CFWL_ComboBoxTP()
-{
+CFWL_ComboBoxTP::~CFWL_ComboBoxTP() {}
+FX_BOOL CFWL_ComboBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_ComboBox;
}
-FX_BOOL CFWL_ComboBoxTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_ComboBox;
-}
-FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_CMB_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_CMB_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_CMB_Background: {
- CFX_Path path;
- path.Create();
- CFX_RectF & rect = pParams->m_rtPart;
- path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
- CFX_Color cr;
- switch(pParams->m_dwStates) {
- case FWL_PARTSTATE_CMB_Selected:
- cr = FWLTHEME_COLOR_BKSelected;
- break;
- case FWL_PARTSTATE_CMB_Disabled:
- cr = FWLTHEME_COLOR_EDGERB1;
- break;
- default:
- cr = 0xFFFFFFFF;
- }
- pParams->m_pGraphics->SaveGraphState();
- pParams->m_pGraphics->SetFillColor(&cr);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
- pParams->m_pGraphics->RestoreGraphState();
- break;
- }
- case FWL_PART_CMB_DropDownButton: {
- DrawDropDownButton(pParams, pParams->m_dwStates, &pParams->m_matrix);
- break;
- }
- case FWL_PART_CMB_StretcgHandler: {
- DrawStrethHandler(pParams, 0, &pParams->m_matrix);
- break;
- }
- default: {
- return FALSE;
- }
+FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_CMB_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_CMB_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_CMB_Background: {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF& rect = pParams->m_rtPart;
+ path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
+ CFX_Color cr;
+ switch (pParams->m_dwStates) {
+ case FWL_PARTSTATE_CMB_Selected:
+ cr = FWLTHEME_COLOR_BKSelected;
+ break;
+ case FWL_PARTSTATE_CMB_Disabled:
+ cr = FWLTHEME_COLOR_EDGERB1;
+ break;
+ default:
+ cr = 0xFFFFFFFF;
+ }
+ pParams->m_pGraphics->SaveGraphState();
+ pParams->m_pGraphics->SetFillColor(&cr);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ break;
}
- return TRUE;
+ case FWL_PART_CMB_DropDownButton: {
+ DrawDropDownButton(pParams, pParams->m_dwStates, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_CMB_StretcgHandler: {
+ DrawStrethHandler(pParams, 0, &pParams->m_matrix);
+ break;
+ }
+ default: { return FALSE; }
+ }
+ return TRUE;
}
-void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground *pParams, FX_DWORD dwStates, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- path.AddRectangle(pParams->m_rtPart.left,
- pParams->m_rtPart.top,
- pParams->m_rtPart.width - 1,
- pParams->m_rtPart.height);
- CFX_Color cr(ArgbEncode(0xff, 0xff, 0, 0));
- pParams->m_pGraphics->SetFillColor(&cr);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
+void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams,
+ FX_DWORD dwStates,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top,
+ pParams->m_rtPart.width - 1, pParams->m_rtPart.height);
+ CFX_Color cr(ArgbEncode(0xff, 0xff, 0, 0));
+ pParams->m_pGraphics->SetFillColor(&cr);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
}
-void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- if (dwCapacity == FWL_WGTCAPACITY_CMB_ComboFormHandler) {
- m_fValue = FWLTHEME_CAPACITY_ComboFormHandler;
- return &m_fValue;
- }
- return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
+void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ if (dwCapacity == FWL_WGTCAPACITY_CMB_ComboFormHandler) {
+ m_fValue = FWLTHEME_CAPACITY_ComboFormHandler;
+ return &m_fValue;
+ }
+ return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
#ifdef THEME_XPSimilar
-void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground *pParams, FX_DWORD dwStates, CFX_Matrix *pMatrix)
-{
- FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
- switch ( dwStates) {
- case FWL_PARTSTATE_CMB_Normal: {
- eState = FWLTHEME_STATE_Normal;
- break;
- }
- case FWL_PARTSTATE_CMB_Hovered: {
- eState = FWLTHEME_STATE_Hover;
- break;
- }
- case FWL_PARTSTATE_CMB_Pressed: {
- eState = FWLTHEME_STATE_Pressed;
- break;
- }
- case FWL_PARTSTATE_CMB_Disabled: {
- eState = FWLTHEME_STATE_Disabale;
- break;
- }
- default: {
- }
+void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
+ FX_DWORD dwStates,
+ CFX_Matrix* pMatrix) {
+ FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
+ switch (dwStates) {
+ case FWL_PARTSTATE_CMB_Normal: {
+ eState = FWLTHEME_STATE_Normal;
+ break;
}
- DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, eState, &pParams->m_matrix);
+ case FWL_PARTSTATE_CMB_Hovered: {
+ eState = FWLTHEME_STATE_Hover;
+ break;
+ }
+ case FWL_PARTSTATE_CMB_Pressed: {
+ eState = FWLTHEME_STATE_Pressed;
+ break;
+ }
+ case FWL_PARTSTATE_CMB_Disabled: {
+ eState = FWLTHEME_STATE_Disabale;
+ break;
+ }
+ default: {}
+ }
+ DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
+ FWLTHEME_DIRECTION_Down, eState, &pParams->m_matrix);
}
#else
-void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground *pParams, FX_DWORD dwStates, CFX_Matrix *pMatrix)
-{
- FX_BOOL bPressed = ((pParams->m_dwStates & FWL_CMBPARTSTATE_Pressed) == FWL_CMBPARTSTATE_Pressed);
- FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f;
- FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
- Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pParams->m_rtPart.left + fWidth, pParams->m_rtPart.top + fWidth, pParams->m_rtPart.width - 2 * fWidth, pParams->m_rtPart.height - 2 * fWidth);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pParams->m_pGraphics->SetFillColor(&crFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
- pParams->m_pGraphics->RestoreGraphState();
- FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133);
- switch(pParams->m_dwStates & 0x03) {
- case FWL_CMBPARTSTATE_Normal: {
- }
- case FWL_CMBPARTSTATE_Hovered: {
- }
- case FWL_CMBPARTSTATE_Pressed: {
- argbFill = 0xFF000000;
- break;
- }
- case FWL_CMBPARTSTATE_Disabled: {
- argbFill = 0xFFF0F0F0;
- break;
- }
+void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
+ FX_DWORD dwStates,
+ CFX_Matrix* pMatrix) {
+ FX_BOOL bPressed = ((pParams->m_dwStates & FWL_CMBPARTSTATE_Pressed) ==
+ FWL_CMBPARTSTATE_Pressed);
+ FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f;
+ FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
+ Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart,
+ FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2,
+ FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pParams->m_rtPart.left + fWidth,
+ pParams->m_rtPart.top + fWidth,
+ pParams->m_rtPart.width - 2 * fWidth,
+ pParams->m_rtPart.height - 2 * fWidth);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color crFill(FWLTHEME_COLOR_Background);
+ pParams->m_pGraphics->SetFillColor(&crFill);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133);
+ switch (pParams->m_dwStates & 0x03) {
+ case FWL_CMBPARTSTATE_Normal: {
+ }
+ case FWL_CMBPARTSTATE_Hovered: {
+ }
+ case FWL_CMBPARTSTATE_Pressed: {
+ argbFill = 0xFF000000;
+ break;
+ }
+ case FWL_CMBPARTSTATE_Disabled: {
+ argbFill = 0xFFF0F0F0;
+ break;
}
- DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, argbFill, bPressed, &pParams->m_matrix);
+ }
+ DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down,
+ argbFill, bPressed, &pParams->m_matrix);
}
#endif
diff --git a/xfa/src/fwl/src/theme/datetimepickertp.cpp b/xfa/src/fwl/src/theme/datetimepickertp.cpp index bc94ee9db1..70d31255b6 100644 --- a/xfa/src/fwl/src/theme/datetimepickertp.cpp +++ b/xfa/src/fwl/src/theme/datetimepickertp.cpp @@ -5,116 +5,129 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_DateTimePickerTP::CFWL_DateTimePickerTP()
-{
- m_pThemeData = FX_NEW DTPThemeData;
- initThemeData();
+CFWL_DateTimePickerTP::CFWL_DateTimePickerTP() {
+ m_pThemeData = FX_NEW DTPThemeData;
+ initThemeData();
}
-CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP()
-{
- delete m_pThemeData;
+CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP() {
+ delete m_pThemeData;
}
-FX_BOOL CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_DateTimePicker;
+FX_BOOL CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_DateTimePicker;
}
-FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_DTP_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_DTP_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_DTP_DropDownButton: {
- DrawDropDownButton(pParams, &pParams->m_matrix);
- break;
- }
- default: {
- }
+FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_DTP_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
}
- return TRUE;
+ case FWL_PART_DTP_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_DTP_DropDownButton: {
+ DrawDropDownButton(pParams, &pParams->m_matrix);
+ break;
+ }
+ default: {}
+ }
+ return TRUE;
}
#ifdef THEME_XPSimilar
-void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- FX_DWORD dwStates = pParams->m_dwStates;
- dwStates &= 0x03;
- FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
- switch (eState & dwStates) {
- case FWL_PARTSTATE_DTP_Normal: {
- eState = FWLTHEME_STATE_Normal;
- break;
- }
- case FWL_PARTSTATE_DTP_Hovered: {
- eState = FWLTHEME_STATE_Hover;
- break;
- }
- case FWL_PARTSTATE_DTP_Pressed: {
- eState = FWLTHEME_STATE_Pressed;
- break;
- }
- case FWL_PARTSTATE_DTP_Disabled: {
- eState = FWLTHEME_STATE_Disabale;
- break;
- }
- default: {
- }
+void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ FX_DWORD dwStates = pParams->m_dwStates;
+ dwStates &= 0x03;
+ FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
+ switch (eState & dwStates) {
+ case FWL_PARTSTATE_DTP_Normal: {
+ eState = FWLTHEME_STATE_Normal;
+ break;
+ }
+ case FWL_PARTSTATE_DTP_Hovered: {
+ eState = FWLTHEME_STATE_Hover;
+ break;
+ }
+ case FWL_PARTSTATE_DTP_Pressed: {
+ eState = FWLTHEME_STATE_Pressed;
+ break;
}
- DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, eState, pMatrix);
+ case FWL_PARTSTATE_DTP_Disabled: {
+ eState = FWLTHEME_STATE_Disabale;
+ break;
+ }
+ default: {}
+ }
+ DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
+ FWLTHEME_DIRECTION_Down, eState, pMatrix);
}
#else
-void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- FX_BOOL bPressed = ((pParams->m_dwStates & FWL_PARTSTATE_DTP_Pressed) == FWL_PARTSTATE_DTP_Pressed);
- FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f;
- FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
- Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pParams->m_rtPart.left + fWidth, pParams->m_rtPart.top + fWidth, pParams->m_rtPart.width - 2 * fWidth, pParams->m_rtPart.height - 2 * fWidth);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pParams->m_pGraphics->SetFillColor(&crFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133);
- switch(pParams->m_dwStates & 0x03) {
- case FWL_PARTSTATE_DTP_Normal: {
- }
- case FWL_PARTSTATE_DTP_Hovered: {
- }
- case FWL_PARTSTATE_DTP_Pressed: {
- argbFill = 0xFF000000;
- break;
- }
- case FWL_PARTSTATE_DTP_Disabled: {
- argbFill = 0xFFF0F0F0;
- break;
- }
+void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ FX_BOOL bPressed = ((pParams->m_dwStates & FWL_PARTSTATE_DTP_Pressed) ==
+ FWL_PARTSTATE_DTP_Pressed);
+ FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f;
+ FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
+ Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart,
+ FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2,
+ FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pParams->m_rtPart.left + fWidth,
+ pParams->m_rtPart.top + fWidth,
+ pParams->m_rtPart.width - 2 * fWidth,
+ pParams->m_rtPart.height - 2 * fWidth);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color crFill(FWLTHEME_COLOR_Background);
+ pParams->m_pGraphics->SetFillColor(&crFill);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133);
+ switch (pParams->m_dwStates & 0x03) {
+ case FWL_PARTSTATE_DTP_Normal: {
+ }
+ case FWL_PARTSTATE_DTP_Hovered: {
+ }
+ case FWL_PARTSTATE_DTP_Pressed: {
+ argbFill = 0xFF000000;
+ break;
+ }
+ case FWL_PARTSTATE_DTP_Disabled: {
+ argbFill = 0xFFF0F0F0;
+ break;
}
- DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, argbFill, bPressed, pMatrix);
+ }
+ DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down,
+ argbFill, bPressed, pMatrix);
}
#endif
-void CFWL_DateTimePickerTP::initThemeData()
-{
- FX_DWORD *pData = (FX_DWORD*)&m_pThemeData->BoxBkColor;
- *pData++ = 0, *pData++ = 0, \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 220, 220, 215), *pData++ = ArgbEncode(255, 255, 255, 255), \
- *pData++ = ArgbEncode(255, 255, 240, 207), *pData++ = ArgbEncode(255, 248, 179, 48), \
- *pData++ = ArgbEncode(255, 176, 176, 167), *pData++ = ArgbEncode(255, 241, 239, 239), \
- *pData++ = ArgbEncode(255, 255, 255, 255), *pData++ = ArgbEncode(255, 255, 255, 255);
+void CFWL_DateTimePickerTP::initThemeData() {
+ FX_DWORD* pData = (FX_DWORD*)&m_pThemeData->BoxBkColor;
+ *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 220, 220, 215),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 240, 207),
+ *pData++ = ArgbEncode(255, 248, 179, 48),
+ *pData++ = ArgbEncode(255, 176, 176, 167),
+ *pData++ = ArgbEncode(255, 241, 239, 239),
+ *pData++ = ArgbEncode(255, 255, 255, 255),
+ *pData++ = ArgbEncode(255, 255, 255, 255);
}
diff --git a/xfa/src/fwl/src/theme/edittp.cpp b/xfa/src/fwl/src/theme/edittp.cpp index 57a96bcb50..155cf57fc4 100644 --- a/xfa/src/fwl/src/theme/edittp.cpp +++ b/xfa/src/fwl/src/theme/edittp.cpp @@ -5,80 +5,79 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_EditTP::CFWL_EditTP()
-{
+CFWL_EditTP::CFWL_EditTP() {}
+CFWL_EditTP::~CFWL_EditTP() {}
+FX_BOOL CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_Edit;
}
-CFWL_EditTP::~CFWL_EditTP()
-{
-}
-FX_BOOL CFWL_EditTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_Edit;
-}
-FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- switch(pParams->m_iPart) {
- case FWL_PART_EDT_Border: {
- DrawBorder(pParams->m_pGraphics, & pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_EDT_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_EDT_Background: {
- if (pParams->m_pPath) {
- CFX_Graphics *pGraphics = pParams->m_pGraphics;
- pGraphics->SaveGraphState();
- CFX_Color crSelected(FWL_GetThemeColor(m_dwThemeID) == 0 ? FWLTHEME_COLOR_BKSelected : FWLTHEME_COLOR_Green_BKSelected);
- pGraphics->SetFillColor(&crSelected);
- pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING, &pParams->m_matrix);
- pGraphics->RestoreGraphState();
- } else {
- FX_BOOL bStatic = pParams->m_dwData == FWL_PARTDATA_EDT_StaticBackground;
- CFX_Path path;
- path.Create();
- path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, pParams->m_rtPart.width, pParams->m_rtPart.height);
- CFX_Color cr(FWLTHEME_COLOR_Background);
- if (!bStatic) {
- if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_Disable) == FWL_PARTSTATE_EDT_Disable) {
- cr.Set(FWLTHEME_COLOR_EDGERB1);
- } else if((pParams->m_dwStates & FWL_PARTSTATE_EDT_ReadOnly) == FWL_PARTSTATE_EDT_ReadOnly) {
- cr.Set(ArgbEncode(255, 236, 233, 216));
- } else {
- cr.Set(0xFFFFFFFF);
- }
- }
- pParams->m_pGraphics->SaveGraphState();
- pParams->m_pGraphics->SetFillColor(&cr);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
- pParams->m_pGraphics->RestoreGraphState();
- }
- break;
- }
- case FWL_PART_EDT_CombTextLine: {
- FX_ARGB cr = 0xFF000000;
- FX_FLOAT fWidth = 1.0f;
- CFX_Color crLine(cr);
- pParams->m_pGraphics->SetStrokeColor(&crLine);
- pParams->m_pGraphics->SetLineWidth(fWidth);
- pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix);
- break;
- }
- default: {
- break;
- }
+FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ switch (pParams->m_iPart) {
+ case FWL_PART_EDT_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_EDT_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_EDT_Background: {
+ if (pParams->m_pPath) {
+ CFX_Graphics* pGraphics = pParams->m_pGraphics;
+ pGraphics->SaveGraphState();
+ CFX_Color crSelected(FWL_GetThemeColor(m_dwThemeID) == 0
+ ? FWLTHEME_COLOR_BKSelected
+ : FWLTHEME_COLOR_Green_BKSelected);
+ pGraphics->SetFillColor(&crSelected);
+ pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING,
+ &pParams->m_matrix);
+ pGraphics->RestoreGraphState();
+ } else {
+ FX_BOOL bStatic =
+ pParams->m_dwData == FWL_PARTDATA_EDT_StaticBackground;
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top,
+ pParams->m_rtPart.width, pParams->m_rtPart.height);
+ CFX_Color cr(FWLTHEME_COLOR_Background);
+ if (!bStatic) {
+ if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_Disable) ==
+ FWL_PARTSTATE_EDT_Disable) {
+ cr.Set(FWLTHEME_COLOR_EDGERB1);
+ } else if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_ReadOnly) ==
+ FWL_PARTSTATE_EDT_ReadOnly) {
+ cr.Set(ArgbEncode(255, 236, 233, 216));
+ } else {
+ cr.Set(0xFFFFFFFF);
+ }
+ }
+ pParams->m_pGraphics->SaveGraphState();
+ pParams->m_pGraphics->SetFillColor(&cr);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING,
+ &pParams->m_matrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ }
+ break;
+ }
+ case FWL_PART_EDT_CombTextLine: {
+ FX_ARGB cr = 0xFF000000;
+ FX_FLOAT fWidth = 1.0f;
+ CFX_Color crLine(cr);
+ pParams->m_pGraphics->SetStrokeColor(&crLine);
+ pParams->m_pGraphics->SetLineWidth(fWidth);
+ pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix);
+ break;
}
- return TRUE;
+ default: { break; }
+ }
+ return TRUE;
}
-FWL_ERR CFWL_EditTP::Initialize()
-{
- InitTTO();
- return CFWL_WidgetTP::Initialize();
+FWL_ERR CFWL_EditTP::Initialize() {
+ InitTTO();
+ return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_EditTP::Finalize()
-{
- FinalizeTTO();
- return CFWL_WidgetTP::Finalize();
+FWL_ERR CFWL_EditTP::Finalize() {
+ FinalizeTTO();
+ return CFWL_WidgetTP::Finalize();
}
diff --git a/xfa/src/fwl/src/theme/formtp.cpp b/xfa/src/fwl/src/theme/formtp.cpp index db152edea5..6bb372d127 100644 --- a/xfa/src/fwl/src/theme/formtp.cpp +++ b/xfa/src/fwl/src/theme/formtp.cpp @@ -5,792 +5,881 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define FWLTHEME_CAPACITY_CXFormBorder 3
-#define FWLTHEME_CAPACITY_CYFormBorder 3
-#define FWLTHEME_CAPACITY_CYNarrowCaption 18
-#define FWLTHEME_CAPACITY_CYCaption 29
-#define FWLTHEME_CAPACITY_BigIconSize 32
-#define FWLTHEME_CAPACITY_SmallIconSize 16
-#define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF
-#define FWLTHEME_FORMBTN_Margin 5
-#define FWLTHEME_FORMBTN_Span 2
-#define FWLTHEME_FORMBTN_Size 21
-CFWL_FormTP::CFWL_FormTP()
- : m_pActiveBitmap(NULL)
- , m_pDeactivebitmap(NULL)
-{
- m_pThemeData = FX_NEW SBThemeData;
- SetThemeData(0);
- m_rtDisLBorder.Reset();
- m_rtDisRBorder.Reset();
- m_rtDisBBorder.Reset();
- m_rtDisCaption.Reset();
+#define FWLTHEME_CAPACITY_CXFormBorder 3
+#define FWLTHEME_CAPACITY_CYFormBorder 3
+#define FWLTHEME_CAPACITY_CYNarrowCaption 18
+#define FWLTHEME_CAPACITY_CYCaption 29
+#define FWLTHEME_CAPACITY_BigIconSize 32
+#define FWLTHEME_CAPACITY_SmallIconSize 16
+#define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF
+#define FWLTHEME_FORMBTN_Margin 5
+#define FWLTHEME_FORMBTN_Span 2
+#define FWLTHEME_FORMBTN_Size 21
+CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) {
+ m_pThemeData = FX_NEW SBThemeData;
+ SetThemeData(0);
+ m_rtDisLBorder.Reset();
+ m_rtDisRBorder.Reset();
+ m_rtDisBBorder.Reset();
+ m_rtDisCaption.Reset();
}
-CFWL_FormTP::~CFWL_FormTP()
-{
- if (m_pThemeData) {
- delete m_pThemeData;
- m_pThemeData = NULL;
- }
+CFWL_FormTP::~CFWL_FormTP() {
+ if (m_pThemeData) {
+ delete m_pThemeData;
+ m_pThemeData = NULL;
+ }
}
-FWL_ERR CFWL_FormTP::Initialize()
-{
- InitTTO();
- InitCaption(TRUE);
- InitCaption(FALSE);
- return CFWL_WidgetTP::Initialize();
+FWL_ERR CFWL_FormTP::Initialize() {
+ InitTTO();
+ InitCaption(TRUE);
+ InitCaption(FALSE);
+ return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_FormTP::Finalize()
-{
- FinalizeTTO();
- if (m_pActiveBitmap) {
- delete m_pActiveBitmap;
- m_pActiveBitmap = NULL;
+FWL_ERR CFWL_FormTP::Finalize() {
+ FinalizeTTO();
+ if (m_pActiveBitmap) {
+ delete m_pActiveBitmap;
+ m_pActiveBitmap = NULL;
+ }
+ if (m_pDeactivebitmap) {
+ delete m_pDeactivebitmap;
+ m_pDeactivebitmap = NULL;
+ }
+ return CFWL_WidgetTP::Finalize();
+}
+FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ FX_DWORD dwHash = pWidget->GetClassID();
+ return dwHash == FWL_CLASSHASH_Form;
+}
+FX_DWORD CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ if (m_pThemeData) {
+ SetThemeData(FWL_GetThemeColor(dwThemeID));
+ }
+ InitCaption(TRUE);
+ InitCaption(FALSE);
+ return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
+}
+FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ int32_t iActive = 0;
+ if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) {
+ iActive = 1;
+ }
+ FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
+ switch (pParams->m_dwStates & 0x03) {
+ case FWL_PARTSTATE_FRM_Hover: {
+ eState = FWLTHEME_STATE_Hover;
+ break;
}
- if (m_pDeactivebitmap) {
- delete m_pDeactivebitmap;
- m_pDeactivebitmap = NULL;
+ case FWL_PARTSTATE_FRM_Pressed: {
+ eState = FWLTHEME_STATE_Pressed;
+ break;
+ }
+ case FWL_PARTSTATE_FRM_Disabled: {
+ eState = FWLTHEME_STATE_Disabale;
+ break;
+ }
+ default: {}
+ }
+ switch (pParams->m_iPart) {
+ case FWL_PART_FRM_Border: {
+ DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState,
+ &pParams->m_matrix, iActive);
+ break;
+ }
+ case FWL_PART_FRM_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_FRM_Background: {
+ FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
+ &pParams->m_matrix);
+ break;
}
- return CFWL_WidgetTP::Finalize();
+ case FWL_PART_FRM_Caption: {
+ DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState,
+ &pParams->m_matrix, iActive);
+ break;
+ }
+ case FWL_PART_FRM_NarrowCaption: {
+ DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState,
+ &pParams->m_matrix, iActive);
+ break;
+ }
+ case FWL_PART_FRM_CloseBox: {
+ DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
+ &pParams->m_matrix, iActive);
+ break;
+ }
+ case FWL_PART_FRM_MinimizeBox: {
+ DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
+ &pParams->m_matrix, iActive);
+ break;
+ }
+ case FWL_PART_FRM_MaximizeBox: {
+ DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
+ pParams->m_dwData, &pParams->m_matrix, iActive);
+ break;
+ }
+ case FWL_PART_FRM_Icon: {
+ DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart,
+ eState, &pParams->m_matrix, iActive);
+ break;
+ }
+ default: {}
+ }
+ return TRUE;
}
-FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- FX_DWORD dwHash = pWidget->GetClassID();
- return dwHash == FWL_CLASSHASH_Form;
+FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
+ if (pParams->m_iPart == FWL_PART_FRM_Caption) {
+ m_pTextOut->SetTextColor(0xFFFFFFFF);
+ } else {
+ m_pTextOut->SetTextColor(0xFF000000);
+ }
+ return CFWL_WidgetTP::DrawText(pParams);
}
-FX_DWORD CFWL_FormTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- if (m_pThemeData) {
- SetThemeData(FWL_GetThemeColor(dwThemeID));
+void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ FX_BOOL bDefPro = FALSE;
+ FX_BOOL bDwordVal = FALSE;
+ switch (dwCapacity) {
+ case FWL_WGTCAPACITY_CXBorder: {
+ m_fValue = FWLTHEME_CAPACITY_CXFormBorder;
+ break;
}
- InitCaption(TRUE);
- InitCaption(FALSE);
- return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
-}
-FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- int32_t iActive = 0;
- if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) {
- iActive = 1;
+ case FWL_WGTCAPACITY_CYBorder: {
+ m_fValue = FWLTHEME_CAPACITY_CYFormBorder;
+ break;
}
- FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
- switch (pParams->m_dwStates & 0x03) {
- case FWL_PARTSTATE_FRM_Hover: {
- eState = FWLTHEME_STATE_Hover;
- break;
- }
- case FWL_PARTSTATE_FRM_Pressed: {
- eState = FWLTHEME_STATE_Pressed;
- break;
- }
- case FWL_PARTSTATE_FRM_Disabled: {
- eState = FWLTHEME_STATE_Disabale;
- break;
- }
- default: {
- }
+ case FWL_WGTCAPACITY_FRM_CYCaption: {
+ m_fValue = FWLTHEME_CAPACITY_CYCaption;
+ break;
}
- switch(pParams->m_iPart) {
- case FWL_PART_FRM_Border: {
- DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState, &pParams->m_matrix, iActive);
- break;
- }
- case FWL_PART_FRM_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_FRM_Background: {
- FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_FRM_Caption: {
- DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, &pParams->m_matrix, iActive);
- break;
- }
- case FWL_PART_FRM_NarrowCaption: {
- DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, &pParams->m_matrix, iActive);
- break;
- }
- case FWL_PART_FRM_CloseBox: {
- DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, &pParams->m_matrix, iActive);
- break;
- }
- case FWL_PART_FRM_MinimizeBox: {
- DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, &pParams->m_matrix, iActive);
- break;
- }
- case FWL_PART_FRM_MaximizeBox: {
- DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, pParams->m_dwData, &pParams->m_matrix, iActive);
- break;
- }
- case FWL_PART_FRM_Icon: {
- DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart, eState, &pParams->m_matrix, iActive);
- break;
- }
- default: {
- }
+ case FWL_WGTCAPACITY_FRM_CYNarrowCaption: {
+ m_fValue = FWLTHEME_CAPACITY_CYCaption;
+ break;
}
- return TRUE;
-}
-FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
- if (pParams->m_iPart == FWL_PART_FRM_Caption) {
- m_pTextOut->SetTextColor(0xFFFFFFFF);
- } else {
- m_pTextOut->SetTextColor(0xFF000000);
+ case FWL_WGTCAPACITY_TextColor: {
+ bDwordVal = TRUE;
+ m_dwValue = FWLTHEME_CAPACITY_FormTextColor;
+ break;
}
- return CFWL_WidgetTP::DrawText(pParams);
-}
-void* CFWL_FormTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- FX_BOOL bDefPro = FALSE;
- FX_BOOL bDwordVal = FALSE;
- switch(dwCapacity) {
- case FWL_WGTCAPACITY_CXBorder: {
- m_fValue = FWLTHEME_CAPACITY_CXFormBorder;
- break;
- }
- case FWL_WGTCAPACITY_CYBorder: {
- m_fValue = FWLTHEME_CAPACITY_CYFormBorder;
- break;
- }
- case FWL_WGTCAPACITY_FRM_CYCaption: {
- m_fValue = FWLTHEME_CAPACITY_CYCaption;
- break;
- }
- case FWL_WGTCAPACITY_FRM_CYNarrowCaption: {
- m_fValue = FWLTHEME_CAPACITY_CYCaption;
- break;
- }
- case FWL_WGTCAPACITY_TextColor: {
- bDwordVal = TRUE;
- m_dwValue = FWLTHEME_CAPACITY_FormTextColor;
- break;
- }
- case FWL_WGTCAPACITY_FRM_BigIcon: {
- m_fValue = FWLTHEME_CAPACITY_BigIconSize;
- break;
- }
- case FWL_WGTCAPACITY_FRM_SmallIcon: {
- m_fValue = FWLTHEME_CAPACITY_SmallIconSize;
- break;
- }
- default: {
- bDefPro = TRUE;
- }
+ case FWL_WGTCAPACITY_FRM_BigIcon: {
+ m_fValue = FWLTHEME_CAPACITY_BigIconSize;
+ break;
}
- if (!bDefPro) {
- if (bDwordVal) {
- return &m_dwValue;
- }
- return &m_fValue;
+ case FWL_WGTCAPACITY_FRM_SmallIcon: {
+ m_fValue = FWLTHEME_CAPACITY_SmallIconSize;
+ break;
}
- return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
-}
-FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart *pThemePart, CFX_RectF& rtPart)
-{
- switch(pThemePart->m_iPart) {
- case FWL_PART_FRM_CloseBox: {
- CalCloseBox(pThemePart->m_pWidget, rtPart);
- break;
- }
- case FWL_PART_FRM_MaximizeBox: {
- CalMaxBox(pThemePart->m_pWidget, rtPart);
- break;
- }
- case FWL_PART_FRM_MinimizeBox: {
- CalMinBox(pThemePart->m_pWidget, rtPart);
- break;
- }
- case FWL_PART_FRM_HeadText: {
- CalCaption(pThemePart->m_pWidget, rtPart);
- break;
- }
- case FWL_PART_FRM_Icon: {
- CalIcon(pThemePart->m_pWidget, rtPart);
- break;
- }
- default: {
- }
+ default: { bDefPro = TRUE; }
+ }
+ if (!bDefPro) {
+ if (bDwordVal) {
+ return &m_dwValue;
}
- return FWL_ERR_Succeeded;
+ return &m_fValue;
+ }
+ return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-void CFWL_FormTP::CalCloseBox(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
- FX_DWORD dwStyles = pWidget->GetStyles();
- CFX_RectF rtWidget;
- pWidget->GetWidgetRect(rtWidget);
- rtWidget.Offset(-rtWidget.left, -rtWidget.top);
- if (dwStyles & FWL_WGTSTYLE_CloseBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
- rtWidget.top + FWLTHEME_FORMBTN_Margin,
- FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
- } else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
- rtWidget.top + FWLTHEME_FORMBTN_Margin,
- 0,
- 0);
+FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart,
+ CFX_RectF& rtPart) {
+ switch (pThemePart->m_iPart) {
+ case FWL_PART_FRM_CloseBox: {
+ CalCloseBox(pThemePart->m_pWidget, rtPart);
+ break;
}
-}
-void CFWL_FormTP::CalMaxBox(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
- FX_DWORD dwStyles = pWidget->GetStyles();
- CFX_RectF rtWidget;
- pWidget->GetWidgetRect(rtWidget);
- rtWidget.Offset(-rtWidget.left, -rtWidget.top);
- if (dwStyles & FWL_WGTSTYLE_MaximizeBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + FWLTHEME_FORMBTN_Span * 2,
- rtWidget.top + FWLTHEME_FORMBTN_Margin,
- FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
- } else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + FWLTHEME_FORMBTN_Span * 2,
- rtWidget.top + FWLTHEME_FORMBTN_Margin,
- 0,
- 0);
+ case FWL_PART_FRM_MaximizeBox: {
+ CalMaxBox(pThemePart->m_pWidget, rtPart);
+ break;
}
-}
-void CFWL_FormTP::CalMinBox(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
- FX_DWORD dwStyles = pWidget->GetStyles();
- CFX_RectF rtWidget;
- pWidget->GetWidgetRect(rtWidget);
- rtWidget.Offset(-rtWidget.left, -rtWidget.top);
- if (dwStyles & FWL_WGTSTYLE_MinimizeBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
- rtWidget.top + FWLTHEME_FORMBTN_Margin,
- FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
- } else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
- rtWidget.top + FWLTHEME_FORMBTN_Margin,
- 0,
- 0);
+ case FWL_PART_FRM_MinimizeBox: {
+ CalMinBox(pThemePart->m_pWidget, rtPart);
+ break;
+ }
+ case FWL_PART_FRM_HeadText: {
+ CalCaption(pThemePart->m_pWidget, rtPart);
+ break;
+ }
+ case FWL_PART_FRM_Icon: {
+ CalIcon(pThemePart->m_pWidget, rtPart);
+ break;
}
+ default: {}
+ }
+ return FWL_ERR_Succeeded;
}
-void CFWL_FormTP::CalCaption(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
- CFX_RectF rtWidget;
- pWidget->GetWidgetRect(rtWidget);
- rtWidget.Offset(-rtWidget.left, -rtWidget.top);
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin,
- rtWidget.top + FWLTHEME_FORMBTN_Margin - 2,
- rtWidget.width - FWLTHEME_FORMBTN_Margin * 2,
- FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4);
+void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
+ FX_DWORD dwStyles = pWidget->GetStyles();
+ CFX_RectF rtWidget;
+ pWidget->GetWidgetRect(rtWidget);
+ rtWidget.Offset(-rtWidget.left, -rtWidget.top);
+ if (dwStyles & FWL_WGTSTYLE_CloseBox) {
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
+ FWLTHEME_FORMBTN_Size);
+ } else {
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ }
}
-void CFWL_FormTP::CalIcon(IFWL_Widget *pWidget, CFX_RectF &rect)
-{
+void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
+ FX_DWORD dwStyles = pWidget->GetStyles();
+ CFX_RectF rtWidget;
+ pWidget->GetWidgetRect(rtWidget);
+ rtWidget.Offset(-rtWidget.left, -rtWidget.top);
+ if (dwStyles & FWL_WGTSTYLE_MaximizeBox) {
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
+ FWLTHEME_FORMBTN_Span * 2,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
+ FWLTHEME_FORMBTN_Size);
+ } else {
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
+ FWLTHEME_FORMBTN_Span * 2,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ }
}
-void CFWL_FormTP::DrawFormBorder(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
- CFX_RectF rt;
- rt.Set(pRect->left, pRect->top, 1, pRect->height);
- FX_FLOAT fBottom, fRight;
- fBottom = pRect->bottom();
- fRight = pRect->right();
- CFX_Path path;
- path.Create();
- CFX_Color clrLine;
- path.Clear();
- path.MoveTo(pRect->left, pRect->top);
- path.LineTo(pRect->left, fBottom - 1);
- path.LineTo(fRight - 1, fBottom - 1);
- path.LineTo(fRight - 1, pRect->top);
- clrLine = m_pThemeData->clrFormBorder[iActive][2];
- pGraphics->SetStrokeColor(&clrLine);
- pGraphics->StrokePath(&path, pMatrix);
- path.Clear();
- path.MoveTo(pRect->left + 1, pRect->top);
- path.LineTo(pRect->left + 1, fBottom - 2);
- path.LineTo(fRight - 2, fBottom - 2);
- path.LineTo(fRight - 2, pRect->top);
- clrLine = m_pThemeData->clrFormBorder[iActive][1];
- pGraphics->SetStrokeColor(&clrLine);
- pGraphics->StrokePath(&path, pMatrix);
- path.Clear();
- path.MoveTo(pRect->left + 2, pRect->top);
- path.LineTo(pRect->left + 2, fBottom - 3);
- path.LineTo(fRight - 3, fBottom - 3);
- path.LineTo(fRight - 3, pRect->top);
- clrLine = m_pThemeData->clrFormBorder[iActive][0];
- pGraphics->SetStrokeColor(&clrLine);
- pGraphics->StrokePath(&path, pMatrix);
- path.Clear();
- path.MoveTo(pRect->left + 3, pRect->top);
- path.LineTo(pRect->left + 3, fBottom - 4);
- path.LineTo(fRight - 4, fBottom - 4);
- path.LineTo(fRight - 4, pRect->top);
- clrLine = m_pThemeData->clrFormBorder[iActive][4];
- pGraphics->SetStrokeColor(&clrLine);
- pGraphics->StrokePath(&path, pMatrix);
- m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29);
- m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4, pRect->height - 29);
- m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4);
- m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29);
+void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
+ FX_DWORD dwStyles = pWidget->GetStyles();
+ CFX_RectF rtWidget;
+ pWidget->GetWidgetRect(rtWidget);
+ rtWidget.Offset(-rtWidget.left, -rtWidget.top);
+ if (dwStyles & FWL_WGTSTYLE_MinimizeBox) {
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
+ FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
+ FWLTHEME_FORMBTN_Size);
+ } else {
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
+ FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ }
}
-void CFWL_FormTP::DrawCaption(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
- CFX_RectF rt;
- FX_FLOAT fBottom, fRight;
- fBottom = pRect->bottom();
- fRight = pRect->right();
- rt.Set(pRect->left, pRect->top, pRect->width, 1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt, pMatrix);
- rt.Offset(0, 1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt, pMatrix);
- rt.Offset(0, 1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt, pMatrix);
- rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt, pMatrix);
- rt.Offset(0, -1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt, pMatrix);
- rt.Set(pRect->left, pRect->top, 1, pRect->height);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt, pMatrix);
- rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt, pMatrix);
- rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt, pMatrix);
- rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt, pMatrix);
- rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt, pMatrix);
- rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2);
- FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt, pMatrix);
- CFX_RectF rect(*pRect);
- rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5);
- if (iActive == 0) {
- pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix);
- } else {
- pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix);
- }
+void CFWL_FormTP::CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect) {
+ CFX_RectF rtWidget;
+ pWidget->GetWidgetRect(rtWidget);
+ rtWidget.Offset(-rtWidget.left, -rtWidget.top);
+ rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin,
+ rtWidget.top + FWLTHEME_FORMBTN_Margin - 2,
+ rtWidget.width - FWLTHEME_FORMBTN_Margin * 2,
+ FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4);
}
-void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
+void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {}
+void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ CFX_RectF rt;
+ rt.Set(pRect->left, pRect->top, 1, pRect->height);
+ FX_FLOAT fBottom, fRight;
+ fBottom = pRect->bottom();
+ fRight = pRect->right();
+ CFX_Path path;
+ path.Create();
+ CFX_Color clrLine;
+ path.Clear();
+ path.MoveTo(pRect->left, pRect->top);
+ path.LineTo(pRect->left, fBottom - 1);
+ path.LineTo(fRight - 1, fBottom - 1);
+ path.LineTo(fRight - 1, pRect->top);
+ clrLine = m_pThemeData->clrFormBorder[iActive][2];
+ pGraphics->SetStrokeColor(&clrLine);
+ pGraphics->StrokePath(&path, pMatrix);
+ path.Clear();
+ path.MoveTo(pRect->left + 1, pRect->top);
+ path.LineTo(pRect->left + 1, fBottom - 2);
+ path.LineTo(fRight - 2, fBottom - 2);
+ path.LineTo(fRight - 2, pRect->top);
+ clrLine = m_pThemeData->clrFormBorder[iActive][1];
+ pGraphics->SetStrokeColor(&clrLine);
+ pGraphics->StrokePath(&path, pMatrix);
+ path.Clear();
+ path.MoveTo(pRect->left + 2, pRect->top);
+ path.LineTo(pRect->left + 2, fBottom - 3);
+ path.LineTo(fRight - 3, fBottom - 3);
+ path.LineTo(fRight - 3, pRect->top);
+ clrLine = m_pThemeData->clrFormBorder[iActive][0];
+ pGraphics->SetStrokeColor(&clrLine);
+ pGraphics->StrokePath(&path, pMatrix);
+ path.Clear();
+ path.MoveTo(pRect->left + 3, pRect->top);
+ path.LineTo(pRect->left + 3, fBottom - 4);
+ path.LineTo(fRight - 4, fBottom - 4);
+ path.LineTo(fRight - 4, pRect->top);
+ clrLine = m_pThemeData->clrFormBorder[iActive][4];
+ pGraphics->SetStrokeColor(&clrLine);
+ pGraphics->StrokePath(&path, pMatrix);
+ m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29);
+ m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4,
+ pRect->height - 29);
+ m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4);
+ m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29);
}
-void CFWL_FormTP::DrawCloseBox(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
- FX_FLOAT fRight = pRect->right();
- FX_FLOAT fBottom = pRect->bottom();
- FX_FLOAT fWidth = pRect->width;
- FX_FLOAT fHeight = pRect->height;
- pGraphics->SaveGraphState();
- CFX_RectF rt(*pRect);
- pGraphics->SetLineWidth(1.0f);
+void CFWL_FormTP::DrawCaption(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ CFX_RectF rt;
+ FX_FLOAT fBottom, fRight;
+ fBottom = pRect->bottom();
+ fRight = pRect->right();
+ rt.Set(pRect->left, pRect->top, pRect->width, 1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt,
+ pMatrix);
+ rt.Offset(0, 1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt,
+ pMatrix);
+ rt.Offset(0, 1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt,
+ pMatrix);
+ rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt,
+ pMatrix);
+ rt.Offset(0, -1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt,
+ pMatrix);
+ rt.Set(pRect->left, pRect->top, 1, pRect->height);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt,
+ pMatrix);
+ rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt,
+ pMatrix);
+ rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt,
+ pMatrix);
+ rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt,
+ pMatrix);
+ rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt,
+ pMatrix);
+ rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2);
+ FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt,
+ pMatrix);
+ CFX_RectF rect(*pRect);
+ rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5);
+ if (iActive == 0) {
+ pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix);
+ } else {
+ pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix);
+ }
+}
+void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {}
+void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fBottom = pRect->bottom();
+ FX_FLOAT fWidth = pRect->width;
+ FX_FLOAT fHeight = pRect->height;
+ pGraphics->SaveGraphState();
+ CFX_RectF rt(*pRect);
+ pGraphics->SetLineWidth(1.0f);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1);
+ path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2);
+ path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2);
+ path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1);
+ CFX_Color crFill;
+ crFill = m_pThemeData->clrBtnEdgeOut[iActive];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1);
+ path.AddRectangle(fRight - 2, rt.top + 1, 1, 1);
+ path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1);
+ path.AddRectangle(fRight - 2, fBottom - 2, 1, 1);
+ crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1);
+ path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4);
+ crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4);
+ path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1);
+ crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4);
+ DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2,
+ fBottom - 2,
+ m_pThemeData->clrCloseBtBKStart[iActive][eState - 1],
+ m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path,
+ FXFILL_WINDING, pMatrix);
+ CFX_RectF rtX(*pRect);
+ rtX.Inflate(-5, -5);
+ FX_FLOAT fR = rtX.right();
+ path.Clear();
+ FX_FLOAT frtXRight = rtX.right();
+ FX_FLOAT frtXBottom = rtX.bottom();
+ path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom);
+ path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom);
+ path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1);
+ path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top);
+ path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top);
+ path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1);
+ CFX_Color clrLine(0xffffffff);
+ pGraphics->SetLineWidth(1.0f);
+ pGraphics->SetStrokeColor(&clrLine);
+ pGraphics->StrokePath(&path, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ pGraphics->SaveGraphState();
+ FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fBottom = pRect->bottom();
+ FX_FLOAT fWidth = pRect->width;
+ FX_FLOAT fHeight = pRect->height;
+ CFX_RectF rt(*pRect);
+ pGraphics->SetLineWidth(1.0f);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1);
+ path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2);
+ path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2);
+ path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1);
+ CFX_Color crFill;
+ crFill = m_pThemeData->clrBtnEdgeOut[iActive];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1);
+ path.AddRectangle(fRight - 2, rt.top + 1, 1, 1);
+ path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1);
+ path.AddRectangle(fRight - 2, fBottom - 2, 1, 1);
+ crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1);
+ path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4);
+ crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4);
+ path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1);
+ crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1];
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+ path.Clear();
+ path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4);
+ DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2,
+ fBottom - 2,
+ m_pThemeData->clrNormalBtBKStart[iActive][eState - 1],
+ m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path,
+ FXFILL_WINDING, pMatrix);
+}
+void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
+ CFX_RectF rtMin;
+ rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14,
+ pRect->height - 18);
+ FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix);
+}
+void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ FX_BOOL bMax,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
+ FX_FLOAT fWidth = pRect->width;
+ FX_FLOAT fHeight = pRect->height;
+ if (bMax) {
CFX_Path path;
path.Create();
- path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1);
- path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2);
- path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2);
- path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1);
- CFX_Color crFill;
- crFill = m_pThemeData->clrBtnEdgeOut[iActive];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1);
- path.AddRectangle(fRight - 2, rt.top + 1, 1, 1);
- path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1);
- path.AddRectangle(fRight - 2, fBottom - 2, 1, 1);
- crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1);
- path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4);
- crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4);
- path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1);
- crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4);
- DrawAxialShading(pGraphics,
- pRect->left + 2,
- pRect->top + 2,
- fRight - 2,
- fBottom - 2,
- m_pThemeData->clrCloseBtBKStart[iActive][eState - 1],
- m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1],
- &path, FXFILL_WINDING, pMatrix);
- CFX_RectF rtX(*pRect);
- rtX.Inflate(-5, -5);
- FX_FLOAT fR = rtX.right();
+ path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14,
+ pRect->top + 6);
+ path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11,
+ pRect->top + 9);
+ pGraphics->SaveGraphState();
+ pGraphics->SetLineWidth(2);
+ CFX_Color crStroke(0xFFFFFFFF);
+ pGraphics->SetStrokeColor(&crStroke);
+ pGraphics->StrokePath(&path, pMatrix);
+ pGraphics->SetLineWidth(1);
path.Clear();
- FX_FLOAT frtXRight = rtX.right();
- FX_FLOAT frtXBottom = rtX.bottom();
- path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom);
- path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom);
- path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1);
- path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top);
- path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top);
- path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1);
- CFX_Color clrLine(0xffffffff);
- pGraphics->SetLineWidth(1.0f);
- pGraphics->SetStrokeColor(&clrLine);
+ path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4,
+ pRect->top + 14);
+ path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10,
+ pRect->top + 14);
+ path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13,
+ pRect->top + 11);
+ path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10,
+ pRect->top + 14);
+ path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12,
+ pRect->top + 11);
pGraphics->StrokePath(&path, pMatrix);
pGraphics->RestoreGraphState();
-}
-void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
- pGraphics->SaveGraphState();
- FX_FLOAT fRight = pRect->right();
- FX_FLOAT fBottom = pRect->bottom();
- FX_FLOAT fWidth = pRect->width;
- FX_FLOAT fHeight = pRect->height;
- CFX_RectF rt(*pRect);
- pGraphics->SetLineWidth(1.0f);
+ } else {
+ CFX_RectF rtMax(*pRect);
+ rtMax.Inflate(-5, -5);
CFX_Path path;
path.Create();
- path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1);
- path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2);
- path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2);
- path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1);
- CFX_Color crFill;
- crFill = m_pThemeData->clrBtnEdgeOut[iActive];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1);
- path.AddRectangle(fRight - 2, rt.top + 1, 1, 1);
- path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1);
- path.AddRectangle(fRight - 2, fBottom - 2, 1, 1);
- crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1);
- path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4);
- crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1];
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4);
- path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1);
- crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1];
+ path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10,
+ fHeight - 10);
+ path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12,
+ fHeight - 14);
+ pGraphics->SaveGraphState();
+ CFX_Color crFill(0xFFFFFFFF);
pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
pGraphics->RestoreGraphState();
- path.Clear();
- path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4);
- DrawAxialShading(pGraphics,
- pRect->left + 2,
- pRect->top + 2,
- fRight - 2,
- fBottom - 2,
- m_pThemeData->clrNormalBtBKStart[iActive][eState - 1],
- m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1],
- &path, FXFILL_WINDING, pMatrix);
+ }
}
-void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
- DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
- CFX_RectF rtMin;
- rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14, pRect->height - 18);
- FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix);
+void CFWL_FormTP::DrawIconImage(CFX_Graphics* pGraphics,
+ CFX_DIBitmap* pDIBitmap,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix,
+ int32_t iActive) {
+ pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix);
}
-void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, FX_BOOL bMax, CFX_Matrix *pMatrix, int32_t iActive)
-{
- DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
- FX_FLOAT fWidth = pRect->width;
- FX_FLOAT fHeight = pRect->height;
- if (bMax) {
- CFX_Path path;
- path.Create();
- path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14, pRect->top + 6);
- path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11, pRect->top + 9);
- pGraphics->SaveGraphState();
- pGraphics->SetLineWidth(2);
- CFX_Color crStroke(0xFFFFFFFF);
- pGraphics->SetStrokeColor(&crStroke);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->SetLineWidth(1);
- path.Clear();
- path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4, pRect->top + 14);
- path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10, pRect->top + 14);
- path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13, pRect->top + 11);
- path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10, pRect->top + 14);
- path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12, pRect->top + 11);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
- } else {
- CFX_RectF rtMax(*pRect);
- rtMax.Inflate(-5, -5);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10, fHeight - 10);
- path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12, fHeight - 14);
- pGraphics->SaveGraphState();
- CFX_Color crFill(0xFFFFFFFF);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
- pGraphics->RestoreGraphState();
- }
+void CFWL_FormTP::SetThemeData(FX_DWORD dwID) {
+ m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255);
+ m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148);
+ m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5);
+ m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176);
+ m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71);
+ m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20);
+ m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33);
+ m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107);
+ m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54);
+ m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74);
+ m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51);
+ m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28);
+ m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13);
+ if (dwID) {
+ m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149);
+ m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131);
+ m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128);
+ m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149);
+ m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94);
+ m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105);
+ m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133);
+ m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125);
+ m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103);
+ m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79);
+ m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105);
+ m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201);
+ m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149);
+ m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133);
+ m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121);
+ m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103);
+ m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162);
+ m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84);
+ m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208);
+ m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112);
+ m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190);
+ m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88);
+ m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137);
+ m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83);
+ m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105);
+ m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105);
+ m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123);
+ m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105);
+ m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220);
+ m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255);
+ m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225);
+ m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255);
+ m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94);
+ m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105);
+ m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133);
+ m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127);
+ m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255);
+ m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133);
+ } else {
+ m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255);
+ m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226);
+ m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226);
+ m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255);
+ m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200);
+ m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220);
+ m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210);
+ m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234);
+ m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193);
+ m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139);
+ m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238);
+ m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255);
+ m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255);
+ m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252);
+ m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255);
+ m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207);
+ m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112);
+ m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188);
+ m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250);
+ m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248);
+ m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255);
+ m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255);
+ m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245);
+ m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187);
+ m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245);
+ m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195);
+ m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244);
+ m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185);
+ m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220);
+ m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255);
+ m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225);
+ m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255);
+ m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241);
+ m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220);
+ m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160);
+ m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140);
+ m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255);
+ m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239);
+ }
+ m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0];
+ m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0];
+ m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1];
+ m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1];
+ m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2];
+ m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2];
+ m_pThemeData->clrCloseBtEdgeLight[1][0] =
+ m_pThemeData->clrCloseBtEdgeLight[0][0];
+ m_pThemeData->clrCloseBtEdgeDark[1][0] =
+ m_pThemeData->clrCloseBtEdgeDark[0][0];
+ m_pThemeData->clrCloseBtEdgeLight[1][1] =
+ m_pThemeData->clrCloseBtEdgeLight[0][1];
+ m_pThemeData->clrCloseBtEdgeDark[1][1] =
+ m_pThemeData->clrCloseBtEdgeDark[0][1];
+ m_pThemeData->clrCloseBtEdgeLight[1][2] =
+ m_pThemeData->clrCloseBtEdgeLight[0][2];
+ m_pThemeData->clrCloseBtEdgeDark[1][2] =
+ m_pThemeData->clrCloseBtEdgeDark[0][2];
+ m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0];
+ m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1];
+ m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2];
+ m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3];
+ m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2];
+ m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1];
+ m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0];
+ m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0];
+ m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1];
+ m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2];
+ m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0];
+ m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1];
+ m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2];
+ m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0];
+ m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1];
+ m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2];
+ m_pThemeData->clrNormalBtBKStart[1][2] =
+ m_pThemeData->clrNormalBtBKStart[0][2];
+ m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2];
+ m_pThemeData->clrNormalBtBKStart[1][0] =
+ m_pThemeData->clrNormalBtBKStart[0][0];
+ m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0];
+ m_pThemeData->clrNormalBtBKStart[1][1] =
+ m_pThemeData->clrNormalBtBKStart[0][1];
+ m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1];
+ m_pThemeData->clrNormalBtEdgeLight[1][0] =
+ m_pThemeData->clrNormalBtEdgeLight[0][0];
+ m_pThemeData->clrNormalBtEdgeDark[1][0] =
+ m_pThemeData->clrNormalBtEdgeDark[0][0];
+ m_pThemeData->clrNormalBtEdgeLight[1][1] =
+ m_pThemeData->clrNormalBtEdgeLight[0][1];
+ m_pThemeData->clrNormalBtEdgeDark[1][1] =
+ m_pThemeData->clrNormalBtEdgeDark[0][1];
+ m_pThemeData->clrNormalBtEdgeLight[1][2] =
+ m_pThemeData->clrNormalBtEdgeLight[0][2];
+ m_pThemeData->clrNormalBtEdgeDark[1][2] =
+ m_pThemeData->clrNormalBtEdgeDark[0][2];
+ m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0];
+ m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1];
+ m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2];
+ m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0];
+ m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0];
+ m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1];
+ m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2];
+ m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3];
+ m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4];
+ m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0];
+ DeactiveForm();
}
-void CFWL_FormTP::DrawIconImage(CFX_Graphics *pGraphics, CFX_DIBitmap *pDIBitmap, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix, int32_t iActive)
-{
- pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix);
+void CFWL_FormTP::DeactiveForm() {
+ TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeLeft[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeLeft[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeLeft[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeRight[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeRight[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeRight[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeTop[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeTop[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeTop[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeBottom[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeBottom[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrHeadEdgeBottom[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtBKStart[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtBKStart[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtBKStart[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtBKEnd[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtBKEnd[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtBKEnd[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtEdgeLight[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtEdgeLight[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtEdgeLight[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtEdgeDark[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtEdgeDark[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrNormalBtEdgeDark[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrBtnCornerLight[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrBtnCornerLight[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrBtnCornerLight[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrFormBorder[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrFormBorder[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrFormBorder[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrFormBorder[1][3]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrFormBorder[1][4]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrFormBorderLight[1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtBKStart[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtBKStart[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtBKStart[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtBKEnd[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtBKEnd[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtBKEnd[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtEdgeLight[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtEdgeLight[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtEdgeLight[1][2]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtEdgeDark[1][0]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtEdgeDark[1][1]);
+ TransModeColor(m_pThemeData->clrTransWhite,
+ m_pThemeData->clrCloseBtEdgeDark[1][2]);
}
-void CFWL_FormTP::SetThemeData(FX_DWORD dwID)
-{
- m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255);
- m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148);
- m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5);
- m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176);
- m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71);
- m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20);
- m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33);
- m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107);
- m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54);
- m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74);
- m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51);
- m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28);
- m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13);
- if (dwID) {
- m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149);
- m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131);
- m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128);
- m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149);
- m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94);
- m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105);
- m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133);
- m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125);
- m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103);
- m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79);
- m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105);
- m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201);
- m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149);
- m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133 );
- m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121);
- m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103);
- m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162);
- m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84);
- m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208);
- m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112);
- m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190);
- m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88);
- m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137);
- m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83);
- m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105);
- m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105);
- m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123);
- m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105);
- m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220);
- m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255);
- m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225);
- m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255);
- m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94);
- m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105);
- m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133);
- m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127);
- m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255);
- m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133);
- } else {
- m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255);
- m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226);
- m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226);
- m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255);
- m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200);
- m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220);
- m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210);
- m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234);
- m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193);
- m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139);
- m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238);
- m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255);
- m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255);
- m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252);
- m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255);
- m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207);
- m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112);
- m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188);
- m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250 );
- m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248);
- m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255);
- m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255);
- m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245);
- m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187);
- m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245);
- m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195);
- m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244);
- m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185);
- m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220);
- m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255);
- m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225);
- m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255);
- m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241);
- m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220);
- m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160);
- m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140);
- m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255);
- m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239);
- }
- m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0];
- m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0];
- m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1];
- m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1];
- m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2];
- m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2];
- m_pThemeData->clrCloseBtEdgeLight[1][0] = m_pThemeData->clrCloseBtEdgeLight[0][0];
- m_pThemeData->clrCloseBtEdgeDark[1][0] = m_pThemeData->clrCloseBtEdgeDark[0][0];
- m_pThemeData->clrCloseBtEdgeLight[1][1] = m_pThemeData->clrCloseBtEdgeLight[0][1];
- m_pThemeData->clrCloseBtEdgeDark[1][1] = m_pThemeData->clrCloseBtEdgeDark[0][1];
- m_pThemeData->clrCloseBtEdgeLight[1][2] = m_pThemeData->clrCloseBtEdgeLight[0][2];
- m_pThemeData->clrCloseBtEdgeDark[1][2] = m_pThemeData->clrCloseBtEdgeDark[0][2];
- m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0];
- m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1];
- m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2];
- m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3];
- m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2];
- m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1];
- m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0];
- m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0];
- m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1];
- m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2];
- m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0];
- m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1];
- m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2];
- m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0];
- m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1];
- m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2];
- m_pThemeData->clrNormalBtBKStart[1][2] = m_pThemeData->clrNormalBtBKStart[0][2];
- m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2];
- m_pThemeData->clrNormalBtBKStart[1][0] = m_pThemeData->clrNormalBtBKStart[0][0];
- m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0];
- m_pThemeData->clrNormalBtBKStart[1][1] = m_pThemeData->clrNormalBtBKStart[0][1];
- m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1];
- m_pThemeData->clrNormalBtEdgeLight[1][0] = m_pThemeData->clrNormalBtEdgeLight[0][0];
- m_pThemeData->clrNormalBtEdgeDark[1][0] = m_pThemeData->clrNormalBtEdgeDark[0][0];
- m_pThemeData->clrNormalBtEdgeLight[1][1] = m_pThemeData->clrNormalBtEdgeLight[0][1];
- m_pThemeData->clrNormalBtEdgeDark[1][1] = m_pThemeData->clrNormalBtEdgeDark[0][1];
- m_pThemeData->clrNormalBtEdgeLight[1][2] = m_pThemeData->clrNormalBtEdgeLight[0][2];
- m_pThemeData->clrNormalBtEdgeDark[1][2] = m_pThemeData->clrNormalBtEdgeDark[0][2];
- m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0];
- m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1];
- m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2];
- m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0];
- m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0];
- m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1];
- m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2];
- m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3];
- m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4];
- m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0];
- DeactiveForm();
+void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack) {
+ int32_t iAlfaF, iRF, iGF, iBF;
+ int32_t iAlfaB, iRB, iGB, iBB;
+ ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF);
+ ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB);
+ clrBack = ArgbEncode(0xff, iRB + (iRF - iRB) * iAlfaF / 255,
+ iGB + (iGF - iGB) * iAlfaF / 255,
+ iBB + (iBF - iBB) * iAlfaF / 255);
}
-void CFWL_FormTP::DeactiveForm()
-{
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeLeft[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeLeft[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeLeft[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeRight[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeRight[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeRight[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeTop[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeTop[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeTop[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeBottom[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeBottom[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadEdgeBottom[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtBKStart[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtBKStart[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtBKStart[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtBKEnd[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtBKEnd[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtBKEnd[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtEdgeLight[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtEdgeLight[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtEdgeLight[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtEdgeDark[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtEdgeDark[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrNormalBtEdgeDark[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnCornerLight[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnCornerLight[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnCornerLight[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrFormBorder[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrFormBorder[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrFormBorder[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrFormBorder[1][3]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrFormBorder[1][4]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrFormBorderLight[1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtBKStart[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtBKStart[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtBKStart[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtBKEnd[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtBKEnd[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtBKEnd[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtEdgeLight[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtEdgeLight[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtEdgeLight[1][2]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtEdgeDark[1][0]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtEdgeDark[1][1]);
- TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrCloseBtEdgeDark[1][2]);
-}
-void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB &clrBack)
-{
- int32_t iAlfaF, iRF, iGF, iBF;
- int32_t iAlfaB, iRB, iGB, iBB;
- ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF);
- ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB);
- clrBack = ArgbEncode(0xff,
- iRB + (iRF - iRB) * iAlfaF / 255,
- iGB + (iGF - iGB) * iAlfaF / 255,
- iBB + (iBF - iBB) * iAlfaF / 255);
-}
-void CFWL_FormTP::InitCaption(FX_BOOL bActive)
-{
- if (bActive) {
- CFX_FxgeDevice dev;
- CFX_Graphics gs;
- CFX_Path path;
- path.Create();
- if (m_pActiveBitmap) {
- delete m_pActiveBitmap;
- m_pActiveBitmap = NULL;
- }
- m_pActiveBitmap = FX_NEW CFX_DIBitmap;
- m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
- dev.Attach(m_pActiveBitmap);
- gs.Create(&dev);
- path.AddRectangle(0, 0, 1, 5);
- DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], m_pThemeData->clrHeadBK[0][1], &path);
- path.Clear();
- path.AddRectangle(0, 5, 1, 15);
- DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1], m_pThemeData->clrHeadBK[0][2], &path);
- path.Clear();
- path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
- DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, m_pThemeData->clrHeadBK[0][2], m_pThemeData->clrHeadBK[0][3], &path);
- } else {
- CFX_FxgeDevice dev;
- CFX_Graphics gs;
- CFX_Path path;
- path.Create();
- if (m_pDeactivebitmap) {
- delete m_pDeactivebitmap;
- m_pDeactivebitmap = NULL;
- }
- m_pDeactivebitmap = FX_NEW CFX_DIBitmap;
- m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
- dev.Attach(m_pDeactivebitmap);
- gs.Create(&dev);
- path.AddRectangle(0, 0, 1, 5);
- DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], m_pThemeData->clrHeadBK[1][1], &path);
- path.Clear();
- path.AddRectangle(0, 5, 1, 15);
- DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1], m_pThemeData->clrHeadBK[1][2], &path);
- path.Clear();
- path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
- DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, m_pThemeData->clrHeadBK[1][2], m_pThemeData->clrHeadBK[1][3], &path);
+void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
+ if (bActive) {
+ CFX_FxgeDevice dev;
+ CFX_Graphics gs;
+ CFX_Path path;
+ path.Create();
+ if (m_pActiveBitmap) {
+ delete m_pActiveBitmap;
+ m_pActiveBitmap = NULL;
}
+ m_pActiveBitmap = FX_NEW CFX_DIBitmap;
+ m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
+ dev.Attach(m_pActiveBitmap);
+ gs.Create(&dev);
+ path.AddRectangle(0, 0, 1, 5);
+ DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0],
+ m_pThemeData->clrHeadBK[0][1], &path);
+ path.Clear();
+ path.AddRectangle(0, 5, 1, 15);
+ DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1],
+ m_pThemeData->clrHeadBK[0][2], &path);
+ path.Clear();
+ path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
+ DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption,
+ m_pThemeData->clrHeadBK[0][2],
+ m_pThemeData->clrHeadBK[0][3], &path);
+ } else {
+ CFX_FxgeDevice dev;
+ CFX_Graphics gs;
+ CFX_Path path;
+ path.Create();
+ if (m_pDeactivebitmap) {
+ delete m_pDeactivebitmap;
+ m_pDeactivebitmap = NULL;
+ }
+ m_pDeactivebitmap = FX_NEW CFX_DIBitmap;
+ m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
+ dev.Attach(m_pDeactivebitmap);
+ gs.Create(&dev);
+ path.AddRectangle(0, 0, 1, 5);
+ DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0],
+ m_pThemeData->clrHeadBK[1][1], &path);
+ path.Clear();
+ path.AddRectangle(0, 5, 1, 15);
+ DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1],
+ m_pThemeData->clrHeadBK[1][2], &path);
+ path.Clear();
+ path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
+ DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption,
+ m_pThemeData->clrHeadBK[1][2],
+ m_pThemeData->clrHeadBK[1][3], &path);
+ }
}
diff --git a/xfa/src/fwl/src/theme/listboxtp.cpp b/xfa/src/fwl/src/theme/listboxtp.cpp index c16df585d9..3542ae4278 100644 --- a/xfa/src/fwl/src/theme/listboxtp.cpp +++ b/xfa/src/fwl/src/theme/listboxtp.cpp @@ -5,88 +5,90 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_ListBoxTP::CFWL_ListBoxTP()
-{
+CFWL_ListBoxTP::CFWL_ListBoxTP() {}
+CFWL_ListBoxTP::~CFWL_ListBoxTP() {}
+FX_BOOL CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_ListBox;
}
-CFWL_ListBoxTP::~CFWL_ListBoxTP()
-{
-}
-FX_BOOL CFWL_ListBoxTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_ListBox;
-}
-FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_LTB_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_LTB_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_LTB_Background: {
- FillSoildRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255), &pParams->m_rtPart, &pParams->m_matrix);
- if (pParams->m_pData) {
- FillSoildRect(pParams->m_pGraphics, FWLTHEME_COLOR_Background, (CFX_RectF*)pParams->m_pData, &pParams->m_matrix);
- }
- break;
- }
- case FWL_PART_LTB_ListItem: {
- DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates, &pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix);
- break;
- }
- case FWL_PART_LTB_Icon: {
- pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_LTB_Check: {
- FX_DWORD color = 0xFF000000;
- if (pParams->m_dwStates == FWL_PARTSTATE_LTB_Checked) {
- color = 0xFFFF0000;
- } else if (pParams->m_dwStates == FWL_PARTSTATE_LTB_UnChecked) {
- color = 0xFF0000FF;
- }
- FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart, &pParams->m_matrix);
- }
- default: {
- }
+FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_LTB_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_LTB_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_LTB_Background: {
+ FillSoildRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ if (pParams->m_pData) {
+ FillSoildRect(pParams->m_pGraphics, FWLTHEME_COLOR_Background,
+ (CFX_RectF*)pParams->m_pData, &pParams->m_matrix);
+ }
+ break;
}
- return TRUE;
+ case FWL_PART_LTB_ListItem: {
+ DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates,
+ &pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_LTB_Icon: {
+ pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart,
+ &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_LTB_Check: {
+ FX_DWORD color = 0xFF000000;
+ if (pParams->m_dwStates == FWL_PARTSTATE_LTB_Checked) {
+ color = 0xFFFF0000;
+ } else if (pParams->m_dwStates == FWL_PARTSTATE_LTB_UnChecked) {
+ color = 0xFF0000FF;
+ }
+ FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart,
+ &pParams->m_matrix);
+ }
+ default: {}
+ }
+ return TRUE;
}
-FWL_ERR CFWL_ListBoxTP::Initialize()
-{
- InitTTO();
- return CFWL_WidgetTP::Initialize();
+FWL_ERR CFWL_ListBoxTP::Initialize() {
+ InitTTO();
+ return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_ListBoxTP::Finalize()
-{
- FinalizeTTO();
- return CFWL_WidgetTP::Finalize();
+FWL_ERR CFWL_ListBoxTP::Finalize() {
+ FinalizeTTO();
+ return CFWL_WidgetTP::Finalize();
}
-void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics *pGraphics, FX_DWORD dwStates, const CFX_RectF *prtItem, void* pData , CFX_Matrix *pMatrix )
-{
- if (dwStates & FWL_PARTSTATE_LTB_Selected) {
- pGraphics->SaveGraphState();
- CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0 ? FWLTHEME_COLOR_BKSelected : FWLTHEME_COLOR_Green_BKSelected);
- pGraphics->SetFillColor(&crFill);
- CFX_RectF rt(*prtItem);
- CFX_Path path;
- path.Create();
-#if (_FX_OS_==_FX_MACOSX_)
- path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1);
+void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics,
+ FX_DWORD dwStates,
+ const CFX_RectF* prtItem,
+ void* pData,
+ CFX_Matrix* pMatrix) {
+ if (dwStates & FWL_PARTSTATE_LTB_Selected) {
+ pGraphics->SaveGraphState();
+ CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0
+ ? FWLTHEME_COLOR_BKSelected
+ : FWLTHEME_COLOR_Green_BKSelected);
+ pGraphics->SetFillColor(&crFill);
+ CFX_RectF rt(*prtItem);
+ CFX_Path path;
+ path.Create();
+#if (_FX_OS_ == _FX_MACOSX_)
+ path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1);
#else
- path.AddRectangle(rt.left, rt.top, rt.width, rt.height);
+ path.AddRectangle(rt.left, rt.top, rt.width, rt.height);
#endif
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
- }
- if (dwStates & FWL_PARTSTATE_LTB_Focused) {
- if (pData) {
- DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix);
- }
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+ }
+ if (dwStates & FWL_PARTSTATE_LTB_Focused) {
+ if (pData) {
+ DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix);
}
+ }
}
diff --git a/xfa/src/fwl/src/theme/monthcalendartp.cpp b/xfa/src/fwl/src/theme/monthcalendartp.cpp index de7f3a847b..67586f1b80 100644 --- a/xfa/src/fwl/src/theme/monthcalendartp.cpp +++ b/xfa/src/fwl/src/theme/monthcalendartp.cpp @@ -5,550 +5,569 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define FWL_THEMECAPACITY_MC_HEADER_WIDTH 200
-#define FWL_THEMECAPACITY_MC_HEADER_HEIGHT 30
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH 18
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT 16
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN 5
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT)/2
-#define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT 100
-#define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT 20
-#define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN (FWL_THEMECAPACITY_MC_HEADER_WIDTH - FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT)/2
-#define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT)/2
-#define FWL_THEMECAPACITY_MC_HSEP_WIDTH (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10)
-#define FWL_THEMECAPACITY_MC_HSEP_HEIGHT 1
-#define FWL_THEMECAPACITY_MC_VSEP_WIDTH 1
-#define FWL_THEMECAPACITY_MC_VSEP_HEIGHT FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT
-#define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH 26
-#define FWL_THEMECAPACITY_MC_SEP_DOFFSET -4
-#define FWL_THEMECAPACITY_MC_SEP_X 3
-#define FWL_THEMECAPACITY_MC_SEP_Y (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + FWL_THEMECAPACITY_MC_SEP_DOFFSET)
-#define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT (6*FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT)
-#define FWL_THEMECAPACITY_MC_WEEK_WIDTH (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH*7)
-#define FWL_THEMECAPACITY_MC_WEEK_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
-#define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH (FWL_THEMECAPACITY_MC_HEADER_WIDTH/7)
-#define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT 16
-#define FWL_THEMECAPACITY_MC_TODAY_WIDHT FWL_THEMECAPACITY_MC_HEADER_WIDTH
-#define FWL_THEMECAPACITY_MC_TODAY_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
-#define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH
-#define FWL_MC_WIDTH 200
-#define FWL_MC_HEIGHT 160
-CFWL_MonthCalendarTP::CFWL_MonthCalendarTP()
-{
- m_pThemeData = FX_NEW MCThemeData;
- SetThemeData(0);
+#define FWL_THEMECAPACITY_MC_HEADER_WIDTH 200
+#define FWL_THEMECAPACITY_MC_HEADER_HEIGHT 30
+#define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH 18
+#define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT 16
+#define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN 5
+#define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN \
+ (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \
+ FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT) / \
+ 2
+#define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT 100
+#define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT 20
+#define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN \
+ (FWL_THEMECAPACITY_MC_HEADER_WIDTH - \
+ FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT) / \
+ 2
+#define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN \
+ (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \
+ FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT) / \
+ 2
+#define FWL_THEMECAPACITY_MC_HSEP_WIDTH (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10)
+#define FWL_THEMECAPACITY_MC_HSEP_HEIGHT 1
+#define FWL_THEMECAPACITY_MC_VSEP_WIDTH 1
+#define FWL_THEMECAPACITY_MC_VSEP_HEIGHT FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT
+#define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH 26
+#define FWL_THEMECAPACITY_MC_SEP_DOFFSET -4
+#define FWL_THEMECAPACITY_MC_SEP_X 3
+#define FWL_THEMECAPACITY_MC_SEP_Y \
+ (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + \
+ FWL_THEMECAPACITY_MC_SEP_DOFFSET)
+#define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT \
+ (6 * FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT)
+#define FWL_THEMECAPACITY_MC_WEEK_WIDTH \
+ (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH * 7)
+#define FWL_THEMECAPACITY_MC_WEEK_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
+#define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH \
+ (FWL_THEMECAPACITY_MC_HEADER_WIDTH / 7)
+#define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT 16
+#define FWL_THEMECAPACITY_MC_TODAY_WIDHT FWL_THEMECAPACITY_MC_HEADER_WIDTH
+#define FWL_THEMECAPACITY_MC_TODAY_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
+#define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT \
+ FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH
+#define FWL_MC_WIDTH 200
+#define FWL_MC_HEIGHT 160
+CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() {
+ m_pThemeData = FX_NEW MCThemeData;
+ SetThemeData(0);
}
-CFWL_MonthCalendarTP::~CFWL_MonthCalendarTP()
-{
- delete m_pThemeData;
+CFWL_MonthCalendarTP::~CFWL_MonthCalendarTP() {
+ delete m_pThemeData;
}
-FX_BOOL CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar;
+FX_BOOL CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar;
}
-FX_DWORD CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- if (m_pThemeData) {
- SetThemeData(FWL_GetThemeColor(dwThemeID));
- }
- return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
+FX_DWORD CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ if (m_pThemeData) {
+ SetThemeData(FWL_GetThemeColor(dwThemeID));
+ }
+ return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
}
-FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch(pParams->m_iPart) {
- case FWL_PART_MCD_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_Background: {
- DrawTotalBK(pParams, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_Header: {
- DrawHeadBk(pParams, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_LBtn: {
+FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_MCD_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_Background: {
+ DrawTotalBK(pParams, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_Header: {
+ DrawHeadBk(pParams, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_LBtn: {
#ifdef THEME_XPSimilar
- FWLTHEME_STATE eState = GetState(pParams->m_dwStates);
- DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix);
+ FWLTHEME_STATE eState = GetState(pParams->m_dwStates);
+ DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
+ FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix);
#else
- DrawLButton(pParams, &pParams->m_matrix);
+ DrawLButton(pParams, &pParams->m_matrix);
#endif
- break;
- }
- case FWL_PART_MCD_RBtn: {
+ break;
+ }
+ case FWL_PART_MCD_RBtn: {
#ifdef THEME_XPSimilar
- FWLTHEME_STATE eState = GetState(pParams->m_dwStates);
- DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix);
+ FWLTHEME_STATE eState = GetState(pParams->m_dwStates);
+ DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
+ FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix);
#else
- DrawRButton(pParams, &pParams->m_matrix);
+ DrawRButton(pParams, &pParams->m_matrix);
#endif
- break;
- }
- case FWL_PART_MCD_HSeparator: {
- DrawHSeperator(pParams, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_DatesIn: {
- DrawDatesInBK(pParams, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_TodayCircle: {
- DrawTodayCircle(pParams, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_DateInCircle: {
- DrawDatesInCircle(pParams, &pParams->m_matrix);
- break;
- }
- case FWL_PART_MCD_WeekNumSep: {
- DrawWeekNumSep(pParams, &pParams->m_matrix);
- break;
- }
- default: {
- }
- }
- return TRUE;
+ break;
+ }
+ case FWL_PART_MCD_HSeparator: {
+ DrawHSeperator(pParams, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_DatesIn: {
+ DrawDatesInBK(pParams, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_TodayCircle: {
+ DrawTodayCircle(pParams, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_DateInCircle: {
+ DrawDatesInCircle(pParams, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_MCD_WeekNumSep: {
+ DrawWeekNumSep(pParams, &pParams->m_matrix);
+ break;
+ }
+ default: {}
+ }
+ return TRUE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
- if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) && !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) &&
- (pParams->m_dwStates & (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) {
- m_pTextOut->SetTextColor(0xFFFFFFFF);
- } else if (pParams->m_iPart == FWL_PART_MCD_Caption) {
- m_pTextOut->SetTextColor(m_pThemeData->clrCaption);
- } else {
- m_pTextOut->SetTextColor(0xFF000000);
- }
- return CFWL_WidgetTP::DrawText(pParams);
+FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
+ if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) &&
+ !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) &&
+ (pParams->m_dwStates &
+ (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) {
+ m_pTextOut->SetTextColor(0xFFFFFFFF);
+ } else if (pParams->m_iPart == FWL_PART_MCD_Caption) {
+ m_pTextOut->SetTextColor(m_pThemeData->clrCaption);
+ } else {
+ m_pTextOut->SetTextColor(0xFF000000);
+ }
+ return CFWL_WidgetTP::DrawText(pParams);
}
-void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- FX_BOOL bDefPro = FALSE;
- FX_BOOL bDwordVal = FALSE;
- switch(dwCapacity) {
- case FWL_WGTCAPACITY_MC_HEADER_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_Height: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: {
- bDwordVal = TRUE;
- m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN;
- break;
- }
- case FWL_WGTCAPACITY_MC_HSEP_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_VSEP_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_WEEK_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_SEP_DOFFSET: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET;
- break;
- }
- case FWL_WGTCAPACITY_MC_SEP_X: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_X;
- break;
- }
- case FWL_WGTCAPACITY_MC_SEP_Y: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_Y;
- break;
- }
- case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_TODAY_WIDHT: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT;
- break;
- }
- case FWL_WGTCAPACITY_MC_WIDTH: {
- m_fValue = FWL_MC_WIDTH;
- break;
- }
- case FWL_WGTCAPACITY_MC_HEIGHT: {
- m_fValue = FWL_MC_HEIGHT;
- break;
- }
- case FWL_MCCAPACITY_Sun: {
- wsResource = L"Sun";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Mon: {
- wsResource = L"Mon";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Tue: {
- wsResource = L"Tue";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Wed: {
- wsResource = L"Wed";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Thu: {
- wsResource = L"Thu";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Fri: {
- wsResource = L"Fri";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Sat: {
- wsResource = L"Sat";
- return &wsResource;
- }
- case FWL_MCCAPACITY_January: {
- wsResource = L"January";
- return &wsResource;
- }
- case FWL_MCCAPACITY_February: {
- wsResource = L"February";
- return &wsResource;
- }
- case FWL_MCCAPACITY_March: {
- wsResource = L"March";
- return &wsResource;
- }
- case FWL_MCCAPACITY_April: {
- wsResource = L"April";
- return &wsResource;
- }
- case FWL_MCCAPACITY_May: {
- wsResource = L"May";
- return &wsResource;
- }
- case FWL_MCCAPACITY_June: {
- wsResource = L"June";
- return &wsResource;
- }
- case FWL_MCCAPACITY_July: {
- wsResource = L"July";
- return &wsResource;
- }
- case FWL_MCCAPACITY_August: {
- wsResource = L"August";
- return &wsResource;
- }
- case FWL_MCCAPACITY_September: {
- wsResource = L"September";
- return &wsResource;
- }
- case FWL_MCCAPACITY_October: {
- wsResource = L"October";
- return &wsResource;
- }
- case FWL_MCCAPACITY_November: {
- wsResource = L"November";
- return &wsResource;
- }
- case FWL_MCCAPACITY_December: {
- wsResource = L"December";
- return &wsResource;
- }
- case FWL_MCCAPACITY_Today: {
- wsResource = L"Today";
- return &wsResource;
- }
- default: {
- bDefPro = TRUE;
- }
- }
- if (!bDefPro) {
- if (bDwordVal) {
- return &m_dwValue;
- }
- return &m_fValue;
- }
- return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
+void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ FX_BOOL bDefPro = FALSE;
+ FX_BOOL bDwordVal = FALSE;
+ switch (dwCapacity) {
+ case FWL_WGTCAPACITY_MC_HEADER_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_Height: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: {
+ bDwordVal = TRUE;
+ m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: {
+ m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HSEP_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_VSEP_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_WEEK_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_SEP_DOFFSET: {
+ m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_SEP_X: {
+ m_fValue = FWL_THEMECAPACITY_MC_SEP_X;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_SEP_Y: {
+ m_fValue = FWL_THEMECAPACITY_MC_SEP_Y;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: {
+ m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_TODAY_WIDHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: {
+ m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_WIDTH: {
+ m_fValue = FWL_MC_WIDTH;
+ break;
+ }
+ case FWL_WGTCAPACITY_MC_HEIGHT: {
+ m_fValue = FWL_MC_HEIGHT;
+ break;
+ }
+ case FWL_MCCAPACITY_Sun: {
+ wsResource = L"Sun";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Mon: {
+ wsResource = L"Mon";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Tue: {
+ wsResource = L"Tue";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Wed: {
+ wsResource = L"Wed";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Thu: {
+ wsResource = L"Thu";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Fri: {
+ wsResource = L"Fri";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Sat: {
+ wsResource = L"Sat";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_January: {
+ wsResource = L"January";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_February: {
+ wsResource = L"February";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_March: {
+ wsResource = L"March";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_April: {
+ wsResource = L"April";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_May: {
+ wsResource = L"May";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_June: {
+ wsResource = L"June";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_July: {
+ wsResource = L"July";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_August: {
+ wsResource = L"August";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_September: {
+ wsResource = L"September";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_October: {
+ wsResource = L"October";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_November: {
+ wsResource = L"November";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_December: {
+ wsResource = L"December";
+ return &wsResource;
+ }
+ case FWL_MCCAPACITY_Today: {
+ wsResource = L"Today";
+ return &wsResource;
+ }
+ default: { bDefPro = TRUE; }
+ }
+ if (!bDefPro) {
+ if (bDwordVal) {
+ return &m_dwValue;
+ }
+ return &m_fValue;
+ }
+ return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FWL_ERR CFWL_MonthCalendarTP::Initialize()
-{
- InitTTO();
- return CFWL_WidgetTP::Initialize();
+FWL_ERR CFWL_MonthCalendarTP::Initialize() {
+ InitTTO();
+ return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_MonthCalendarTP::Finalize()
-{
- FinalizeTTO();
- return CFWL_WidgetTP::Finalize();
+FWL_ERR CFWL_MonthCalendarTP::Finalize() {
+ FinalizeTTO();
+ return CFWL_WidgetTP::Finalize();
}
-FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_RectF rtTotal(pParams->m_rtPart);
- path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrBK(m_pThemeData->clrBK);
- pParams->m_pGraphics->SetFillColor(&clrBK);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtTotal(pParams->m_rtPart);
+ path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrBK(m_pThemeData->clrBK);
+ pParams->m_pGraphics->SetFillColor(&clrBK);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_RectF rtHead = pParams->m_rtPart;
- path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrHeadBK(m_pThemeData->clrBK);
- pParams->m_pGraphics->SetFillColor(&clrHeadBK);
+FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtHead = pParams->m_rtPart;
+ path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrHeadBK(m_pThemeData->clrBK);
+ pParams->m_pGraphics->SetFillColor(&clrHeadBK);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
+}
+FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtLBtn;
+ rtLBtn = pParams->m_rtPart;
+ path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243));
+ pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) ==
+ FWL_PARTSTATE_MCD_Pressed) {
+ CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242));
+ pParams->m_pGraphics->SetFillColor(&clrLBtnFill);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ } else {
+ CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249));
+ pParams->m_pGraphics->SetFillColor(&clrLBtnFill);
pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+ }
+ path.Clear();
+ path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2,
+ rtLBtn.top + rtLBtn.height / 4);
+ path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2);
+ path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2,
+ rtLBtn.bottom() - rtLBtn.height / 4);
+ CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205));
+ pParams->m_pGraphics->SetStrokeColor(&clrFlag);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_RectF rtLBtn;
- rtLBtn = pParams->m_rtPart;
- path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243));
- pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == FWL_PARTSTATE_MCD_Pressed) {
- CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242));
- pParams->m_pGraphics->SetFillColor(&clrLBtnFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- } else {
- CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249));
- pParams->m_pGraphics->SetFillColor(&clrLBtnFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- }
- path.Clear();
- path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, rtLBtn.top + rtLBtn.height / 4);
- path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2);
- path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, rtLBtn.bottom() - rtLBtn.height / 4);
- CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205));
- pParams->m_pGraphics->SetStrokeColor(&clrFlag);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtRBtn;
+ rtRBtn = pParams->m_rtPart;
+ path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243));
+ pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) ==
+ FWL_PARTSTATE_MCD_Pressed) {
+ CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242));
+ pParams->m_pGraphics->SetFillColor(&clrRBtnFill);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ } else {
+ CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249));
+ pParams->m_pGraphics->SetFillColor(&clrRBtnFill);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ }
+ path.Clear();
+ path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4);
+ path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2,
+ rtRBtn.top + rtRBtn.height / 2);
+ path.LineTo(rtRBtn.left + rtRBtn.Width() / 3,
+ rtRBtn.bottom() - rtRBtn.height / 4);
+ CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205));
+ pParams->m_pGraphics->SetStrokeColor(&clrFlag);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_RectF rtRBtn;
- rtRBtn = pParams->m_rtPart;
- path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243));
- pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == FWL_PARTSTATE_MCD_Pressed) {
- CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242));
- pParams->m_pGraphics->SetFillColor(&clrRBtnFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- } else {
- CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249));
- pParams->m_pGraphics->SetFillColor(&clrRBtnFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- }
- path.Clear();
- path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4);
- path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, rtRBtn.top + rtRBtn.height / 2);
- path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.bottom() - rtRBtn.height / 4);
- CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205));
- pParams->m_pGraphics->SetStrokeColor(&clrFlag);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtHSep;
+ rtHSep = pParams->m_rtPart;
+ path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2);
+ path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrHSep(m_pThemeData->clrSeperator);
+ pParams->m_pGraphics->SetStrokeColor(&clrHSep);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_RectF rtHSep;
- rtHSep = pParams->m_rtPart;
- path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2);
- path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrHSep(m_pThemeData->clrSeperator);
- pParams->m_pGraphics->SetStrokeColor(&clrHSep);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtWeekSep;
+ rtWeekSep = pParams->m_rtPart;
+ path.MoveTo(rtWeekSep.left, rtWeekSep.top);
+ path.LineTo(rtWeekSep.left, rtWeekSep.bottom());
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrHSep(m_pThemeData->clrSeperator);
+ pParams->m_pGraphics->SetStrokeColor(&clrHSep);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
+FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ pParams->m_pGraphics->SaveGraphState();
+ if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) {
CFX_Path path;
path.Create();
- CFX_RectF rtWeekSep;
- rtWeekSep = pParams->m_rtPart;
- path.MoveTo(rtWeekSep.left, rtWeekSep.top);
- path.LineTo(rtWeekSep.left, rtWeekSep.bottom());
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrHSep(m_pThemeData->clrSeperator);
- pParams->m_pGraphics->SetStrokeColor(&clrHSep);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
-}
-FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- pParams->m_pGraphics->SaveGraphState();
- if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) {
- CFX_Path path;
- path.Create();
- CFX_RectF rtSelDay;
- rtSelDay = pParams->m_rtPart;
- path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height);
- CFX_Color clrSelDayBK;
- clrSelDayBK = m_pThemeData->clrDatesSelectedBK;
- pParams->m_pGraphics->SetFillColor(&clrSelDayBK);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- } else if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Hovered) {
- CFX_Path path;
- path.Create();
- CFX_RectF rtSelDay;
- rtSelDay = pParams->m_rtPart;
- path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height);
- CFX_Color clrSelDayBK;
- clrSelDayBK = m_pThemeData->clrDatesHoverBK;
- pParams->m_pGraphics->SetFillColor(&clrSelDayBK);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- }
- pParams->m_pGraphics->RestoreGraphState();
- return FALSE;
-}
-FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
+ CFX_RectF rtSelDay;
+ rtSelDay = pParams->m_rtPart;
+ path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
+ rtSelDay.height);
+ CFX_Color clrSelDayBK;
+ clrSelDayBK = m_pThemeData->clrDatesSelectedBK;
+ pParams->m_pGraphics->SetFillColor(&clrSelDayBK);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ } else if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Hovered) {
CFX_Path path;
path.Create();
CFX_RectF rtSelDay;
rtSelDay = pParams->m_rtPart;
- path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height);
- pParams->m_pGraphics->SaveGraphState();
+ path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
+ rtSelDay.height);
CFX_Color clrSelDayBK;
- clrSelDayBK = m_pThemeData->clrDatesCircle;
- pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+ clrSelDayBK = m_pThemeData->clrDatesHoverBK;
+ pParams->m_pGraphics->SetFillColor(&clrSelDayBK);
+ pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ }
+ pParams->m_pGraphics->RestoreGraphState();
+ return FALSE;
}
-FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground *pParams, CFX_Matrix *pMatrix)
-{
- CFX_Path path;
- path.Create();
- CFX_RectF rtTodayCircle;
- rtTodayCircle = pParams->m_rtPart;
- path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, rtTodayCircle.height);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color clrTodayCircle;
- clrTodayCircle = m_pThemeData->clrDatesCircle;
- pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle);
- pParams->m_pGraphics->StrokePath(&path, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- return TRUE;
+FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtSelDay;
+ rtSelDay = pParams->m_rtPart;
+ path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width,
+ rtSelDay.height);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrSelDayBK;
+ clrSelDayBK = m_pThemeData->clrDatesCircle;
+ pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(FX_DWORD dwFWLStates)
-{
- if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) {
- return FWLTHEME_STATE_Hover;
- } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) {
- return FWLTHEME_STATE_Pressed;
- }
- return FWLTHEME_STATE_Normal;
+FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rtTodayCircle;
+ rtTodayCircle = pParams->m_rtPart;
+ path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width,
+ rtTodayCircle.height);
+ pParams->m_pGraphics->SaveGraphState();
+ CFX_Color clrTodayCircle;
+ clrTodayCircle = m_pThemeData->clrDatesCircle;
+ pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle);
+ pParams->m_pGraphics->StrokePath(&path, pMatrix);
+ pParams->m_pGraphics->RestoreGraphState();
+ return TRUE;
}
-void CFWL_MonthCalendarTP::SetThemeData(FX_DWORD dwThemeID)
-{
- if (dwThemeID == 0) {
- m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255);
- m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239);
- m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251);
- m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239);
- m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209);
- m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0);
- m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255);
- } else {
- m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0);
- m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64);
- m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 217, 220, 191);
- m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183);
- m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0);
- m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0);
- m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255);
- }
+FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(FX_DWORD dwFWLStates) {
+ if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) {
+ return FWLTHEME_STATE_Hover;
+ } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) {
+ return FWLTHEME_STATE_Pressed;
+ }
+ return FWLTHEME_STATE_Normal;
+}
+void CFWL_MonthCalendarTP::SetThemeData(FX_DWORD dwThemeID) {
+ if (dwThemeID == 0) {
+ m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255);
+ m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239);
+ m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251);
+ m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239);
+ m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209);
+ m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0);
+ m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255);
+ } else {
+ m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0);
+ m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64);
+ m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 217, 220, 191);
+ m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183);
+ m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0);
+ m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0);
+ m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255);
+ }
}
diff --git a/xfa/src/fwl/src/theme/pictureboxtp.cpp b/xfa/src/fwl/src/theme/pictureboxtp.cpp index 919e786e29..ef59bbf5c1 100644 --- a/xfa/src/fwl/src/theme/pictureboxtp.cpp +++ b/xfa/src/fwl/src/theme/pictureboxtp.cpp @@ -5,31 +5,25 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-CFWL_PictureBoxTP::CFWL_PictureBoxTP()
-{
+CFWL_PictureBoxTP::CFWL_PictureBoxTP() {}
+CFWL_PictureBoxTP::~CFWL_PictureBoxTP() {}
+FX_BOOL CFWL_PictureBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_PictureBox;
}
-CFWL_PictureBoxTP::~CFWL_PictureBoxTP()
-{
-}
-FX_BOOL CFWL_PictureBoxTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_PictureBox;
-}
-FX_BOOL CFWL_PictureBoxTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- switch (pParams->m_iPart) {
- case FWL_PART_PTB_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_PTB_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- default: {
- }
+FX_BOOL CFWL_PictureBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ switch (pParams->m_iPart) {
+ case FWL_PART_PTB_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_PTB_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
}
- return TRUE;
+ default: {}
+ }
+ return TRUE;
}
diff --git a/xfa/src/fwl/src/theme/pushbuttontp.cpp b/xfa/src/fwl/src/theme/pushbuttontp.cpp index 9f3127f5b7..5820113f3b 100644 --- a/xfa/src/fwl/src/theme/pushbuttontp.cpp +++ b/xfa/src/fwl/src/theme/pushbuttontp.cpp @@ -5,161 +5,149 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define PUSHBUTTON_SIZE_Corner 2
-CFWL_PushButtonTP::CFWL_PushButtonTP()
-{
- m_pThemeData = FX_NEW PBThemeData;
- SetThemeData(0);
+#define PUSHBUTTON_SIZE_Corner 2
+CFWL_PushButtonTP::CFWL_PushButtonTP() {
+ m_pThemeData = FX_NEW PBThemeData;
+ SetThemeData(0);
}
-CFWL_PushButtonTP::~CFWL_PushButtonTP()
-{
- if (m_pThemeData) {
- delete m_pThemeData;
- }
+CFWL_PushButtonTP::~CFWL_PushButtonTP() {
+ if (m_pThemeData) {
+ delete m_pThemeData;
+ }
}
-FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- return pWidget->GetClassID() == FWL_CLASSHASH_PushButton;
+FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget->GetClassID() == FWL_CLASSHASH_PushButton;
}
-FX_DWORD CFWL_PushButtonTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- SetThemeData(FWL_GetThemeColor(dwThemeID));
- return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
+FX_DWORD CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ SetThemeData(FWL_GetThemeColor(dwThemeID));
+ return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
}
-FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- switch(pParams->m_iPart) {
- case FWL_PART_PSB_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_PSB_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_PSB_Background: {
- CFX_RectF &rect = pParams->m_rtPart;
- FX_FLOAT fRight = rect.right();
- FX_FLOAT fBottom = rect.bottom();
- CFX_Path strokePath;
- strokePath.Create();
- strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
- strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top);
- strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom);
- strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom);
- strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
- CFX_Path fillPath;
- fillPath.Create();
- fillPath.AddSubpath(&strokePath);
- CFX_Graphics *pGraphics = pParams->m_pGraphics;
- pGraphics->SaveGraphState();
- CFX_RectF rtInner(rect);
- rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1,
- PUSHBUTTON_SIZE_Corner + 1,
- PUSHBUTTON_SIZE_Corner,
- PUSHBUTTON_SIZE_Corner);
- fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
- int32_t iColor = GetColorID(pParams->m_dwStates);
- DrawAxialShading(pGraphics,
- rect.left + PUSHBUTTON_SIZE_Corner,
- rect.top,
- rect.left + PUSHBUTTON_SIZE_Corner,
- rect.bottom(),
- m_pThemeData->clrStart[iColor],
- m_pThemeData->clrEnd[iColor],
- &fillPath,
- FXFILL_ALTERNATE,
- &pParams->m_matrix);
- CFX_Color crStroke(m_pThemeData->clrBorder[iColor]);
- pGraphics->SetStrokeColor(&crStroke);
- pGraphics->StrokePath(&strokePath, &pParams->m_matrix);
- fillPath.Clear();
- fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
- CFX_Color crFill(m_pThemeData->clrFill[iColor]);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix);
- if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) {
- rtInner.Inflate(1, 1, 0, 0);
- DrawFocus(pGraphics, &rtInner, &pParams->m_matrix);
- }
- pGraphics->RestoreGraphState();
- break;
- }
- default: {
- }
+FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ switch (pParams->m_iPart) {
+ case FWL_PART_PSB_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
}
- return TRUE;
-}
-void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) {
- m_fValue = 0;
- return &m_fValue;
+ case FWL_PART_PSB_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_PSB_Background: {
+ CFX_RectF& rect = pParams->m_rtPart;
+ FX_FLOAT fRight = rect.right();
+ FX_FLOAT fBottom = rect.bottom();
+ CFX_Path strokePath;
+ strokePath.Create();
+ strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
+ strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top);
+ strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom);
+ strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom);
+ strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
+ CFX_Path fillPath;
+ fillPath.Create();
+ fillPath.AddSubpath(&strokePath);
+ CFX_Graphics* pGraphics = pParams->m_pGraphics;
+ pGraphics->SaveGraphState();
+ CFX_RectF rtInner(rect);
+ rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1,
+ PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner);
+ fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width,
+ rtInner.height);
+ int32_t iColor = GetColorID(pParams->m_dwStates);
+ DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top,
+ rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(),
+ m_pThemeData->clrStart[iColor],
+ m_pThemeData->clrEnd[iColor], &fillPath,
+ FXFILL_ALTERNATE, &pParams->m_matrix);
+ CFX_Color crStroke(m_pThemeData->clrBorder[iColor]);
+ pGraphics->SetStrokeColor(&crStroke);
+ pGraphics->StrokePath(&strokePath, &pParams->m_matrix);
+ fillPath.Clear();
+ fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width,
+ rtInner.height);
+ CFX_Color crFill(m_pThemeData->clrFill[iColor]);
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix);
+ if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) {
+ rtInner.Inflate(1, 1, 0, 0);
+ DrawFocus(pGraphics, &rtInner, &pParams->m_matrix);
+ }
+ pGraphics->RestoreGraphState();
+ break;
}
- return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
+ default: {}
+ }
+ return TRUE;
}
-FWL_ERR CFWL_PushButtonTP::Initialize()
-{
- InitTTO();
- return CFWL_WidgetTP::Initialize();
+void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) {
+ m_fValue = 0;
+ return &m_fValue;
+ }
+ return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FWL_ERR CFWL_PushButtonTP::Finalize()
-{
- FinalizeTTO();
- return CFWL_WidgetTP::Finalize();
+FWL_ERR CFWL_PushButtonTP::Initialize() {
+ InitTTO();
+ return CFWL_WidgetTP::Initialize();
}
-void CFWL_PushButtonTP::SetThemeData(FX_DWORD dwID)
-{
- FX_ARGB *pData = (FX_ARGB*)&*m_pThemeData;
- if (dwID) {
- m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153);
- m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246);
- m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180);
- m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149);
- m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143);
- m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216);
- m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184);
- m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228);
- m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37);
- m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84);
- m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153);
- m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
- m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
- } else {
- m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186);
- m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193);
- m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207);
- m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255);
- m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234);
- m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197);
- m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238);
- m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0);
- m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238);
- m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234);
- m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
- m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
- }
+FWL_ERR CFWL_PushButtonTP::Finalize() {
+ FinalizeTTO();
+ return CFWL_WidgetTP::Finalize();
+}
+void CFWL_PushButtonTP::SetThemeData(FX_DWORD dwID) {
+ FX_ARGB* pData = (FX_ARGB*)&*m_pThemeData;
+ if (dwID) {
+ m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153);
+ m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246);
+ m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180);
+ m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149);
+ m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143);
+ m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216);
+ m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184);
+ m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228);
+ m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37);
+ m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84);
+ m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153);
+ m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
+ m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
+ } else {
+ m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186);
+ m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193);
+ m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207);
+ m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255);
+ m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234);
+ m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197);
+ m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238);
+ m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0);
+ m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238);
+ m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234);
+ m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
+ m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
+ }
}
-int32_t CFWL_PushButtonTP::GetColorID(FX_DWORD dwStates)
-{
- return dwStates &= FWL_PARTSTATE_PSB_Mask;
+int32_t CFWL_PushButtonTP::GetColorID(FX_DWORD dwStates) {
+ return dwStates &= FWL_PARTSTATE_PSB_Mask;
}
diff --git a/xfa/src/fwl/src/theme/scrollbartp.cpp b/xfa/src/fwl/src/theme/scrollbartp.cpp index c10507a57e..bc9f41913c 100644 --- a/xfa/src/fwl/src/theme/scrollbartp.cpp +++ b/xfa/src/fwl/src/theme/scrollbartp.cpp @@ -5,358 +5,367 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define FWL_SCROLL_PawLen 12.5f
-CFWL_ScrollBarTP::CFWL_ScrollBarTP()
-{
- m_pThemeData = FX_NEW SBThemeData;
- SetThemeData(0);
+#define FWL_SCROLL_PawLen 12.5f
+CFWL_ScrollBarTP::CFWL_ScrollBarTP() {
+ m_pThemeData = FX_NEW SBThemeData;
+ SetThemeData(0);
}
-CFWL_ScrollBarTP::~CFWL_ScrollBarTP()
-{
- if (m_pThemeData) {
- delete m_pThemeData;
- m_pThemeData = NULL;
- }
+CFWL_ScrollBarTP::~CFWL_ScrollBarTP() {
+ if (m_pThemeData) {
+ delete m_pThemeData;
+ m_pThemeData = NULL;
+ }
}
-FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
- return pWidget->GetClassID() == FWL_CLASSHASH_ScrollBar;
+FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) {
+ _FWL_RETURN_VALUE_IF_FAIL(pWidget, FALSE);
+ return pWidget->GetClassID() == FWL_CLASSHASH_ScrollBar;
}
-void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- if (dwCapacity == FWL_CAPACITY_SCB_Size) {
- m_fValue = 5;
- return &m_fValue;
- }
- return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
+void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ if (dwCapacity == FWL_CAPACITY_SCB_Size) {
+ m_fValue = 5;
+ return &m_fValue;
+ }
+ return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FX_DWORD CFWL_ScrollBarTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- if (m_pThemeData) {
- SetThemeData(FWL_GetThemeColor(dwThemeID));
- }
- return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
+FX_DWORD CFWL_ScrollBarTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ if (m_pThemeData) {
+ SetThemeData(FWL_GetThemeColor(dwThemeID));
+ }
+ return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
}
-FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- IFWL_Widget *pWidget = pParams->m_pWidget;
- FX_DWORD dwStyleEx = pWidget->GetStylesEx();
- FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
- switch (pParams->m_dwStates & 0x03) {
- case FWL_PARTSTATE_SCB_Hovered: {
- eState = FWLTHEME_STATE_Hover;
- break;
- }
- case FWL_PARTSTATE_SCB_Pressed: {
- eState = FWLTHEME_STATE_Pressed;
- break;
- }
- case FWL_PARTSTATE_SCB_Disabled: {
- eState = FWLTHEME_STATE_Disabale;
- break;
- }
+FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ IFWL_Widget* pWidget = pParams->m_pWidget;
+ FX_DWORD dwStyleEx = pWidget->GetStylesEx();
+ FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
+ switch (pParams->m_dwStates & 0x03) {
+ case FWL_PARTSTATE_SCB_Hovered: {
+ eState = FWLTHEME_STATE_Hover;
+ break;
}
- CFX_Graphics *pGraphics = pParams->m_pGraphics;
- CFX_RectF *pRect = &pParams->m_rtPart;
- FX_BOOL bVert = pWidget->GetStylesEx();
- switch (pParams->m_iPart) {
- case FWL_PART_SCB_ForeArrow: {
- DrawMaxMinBtn(pGraphics, pRect, bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix);
- break;
- }
- case FWL_PART_SCB_BackArrow: {
- DrawMaxMinBtn(pGraphics, pRect, bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix);
- break;
- }
- case FWL_PART_SCB_Thumb: {
- DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix);
- break;
- }
- case FWL_PART_SCB_LowerTrack: {
- DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix);
- break;
- }
- case FWL_PART_SCB_UpperTrack: {
- DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix);
- break;
- }
- default: {
- }
+ case FWL_PARTSTATE_SCB_Pressed: {
+ eState = FWLTHEME_STATE_Pressed;
+ break;
}
- return TRUE;
-}
-#ifdef THEME_XPSimilar
-void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_BOOL bVert, FWLTHEME_STATE eState, FX_BOOL bPawButton, CFX_Matrix *pMatrix )
-{
- if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) {
- return;
+ case FWL_PARTSTATE_SCB_Disabled: {
+ eState = FWLTHEME_STATE_Disabale;
+ break;
}
- CFX_Path path;
- path.Create();
- CFX_RectF rect(*pRect);
- if (bVert) {
- rect.Deflate(1, 0);
- if (rect.IsEmpty(0.1f)) {
- return;
- }
- path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
- DrawAxialShading(pGraphics,
- rect.left,
- rect.top,
- rect.right(),
- rect.top,
- m_pThemeData->clrBtnBK[eState - 1][0],
- m_pThemeData->clrBtnBK[eState - 1][1],
- &path,
- FXFILL_WINDING,
- pMatrix);
- CFX_Color rcStroke;
- rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]);
- pGraphics->SaveGraphState();
- pGraphics->SetStrokeColor(&rcStroke);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
- } else {
- rect.Deflate(0, 1);
- if (rect.IsEmpty(0.1f)) {
- return;
- }
- path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
- DrawAxialShading(pGraphics,
- rect.left,
- rect.top,
- rect.left,
- rect.bottom(),
- m_pThemeData->clrBtnBK[eState - 1][0],
- m_pThemeData->clrBtnBK[eState - 1][1],
- &path,
- FXFILL_WINDING,
- pMatrix);
- CFX_Color rcStroke;
- rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]);
- pGraphics->SaveGraphState();
- pGraphics->SetStrokeColor(&rcStroke);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
+ }
+ CFX_Graphics* pGraphics = pParams->m_pGraphics;
+ CFX_RectF* pRect = &pParams->m_rtPart;
+ FX_BOOL bVert = pWidget->GetStylesEx();
+ switch (pParams->m_iPart) {
+ case FWL_PART_SCB_ForeArrow: {
+ DrawMaxMinBtn(pGraphics, pRect,
+ bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left,
+ eState, &pParams->m_matrix);
+ break;
}
-}
-void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_BOOL bVert, FWLTHEME_STATE eState, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- if (bVert) {
- FX_FLOAT fPawLen = FWL_SCROLL_PawLen;
- if (pRect->width / 2 <= fPawLen) {
- fPawLen = (pRect->width - 6) / 2 ;
- }
- FX_FLOAT fX = pRect->left + pRect->width / 4;
- FX_FLOAT fY = pRect->top + pRect->height / 2;
- path.MoveTo(fX, fY - 4);
- path.LineTo(fX + fPawLen, fY - 4);
- path.MoveTo(fX, fY - 2);
- path.LineTo(fX + fPawLen, fY - 2);
- path.MoveTo(fX , fY);
- path.LineTo(fX + fPawLen, fY);
- path.MoveTo(fX, fY + 2);
- path.LineTo(fX + fPawLen, fY + 2);
- CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]);
- pGraphics->SetLineWidth(1);
- pGraphics->SetStrokeColor(&clrLight);
- pGraphics->StrokePath(&path);
- fX++;
- path.Clear();
- path.MoveTo(fX, fY - 3);
- path.LineTo(fX + fPawLen, fY - 3);
- path.MoveTo(fX, fY - 1);
- path.LineTo(fX + fPawLen, fY - 1);
- path.MoveTo(fX, fY + 1);
- path.LineTo(fX + fPawLen, fY + 1);
- path.MoveTo(fX, fY + 3);
- path.LineTo(fX + fPawLen, fY + 3);
- CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]);
- pGraphics->SetLineWidth(1);
- pGraphics->SetStrokeColor(&clrDark);
- pGraphics->StrokePath(&path, pMatrix);
- } else {
- FX_FLOAT fPawLen = FWL_SCROLL_PawLen;
- if (pRect->height / 2 <= fPawLen) {
- fPawLen = (pRect->height - 6) / 2;
- }
- FX_FLOAT fX = pRect->left + pRect->width / 2;
- FX_FLOAT fY = pRect->top + pRect->height / 4;
- path.MoveTo(fX - 4, fY);
- path.LineTo(fX - 4, fY + fPawLen);
- path.MoveTo(fX - 2, fY);
- path.LineTo(fX - 2, fY + fPawLen);
- path.MoveTo(fX, fY);
- path.LineTo(fX, fY + fPawLen);
- path.MoveTo(fX + 2, fY);
- path.LineTo(fX + 2, fY + fPawLen);
- CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]);
- pGraphics->SetLineWidth(1);
- pGraphics->SetStrokeColor(&clrLight);
- pGraphics->StrokePath(&path, pMatrix);
- fY ++;
- path.Clear();
- path.MoveTo(fX - 3, fY);
- path.LineTo(fX - 3, fY + fPawLen);
- path.MoveTo(fX - 1, fY);
- path.LineTo(fX - 1, fY + fPawLen);
- path.MoveTo(fX + 1, fY);
- path.LineTo(fX + 1, fY + fPawLen);
- path.MoveTo(fX + 3, fY);
- path.LineTo(fX + 3, fY + fPawLen);
- CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]);
- pGraphics->SetLineWidth(1);
- pGraphics->SetStrokeColor(&clrDark);
- pGraphics->StrokePath(&path, pMatrix);
+ case FWL_PART_SCB_BackArrow: {
+ DrawMaxMinBtn(pGraphics, pRect,
+ bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right,
+ eState, &pParams->m_matrix);
+ break;
}
-}
-void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_BOOL bVert, FWLTHEME_STATE eState, FX_BOOL bLowerTrack, CFX_Matrix *pMatrix )
-{
- if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) {
- return;
+ case FWL_PART_SCB_Thumb: {
+ DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix);
+ break;
}
- pGraphics->SaveGraphState();
- CFX_Color colorLine(ArgbEncode(255, 238, 237, 229));
- CFX_Path path;
- path.Create();
- FX_FLOAT fRight = pRect->right();
- FX_FLOAT fBottom = pRect->bottom();
- if (bVert) {
- path.AddRectangle(pRect->left, pRect->top, 1, pRect->height);
- path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height);
- } else {
- path.AddRectangle(pRect->left, pRect->top, pRect->width, 1);
- path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1);
+ case FWL_PART_SCB_LowerTrack: {
+ DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix);
+ break;
}
- pGraphics->SetFillColor(&colorLine);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, pRect->height);
- FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left;
- FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1;
- FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left;
- FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1;
- pGraphics->RestoreGraphState();
- DrawAxialShading(pGraphics,
- x1, y1, x2, y2,
- m_pThemeData->clrTrackBKStart,
- m_pThemeData->clrTrackBKEnd,
- &path,
- FXFILL_WINDING,
- pMatrix);
-}
-void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_DIRECTION eDict, FWLTHEME_STATE eState, CFX_Matrix *pMatrix )
-{
- DrawTrack(pGraphics,
- pRect,
- eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down,
- eState,
- TRUE,
- pMatrix);
- CFX_RectF rtArrowBtn(*pRect);
- rtArrowBtn.Deflate(1, 1, 1, 1);
- DrawArrowBtn(pGraphics, &rtArrowBtn, eDict, eState, pMatrix);
+ case FWL_PART_SCB_UpperTrack: {
+ DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix);
+ break;
+ }
+ default: {}
+ }
+ return TRUE;
}
-#else
-void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_BOOL bVert, FWLTHEME_STATE eState, FX_BOOL bPawButton, CFX_Matrix *pMatrix )
-{
- if (pRect->IsEmpty()) {
- return;
+#ifdef THEME_XPSimilar
+void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FX_BOOL bVert,
+ FWLTHEME_STATE eState,
+ FX_BOOL bPawButton,
+ CFX_Matrix* pMatrix) {
+ if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) {
+ return;
+ }
+ CFX_Path path;
+ path.Create();
+ CFX_RectF rect(*pRect);
+ if (bVert) {
+ rect.Deflate(1, 0);
+ if (rect.IsEmpty(0.1f)) {
+ return;
}
- CFX_RectF rtThumb(*pRect);
- FX_FLOAT fWidth = 2;
- Draw3DRect(pGraphics, FWLTHEME_EDGE_Raised, fWidth, pRect, FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth, pRect->width - 2 * fWidth, pRect->height - 2 * fWidth);
+ path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
+ DrawAxialShading(pGraphics, rect.left, rect.top, rect.right(), rect.top,
+ m_pThemeData->clrBtnBK[eState - 1][0],
+ m_pThemeData->clrBtnBK[eState - 1][1], &path,
+ FXFILL_WINDING, pMatrix);
+ CFX_Color rcStroke;
+ rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]);
pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->SetStrokeColor(&rcStroke);
+ pGraphics->StrokePath(&path, pMatrix);
pGraphics->RestoreGraphState();
-}
-void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FX_BOOL bVert, FWLTHEME_STATE eState, FX_BOOL bLowerTrack, CFX_Matrix *pMatrix )
-{
- if (pRect->IsEmpty()) {
- return;
+ } else {
+ rect.Deflate(0, 1);
+ if (rect.IsEmpty(0.1f)) {
+ return;
}
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
+ DrawAxialShading(pGraphics, rect.left, rect.top, rect.left, rect.bottom(),
+ m_pThemeData->clrBtnBK[eState - 1][0],
+ m_pThemeData->clrBtnBK[eState - 1][1], &path,
+ FXFILL_WINDING, pMatrix);
+ CFX_Color rcStroke;
+ rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]);
pGraphics->SaveGraphState();
- CFX_Color clrFill(0xFFF0F0F0);
- pGraphics->SetFillColor(&clrFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->SetStrokeColor(&rcStroke);
+ pGraphics->StrokePath(&path, pMatrix);
pGraphics->RestoreGraphState();
+ }
}
-void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_DIRECTION eDict, FWLTHEME_STATE eState, CFX_Matrix *pMatrix )
-{
- CFX_RectF rtThumb(*pRect);
- FX_FLOAT fWidth = eState == FWLTHEME_STATE_Pressed ? 1.0f : 2.0f;
- FWLTHEME_EDGE eType = eState == FWLTHEME_STATE_Pressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
- Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth, pRect->width - 2 * fWidth, pRect->height - 2 * fWidth);
- pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
- DrawArrow(pGraphics,
- pRect,
- eDict,
- eState == FWLTHEME_STATE_Disabale ? 0xFFA0A0A0 : 0xFF000000,
- eState == FWLTHEME_STATE_Pressed,
- pMatrix);
+void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FX_BOOL bVert,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ if (bVert) {
+ FX_FLOAT fPawLen = FWL_SCROLL_PawLen;
+ if (pRect->width / 2 <= fPawLen) {
+ fPawLen = (pRect->width - 6) / 2;
+ }
+ FX_FLOAT fX = pRect->left + pRect->width / 4;
+ FX_FLOAT fY = pRect->top + pRect->height / 2;
+ path.MoveTo(fX, fY - 4);
+ path.LineTo(fX + fPawLen, fY - 4);
+ path.MoveTo(fX, fY - 2);
+ path.LineTo(fX + fPawLen, fY - 2);
+ path.MoveTo(fX, fY);
+ path.LineTo(fX + fPawLen, fY);
+ path.MoveTo(fX, fY + 2);
+ path.LineTo(fX + fPawLen, fY + 2);
+ CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]);
+ pGraphics->SetLineWidth(1);
+ pGraphics->SetStrokeColor(&clrLight);
+ pGraphics->StrokePath(&path);
+ fX++;
+ path.Clear();
+ path.MoveTo(fX, fY - 3);
+ path.LineTo(fX + fPawLen, fY - 3);
+ path.MoveTo(fX, fY - 1);
+ path.LineTo(fX + fPawLen, fY - 1);
+ path.MoveTo(fX, fY + 1);
+ path.LineTo(fX + fPawLen, fY + 1);
+ path.MoveTo(fX, fY + 3);
+ path.LineTo(fX + fPawLen, fY + 3);
+ CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]);
+ pGraphics->SetLineWidth(1);
+ pGraphics->SetStrokeColor(&clrDark);
+ pGraphics->StrokePath(&path, pMatrix);
+ } else {
+ FX_FLOAT fPawLen = FWL_SCROLL_PawLen;
+ if (pRect->height / 2 <= fPawLen) {
+ fPawLen = (pRect->height - 6) / 2;
+ }
+ FX_FLOAT fX = pRect->left + pRect->width / 2;
+ FX_FLOAT fY = pRect->top + pRect->height / 4;
+ path.MoveTo(fX - 4, fY);
+ path.LineTo(fX - 4, fY + fPawLen);
+ path.MoveTo(fX - 2, fY);
+ path.LineTo(fX - 2, fY + fPawLen);
+ path.MoveTo(fX, fY);
+ path.LineTo(fX, fY + fPawLen);
+ path.MoveTo(fX + 2, fY);
+ path.LineTo(fX + 2, fY + fPawLen);
+ CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]);
+ pGraphics->SetLineWidth(1);
+ pGraphics->SetStrokeColor(&clrLight);
+ pGraphics->StrokePath(&path, pMatrix);
+ fY++;
+ path.Clear();
+ path.MoveTo(fX - 3, fY);
+ path.LineTo(fX - 3, fY + fPawLen);
+ path.MoveTo(fX - 1, fY);
+ path.LineTo(fX - 1, fY + fPawLen);
+ path.MoveTo(fX + 1, fY);
+ path.LineTo(fX + 1, fY + fPawLen);
+ path.MoveTo(fX + 3, fY);
+ path.LineTo(fX + 3, fY + fPawLen);
+ CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]);
+ pGraphics->SetLineWidth(1);
+ pGraphics->SetStrokeColor(&clrDark);
+ pGraphics->StrokePath(&path, pMatrix);
+ }
+}
+void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FX_BOOL bVert,
+ FWLTHEME_STATE eState,
+ FX_BOOL bLowerTrack,
+ CFX_Matrix* pMatrix) {
+ if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) {
+ return;
+ }
+ pGraphics->SaveGraphState();
+ CFX_Color colorLine(ArgbEncode(255, 238, 237, 229));
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fBottom = pRect->bottom();
+ if (bVert) {
+ path.AddRectangle(pRect->left, pRect->top, 1, pRect->height);
+ path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height);
+ } else {
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, 1);
+ path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1);
+ }
+ pGraphics->SetFillColor(&colorLine);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ path.Clear();
+ path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2,
+ pRect->height);
+ FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left;
+ FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1;
+ FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left;
+ FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1;
+ pGraphics->RestoreGraphState();
+ DrawAxialShading(pGraphics, x1, y1, x2, y2, m_pThemeData->clrTrackBKStart,
+ m_pThemeData->clrTrackBKEnd, &path, FXFILL_WINDING, pMatrix);
+}
+void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_DIRECTION eDict,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix) {
+ DrawTrack(pGraphics, pRect,
+ eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down,
+ eState, TRUE, pMatrix);
+ CFX_RectF rtArrowBtn(*pRect);
+ rtArrowBtn.Deflate(1, 1, 1, 1);
+ DrawArrowBtn(pGraphics, &rtArrowBtn, eDict, eState, pMatrix);
+}
+#else
+void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FX_BOOL bVert,
+ FWLTHEME_STATE eState,
+ FX_BOOL bPawButton,
+ CFX_Matrix* pMatrix) {
+ if (pRect->IsEmpty()) {
+ return;
+ }
+ CFX_RectF rtThumb(*pRect);
+ FX_FLOAT fWidth = 2;
+ Draw3DRect(pGraphics, FWLTHEME_EDGE_Raised, fWidth, pRect,
+ FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2,
+ FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth,
+ pRect->width - 2 * fWidth, pRect->height - 2 * fWidth);
+ pGraphics->SaveGraphState();
+ CFX_Color crFill(FWLTHEME_COLOR_Background);
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FX_BOOL bVert,
+ FWLTHEME_STATE eState,
+ FX_BOOL bLowerTrack,
+ CFX_Matrix* pMatrix) {
+ if (pRect->IsEmpty()) {
+ return;
+ }
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ pGraphics->SaveGraphState();
+ CFX_Color clrFill(0xFFF0F0F0);
+ pGraphics->SetFillColor(&clrFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_DIRECTION eDict,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix) {
+ CFX_RectF rtThumb(*pRect);
+ FX_FLOAT fWidth = eState == FWLTHEME_STATE_Pressed ? 1.0f : 2.0f;
+ FWLTHEME_EDGE eType = eState == FWLTHEME_STATE_Pressed ? FWLTHEME_EDGE_Flat
+ : FWLTHEME_EDGE_Raised;
+ Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1,
+ FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1,
+ FWLTHEME_COLOR_EDGERB2, pMatrix);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth,
+ pRect->width - 2 * fWidth, pRect->height - 2 * fWidth);
+ pGraphics->SaveGraphState();
+ CFX_Color crFill(FWLTHEME_COLOR_Background);
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+ DrawArrow(pGraphics, pRect, eDict,
+ eState == FWLTHEME_STATE_Disabale ? 0xFFA0A0A0 : 0xFF000000,
+ eState == FWLTHEME_STATE_Pressed, pMatrix);
}
#endif
-void CFWL_ScrollBarTP::SetThemeData(FX_DWORD dwID)
-{
- m_pThemeData->clrPawColorLight[3] = ArgbEncode(0xff, 208, 223, 172);
- m_pThemeData->clrPawColorDark[3] = ArgbEncode(0xff, 140, 157, 115);
- m_pThemeData->clrBtnBK[3][0] = ArgbEncode(0xff, 164, 180, 139);
- m_pThemeData->clrBtnBK[3][1] = ArgbEncode(0xff, 141, 157, 115);
- m_pThemeData->clrBtnBorder[3] = ArgbEncode(0xff, 236, 233, 216);
- if (dwID) {
- m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 208, 223, 172);
- m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 157, 115);
- m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 162, 179, 141);
- m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 149, 167, 117);
- m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 142, 153, 125);
- m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 235, 245, 212);
- m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 182, 198, 142);
- m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 200, 213, 170);
- m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 195, 208, 150);
- m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 189, 203, 150);
- m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 208, 223, 172);
- m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 140, 157, 115);
- m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 164, 180, 139);
- m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 141, 157, 115);
- m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 128, 146, 102);
- m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236);
- m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251);
- } else {
- m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 238, 244, 254);
- m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 176, 248);
- m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 197, 213, 252);
- m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 182, 205, 251);
- m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 148, 176, 221);
- m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 252, 253, 255);
- m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 156, 197, 255);
- m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 216, 232, 255);
- m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 204, 225, 255);
- m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254);
- m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253);
- m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216);
- m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245);
- m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249);
- m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211);
- m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236);
- m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251);
- }
+void CFWL_ScrollBarTP::SetThemeData(FX_DWORD dwID) {
+ m_pThemeData->clrPawColorLight[3] = ArgbEncode(0xff, 208, 223, 172);
+ m_pThemeData->clrPawColorDark[3] = ArgbEncode(0xff, 140, 157, 115);
+ m_pThemeData->clrBtnBK[3][0] = ArgbEncode(0xff, 164, 180, 139);
+ m_pThemeData->clrBtnBK[3][1] = ArgbEncode(0xff, 141, 157, 115);
+ m_pThemeData->clrBtnBorder[3] = ArgbEncode(0xff, 236, 233, 216);
+ if (dwID) {
+ m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 208, 223, 172);
+ m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 157, 115);
+ m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 162, 179, 141);
+ m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 149, 167, 117);
+ m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 142, 153, 125);
+ m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 235, 245, 212);
+ m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 182, 198, 142);
+ m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 200, 213, 170);
+ m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 195, 208, 150);
+ m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 189, 203, 150);
+ m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 208, 223, 172);
+ m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 140, 157, 115);
+ m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 164, 180, 139);
+ m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 141, 157, 115);
+ m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 128, 146, 102);
+ m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236);
+ m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251);
+ } else {
+ m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 238, 244, 254);
+ m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 176, 248);
+ m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 197, 213, 252);
+ m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 182, 205, 251);
+ m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 148, 176, 221);
+ m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 252, 253, 255);
+ m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 156, 197, 255);
+ m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 216, 232, 255);
+ m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 204, 225, 255);
+ m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254);
+ m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253);
+ m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216);
+ m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245);
+ m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249);
+ m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211);
+ m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236);
+ m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251);
+ }
}
diff --git a/xfa/src/fwl/src/theme/widgettp.cpp b/xfa/src/fwl/src/theme/widgettp.cpp index 7ce08abb27..8d421b6209 100644 --- a/xfa/src/fwl/src/theme/widgettp.cpp +++ b/xfa/src/fwl/src/theme/widgettp.cpp @@ -5,823 +5,824 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-static void FWL_SetChildThemeID(IFWL_Widget *pParent, FX_DWORD dwThemeID)
-{
- IFWL_WidgetMgr *pWidgetMgr = FWL_GetWidgetMgr();
- IFWL_Widget *pChild = pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
- while (pChild) {
- IFWL_ThemeProvider *pTheme = pChild->GetThemeProvider();
- if (pTheme) {
- pTheme->SetThemeID(pChild, dwThemeID, FALSE);
- }
- FWL_SetChildThemeID(pChild, dwThemeID);
- pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
+static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) {
+ IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
+ IFWL_Widget* pChild =
+ pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
+ while (pChild) {
+ IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider();
+ if (pTheme) {
+ pTheme->SetThemeID(pChild, dwThemeID, FALSE);
}
-}
-FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- return FALSE;
-}
-FX_DWORD CFWL_WidgetTP::GetThemeID(IFWL_Widget *pWidget)
-{
- return m_dwThemeID;
-}
-FX_DWORD CFWL_WidgetTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- FX_DWORD dwOld = m_dwThemeID;
- m_dwThemeID = dwThemeID;
- if (CFWL_ArrowData::IsInstance()) {
- CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID));
+ FWL_SetChildThemeID(pChild, dwThemeID);
+ pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
+ }
+}
+FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return FALSE;
+}
+FX_DWORD CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) {
+ return m_dwThemeID;
+}
+FX_DWORD CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ FX_DWORD dwOld = m_dwThemeID;
+ m_dwThemeID = dwThemeID;
+ if (CFWL_ArrowData::IsInstance()) {
+ CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID));
+ }
+ if (bChildren) {
+ FWL_SetChildThemeID(pWidget, dwThemeID);
+ }
+ return dwOld;
+}
+FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget,
+ CFX_Matrix& matrix) {
+ matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) {
+ _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ return TRUE;
+}
+FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
+ if (!m_pTextOut) {
+ InitTTO();
+ }
+ int32_t iLen = pParams->m_wsText.GetLength();
+ _FWL_RETURN_VALUE_IF_FAIL(iLen > 0, FALSE)
+ CFX_Graphics* pGraphics = pParams->m_pGraphics;
+ m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice());
+ m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
+ m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
+ CFX_Matrix* pMatrix = &pParams->m_matrix;
+ pMatrix->Concat(*pGraphics->GetMatrix());
+ m_pTextOut->SetMatrix(*pMatrix);
+ m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart);
+ return TRUE;
+}
+void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ switch (dwCapacity) {
+ case FWL_WGTCAPACITY_CXBorder: {
+ m_fValue = FWLTHEME_CAPACITY_CXBorder;
+ break;
}
- if (bChildren) {
- FWL_SetChildThemeID(pWidget, dwThemeID);
+ case FWL_WGTCAPACITY_CYBorder: {
+ m_fValue = FWLTHEME_CAPACITY_CYBorder;
+ break;
}
- return dwOld;
-}
-FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget *pWidget, CFX_Matrix &matrix)
-{
- matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget *pWidget, const CFX_Matrix &matrix)
-{
- _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- return TRUE;
-}
-FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText *pParams)
-{
- if (!m_pTextOut) {
- InitTTO();
+ case FWL_WGTCAPACITY_EdgeFlat: {
+ m_fValue = FWLTHEME_CAPACITY_EdgeFlat;
+ break;
}
- int32_t iLen = pParams->m_wsText.GetLength();
- _FWL_RETURN_VALUE_IF_FAIL(iLen > 0, FALSE)
- CFX_Graphics *pGraphics = pParams->m_pGraphics;
- m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice());
- m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
- m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
- CFX_Matrix *pMatrix = &pParams->m_matrix;
- pMatrix->Concat(*pGraphics->GetMatrix());
- m_pTextOut->SetMatrix(*pMatrix);
- m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart);
- return TRUE;
-}
-void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- switch(dwCapacity) {
- case FWL_WGTCAPACITY_CXBorder: {
- m_fValue = FWLTHEME_CAPACITY_CXBorder;
- break;
- }
- case FWL_WGTCAPACITY_CYBorder: {
- m_fValue = FWLTHEME_CAPACITY_CYBorder;
- break;
- }
- case FWL_WGTCAPACITY_EdgeFlat: {
- m_fValue = FWLTHEME_CAPACITY_EdgeFlat;
- break;
- }
- case FWL_WGTCAPACITY_EdgeRaised: {
- m_fValue = FWLTHEME_CAPACITY_EdgeRaised;
- break;
- }
- case FWL_WGTCAPACITY_EdgeSunken: {
- m_fValue = FWLTHEME_CAPACITY_EdgeSunken;
- break;
- }
- case FWL_WGTCAPACITY_FontSize: {
- m_fValue = FWLTHEME_CAPACITY_FontSize;
- break;
- }
- case FWL_WGTCAPACITY_TextColor: {
- m_dwValue = FWLTHEME_CAPACITY_TextColor;
- return &m_dwValue;
- }
- case FWL_WGTCAPACITY_ScrollBarWidth: {
- m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth;
- break;
- }
- case FWL_WGTCAPACITY_Font: {
- return m_pFDEFont;
- }
- case FWL_WGTCAPACITY_TextSelColor: {
- m_dwValue = (m_dwThemeID == 0) ? FWLTHEME_CAPACITY_TextSelColor : FWLTHEME_COLOR_Green_BKSelected;
- return &m_dwValue;
- }
- case FWL_WGTCAPACITY_LineHeight: {
- m_fValue = FWLTHEME_CAPACITY_LineHeight;
- break;
- }
- case FWL_WGTCAPACITY_UIMargin: {
- m_rtMargin.Set(0, 0, 0, 0);
- return &m_rtMargin;
- }
- default: {
- return NULL;
- }
+ case FWL_WGTCAPACITY_EdgeRaised: {
+ m_fValue = FWLTHEME_CAPACITY_EdgeRaised;
+ break;
}
- return &m_fValue;
-}
-FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget *pWidget)
-{
- return FWL_GetThemeLayout(m_dwThemeID);
-}
-FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart *pThemePart, CFX_RectF &rect)
-{
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart *pThemePart, FX_FLOAT fx, FX_FLOAT fy)
-{
- return TRUE;
-}
-FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText *pParams, CFX_RectF &rect)
-{
- _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
- _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
- m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
- m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext);
- m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(), rect);
- return TRUE;
-}
-FWL_ERR CFWL_WidgetTP::Initialize()
-{
- m_dwThemeID = 0;
- _ctm.Reset();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetTP::Finalize()
-{
- if(!m_pTextOut) {
- FinalizeTTO();
+ case FWL_WGTCAPACITY_EdgeSunken: {
+ m_fValue = FWLTHEME_CAPACITY_EdgeSunken;
+ break;
}
- return FWL_ERR_Succeeded;
-}
-CFWL_WidgetTP::~CFWL_WidgetTP()
-{
-}
-FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget *pWidget, const FX_WCHAR* strFont, FX_FLOAT fFontSize, FX_ARGB rgbFont)
-{
- if (!m_pTextOut) {
- return FWL_ERR_Succeeded;
+ case FWL_WGTCAPACITY_FontSize: {
+ m_fValue = FWLTHEME_CAPACITY_FontSize;
+ break;
}
- m_pFDEFont = FWL_GetFontManager()->FindFont(strFont, 0, 0);
- m_pTextOut->SetFont(m_pFDEFont);
- m_pTextOut->SetFontSize(fFontSize);
- m_pTextOut->SetTextColor(rgbFont);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget *pWidget, IFX_Font *pFont, FX_FLOAT fFontSize, FX_ARGB rgbFont)
-{
- if (!m_pTextOut) {
- return FWL_ERR_Succeeded;
+ case FWL_WGTCAPACITY_TextColor: {
+ m_dwValue = FWLTHEME_CAPACITY_TextColor;
+ return &m_dwValue;
+ }
+ case FWL_WGTCAPACITY_ScrollBarWidth: {
+ m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth;
+ break;
+ }
+ case FWL_WGTCAPACITY_Font: {
+ return m_pFDEFont;
}
- m_pTextOut->SetFont(pFont);
- m_pTextOut->SetFontSize(fFontSize);
- m_pTextOut->SetTextColor(rgbFont);
+ case FWL_WGTCAPACITY_TextSelColor: {
+ m_dwValue = (m_dwThemeID == 0) ? FWLTHEME_CAPACITY_TextSelColor
+ : FWLTHEME_COLOR_Green_BKSelected;
+ return &m_dwValue;
+ }
+ case FWL_WGTCAPACITY_LineHeight: {
+ m_fValue = FWLTHEME_CAPACITY_LineHeight;
+ break;
+ }
+ case FWL_WGTCAPACITY_UIMargin: {
+ m_rtMargin.Set(0, 0, 0, 0);
+ return &m_rtMargin;
+ }
+ default: { return NULL; }
+ }
+ return &m_fValue;
+}
+FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) {
+ return FWL_GetThemeLayout(m_dwThemeID);
+}
+FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart,
+ CFX_RectF& rect) {
+ return FWL_ERR_Succeeded;
+}
+FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ return TRUE;
+}
+FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
+ _FWL_RETURN_VALUE_IF_FAIL(pParams, FALSE);
+ _FWL_RETURN_VALUE_IF_FAIL(m_pTextOut, FALSE);
+ m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
+ m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext);
+ m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(),
+ rect);
+ return TRUE;
+}
+FWL_ERR CFWL_WidgetTP::Initialize() {
+ m_dwThemeID = 0;
+ _ctm.Reset();
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetTP::Finalize() {
+ if (!m_pTextOut) {
+ FinalizeTTO();
+ }
+ return FWL_ERR_Succeeded;
+}
+CFWL_WidgetTP::~CFWL_WidgetTP() {}
+FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
+ const FX_WCHAR* strFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont) {
+ if (!m_pTextOut) {
return FWL_ERR_Succeeded;
+ }
+ m_pFDEFont = FWL_GetFontManager()->FindFont(strFont, 0, 0);
+ m_pTextOut->SetFont(m_pFDEFont);
+ m_pTextOut->SetFontSize(fFontSize);
+ m_pTextOut->SetTextColor(rgbFont);
+ return FWL_ERR_Succeeded;
+}
+FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
+ IFX_Font* pFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont) {
+ if (!m_pTextOut) {
+ return FWL_ERR_Succeeded;
+ }
+ m_pTextOut->SetFont(pFont);
+ m_pTextOut->SetFontSize(fFontSize);
+ m_pTextOut->SetTextColor(rgbFont);
+ return FWL_ERR_Succeeded;
}
-IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget *pWidget)
-{
- return m_pFDEFont;
+IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) {
+ return m_pFDEFont;
}
CFWL_WidgetTP::CFWL_WidgetTP()
- : m_dwRefCount(1)
- , m_pTextOut(NULL)
- , m_pFDEFont(NULL)
- , m_dwThemeID(0)
-{
-}
-FX_ERR CFWL_WidgetTP::InitTTO()
-{
- if (m_pTextOut) {
- return FWL_ERR_Succeeded;
- }
- m_pFDEFont = FWL_GetFontManager()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
- m_pTextOut = IFDE_TextOut::Create();
- m_pTextOut->SetFont(m_pFDEFont);
- m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
- m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
- m_pTextOut->SetEllipsisString(L"...");
- return FWL_ERR_Succeeded;
-}
-FX_ERR CFWL_WidgetTP::FinalizeTTO()
-{
- if (m_pTextOut) {
- m_pTextOut->Release();
- m_pTextOut = NULL;
- }
+ : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {}
+FX_ERR CFWL_WidgetTP::InitTTO() {
+ if (m_pTextOut) {
return FWL_ERR_Succeeded;
+ }
+ m_pFDEFont = FWL_GetFontManager()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
+ m_pTextOut = IFDE_TextOut::Create();
+ m_pTextOut->SetFont(m_pFDEFont);
+ m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
+ m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
+ m_pTextOut->SetEllipsisString(L"...");
+ return FWL_ERR_Succeeded;
+}
+FX_ERR CFWL_WidgetTP::FinalizeTTO() {
+ if (m_pTextOut) {
+ m_pTextOut->Release();
+ m_pTextOut = NULL;
+ }
+ return FWL_ERR_Succeeded;
}
#ifdef THEME_XPSimilar
-void CFWL_WidgetTP::DrawEdge(CFX_Graphics *pGraphics, FX_DWORD dwStyles, const CFX_RectF *pRect, CFX_Matrix *pMatrix)
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- pGraphics->SaveGraphState();
- CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 ? ArgbEncode(255, 127, 157, 185) : FWLTHEME_COLOR_Green_BKSelected);
- pGraphics->SetStrokeColor(&crStroke);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, pRect->height - 1);
- pGraphics->StrokePath(&path, pMatrix);
- path.Clear();
- crStroke = ArgbEncode(255, 255, 255, 255);
- pGraphics->SetStrokeColor(&crStroke);
- path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, pRect->height - 3);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
+void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics,
+ FX_DWORD dwStyles,
+ const CFX_RectF* pRect,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ pGraphics->SaveGraphState();
+ CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0
+ ? ArgbEncode(255, 127, 157, 185)
+ : FWLTHEME_COLOR_Green_BKSelected);
+ pGraphics->SetStrokeColor(&crStroke);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left, pRect->top, pRect->width - 1,
+ pRect->height - 1);
+ pGraphics->StrokePath(&path, pMatrix);
+ path.Clear();
+ crStroke = ArgbEncode(255, 255, 255, 255);
+ pGraphics->SetStrokeColor(&crStroke);
+ path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3,
+ pRect->height - 3);
+ pGraphics->StrokePath(&path, pMatrix);
+ pGraphics->RestoreGraphState();
}
#else
-void CFWL_WidgetTP::DrawEdge(CFX_Graphics *pGraphics, FX_DWORD dwStyles, const CFX_RectF *pRect, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- FWLTHEME_EDGE eType;
- FX_FLOAT fWidth;
- switch(dwStyles & FWL_WGTSTYLE_EdgeMask) {
- case FWL_WGTSTYLE_EdgeRaised: {
- eType = FWLTHEME_EDGE_Raised, fWidth = FWLTHEME_CAPACITY_EdgeRaised;
- break;
- }
- case FWL_WGTSTYLE_EdgeSunken: {
- eType = FWLTHEME_EDGE_Sunken, fWidth = FWLTHEME_CAPACITY_EdgeSunken;
- break;
- }
- case FWL_WGTSTYLE_EdgeFlat:
- default: {
- return;
- }
+void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics,
+ FX_DWORD dwStyles,
+ const CFX_RectF* pRect,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ FWLTHEME_EDGE eType;
+ FX_FLOAT fWidth;
+ switch (dwStyles & FWL_WGTSTYLE_EdgeMask) {
+ case FWL_WGTSTYLE_EdgeRaised: {
+ eType = FWLTHEME_EDGE_Raised, fWidth = FWLTHEME_CAPACITY_EdgeRaised;
+ break;
}
- Draw3DRect(pGraphics,
- eType,
- fWidth,
- pRect,
- FWLTHEME_COLOR_EDGELT1,
- FWLTHEME_COLOR_EDGELT2,
- FWLTHEME_COLOR_EDGERB1,
- FWLTHEME_COLOR_EDGERB2,
- pMatrix);
-}
-#endif
-void CFWL_WidgetTP::Draw3DRect(CFX_Graphics *pGraphics, FWLTHEME_EDGE eType, FX_FLOAT fWidth, const CFX_RectF *pRect, FX_ARGB cr1, FX_ARGB cr2, FX_ARGB cr3, FX_ARGB cr4, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- pGraphics->SaveGraphState();
- if (eType == FWLTHEME_EDGE_Flat) {
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left,
- pRect->top,
- pRect->width,
- pRect->height);
- path.AddRectangle(pRect->left + 1,
- pRect->top + 1,
- pRect->width - 2,
- pRect->height - 2);
- CFX_Color cr(ArgbEncode(255, 100, 100, 100));
- pGraphics->SetFillColor(&cr);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- path.Clear();
- path.AddRectangle(pRect->left + 1,
- pRect->top + 1,
- pRect->width - 2,
- pRect->height - 2);
- path.AddRectangle(pRect->left + 2,
- pRect->top + 2,
- pRect->width - 4,
- pRect->height - 4);
- cr.Set(0xFFFFFFFF);
- pGraphics->SetFillColor(&cr);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- } else {
- FX_FLOAT fLeft = pRect->left;
- FX_FLOAT fRight = pRect->right();
- FX_FLOAT fTop = pRect->top;
- FX_FLOAT fBottom = pRect->bottom();
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
- CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1);
- pGraphics->SetFillColor(&crLT);
- CFX_Path pathLT;
- pathLT.Create();
- pathLT.MoveTo(fLeft, fBottom - fHalfWidth);
- pathLT.LineTo(fLeft, fTop);
- pathLT.LineTo(fRight - fHalfWidth, fTop);
- pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth);
- pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth);
- pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth);
- pathLT.LineTo(fLeft, fBottom - fHalfWidth);
- pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix);
- crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2);
- pGraphics->SetFillColor(&crLT);
- pathLT.Clear();
- pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth);
- pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth);
- pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth);
- pathLT.LineTo(fRight - fWidth, fTop + fWidth);
- pathLT.LineTo(fLeft + fWidth, fTop + fWidth);
- pathLT.LineTo(fLeft + fWidth, fBottom - fWidth);
- pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth);
- pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix);
- CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3);
- pGraphics->SetFillColor(&crRB);
- CFX_Path pathRB;
- pathRB.Create();
- pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth);
- pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth);
- pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth);
- pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth);
- pathRB.LineTo(fRight - fWidth, fBottom - fWidth);
- pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth);
- pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth);
- pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix);
- crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised
- ? cr2 : cr4);
- pGraphics->SetFillColor(&crRB);
- pathRB.Clear();
- pathRB.MoveTo(fRight, fTop);
- pathRB.LineTo(fRight, fBottom);
- pathRB.LineTo(fLeft, fBottom);
- pathRB.LineTo(fLeft, fBottom - fHalfWidth);
- pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth);
- pathRB.LineTo(fRight - fHalfWidth, fTop);
- pathRB.LineTo(fRight, fTop);
- pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix);
+ case FWL_WGTSTYLE_EdgeSunken: {
+ eType = FWLTHEME_EDGE_Sunken, fWidth = FWLTHEME_CAPACITY_EdgeSunken;
+ break;
}
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics *pGraphics, FWLTHEME_EDGE eType, FX_FLOAT fWidth, const CFX_RectF *pRect, FX_ARGB cr1, FX_ARGB cr2, FX_ARGB cr3, FX_ARGB cr4, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- pGraphics->SaveGraphState();
- FX_FLOAT fRadius = pRect->width / 2;
- CFX_Path path;
- path.Create();
- path.AddArc(pRect->left,
- pRect->top,
- pRect->width,
- pRect->height,
- FWLTHEME_PI * 3 / 4,
- FWLTHEME_PI);
- CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1);
- pGraphics->SetStrokeColor(&crFill1);
- pGraphics->StrokePath(&path, pMatrix);
- CFX_RectF rtInner(*pRect);
- rtInner.Deflate(pRect->width / 4, pRect->height / 4);
- path.Clear();
- path.AddArc(rtInner.left,
- rtInner.top,
- rtInner.width,
- rtInner.height,
- FWLTHEME_PI * 3 / 4,
- FWLTHEME_PI);
- CFX_Color crFill2(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2);
- pGraphics->SetStrokeColor(&crFill2);
- pGraphics->StrokePath(&path, pMatrix);
- path.Clear();
- path.AddArc(pRect->left,
- pRect->top,
- pRect->width,
- pRect->height,
- FWLTHEME_PI * 7 / 4,
- FWLTHEME_PI);
- CFX_Color crFill3(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3);
- pGraphics->SetStrokeColor(&crFill3);
- pGraphics->StrokePath(&path, pMatrix);
- path.AddArc(rtInner.left,
- rtInner.top,
- rtInner.width,
- rtInner.height,
- FWLTHEME_PI * 7 / 4,
- FWLTHEME_PI);
- CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4);
- pGraphics->SetStrokeColor(&crFill4);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::DrawBorder(CFX_Graphics *pGraphics, const CFX_RectF *pRect, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
- path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, pRect->height - 2);
- pGraphics->SaveGraphState();
- CFX_Color crFill(ArgbEncode(255, 0, 0, 0));
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::FillBackground(CFX_Graphics *pGraphics, const CFX_RectF *pRect, CFX_Matrix *pMatrix )
-{
- FillSoildRect(pGraphics, FWLTHEME_COLOR_Background, pRect, pMatrix);
+ case FWL_WGTSTYLE_EdgeFlat:
+ default: { return; }
+ }
+ Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1,
+ FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1,
+ FWLTHEME_COLOR_EDGERB2, pMatrix);
}
-void CFWL_WidgetTP::FillSoildRect(CFX_Graphics *pGraphics, FX_ARGB fillColor, const CFX_RectF *pRect, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- pGraphics->SaveGraphState();
- CFX_Color crFill(fillColor);
- pGraphics->SetFillColor(&crFill);
+#endif
+void CFWL_WidgetTP::Draw3DRect(CFX_Graphics* pGraphics,
+ FWLTHEME_EDGE eType,
+ FX_FLOAT fWidth,
+ const CFX_RectF* pRect,
+ FX_ARGB cr1,
+ FX_ARGB cr2,
+ FX_ARGB cr3,
+ FX_ARGB cr4,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ pGraphics->SaveGraphState();
+ if (eType == FWLTHEME_EDGE_Flat) {
CFX_Path path;
path.Create();
path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2,
+ pRect->height - 2);
+ CFX_Color cr(ArgbEncode(255, 100, 100, 100));
+ pGraphics->SetFillColor(&cr);
pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics *pGraphics, FX_FLOAT fx1, FX_FLOAT fy1, FX_FLOAT fx2, FX_FLOAT fy2, FX_ARGB beginColor, FX_ARGB endColor, CFX_Path *path, int32_t fillMode, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(path);
- CFX_PointF begPoint, endPoint;
- begPoint.Set(fx1, fy1);
- endPoint.Set(fx2, fy2);
- CFX_Shading shading;
- shading.CreateAxial(begPoint, endPoint, FALSE, FALSE, beginColor, endColor);
- pGraphics->SaveGraphState();
- CFX_Color color1(&shading);
- pGraphics->SetFillColor(&color1);
- pGraphics->FillPath(path, fillMode, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics *pGraphics, FX_ARGB fillColor, const CFX_RectF *pRect, FX_FLOAT fRingWidth , CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- pGraphics->SaveGraphState();
- CFX_Color cr(fillColor);
+ path.Clear();
+ path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2,
+ pRect->height - 2);
+ path.AddRectangle(pRect->left + 2, pRect->top + 2, pRect->width - 4,
+ pRect->height - 4);
+ cr.Set(0xFFFFFFFF);
pGraphics->SetFillColor(&cr);
- CFX_Path path;
- path.Create();
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ } else {
+ FX_FLOAT fLeft = pRect->left;
FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fTop = pRect->top;
FX_FLOAT fBottom = pRect->bottom();
- CFX_RectF rtInner(*pRect);
- rtInner.Deflate(fRingWidth, fRingWidth);
- path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
- pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::DrawAnnulusCircle(CFX_Graphics *pGraphics, FX_ARGB fillColor, const CFX_RectF *pRect, FX_FLOAT fWidth , CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- if (fWidth > pRect->width / 2) {
- return;
+ FX_FLOAT fHalfWidth = fWidth / 2.0f;
+ CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1);
+ pGraphics->SetFillColor(&crLT);
+ CFX_Path pathLT;
+ pathLT.Create();
+ pathLT.MoveTo(fLeft, fBottom - fHalfWidth);
+ pathLT.LineTo(fLeft, fTop);
+ pathLT.LineTo(fRight - fHalfWidth, fTop);
+ pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth);
+ pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth);
+ pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth);
+ pathLT.LineTo(fLeft, fBottom - fHalfWidth);
+ pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix);
+ crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2);
+ pGraphics->SetFillColor(&crLT);
+ pathLT.Clear();
+ pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth);
+ pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth);
+ pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth);
+ pathLT.LineTo(fRight - fWidth, fTop + fWidth);
+ pathLT.LineTo(fLeft + fWidth, fTop + fWidth);
+ pathLT.LineTo(fLeft + fWidth, fBottom - fWidth);
+ pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth);
+ pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix);
+ CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3);
+ pGraphics->SetFillColor(&crRB);
+ CFX_Path pathRB;
+ pathRB.Create();
+ pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth);
+ pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth);
+ pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth);
+ pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth);
+ pathRB.LineTo(fRight - fWidth, fBottom - fWidth);
+ pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth);
+ pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth);
+ pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix);
+ crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4);
+ pGraphics->SetFillColor(&crRB);
+ pathRB.Clear();
+ pathRB.MoveTo(fRight, fTop);
+ pathRB.LineTo(fRight, fBottom);
+ pathRB.LineTo(fLeft, fBottom);
+ pathRB.LineTo(fLeft, fBottom - fHalfWidth);
+ pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth);
+ pathRB.LineTo(fRight - fHalfWidth, fTop);
+ pathRB.LineTo(fRight, fTop);
+ pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix);
+ }
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics,
+ FWLTHEME_EDGE eType,
+ FX_FLOAT fWidth,
+ const CFX_RectF* pRect,
+ FX_ARGB cr1,
+ FX_ARGB cr2,
+ FX_ARGB cr3,
+ FX_ARGB cr4,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ pGraphics->SaveGraphState();
+ FX_FLOAT fRadius = pRect->width / 2;
+ CFX_Path path;
+ path.Create();
+ path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height,
+ FWLTHEME_PI * 3 / 4, FWLTHEME_PI);
+ CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1);
+ pGraphics->SetStrokeColor(&crFill1);
+ pGraphics->StrokePath(&path, pMatrix);
+ CFX_RectF rtInner(*pRect);
+ rtInner.Deflate(pRect->width / 4, pRect->height / 4);
+ path.Clear();
+ path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height,
+ FWLTHEME_PI * 3 / 4, FWLTHEME_PI);
+ CFX_Color crFill2(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2);
+ pGraphics->SetStrokeColor(&crFill2);
+ pGraphics->StrokePath(&path, pMatrix);
+ path.Clear();
+ path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height,
+ FWLTHEME_PI * 7 / 4, FWLTHEME_PI);
+ CFX_Color crFill3(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3);
+ pGraphics->SetStrokeColor(&crFill3);
+ pGraphics->StrokePath(&path, pMatrix);
+ path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height,
+ FWLTHEME_PI * 7 / 4, FWLTHEME_PI);
+ CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4);
+ pGraphics->SetStrokeColor(&crFill4);
+ pGraphics->StrokePath(&path, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::DrawBorder(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2,
+ pRect->height - 2);
+ pGraphics->SaveGraphState();
+ CFX_Color crFill(ArgbEncode(255, 0, 0, 0));
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::FillBackground(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ CFX_Matrix* pMatrix) {
+ FillSoildRect(pGraphics, FWLTHEME_COLOR_Background, pRect, pMatrix);
+}
+void CFWL_WidgetTP::FillSoildRect(CFX_Graphics* pGraphics,
+ FX_ARGB fillColor,
+ const CFX_RectF* pRect,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ pGraphics->SaveGraphState();
+ CFX_Color crFill(fillColor);
+ pGraphics->SetFillColor(&crFill);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics,
+ FX_FLOAT fx1,
+ FX_FLOAT fy1,
+ FX_FLOAT fx2,
+ FX_FLOAT fy2,
+ FX_ARGB beginColor,
+ FX_ARGB endColor,
+ CFX_Path* path,
+ int32_t fillMode,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(path);
+ CFX_PointF begPoint, endPoint;
+ begPoint.Set(fx1, fy1);
+ endPoint.Set(fx2, fy2);
+ CFX_Shading shading;
+ shading.CreateAxial(begPoint, endPoint, FALSE, FALSE, beginColor, endColor);
+ pGraphics->SaveGraphState();
+ CFX_Color color1(&shading);
+ pGraphics->SetFillColor(&color1);
+ pGraphics->FillPath(path, fillMode, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics,
+ FX_ARGB fillColor,
+ const CFX_RectF* pRect,
+ FX_FLOAT fRingWidth,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ pGraphics->SaveGraphState();
+ CFX_Color cr(fillColor);
+ pGraphics->SetFillColor(&cr);
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fBottom = pRect->bottom();
+ CFX_RectF rtInner(*pRect);
+ rtInner.Deflate(fRingWidth, fRingWidth);
+ path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::DrawAnnulusCircle(CFX_Graphics* pGraphics,
+ FX_ARGB fillColor,
+ const CFX_RectF* pRect,
+ FX_FLOAT fWidth,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ if (fWidth > pRect->width / 2) {
+ return;
+ }
+ pGraphics->SaveGraphState();
+ CFX_Color cr(fillColor);
+ pGraphics->SetFillColor(&cr);
+ CFX_Path path;
+ path.Create();
+ path.AddEllipse(*pRect);
+ CFX_RectF rtIn(*pRect);
+ rtIn.Inflate(-fWidth, -fWidth);
+ path.AddEllipse(rtIn);
+ pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ CFX_Matrix* pMatrix) {
+ _FWL_RETURN_IF_FAIL(pGraphics);
+ _FWL_RETURN_IF_FAIL(pRect);
+ pGraphics->SaveGraphState();
+ CFX_Color cr(0xFF000000);
+ pGraphics->SetStrokeColor(&cr);
+ FX_FLOAT DashPattern[2] = {1, 1};
+ pGraphics->SetLineDash(0.0f, DashPattern, 2);
+ CFX_Path path;
+ path.Create();
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ pGraphics->StrokePath(&path, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+#define FWLTHEME_ARROW_Denominator 3
+void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_DIRECTION eDict,
+ FX_ARGB argbFill,
+ FX_BOOL bPressed,
+ CFX_Matrix* pMatrix) {
+ CFX_RectF rtArrow(*pRect);
+ CFX_Path path;
+ path.Create();
+ FX_FLOAT fBtn =
+ FX_MIN(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator;
+ rtArrow.left = pRect->left + (pRect->width - fBtn) / 2;
+ rtArrow.top = pRect->top + (pRect->height - fBtn) / 2;
+ rtArrow.width = fBtn;
+ rtArrow.height = fBtn;
+ if (bPressed) {
+ rtArrow.Offset(1, 1);
+ }
+ switch (eDict) {
+ case FWLTHEME_DIRECTION_Up: {
+ path.MoveTo(rtArrow.left, rtArrow.bottom());
+ path.LineTo(rtArrow.right(), rtArrow.bottom());
+ path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top);
+ path.LineTo(rtArrow.left, rtArrow.bottom());
+ break;
}
- pGraphics->SaveGraphState();
- CFX_Color cr(fillColor);
- pGraphics->SetFillColor(&cr);
- CFX_Path path;
- path.Create();
- path.AddEllipse(*pRect);
- CFX_RectF rtIn(*pRect);
- rtIn.Inflate(-fWidth, -fWidth);
- path.AddEllipse(rtIn);
- pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::DrawFocus(CFX_Graphics *pGraphics, const CFX_RectF *pRect, CFX_Matrix *pMatrix )
-{
- _FWL_RETURN_IF_FAIL(pGraphics);
- _FWL_RETURN_IF_FAIL(pRect);
- pGraphics->SaveGraphState();
- CFX_Color cr(0xFF000000);
- pGraphics->SetStrokeColor(&cr);
- FX_FLOAT DashPattern[2] = {1, 1};
- pGraphics->SetLineDash(0.0f, DashPattern, 2);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
- pGraphics->StrokePath(&path, pMatrix);
- pGraphics->RestoreGraphState();
-}
-#define FWLTHEME_ARROW_Denominator 3
-void CFWL_WidgetTP::DrawArrow(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_DIRECTION eDict, FX_ARGB argbFill, FX_BOOL bPressed, CFX_Matrix *pMatrix )
-{
- CFX_RectF rtArrow(*pRect);
- CFX_Path path;
- path.Create();
- FX_FLOAT fBtn = FX_MIN(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator;
- rtArrow.left = pRect->left + (pRect->width - fBtn) / 2;
- rtArrow.top = pRect->top + (pRect->height - fBtn) / 2;
- rtArrow.width = fBtn;
- rtArrow.height = fBtn;
- if (bPressed) {
- rtArrow.Offset(1, 1);
+ case FWLTHEME_DIRECTION_Left: {
+ path.MoveTo(rtArrow.right(), rtArrow.top);
+ path.LineTo(rtArrow.right(), rtArrow.bottom());
+ path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2);
+ path.LineTo(rtArrow.right(), rtArrow.top);
+ break;
}
- switch (eDict) {
- case FWLTHEME_DIRECTION_Up: {
- path.MoveTo(rtArrow.left, rtArrow.bottom());
- path.LineTo(rtArrow.right(), rtArrow.bottom());
- path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top);
- path.LineTo(rtArrow.left, rtArrow.bottom());
- break;
- }
- case FWLTHEME_DIRECTION_Left: {
- path.MoveTo(rtArrow.right(), rtArrow.top);
- path.LineTo(rtArrow.right(), rtArrow.bottom());
- path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2);
- path.LineTo(rtArrow.right(), rtArrow.top);
- break ;
- }
- case FWLTHEME_DIRECTION_Right: {
- path.MoveTo(rtArrow.left, rtArrow.top);
- path.LineTo(rtArrow.left, rtArrow.bottom());
- path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2);
- path.LineTo(rtArrow.left, rtArrow.top);
- break;
- }
- case FWLTHEME_DIRECTION_Down:
- default: {
- path.MoveTo(rtArrow.left, rtArrow.top);
- path.LineTo(rtArrow.right(), rtArrow.top);
- path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom());
- path.LineTo(rtArrow.left, rtArrow.top);
- }
+ case FWLTHEME_DIRECTION_Right: {
+ path.MoveTo(rtArrow.left, rtArrow.top);
+ path.LineTo(rtArrow.left, rtArrow.bottom());
+ path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2);
+ path.LineTo(rtArrow.left, rtArrow.top);
+ break;
}
- pGraphics->SaveGraphState();
- CFX_Color cr(argbFill);
- pGraphics->SetFillColor(&cr);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_WidgetTP::DrawArrow(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_DIRECTION eDict, FX_ARGB argSign, CFX_Matrix *pMatrix )
-{
- CFX_RectF rtArrow(*pRect);
- FX_BOOL bVert = (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down);
- FX_FLOAT fLeft = (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5);
- FX_FLOAT fTop = (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5);
- CFX_Path path;
- path.Create();
- switch (eDict) {
- case FWLTHEME_DIRECTION_Down: {
- path.MoveTo(fLeft, fTop + 1);
- path.LineTo(fLeft + 4, fTop + 5);
- path.LineTo(fLeft + 8, fTop + 1);
- path.LineTo(fLeft + 7, fTop);
- path.LineTo(fLeft + 4, fTop + 3);
- path.LineTo(fLeft + 1, fTop);
- break;
- }
- case FWLTHEME_DIRECTION_Up: {
- path.MoveTo(fLeft, fTop + 4);
- path.LineTo(fLeft + 4, fTop);
- path.LineTo(fLeft + 8, fTop + 4);
- path.LineTo(fLeft + 7, fTop + 5);
- path.LineTo(fLeft + 4, fTop + 2);
- path.LineTo(fLeft + 1, fTop + 5);
- break;
- }
- case FWLTHEME_DIRECTION_Right: {
- path.MoveTo(fLeft + 1, fTop);
- path.LineTo(fLeft + 5, fTop + 4);
- path.LineTo(fLeft + 1, fTop + 8);
- path.LineTo(fLeft, fTop + 7);
- path.LineTo(fLeft + 3, fTop + 4);
- path.LineTo(fLeft, fTop + 1);
- break;
- }
- case FWLTHEME_DIRECTION_Left: {
- path.MoveTo(fLeft, fTop + 4);
- path.LineTo(fLeft + 4, fTop);
- path.LineTo(fLeft + 5, fTop + 1);
- path.LineTo(fLeft + 2, fTop + 4);
- path.LineTo(fLeft + 5, fTop + 7);
- path.LineTo(fLeft + 4, fTop + 8);
- break;
- }
+ case FWLTHEME_DIRECTION_Down:
+ default: {
+ path.MoveTo(rtArrow.left, rtArrow.top);
+ path.LineTo(rtArrow.right(), rtArrow.top);
+ path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom());
+ path.LineTo(rtArrow.left, rtArrow.top);
}
- CFX_Color cr(argSign);
- pGraphics->SetFillColor(&cr);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
-}
-void CFWL_WidgetTP::DrawBtn(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_STATE eState, CFX_Matrix *pMatrix )
-{
- CFX_Path path;
- path.Create();
- if (!CFWL_ArrowData::IsInstance()) {
- CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID));
+ }
+ pGraphics->SaveGraphState();
+ CFX_Color cr(argbFill);
+ pGraphics->SetFillColor(&cr);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+ pGraphics->RestoreGraphState();
+}
+void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_DIRECTION eDict,
+ FX_ARGB argSign,
+ CFX_Matrix* pMatrix) {
+ CFX_RectF rtArrow(*pRect);
+ FX_BOOL bVert =
+ (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down);
+ FX_FLOAT fLeft =
+ (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5);
+ FX_FLOAT fTop =
+ (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5);
+ CFX_Path path;
+ path.Create();
+ switch (eDict) {
+ case FWLTHEME_DIRECTION_Down: {
+ path.MoveTo(fLeft, fTop + 1);
+ path.LineTo(fLeft + 4, fTop + 5);
+ path.LineTo(fLeft + 8, fTop + 1);
+ path.LineTo(fLeft + 7, fTop);
+ path.LineTo(fLeft + 4, fTop + 3);
+ path.LineTo(fLeft + 1, fTop);
+ break;
}
- CFWL_ArrowData::CColorData *pColorData = CFWL_ArrowData::GetInstance()->m_pColorData;
- FX_FLOAT fRight = pRect->right();
- FX_FLOAT fBottom = pRect->bottom();
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
- DrawAxialShading(pGraphics,
- pRect->left,
- pRect->top,
- fRight,
- fBottom,
- pColorData->clrStart[eState - 1],
- pColorData->clrEnd[eState - 1],
- &path,
- FXFILL_WINDING,
- pMatrix);
- CFX_Color rcStroke;
- rcStroke.Set(pColorData->clrBorder[eState - 1]);
- pGraphics->SetStrokeColor(&rcStroke);
- pGraphics->StrokePath(&path, pMatrix);
-}
-void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics *pGraphics, const CFX_RectF *pRect, FWLTHEME_DIRECTION eDict, FWLTHEME_STATE eState, CFX_Matrix *pMatrix )
-{
- DrawBtn(pGraphics, pRect, eState, pMatrix);
- if (!CFWL_ArrowData::IsInstance()) {
- CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID));
+ case FWLTHEME_DIRECTION_Up: {
+ path.MoveTo(fLeft, fTop + 4);
+ path.LineTo(fLeft + 4, fTop);
+ path.LineTo(fLeft + 8, fTop + 4);
+ path.LineTo(fLeft + 7, fTop + 5);
+ path.LineTo(fLeft + 4, fTop + 2);
+ path.LineTo(fLeft + 1, fTop + 5);
+ break;
}
- CFWL_ArrowData::CColorData *pColorData = CFWL_ArrowData::GetInstance()->m_pColorData;
- DrawArrow(pGraphics, pRect, eDict, pColorData->clrSign[eState - 1], pMatrix);
-}
-FWLCOLOR CFWL_WidgetTP::BlendColor(FWLCOLOR srcColor, FWLCOLOR renderColor, uint8_t scale)
-{
- FWLCOLOR dstColor;
- uint8_t n = 255 - scale;
- dstColor.a = (uint8_t)(((FX_WORD)srcColor.a * n + (FX_WORD)renderColor.a * scale) >> 8);
- dstColor.r = (uint8_t)(((FX_WORD)srcColor.r * n + (FX_WORD)renderColor.r * scale) >> 8);
- dstColor.g = (uint8_t)(((FX_WORD)srcColor.g * n + (FX_WORD)renderColor.g * scale) >> 8);
- dstColor.b = (uint8_t)(((FX_WORD)srcColor.b * n + (FX_WORD)renderColor.b * scale) >> 8);
- return dstColor;
-}
-CFWL_ArrowData::CFWL_ArrowData()
- : m_pColorData(NULL)
-{
- SetColorData(0);
-}
-CFWL_FontManager *FWL_GetFontManager()
-{
- static CFWL_FontManager * _fontManager = NULL;
- if (_fontManager == NULL) {
- _fontManager = FX_NEW CFWL_FontManager;
+ case FWLTHEME_DIRECTION_Right: {
+ path.MoveTo(fLeft + 1, fTop);
+ path.LineTo(fLeft + 5, fTop + 4);
+ path.LineTo(fLeft + 1, fTop + 8);
+ path.LineTo(fLeft, fTop + 7);
+ path.LineTo(fLeft + 3, fTop + 4);
+ path.LineTo(fLeft, fTop + 1);
+ break;
}
- return _fontManager;
-}
-void FWL_ReleaseFontManager()
-{
- CFWL_FontManager * fontManager = FWL_GetFontManager();
- delete fontManager;
+ case FWLTHEME_DIRECTION_Left: {
+ path.MoveTo(fLeft, fTop + 4);
+ path.LineTo(fLeft + 4, fTop);
+ path.LineTo(fLeft + 5, fTop + 1);
+ path.LineTo(fLeft + 2, fTop + 4);
+ path.LineTo(fLeft + 5, fTop + 7);
+ path.LineTo(fLeft + 4, fTop + 8);
+ break;
+ }
+ }
+ CFX_Color cr(argSign);
+ pGraphics->SetFillColor(&cr);
+ pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
+}
+void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix) {
+ CFX_Path path;
+ path.Create();
+ if (!CFWL_ArrowData::IsInstance()) {
+ CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID));
+ }
+ CFWL_ArrowData::CColorData* pColorData =
+ CFWL_ArrowData::GetInstance()->m_pColorData;
+ FX_FLOAT fRight = pRect->right();
+ FX_FLOAT fBottom = pRect->bottom();
+ path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
+ DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom,
+ pColorData->clrStart[eState - 1],
+ pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING,
+ pMatrix);
+ CFX_Color rcStroke;
+ rcStroke.Set(pColorData->clrBorder[eState - 1]);
+ pGraphics->SetStrokeColor(&rcStroke);
+ pGraphics->StrokePath(&path, pMatrix);
+}
+void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics* pGraphics,
+ const CFX_RectF* pRect,
+ FWLTHEME_DIRECTION eDict,
+ FWLTHEME_STATE eState,
+ CFX_Matrix* pMatrix) {
+ DrawBtn(pGraphics, pRect, eState, pMatrix);
+ if (!CFWL_ArrowData::IsInstance()) {
+ CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID));
+ }
+ CFWL_ArrowData::CColorData* pColorData =
+ CFWL_ArrowData::GetInstance()->m_pColorData;
+ DrawArrow(pGraphics, pRect, eDict, pColorData->clrSign[eState - 1], pMatrix);
+}
+FWLCOLOR CFWL_WidgetTP::BlendColor(FWLCOLOR srcColor,
+ FWLCOLOR renderColor,
+ uint8_t scale) {
+ FWLCOLOR dstColor;
+ uint8_t n = 255 - scale;
+ dstColor.a = (uint8_t)(
+ ((FX_WORD)srcColor.a * n + (FX_WORD)renderColor.a * scale) >> 8);
+ dstColor.r = (uint8_t)(
+ ((FX_WORD)srcColor.r * n + (FX_WORD)renderColor.r * scale) >> 8);
+ dstColor.g = (uint8_t)(
+ ((FX_WORD)srcColor.g * n + (FX_WORD)renderColor.g * scale) >> 8);
+ dstColor.b = (uint8_t)(
+ ((FX_WORD)srcColor.b * n + (FX_WORD)renderColor.b * scale) >> 8);
+ return dstColor;
+}
+CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) {
+ SetColorData(0);
+}
+CFWL_FontManager* FWL_GetFontManager() {
+ static CFWL_FontManager* _fontManager = NULL;
+ if (_fontManager == NULL) {
+ _fontManager = FX_NEW CFWL_FontManager;
+ }
+ return _fontManager;
+}
+void FWL_ReleaseFontManager() {
+ CFWL_FontManager* fontManager = FWL_GetFontManager();
+ delete fontManager;
}
CFWL_FontData::CFWL_FontData()
- : m_dwStyles(0)
- , m_dwCodePage(0)
- , m_pFont(0)
- , m_pFontMgr(NULL)
+ : m_dwStyles(0),
+ m_dwCodePage(0),
+ m_pFont(0),
+ m_pFontMgr(NULL)
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- , m_pFontSource(NULL)
+ ,
+ m_pFontSource(NULL)
#endif
{
}
-CFWL_FontData::~CFWL_FontData()
-{
- if (m_pFont) {
- m_pFont->Release();
- }
- if (m_pFontMgr) {
- m_pFontMgr->Release();
- }
+CFWL_FontData::~CFWL_FontData() {
+ if (m_pFont) {
+ m_pFont->Release();
+ }
+ if (m_pFontMgr) {
+ m_pFontMgr->Release();
+ }
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- if(m_pFontSource != NULL) {
- m_pFontSource->Release();
- }
+ if (m_pFontSource != NULL) {
+ m_pFontSource->Release();
+ }
#endif
}
-FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage)
-{
- return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && m_dwCodePage == wCodePage;
-}
-FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, FX_DWORD dwFontStyles, FX_WORD dwCodePage)
-{
- m_wsFamily = wsFontFamily;
- m_dwStyles = dwFontStyles;
- m_dwCodePage = dwCodePage;
- if (!m_pFontMgr) {
+FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily,
+ FX_DWORD dwFontStyles,
+ FX_WORD wCodePage) {
+ return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles &&
+ m_dwCodePage == wCodePage;
+}
+FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
+ FX_DWORD dwFontStyles,
+ FX_WORD dwCodePage) {
+ m_wsFamily = wsFontFamily;
+ m_dwStyles = dwFontStyles;
+ m_dwCodePage = dwCodePage;
+ if (!m_pFontMgr) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator());
+ m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator());
#else
- m_pFontSource = FX_CreateDefaultFontSourceEnum();
- m_pFontMgr = IFX_FontMgr::Create(m_pFontSource);
+ m_pFontSource = FX_CreateDefaultFontSourceEnum();
+ m_pFontMgr = IFX_FontMgr::Create(m_pFontSource);
#endif
+ }
+ m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage,
+ m_pFontMgr);
+ return m_pFont != NULL;
+}
+CFWL_FontManager::CFWL_FontManager() {}
+CFWL_FontManager::~CFWL_FontManager() {
+ int32_t count = m_arrFonts.GetSize();
+ for (int32_t i = 0; i < count; i++) {
+ CFWL_FontData* data = (CFWL_FontData*)m_arrFonts[i];
+ delete data;
+ }
+ m_arrFonts.RemoveAll();
+}
+IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily,
+ FX_DWORD dwFontStyles,
+ FX_WORD wCodePage) {
+ int32_t count = m_arrFonts.GetSize();
+ for (int32_t i = 0; i < count; i++) {
+ CFWL_FontData* data = (CFWL_FontData*)m_arrFonts[i];
+ if (data->Equal(wsFontFamily, dwFontStyles, wCodePage)) {
+ return data->GetFont();
}
- m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage, m_pFontMgr);
- return m_pFont != NULL;
-}
-CFWL_FontManager::CFWL_FontManager()
-{
-}
-CFWL_FontManager::~CFWL_FontManager()
-{
- int32_t count = m_arrFonts.GetSize();
- for (int32_t i = 0; i < count; i ++) {
- CFWL_FontData *data = (CFWL_FontData*)m_arrFonts[i];
- delete data;
- }
- m_arrFonts.RemoveAll();
-}
-IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, FX_DWORD dwFontStyles, FX_WORD wCodePage)
-{
- int32_t count = m_arrFonts.GetSize();
- for (int32_t i = 0; i < count; i ++) {
- CFWL_FontData *data = (CFWL_FontData*)m_arrFonts[i];
- if (data->Equal(wsFontFamily, dwFontStyles, wCodePage)) {
- return data->GetFont();
- }
- }
- CFWL_FontData *fontData = FX_NEW CFWL_FontData;
- if (!fontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) {
- delete fontData;
- return NULL;
- }
- m_arrFonts.Add(fontData);
- return fontData->GetFont();
-}
-FX_BOOL FWLTHEME_Init()
-{
- return TRUE;
-}
-void FWLTHEME_Release()
-{
- CFWL_ArrowData::DestroyInstance();
- FWL_ReleaseFontManager();
-}
-FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID)
-{
- return 0xffff0000 & dwThemeID;
-}
-FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID)
-{
- return 0x0000ffff & dwThemeID;
-}
-FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor)
-{
- return (dwLayout << 16) | (0x0000FFFF & dwColor);
-}
-CFWL_ArrowData *CFWL_ArrowData::m_pInstance = NULL;
-CFWL_ArrowData* CFWL_ArrowData::GetInstance()
-{
- if (!m_pInstance) {
- m_pInstance = FX_NEW CFWL_ArrowData;
- }
- return m_pInstance;
-}
-FX_BOOL CFWL_ArrowData::IsInstance()
-{
- return (m_pInstance != NULL);
-}
-void CFWL_ArrowData::DestroyInstance()
-{
- if (m_pInstance) {
- delete m_pInstance;
- m_pInstance = NULL;
- }
-}
-CFWL_ArrowData::~CFWL_ArrowData()
-{
- if (m_pColorData) {
- delete m_pColorData;
- m_pColorData = NULL;
- }
-}
-void CFWL_ArrowData::SetColorData(FX_DWORD dwID)
-{
- if (!m_pColorData) {
- m_pColorData = FX_NEW CColorData;
- }
- if (dwID) {
- m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125);
- m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119);
- m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97);
- m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153);
- m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186);
- m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185);
- m_pColorData->clrStart[2] = ArgbEncode(255, 203, 215, 186);
- m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251);
- m_pColorData->clrEnd[0] = ArgbEncode(255, 149, 167, 117);
- m_pColorData->clrEnd[1] = ArgbEncode(255, 198, 211, 155);
- m_pColorData->clrEnd[2] = ArgbEncode(255, 149, 167, 117);
- m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236);
- m_pColorData->clrSign[0] = ArgbEncode(255, 255, 255, 255);
- m_pColorData->clrSign[1] = ArgbEncode(255, 255, 255, 255);
- m_pColorData->clrSign[2] = ArgbEncode(255, 255, 255, 255);
- m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128);
- } else {
- m_pColorData->clrBorder[0] = ArgbEncode(255, 202, 216, 249);
- m_pColorData->clrBorder[1] = ArgbEncode(255, 171, 190, 233);
- m_pColorData->clrBorder[2] = ArgbEncode(255, 135, 147, 219);
- m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153);
- m_pColorData->clrStart[0] = ArgbEncode(255, 225, 234, 254);
- m_pColorData->clrStart[1] = ArgbEncode(255, 253, 255, 255);
- m_pColorData->clrStart[2] = ArgbEncode(255, 110, 142, 241);
- m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251);
- m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251);
- m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251);
- m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235);
- m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236);
- m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133);
- m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133);
- m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133);
- m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128);
- }
+ }
+ CFWL_FontData* fontData = FX_NEW CFWL_FontData;
+ if (!fontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) {
+ delete fontData;
+ return NULL;
+ }
+ m_arrFonts.Add(fontData);
+ return fontData->GetFont();
+}
+FX_BOOL FWLTHEME_Init() {
+ return TRUE;
+}
+void FWLTHEME_Release() {
+ CFWL_ArrowData::DestroyInstance();
+ FWL_ReleaseFontManager();
+}
+FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID) {
+ return 0xffff0000 & dwThemeID;
+}
+FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID) {
+ return 0x0000ffff & dwThemeID;
+}
+FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor) {
+ return (dwLayout << 16) | (0x0000FFFF & dwColor);
+}
+CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL;
+CFWL_ArrowData* CFWL_ArrowData::GetInstance() {
+ if (!m_pInstance) {
+ m_pInstance = FX_NEW CFWL_ArrowData;
+ }
+ return m_pInstance;
+}
+FX_BOOL CFWL_ArrowData::IsInstance() {
+ return (m_pInstance != NULL);
+}
+void CFWL_ArrowData::DestroyInstance() {
+ if (m_pInstance) {
+ delete m_pInstance;
+ m_pInstance = NULL;
+ }
+}
+CFWL_ArrowData::~CFWL_ArrowData() {
+ if (m_pColorData) {
+ delete m_pColorData;
+ m_pColorData = NULL;
+ }
+}
+void CFWL_ArrowData::SetColorData(FX_DWORD dwID) {
+ if (!m_pColorData) {
+ m_pColorData = FX_NEW CColorData;
+ }
+ if (dwID) {
+ m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125);
+ m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119);
+ m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97);
+ m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153);
+ m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186);
+ m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185);
+ m_pColorData->clrStart[2] = ArgbEncode(255, 203, 215, 186);
+ m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251);
+ m_pColorData->clrEnd[0] = ArgbEncode(255, 149, 167, 117);
+ m_pColorData->clrEnd[1] = ArgbEncode(255, 198, 211, 155);
+ m_pColorData->clrEnd[2] = ArgbEncode(255, 149, 167, 117);
+ m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236);
+ m_pColorData->clrSign[0] = ArgbEncode(255, 255, 255, 255);
+ m_pColorData->clrSign[1] = ArgbEncode(255, 255, 255, 255);
+ m_pColorData->clrSign[2] = ArgbEncode(255, 255, 255, 255);
+ m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128);
+ } else {
+ m_pColorData->clrBorder[0] = ArgbEncode(255, 202, 216, 249);
+ m_pColorData->clrBorder[1] = ArgbEncode(255, 171, 190, 233);
+ m_pColorData->clrBorder[2] = ArgbEncode(255, 135, 147, 219);
+ m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153);
+ m_pColorData->clrStart[0] = ArgbEncode(255, 225, 234, 254);
+ m_pColorData->clrStart[1] = ArgbEncode(255, 253, 255, 255);
+ m_pColorData->clrStart[2] = ArgbEncode(255, 110, 142, 241);
+ m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251);
+ m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251);
+ m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251);
+ m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235);
+ m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236);
+ m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133);
+ m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133);
+ m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133);
+ m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128);
+ }
}
|