From 9242a80a84fa5c96dbadec9594177875aeeec1ac Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Tue, 10 Jul 2012 18:37:21 +0000 Subject: only added MyDetails and Skins. not adopted yet git-svn-id: http://svn.miranda-ng.org/main/trunk@892 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Skins/SkinLib/ControlField.cpp | 123 +++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 plugins/Skins/SkinLib/ControlField.cpp (limited to 'plugins/Skins/SkinLib/ControlField.cpp') diff --git a/plugins/Skins/SkinLib/ControlField.cpp b/plugins/Skins/SkinLib/ControlField.cpp new file mode 100644 index 0000000000..dd9d7026d9 --- /dev/null +++ b/plugins/Skins/SkinLib/ControlField.cpp @@ -0,0 +1,123 @@ +#include "globals.h" +#include "ControlField.h" +#include "ControlFieldState.h" + + +ControlField::ControlField(Dialog *dlg, const char *name, HWND aHwnd) + : Field(dlg, name), hwnd(aHwnd), textSet(false), hFont(NULL) +{ +} + + +ControlField::~ControlField() +{ +} + + +HWND ControlField::getHWND() +{ + return hwnd; +} + + + +void ControlField::setText(const TCHAR *text) +{ + if (text == NULL) + { + if (!textSet) + return; + + textSet = false; + this->text.clear(); + fireOnChange(); + } + else + { + textSet = true; + if (this->text == text) + return; + + this->text = text; + // SetWindowText(hwnd, text); + fireOnChange(); + } +} + + +const TCHAR * ControlField::getText() +{ + if (textSet) + return text.c_str(); + + // Control text is the default value + int length = GetWindowTextLength(hwnd); + if (length <= 0) + { + text = _T(""); + } + else + { + TCHAR *tmp = new TCHAR[length+1]; + + if (GetWindowText(hwnd, tmp, length+1) == 0) + tmp[0] = 0; + + text = tmp; + + delete[] tmp; + } + + return text.c_str(); +} + + +void ControlField::setFont(HFONT hFont) +{ + if (this->hFont == hFont) + return; + + this->hFont = hFont; +// SendMessage(hwnd, WM_SETFONT, (WPARAM) hFont, FALSE); + fireOnChange(); +} + + +HFONT ControlField::getFont() const +{ + if (hFont != NULL) + return hFont; + + // Control font is the default value + return (HFONT) SendMessage(hwnd, WM_GETFONT, 0, 0); +} + + +COLORREF ControlField::getFontColor() const +{ + return GetSysColor(COLOR_WINDOWTEXT); +} + + +int ControlField::getBorderSize() const +{ + int exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); + if (exstyle & WS_EX_CLIENTEDGE) + return GetSystemMetrics(SM_CXEDGE); + if (exstyle & WS_EX_STATICEDGE) + return GetSystemMetrics(SM_CXBORDER); + + int style = GetWindowLong(hwnd, GWL_STYLE); + if (style & WS_BORDER) + return GetSystemMetrics(SM_CXBORDER); + + return 0; +} + +bool ControlField::isScrollVisible(bool horizontal) const +{ + SCROLLBARINFO sbi = {0}; + sbi.cbSize = sizeof(SCROLLBARINFO); + GetScrollBarInfo(hwnd, horizontal ? OBJID_HSCROLL : OBJID_VSCROLL, &sbi); + return (sbi.rgstate[0] & STATE_SYSTEM_INVISIBLE) == 0; +} -- cgit v1.2.3