* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
// ux themed. dufa
|
2009-08-05 17:45:57 +00:00
|
|
|
unit mckCtrlDraw;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
2014-12-04 10:53:59 +00:00
|
|
|
uses
|
|
|
|
Windows, Types, KOL, Themes;
|
2009-08-05 17:45:57 +00:00
|
|
|
|
2015-04-30 14:42:15 +00:00
|
|
|
type
|
|
|
|
TScrollStyle = (ssNone, ssHorz, ssVert, ssBoth);
|
|
|
|
|
2009-08-05 17:45:57 +00:00
|
|
|
const
|
2014-12-03 09:39:14 +00:00
|
|
|
TextHFlags: array[TTextAlign] of DWORD = (DT_LEFT, DT_RIGHT, DT_CENTER);
|
|
|
|
TextVFlags: array[TVerticalAlign] of DWORD = (DT_TOP, DT_VCENTER, DT_BOTTOM);
|
|
|
|
WordWrapFlags: array[Boolean] of DWORD = (DT_SINGLELINE, 0);//!
|
|
|
|
CheckFlags: array[Boolean] of DWORD = (0, DFCS_CHECKED);
|
2009-08-05 17:45:57 +00:00
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawButton(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aDefBtn: Boolean; dwTextFlags: DWORD; aText: WideString);
|
|
|
|
procedure DrawEditBox(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aIsPwd: Boolean; dwTextFlags: DWORD; aText: WideString);
|
2015-04-30 14:42:15 +00:00
|
|
|
procedure DrawMemo(aUX: Boolean; DC: HDC; R: TRect; aColor: Integer; aEnabled: Boolean; aScrollStyle: TScrollStyle; dwTextFlags: DWORD; aText: WideString);
|
2014-12-04 10:53:59 +00:00
|
|
|
procedure DrawCombobox(DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
|
|
|
procedure DrawLabel(DC: HDC; R: TRect; dwTextFlags: DWORD; aText: WideString);
|
|
|
|
procedure DrawCheckbox(DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawRadiobox(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
|
|
|
procedure DrawListBox(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
|
|
|
procedure DrawTreeView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
2014-12-21 16:31:42 +00:00
|
|
|
procedure DrawListView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aColumns: KOLWideString);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawProgressBar(DC: HDC; R: TRect; aVertical: Boolean; aProgress, aMaxProgress: Integer);
|
|
|
|
procedure DrawTrackBar(DC: HDC; R: TRect; aVertical: Boolean; aProgress, aMaxProgress: Integer);
|
|
|
|
procedure DrawGroupBox(aUX: Boolean; DC: HDC; R: TRect; aText: WideString);
|
2015-04-30 14:42:15 +00:00
|
|
|
procedure DrawScrollBar(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aVertical: Boolean; aPos, aMin, aMax: Integer);
|
|
|
|
procedure DrawScrollBox(aUX: Boolean; DC: HDC; R: TRect; aScrollStyle: TScrollStyle);
|
|
|
|
// not yet
|
|
|
|
procedure DrawToolbar(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
2014-12-04 10:53:59 +00:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
const
|
|
|
|
arrThemedEdit: array[Boolean] of TThemedEdit = (teEditTextDisabled, teEditTextNormal);
|
|
|
|
|
2015-04-30 14:42:15 +00:00
|
|
|
function pos2pix(aPos, aMin, aMax, aPixelMax, aPixelX: Integer): Integer;
|
|
|
|
begin
|
|
|
|
Result := aPixelX + Round((aPos + Abs(aMin)) / (aMax + Abs(aMin)) * (aPixelMax - aPixelX * 3));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure DrawScrollBar(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aVertical: Boolean; aPos, aMin, aMax: Integer);
|
|
|
|
const //enb btn
|
|
|
|
arrThemedSBLU: array[Boolean, Boolean] of TThemedScrollBar = (
|
|
|
|
(tsArrowBtnLeftDisabled, tsArrowBtnUpDisabled), (tsArrowBtnLeftNormal, tsArrowBtnUpNormal));
|
|
|
|
arrThemedSBRD: array[Boolean, Boolean] of TThemedScrollBar = (
|
|
|
|
(tsArrowBtnRightDisabled, tsArrowBtnDownDisabled), (tsArrowBtnRightNormal, tsArrowBtnDownNormal));
|
|
|
|
arrThemedSBTH: array[Boolean] of TThemedScrollBar = (tsThumbBtnHorzNormal, tsThumbBtnVertNormal);
|
|
|
|
arrSBLU: array[Boolean, Boolean] of DWORD = (
|
|
|
|
(DFCS_SCROLLLEFT or DFCS_INACTIVE,DFCS_SCROLLUP or DFCS_INACTIVE), (DFCS_SCROLLLEFT, DFCS_SCROLLUP));
|
|
|
|
arrSBRD: array[Boolean, Boolean] of DWORD = (
|
|
|
|
(DFCS_SCROLLRIGHT or DFCS_INACTIVE, DFCS_SCROLLDOWN or DFCS_INACTIVE), (DFCS_SCROLLRIGHT, DFCS_SCROLLDOWN));
|
|
|
|
|
|
|
|
var
|
|
|
|
w: Integer;
|
|
|
|
h: Integer;
|
|
|
|
rr: TRect;
|
|
|
|
begin
|
|
|
|
// get btn size
|
|
|
|
w := GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
h := GetSystemMetrics(SM_CYVSCROLL);
|
|
|
|
// pos2pix
|
|
|
|
if aVertical then
|
|
|
|
rr := Bounds(R.Left, pos2pix(aPos, aMin, aMax, R.Bottom, h), R.Right - R.Left, GetSystemMetrics(SM_CYVTHUMB))
|
|
|
|
else
|
|
|
|
rr := Bounds(pos2pix(aPos, aMin, aMax, R.Right, w), R.Top, GetSystemMetrics(SM_CXHTHUMB), R.Bottom - R.Top);
|
|
|
|
// ux
|
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
|
|
|
// draw track
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(tsLowerTrackVertNormal), R, nil);
|
|
|
|
// draw btn-left/up
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedSBLU[aEnabled, aVertical]), Bounds(R.Left, R.Top, w, h), nil);
|
|
|
|
// draw btn-right/down
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedSBRD[aEnabled, aVertical]), Rect(R.Right - w, R.Bottom - h, R.Right, R.Bottom), nil);
|
|
|
|
// draw thumb
|
|
|
|
if aEnabled then
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedSBTH[aVertical]), rr, nil);
|
|
|
|
end else begin
|
|
|
|
// draw track
|
|
|
|
FillRect(DC, R, GetSysColorBrush(COLOR_SCROLLBAR));
|
|
|
|
// draw btn-left/up
|
|
|
|
DrawFrameControl(DC, Bounds(R.Left, R.Top, w, h), DFC_SCROLL, arrSBLU[aEnabled, aVertical]);
|
|
|
|
// draw btn-right/down
|
|
|
|
DrawFrameControl(DC, Rect(R.Right - w, R.Bottom - h, R.Right, R.Bottom), DFC_SCROLL, arrSBRD[aEnabled, aVertical]);
|
|
|
|
// draw thumb
|
|
|
|
if aEnabled then
|
|
|
|
DrawFrameControl(DC, rr, DFC_BUTTON, DFCS_BUTTONPUSH);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawButton(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aDefBtn: Boolean; dwTextFlags: DWORD; aText: WideString);
|
2014-12-04 10:53:59 +00:00
|
|
|
const //enb defbtn
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
arrThemedButton: array[Boolean, Boolean] of TThemedButton =
|
2014-12-04 10:53:59 +00:00
|
|
|
((tbPushButtonDisabled, tbPushButtonDisabled), (tbPushButtonNormal, tbPushButtonDefaulted));
|
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
arrSimpleButton: array[Boolean] of DWORD = (DFCS_BUTTONPUSH or DFCS_INACTIVE, DFCS_BUTTONPUSH);
|
|
|
|
|
2009-08-05 17:45:57 +00:00
|
|
|
var
|
2014-12-03 09:39:14 +00:00
|
|
|
d: TThemedElementDetails;
|
2009-08-05 17:45:57 +00:00
|
|
|
begin
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
|
|
|
// get element
|
|
|
|
d := ThemeServices.GetElementDetails(arrThemedButton[aEnabled, aDefBtn]);
|
|
|
|
// draw element
|
|
|
|
ThemeServices.DrawElement(DC, d, R, nil);
|
|
|
|
// text
|
|
|
|
ThemeServices.DrawText(DC, d, aText, R, dwTextFlags or DT_SINGLELINE, 0);
|
|
|
|
end else begin
|
|
|
|
// draw defbtn
|
|
|
|
if aDefBtn then begin
|
|
|
|
// draw the defaulted border
|
|
|
|
FrameRect(DC, R, GetSysColorBrush(COLOR_WINDOWFRAME));
|
|
|
|
InflateRect(R, -1, -1);
|
|
|
|
end;
|
|
|
|
// draw element
|
|
|
|
DrawFrameControl(DC, R, DFC_BUTTON, arrSimpleButton[aEnabled]);
|
|
|
|
// draw text
|
|
|
|
SetBkMode(DC, TRANSPARENT);
|
|
|
|
SetTextColor(DC, GetSysColor(COLOR_GRAYTEXT + Ord(aEnabled)));
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), R, dwTextFlags or DT_SINGLELINE);
|
|
|
|
end;
|
2009-08-05 17:45:57 +00:00
|
|
|
end;
|
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawEditBox(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aIsPwd: Boolean; dwTextFlags: DWORD; aText: WideString);
|
2009-08-05 17:45:57 +00:00
|
|
|
begin
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
|
|
|
// draw element
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedEdit[True]), r, nil);
|
|
|
|
// draw text
|
|
|
|
Inc(r.Left, 6);
|
|
|
|
Inc(r.Top, 3);
|
|
|
|
Dec(r.Right, 3);
|
|
|
|
Dec(r.Bottom, 3);
|
|
|
|
ThemeServices.DrawText(DC, ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]), aText, r, dwTextFlags or DT_SINGLELINE, 0);
|
|
|
|
end else begin
|
|
|
|
// draw back
|
|
|
|
FillRect(DC, R, GetSysColorBrush(COLOR_WINDOW));
|
|
|
|
DrawEdge(DC, R, EDGE_SUNKEN, BF_RECT or BF_ADJUST);
|
|
|
|
InflateRect(R, -4, -1);
|
|
|
|
// draw text
|
|
|
|
SetBkMode(DC, TRANSPARENT);
|
|
|
|
SetTextColor(DC, GetSysColor(COLOR_GRAYTEXT + Ord(aEnabled)));
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), R, dwTextFlags or DT_SINGLELINE);
|
|
|
|
end;
|
2009-08-05 17:45:57 +00:00
|
|
|
end;
|
|
|
|
|
2015-04-30 14:42:15 +00:00
|
|
|
procedure DrawMemo(aUX: Boolean; DC: HDC; R: TRect; aColor: Integer; aEnabled: Boolean; aScrollStyle: TScrollStyle; dwTextFlags: DWORD; aText: WideString);
|
2009-08-05 17:45:57 +00:00
|
|
|
var
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
w: Integer;
|
|
|
|
h: Integer;
|
2015-04-30 14:42:15 +00:00
|
|
|
b: HBRUSH;
|
2009-08-05 17:45:57 +00:00
|
|
|
begin
|
2015-04-30 14:42:15 +00:00
|
|
|
// get btn size
|
|
|
|
w := GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
h := GetSystemMetrics(SM_CYVSCROLL);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
2015-04-30 14:42:15 +00:00
|
|
|
// draw border
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedEdit[True]), R, nil);
|
|
|
|
InflateRect(R, -1, -1);
|
|
|
|
// draw back
|
|
|
|
b := CreateSolidBrush(Color2RGB(aColor));
|
|
|
|
FillRect(DC, R, b);
|
|
|
|
DeleteObject(b);
|
|
|
|
InflateRect(R, -1, -1);
|
|
|
|
// draw scrolls
|
|
|
|
case aScrollStyle of
|
|
|
|
ssHorz: DrawScrollBar(aUX, DC, Rect(R.Left, R.Bottom - h, R.Right, R.Bottom), False, False, 2, 0, 100);
|
|
|
|
ssVert: DrawScrollBar(aUX, DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom), False, True, 2, 0, 100);
|
|
|
|
ssBoth:
|
|
|
|
begin
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(tsLowerTrackVertNormal), Rect(R.Left, R.Bottom - h, R.Right, R.Bottom), nil);
|
|
|
|
DrawScrollBar(aUX, DC, Rect(R.Left, R.Bottom - h, R.Right - w, R.Bottom), False, False, 2, 0, 100);
|
|
|
|
DrawScrollBar(aUX, DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom - h), False, True, 2, 0, 100);
|
|
|
|
end;
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
end;
|
|
|
|
// draw text
|
2015-04-30 14:42:15 +00:00
|
|
|
Inc(R.Left, 4);
|
|
|
|
Inc(R.Top, 1);
|
|
|
|
Dec(R.Right, 21);
|
|
|
|
Dec(R.Bottom, 21);
|
|
|
|
ThemeServices.DrawText(DC, ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]), aText, R, dwTextFlags, 0);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
end else begin
|
|
|
|
// draw back
|
2015-04-30 14:42:15 +00:00
|
|
|
b := CreateSolidBrush(Color2RGB(aColor));
|
|
|
|
FillRect(DC, R, b);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
DrawEdge(DC, R, EDGE_SUNKEN, BF_RECT or BF_ADJUST);
|
2015-04-30 14:42:15 +00:00
|
|
|
DeleteObject(b);
|
|
|
|
// draw scrolls
|
|
|
|
case aScrollStyle of
|
|
|
|
ssHorz: DrawScrollBar(aUX, DC, Rect(R.Left, R.Bottom - h, R.Right, R.Bottom), False, False, 2, 0, 100);
|
|
|
|
ssVert: DrawScrollBar(aUX, DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom), False, True, 2, 0, 100);
|
|
|
|
ssBoth:
|
|
|
|
begin
|
|
|
|
FillRect(DC, Rect(R.Left, R.Bottom - h, R.Right, R.Bottom), GetSysColorBrush(COLOR_BTNFACE));
|
|
|
|
DrawScrollBar(aUX, DC, Rect(R.Left, R.Bottom - h, R.Right - w, R.Bottom), False, False, 2, 0, 100);
|
|
|
|
DrawScrollBar(aUX, DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom - h), False, True, 2, 0, 100);
|
|
|
|
end;
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
end;
|
|
|
|
// draw text
|
|
|
|
InflateRect(R, -4, -1);
|
|
|
|
SetBkMode(DC, TRANSPARENT);
|
|
|
|
SetTextColor(DC, GetSysColor(COLOR_GRAYTEXT + Ord(aEnabled)));
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), R, dwTextFlags);
|
|
|
|
end;
|
2009-08-05 17:45:57 +00:00
|
|
|
end;
|
|
|
|
|
2014-12-04 10:53:59 +00:00
|
|
|
procedure DrawCombobox(DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
|
|
|
const
|
|
|
|
arrThemedComboBox: array[Boolean] of TThemedComboBox = (tcDropDownButtonDisabled, tcDropDownButtonNormal);
|
|
|
|
begin
|
|
|
|
// draw element
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(tcComboBoxRoot), r, nil);
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw element
|
|
|
|
r.Left := r.Right - 18;
|
|
|
|
Inc(r.Top, 1);
|
|
|
|
Dec(r.Right, 1);
|
|
|
|
Dec(r.Bottom, 1);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedComboBox[aEnabled]), r, nil);
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw text
|
|
|
|
r.Left := 6;
|
|
|
|
Inc(r.Top, 2);
|
|
|
|
Dec(r.Right, 18);
|
|
|
|
Inc(r.Bottom, 1);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
ThemeServices.DrawText(DC, ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]), aText, r, DT_LEFT or DT_SINGLELINE, 0);
|
2014-12-04 10:53:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
//TextHFlags[Sender.TextAlign] or TextVFlags[Sender.VerticalAlign] or WordWrapFlags[Sender.WordWrap]
|
|
|
|
procedure DrawLabel(DC: HDC; R: TRect; dwTextFlags: DWORD; aText: WideString);
|
2009-08-05 17:45:57 +00:00
|
|
|
begin
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
FillRect(DC, r, GetSysColorBrush(COLOR_BTNFACE));
|
2014-12-04 10:53:59 +00:00
|
|
|
SetBkMode(DC, TRANSPARENT);
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), r, dwTextFlags);
|
2014-12-03 09:39:14 +00:00
|
|
|
end;
|
2009-08-05 17:45:57 +00:00
|
|
|
|
2014-12-04 10:53:59 +00:00
|
|
|
procedure DrawCheckbox(DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
|
|
|
const //enb chk
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
arrThemedCB: array[Boolean, Boolean] of TThemedButton =
|
2014-12-04 10:53:59 +00:00
|
|
|
((tbCheckBoxUncheckedDisabled, tbCheckBoxCheckedDisabled), (tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal));
|
|
|
|
|
2014-12-03 09:39:14 +00:00
|
|
|
var
|
|
|
|
d: TThemedElementDetails;
|
|
|
|
rr: TRect;
|
|
|
|
begin
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw back
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
FillRect(DC, r, GetSysColorBrush(COLOR_BTNFACE));
|
|
|
|
// get element
|
|
|
|
d := ThemeServices.GetElementDetails(arrThemedCB[aEnabled, aChecked]);
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw border
|
|
|
|
if aHasBorder then
|
|
|
|
ThemeServices.DrawEdge(DC, d, r, EDGE_BUMP, BF_RECT or BF_MIDDLE);
|
2014-12-03 09:39:14 +00:00
|
|
|
// draw element
|
|
|
|
rr := Bounds(-3, -3, 22, 22);
|
|
|
|
ThemeServices.DrawElement(DC, d, rr);
|
|
|
|
// draw text
|
|
|
|
Inc(r.Left, 18);
|
2014-12-04 10:53:59 +00:00
|
|
|
ThemeServices.DrawText(DC, d, aText, r, DT_LEFT, 0);
|
2009-08-05 17:45:57 +00:00
|
|
|
end;
|
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawRadiobox(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
2014-12-04 10:53:59 +00:00
|
|
|
const //enb chk
|
|
|
|
arrFlags: array[Boolean, Boolean] of DWORD =
|
|
|
|
((DFCS_INACTIVE, DFCS_CHECKED or DFCS_INACTIVE), (0, DFCS_CHECKED));
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
//enb chk
|
|
|
|
arrThemedRB: array[Boolean, Boolean] of TThemedButton =
|
|
|
|
((tbRadioButtonUncheckedDisabled, tbRadioButtonCheckedDisabled),
|
|
|
|
(tbRadioButtonUncheckedNormal, tbRadioButtonCheckedNormal));
|
2014-12-03 09:39:14 +00:00
|
|
|
|
2009-08-05 17:45:57 +00:00
|
|
|
var
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
d: TThemedElementDetails;
|
2014-12-04 10:53:59 +00:00
|
|
|
rr: TRect;
|
2009-08-05 17:45:57 +00:00
|
|
|
begin
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw back
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
FillRect(DC, R, GetSysColorBrush(COLOR_BTNFACE));
|
|
|
|
// draw other
|
|
|
|
if aUX then begin
|
|
|
|
// get element
|
|
|
|
d := ThemeServices.GetElementDetails(arrThemedRB[aEnabled, aChecked]);
|
|
|
|
// draw border
|
|
|
|
if aHasBorder then
|
|
|
|
ThemeServices.DrawEdge(DC, d, R, EDGE_BUMP, BF_RECT or BF_MIDDLE);
|
|
|
|
// draw element
|
|
|
|
rr := Bounds(0, 0, 15, 15);
|
|
|
|
ThemeServices.DrawElement(DC, d, rr);
|
|
|
|
// draw text
|
|
|
|
r.Left := rr.Right + 2;
|
|
|
|
ThemeServices.DrawText(DC, d, aText, R, DT_LEFT, 0);
|
|
|
|
end else begin
|
|
|
|
// draw border
|
|
|
|
if aHasBorder then
|
|
|
|
DrawEdge(DC, r, EDGE_RAISED, BF_RECT or BF_MIDDLE);
|
|
|
|
// draw element
|
|
|
|
rr := Bounds(R.Left + 2, (R.Bottom + R.Top - 13) div 2, 13, 13);
|
|
|
|
DrawFrameControl(DC, rr, DFC_BUTTON, DFCS_BUTTONRADIO or arrFlags[aEnabled, aChecked]);
|
|
|
|
// draw text
|
|
|
|
Inc(R.Left, 17);
|
|
|
|
SetBkMode(DC, TRANSPARENT);
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), R, DT_VCENTER or DT_SINGLELINE);
|
|
|
|
end;
|
2009-08-05 17:45:57 +00:00
|
|
|
end;
|
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawListBox(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
|
|
|
begin
|
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
|
|
|
// draw element
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(tlListviewRoot), R, nil);
|
|
|
|
// draw text
|
|
|
|
Inc(R.Left, 3);
|
|
|
|
Inc(R.Top, 3);
|
|
|
|
Dec(R.Right, 3);
|
|
|
|
Dec(R.Bottom, 3);
|
|
|
|
ThemeServices.DrawText(DC, ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]), aText, R, DT_LEFT, 0);
|
|
|
|
end else begin
|
|
|
|
// draw back
|
|
|
|
FillRect(DC, R, GetSysColorBrush(COLOR_WINDOW));
|
|
|
|
DrawEdge(DC, R, EDGE_SUNKEN, BF_RECT or BF_ADJUST);
|
|
|
|
InflateRect(R, -1, 0);
|
|
|
|
// draw text
|
|
|
|
SetBkMode(DC, TRANSPARENT);
|
|
|
|
SetTextColor(DC, GetSysColor(COLOR_GRAYTEXT + Ord(aEnabled)));
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), R, DT_LEFT);
|
|
|
|
end;
|
|
|
|
end;
|
2014-12-04 10:53:59 +00:00
|
|
|
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
procedure DrawTreeView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
|
|
|
begin
|
|
|
|
DrawListBox(aUX, DC, R, aEnabled, aText);
|
|
|
|
end;
|
|
|
|
|
2014-12-21 16:31:42 +00:00
|
|
|
procedure DrawListView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aColumns: KOLWideString);
|
2014-12-03 09:39:14 +00:00
|
|
|
var
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
w: WideString;
|
2014-12-04 10:53:59 +00:00
|
|
|
d: TThemedElementDetails;
|
2009-08-05 17:45:57 +00:00
|
|
|
begin
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
// draw main
|
|
|
|
DrawListBox(aUX, DC, R, aEnabled, '');
|
|
|
|
// columns
|
|
|
|
if (aColumns <> '') then begin
|
|
|
|
// draw head back
|
|
|
|
R := Bounds(2, 2, R.Right - 4, 20);
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(thHeaderRoot), R, nil);
|
|
|
|
// draw columns
|
|
|
|
R := Bounds(2, 2, 50, 20);
|
|
|
|
repeat
|
|
|
|
w := ParseW(aColumns, #13);
|
|
|
|
if (aColumns = '') and (w = '') then
|
|
|
|
Break
|
|
|
|
else begin
|
|
|
|
// get element
|
|
|
|
d := ThemeServices.GetElementDetails(thHeaderItemNormal);
|
|
|
|
// draw head column
|
|
|
|
ThemeServices.DrawElement(DC, d, R, nil);
|
|
|
|
// draw text
|
|
|
|
Inc(R.Left, 10);
|
|
|
|
ThemeServices.DrawText(DC, d, w, R, DT_LEFT or DT_VCENTER or DT_SINGLELINE, 0);
|
|
|
|
// next
|
|
|
|
Inc(R.Left, 40);
|
|
|
|
Inc(R.Right, 50);
|
|
|
|
end;
|
|
|
|
until False;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure DrawProgressBar(DC: HDC; R: TRect; aVertical: Boolean; aProgress, aMaxProgress: Integer);
|
|
|
|
begin
|
|
|
|
// draw bar
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(TThemedProgress(Ord(tpBar) + Ord(aVertical))), R, nil);
|
|
|
|
// draw progress
|
|
|
|
if aVertical then
|
|
|
|
R.Top := Trunc(R.Bottom - R.Bottom * aProgress / aMaxProgress)
|
|
|
|
else
|
|
|
|
R.Right := Trunc(R.Right * aProgress / aMaxProgress);
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(TThemedProgress(Ord(tpChunk) + Ord(aVertical))), R, nil);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure DrawTrackBar(DC: HDC; R: TRect; aVertical: Boolean; aProgress, aMaxProgress: Integer);
|
2015-04-30 14:42:15 +00:00
|
|
|
var
|
|
|
|
a: TRect;
|
|
|
|
x: Integer;
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
begin
|
|
|
|
// draw root
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(ttbTrackBarRoot), R, nil);
|
|
|
|
// draw bar
|
2015-04-30 14:42:15 +00:00
|
|
|
a := Bounds(8, 14, R.Right - 16, 4);
|
|
|
|
x := GetSystemMetrics(SM_CXHTHUMB);
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(ttbTrack), a, nil);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
// draw progress
|
2015-04-30 14:42:15 +00:00
|
|
|
a := Bounds(5 + Trunc(aProgress / aMaxProgress * (a.Right - 19)), 0, x, R.Bottom);
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(ttbThumbBottomNormal), a, nil);
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure DrawGroupBox(aUX: Boolean; DC: HDC; R: TRect; aText: WideString);
|
|
|
|
begin
|
|
|
|
// draw background
|
|
|
|
FillRect(DC, R, GetSysColorBrush(COLOR_BTNFACE));
|
|
|
|
Inc(R.Top, 8);
|
|
|
|
// draw border
|
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
|
|
|
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(tbGroupBoxNormal), R, nil);
|
|
|
|
SetTextColor(DC, GetSysColor(COLOR_HIGHLIGHT));
|
|
|
|
end else begin
|
|
|
|
DrawEdge(DC, R, EDGE_ETCHED, BF_RECT);
|
|
|
|
SetTextColor(DC, GetSysColor(COLOR_BTNTEXT));
|
|
|
|
end;
|
2014-12-04 10:53:59 +00:00
|
|
|
// draw text
|
* updates for ux designer mode, supported controls: button, groupbox, checkbox, radiobox, edit, memo, richedit, listbox, combobox, progressbar, listview, treeview
git-svn-id: https://svn.code.sf.net/p/kolmck/code@149 91bb2d04-0c0c-4d2d-88a5-bbb6f4c1fa07
2014-12-16 08:50:47 +00:00
|
|
|
Inc(R.Left, 9);
|
|
|
|
Dec(R.Top, 8);
|
|
|
|
SetBkColor(DC, GetSysColor(COLOR_BTNFACE));
|
|
|
|
SetBkMode(DC, OPAQUE);
|
|
|
|
DrawTextW(DC, PWideChar(aText), Length(aText), R, DT_LEFT);
|
2009-08-05 17:45:57 +00:00
|
|
|
end;
|
|
|
|
|
2015-04-30 14:42:15 +00:00
|
|
|
procedure DrawScrollBox(aUX: Boolean; DC: HDC; R: TRect; aScrollStyle: TScrollStyle);
|
|
|
|
var
|
|
|
|
w: Integer;
|
|
|
|
h: Integer;
|
|
|
|
begin
|
|
|
|
// get btn size
|
|
|
|
w := GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
h := GetSystemMetrics(SM_CYVSCROLL);
|
|
|
|
// draw back
|
|
|
|
FillRect(DC, R, GetSysColorBrush(COLOR_BTNFACE));
|
|
|
|
DrawEdge(DC, R, EDGE_SUNKEN, BF_RECT or BF_ADJUST);
|
|
|
|
case aScrollStyle of
|
|
|
|
ssHorz: DrawScrollBar(aUX, DC, Rect(R.Left, R.Bottom - h, R.Right, R.Bottom), True, False, 2, 0, 100);
|
|
|
|
ssVert: DrawScrollBar(aUX, DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom), True, True, 2, 0, 100);
|
|
|
|
ssBoth:
|
|
|
|
begin
|
|
|
|
DrawScrollBar(aUX, DC, Rect(R.Left, R.Bottom - h, R.Right - w, R.Bottom), True, False, 2, 0, 100);
|
|
|
|
DrawScrollBar(aUX, DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom - h), True, True, 2, 0, 100);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
// not yet
|
|
|
|
procedure DrawToolbar(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
|
|
|
var
|
|
|
|
d: TThemedElementDetails;
|
|
|
|
begin
|
|
|
|
if ThemeServices.ThemesAvailable and aUX then begin
|
|
|
|
// get element
|
|
|
|
d := ThemeServices.GetElementDetails(ttbToolBarRoot);
|
|
|
|
// draw element
|
|
|
|
ThemeServices.DrawElement(DC, d, R, nil);
|
|
|
|
|
|
|
|
// get element
|
|
|
|
d := ThemeServices.GetElementDetails(ttbSplitButtonNormal);
|
|
|
|
// draw element
|
|
|
|
ThemeServices.DrawElement(DC, d, R, nil);
|
|
|
|
// text
|
|
|
|
ThemeServices.DrawText(DC, d, aText, R, 0, 0);
|
|
|
|
end else begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-08-05 17:45:57 +00:00
|
|
|
|
2014-12-04 10:53:59 +00:00
|
|
|
end.
|