* 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
This commit is contained in:
399
mckCtrlDraw.pas
399
mckCtrlDraw.pas
@ -1,5 +1,4 @@
|
||||
// ux themed
|
||||
//dufa
|
||||
// ux themed. dufa
|
||||
unit mckCtrlDraw;
|
||||
|
||||
interface
|
||||
@ -13,151 +12,204 @@ const
|
||||
WordWrapFlags: array[Boolean] of DWORD = (DT_SINGLELINE, 0);//!
|
||||
CheckFlags: array[Boolean] of DWORD = (0, DFCS_CHECKED);
|
||||
|
||||
procedure DrawButton(DC: HDC; R: TRect; aEnabled, aDefBtn: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
procedure DrawEditBox(DC: HDC; R: TRect; aEnabled, aIsPwd: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
procedure DrawMemo(DC: HDC; R: TRect; aEnabled: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
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);
|
||||
procedure DrawMemo(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aScrollH, aScrollV: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
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);
|
||||
procedure DrawRadiobox(DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
||||
procedure DrawListBox(DC: HDC; R: TRect; aEnabled: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
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);
|
||||
procedure DrawListView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aColumns: WideString);
|
||||
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);
|
||||
|
||||
implementation
|
||||
|
||||
procedure DrawButton(DC: HDC; R: TRect; aEnabled, aDefBtn: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
const
|
||||
arrThemedEdit: array[Boolean] of TThemedEdit = (teEditTextDisabled, teEditTextNormal);
|
||||
|
||||
procedure DrawButton(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aDefBtn: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
const //enb defbtn
|
||||
arrTThemedButton: array[Boolean, Boolean] of TThemedButton =
|
||||
arrThemedButton: array[Boolean, Boolean] of TThemedButton =
|
||||
((tbPushButtonDisabled, tbPushButtonDisabled), (tbPushButtonNormal, tbPushButtonDefaulted));
|
||||
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
begin
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrTThemedButton[aEnabled, aDefBtn]);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, R, nil);
|
||||
// text
|
||||
ThemeServices.DrawText(DC, d, aText, R, dwTextFlags or DT_SINGLELINE, 0);
|
||||
end;
|
||||
|
||||
procedure DrawEditBox(DC: HDC; R: TRect; aEnabled, aIsPwd: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
const
|
||||
arrThemedEdit: array[Boolean] of TThemedEdit = (teEditTextDisabled, teEditTextNormal);
|
||||
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
// ss: WideString;
|
||||
begin
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, r, nil);
|
||||
// password text style
|
||||
// ss := aText;
|
||||
// if (Length(ss) > 0) and aIsPwd then
|
||||
// ss := StrRepeat('*', Length(ss));
|
||||
// draw text
|
||||
Inc(r.Left, 6);
|
||||
Inc(r.Top, 3);
|
||||
Dec(r.Right, 3);
|
||||
Dec(r.Bottom, 3);
|
||||
ThemeServices.DrawText(DC, d, {ss}aText, r, dwTextFlags or DT_SINGLELINE, 0);
|
||||
end;
|
||||
|
||||
procedure DrawMemo(DC: HDC; R: TRect; aEnabled: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
const
|
||||
arrThemedEdit: array[Boolean] of TThemedEdit = (teEditTextDisabled, teEditTextNormal);
|
||||
arrSimpleButton: array[Boolean] of DWORD = (DFCS_BUTTONPUSH or DFCS_INACTIVE, DFCS_BUTTONPUSH);
|
||||
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
begin
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, r, nil);
|
||||
// get element v-track
|
||||
d := ThemeServices.GetElementDetails(tsLowerTrackVertDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 20, 1, r.Right - 1, r.Bottom - 1), nil);
|
||||
// get element btn-up
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnUpDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 20, 1, r.Right - 1, 20), nil);
|
||||
// get element btn-dn
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnDownDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 20, r.Bottom - 40, r.Right - 1, r.Bottom - 20), nil);
|
||||
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;
|
||||
end;
|
||||
|
||||
// get element h-track
|
||||
d := ThemeServices.GetElementDetails(tsLowerTrackHorzDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(1, r.Bottom - 20, r.Right - 20, r.Bottom - 1), nil);
|
||||
// get element btn-left
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnLeftDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(1, r.Bottom - 20, 20, r.Bottom - 1), nil);
|
||||
// get element btn-right
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnRightDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 40, r.Bottom - 20, r.Right - 20, r.Bottom - 1), nil);
|
||||
procedure DrawEditBox(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aIsPwd: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
begin
|
||||
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;
|
||||
end;
|
||||
|
||||
// draw text
|
||||
Inc(r.Left, 6);
|
||||
Inc(r.Top, 3);
|
||||
Dec(r.Right, 23);
|
||||
Dec(r.Bottom, 23);
|
||||
ThemeServices.DrawText(DC, d, aText, r, dwTextFlags, 0);
|
||||
procedure DrawMemo(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aScrollH, aScrollV: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
w: Integer;
|
||||
h: Integer;
|
||||
begin
|
||||
if ThemeServices.ThemesAvailable and aUX then begin
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedEdit[True]), r, nil);
|
||||
// v
|
||||
if aScrollV then begin
|
||||
// get element v-track
|
||||
d := ThemeServices.GetElementDetails(tsLowerTrackVertDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 20, 1, r.Right - 1, r.Bottom - 1), nil);
|
||||
// get element btn-up
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnUpDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 20, 1, r.Right - 1, 20), nil);
|
||||
// get element btn-dn
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnDownDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 20, r.Bottom - 40, r.Right - 1, r.Bottom - 20), nil);
|
||||
end;
|
||||
// h
|
||||
if aScrollH then begin
|
||||
// get element h-track
|
||||
d := ThemeServices.GetElementDetails(tsLowerTrackHorzDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(1, r.Bottom - 20, r.Right - 20, r.Bottom - 1), nil);
|
||||
// get element btn-left
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnLeftDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(1, r.Bottom - 20, 20, r.Bottom - 1), nil);
|
||||
// get element btn-right
|
||||
d := ThemeServices.GetElementDetails(tsArrowBtnRightDisabled);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, Rect(r.Right - 40, r.Bottom - 20, r.Right - 20, r.Bottom - 1), nil);
|
||||
end;
|
||||
// draw text
|
||||
Inc(r.Left, 6);
|
||||
Inc(r.Top, 3);
|
||||
Dec(r.Right, 23);
|
||||
Dec(r.Bottom, 23);
|
||||
ThemeServices.DrawText(DC, ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]), aText, r, dwTextFlags, 0);
|
||||
end else begin
|
||||
// draw back
|
||||
FillRect(DC, R, GetSysColorBrush(COLOR_WINDOW));
|
||||
DrawEdge(DC, R, EDGE_SUNKEN, BF_RECT or BF_ADJUST);
|
||||
// v
|
||||
if aScrollV then begin
|
||||
// get btn size
|
||||
w := GetSystemMetrics(SM_CXVSCROLL);
|
||||
h := GetSystemMetrics(SM_CYVSCROLL);
|
||||
// draw element v-track
|
||||
FillRect(DC, Rect(R.Right - w, R.Top, R.Right, R.Bottom), GetSysColorBrush(COLOR_SCROLLBAR));
|
||||
// draw element btn-up
|
||||
DrawFrameControl(DC, Bounds(R.Right - w, R.Top, w, h), DFC_SCROLL, DFCS_SCROLLUP or DFCS_INACTIVE);
|
||||
// get element btn-dn
|
||||
DrawFrameControl(DC, Bounds(R.Right - w, R.Bottom - h * 2, w, h), DFC_SCROLL, DFCS_SCROLLDOWN or DFCS_INACTIVE);
|
||||
end;
|
||||
// h
|
||||
if aScrollH then begin
|
||||
// get btn size
|
||||
w := GetSystemMetrics(SM_CXHSCROLL);
|
||||
h := GetSystemMetrics(SM_CYHSCROLL);
|
||||
// draw element v-track
|
||||
FillRect(DC, Rect(R.Left, R.Bottom - h, R.Right - w, R.Bottom), GetSysColorBrush(COLOR_SCROLLBAR));
|
||||
// draw element btn-left
|
||||
DrawFrameControl(DC, Bounds(R.Left, R.Bottom - h, w, h), DFC_SCROLL, DFCS_SCROLLLEFT or DFCS_INACTIVE);
|
||||
// get element btn-right
|
||||
DrawFrameControl(DC, Bounds(R.Right - w * 2, R.Bottom - h, w, h), DFC_SCROLL, DFCS_SCROLLRIGHT or DFCS_INACTIVE);
|
||||
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;
|
||||
end;
|
||||
|
||||
procedure DrawCombobox(DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
||||
const
|
||||
arrThemedComboBox: array[Boolean] of TThemedComboBox = (tcDropDownButtonDisabled, tcDropDownButtonNormal);
|
||||
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
begin
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(tcComboBoxRoot);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, r, nil);
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrThemedComboBox[aEnabled]);
|
||||
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(tcComboBoxRoot), r, nil);
|
||||
// draw element
|
||||
r.Left := r.Right - 18;
|
||||
Inc(r.Top, 1);
|
||||
Dec(r.Right, 1);
|
||||
Dec(r.Bottom, 1);
|
||||
ThemeServices.DrawElement(DC, d, r, nil);
|
||||
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(arrThemedComboBox[aEnabled]), r, nil);
|
||||
// draw text
|
||||
r.Left := 6;
|
||||
Inc(r.Top, 2);
|
||||
Dec(r.Right, 18);
|
||||
Inc(r.Bottom, 1);
|
||||
ThemeServices.DrawText(DC, d, aText, r, DT_LEFT or DT_SINGLELINE, 0);
|
||||
ThemeServices.DrawText(DC, ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]), aText, r, DT_LEFT or DT_SINGLELINE, 0);
|
||||
end;
|
||||
|
||||
//TextHFlags[Sender.TextAlign] or TextVFlags[Sender.VerticalAlign] or WordWrapFlags[Sender.WordWrap]
|
||||
procedure DrawLabel(DC: HDC; R: TRect; dwTextFlags: DWORD; aText: WideString);
|
||||
begin
|
||||
// draw
|
||||
FillRect(DC, r, HBRUSH(COLOR_BTNFACE + 1));
|
||||
FillRect(DC, r, GetSysColorBrush(COLOR_BTNFACE));
|
||||
SetBkMode(DC, TRANSPARENT);
|
||||
DrawTextW(DC, PWideChar(aText), Length(aText), r, dwTextFlags);
|
||||
end;
|
||||
|
||||
procedure DrawCheckbox(DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
||||
const //enb chk
|
||||
arrTThemedButton: array[Boolean, Boolean] of TThemedButton =
|
||||
arrThemedCB: array[Boolean, Boolean] of TThemedButton =
|
||||
((tbCheckBoxUncheckedDisabled, tbCheckBoxCheckedDisabled), (tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal));
|
||||
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
rr: TRect;
|
||||
begin
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrTThemedButton[aEnabled, aChecked]);
|
||||
// draw back
|
||||
FillRect(DC, r, HBRUSH(COLOR_BTNFACE + 1));
|
||||
FillRect(DC, r, GetSysColorBrush(COLOR_BTNFACE));
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrThemedCB[aEnabled, aChecked]);
|
||||
// draw border
|
||||
if aHasBorder then
|
||||
ThemeServices.DrawEdge(DC, d, r, EDGE_BUMP, BF_RECT or BF_MIDDLE);
|
||||
@ -169,45 +221,152 @@ begin
|
||||
ThemeServices.DrawText(DC, d, aText, r, DT_LEFT, 0);
|
||||
end;
|
||||
|
||||
procedure DrawRadiobox(DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
||||
procedure DrawRadiobox(aUX: Boolean; DC: HDC; R: TRect; aEnabled, aChecked, aHasBorder: Boolean; aText: WideString);
|
||||
const //enb chk
|
||||
arrFlags: array[Boolean, Boolean] of DWORD =
|
||||
((DFCS_INACTIVE, DFCS_CHECKED or DFCS_INACTIVE), (0, DFCS_CHECKED));
|
||||
//enb chk
|
||||
arrThemedRB: array[Boolean, Boolean] of TThemedButton =
|
||||
((tbRadioButtonUncheckedDisabled, tbRadioButtonCheckedDisabled),
|
||||
(tbRadioButtonUncheckedNormal, tbRadioButtonCheckedNormal));
|
||||
|
||||
var
|
||||
d: TThemedElementDetails;
|
||||
rr: TRect;
|
||||
begin
|
||||
// draw back
|
||||
FillRect(DC, r, HBRUSH(COLOR_BTNFACE + 1));
|
||||
// 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);
|
||||
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;
|
||||
end;
|
||||
|
||||
procedure DrawListBox(DC: HDC; R: TRect; aEnabled: Boolean; dwTextFlags: DWORD; aText: WideString);
|
||||
const
|
||||
arrThemedEdit: array[Boolean] of TThemedListview = (tlListItemDisabled, tlListItemDisabled);
|
||||
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;
|
||||
|
||||
procedure DrawTreeView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aText: WideString);
|
||||
begin
|
||||
DrawListBox(aUX, DC, R, aEnabled, aText);
|
||||
end;
|
||||
|
||||
procedure DrawListView(aUX: Boolean; DC: HDC; R: TRect; aEnabled: Boolean; aColumns: WideString);
|
||||
var
|
||||
w: WideString;
|
||||
d: TThemedElementDetails;
|
||||
begin
|
||||
// get element
|
||||
d := ThemeServices.GetElementDetails(arrThemedEdit[aEnabled]);
|
||||
// draw element
|
||||
ThemeServices.DrawElement(DC, d, r, nil);
|
||||
// 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);
|
||||
begin
|
||||
// draw root
|
||||
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(ttbTrackBarRoot), R, nil);
|
||||
// draw bar
|
||||
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(ttbTrack), Bounds(8, 14, R.Right - 16, 4), nil);
|
||||
// draw progress
|
||||
R := Bounds(4 + Trunc(aProgress / aMaxProgress * R.Right), 0, GetSystemMetrics(SM_CXHTHUMB), R.Bottom);
|
||||
ThemeServices.DrawElement(DC, ThemeServices.GetElementDetails(ttbThumbBottomNormal), R, nil);
|
||||
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;
|
||||
// draw text
|
||||
Inc(r.Left, 6);
|
||||
Inc(r.Top, 3);
|
||||
Dec(r.Right, 3);
|
||||
Dec(r.Bottom, 3);
|
||||
ThemeServices.DrawText(DC, d, aText, r, dwTextFlags, 0);
|
||||
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);
|
||||
end;
|
||||
|
||||
|
||||
|
120
mckCtrls.pas
120
mckCtrls.pas
@ -539,6 +539,9 @@ type
|
||||
function SupportsFormCompact: Boolean; override;
|
||||
procedure SetupConstruct_Compact; override;
|
||||
public
|
||||
//dufa
|
||||
function WYSIWIGPaintImplemented: Boolean; override;
|
||||
procedure Paint; override;
|
||||
constructor Create( AOwner: TComponent ); override;
|
||||
function Pcode_Generate: Boolean; override;
|
||||
published
|
||||
@ -895,6 +898,9 @@ type
|
||||
function SupportsFormCompact: Boolean; override;
|
||||
procedure SetupConstruct_Compact; override;
|
||||
public
|
||||
//dufa
|
||||
function WYSIWIGPaintImplemented: Boolean; override;
|
||||
procedure Paint; override;
|
||||
constructor Create( AOwner: TComponent ); override;
|
||||
destructor Destroy; override;
|
||||
function Pcode_Generate: Boolean; override;
|
||||
@ -993,6 +999,9 @@ type
|
||||
function SupportsFormCompact: Boolean; override;
|
||||
procedure SetupConstruct_Compact; override;
|
||||
public
|
||||
//dufa
|
||||
procedure Paint; override;
|
||||
function WYSIWIGPaintImplemented: Boolean; override;
|
||||
constructor Create( AOwner: TComponent ); override;
|
||||
destructor Destroy; override;
|
||||
function Pcode_Generate: Boolean; override;
|
||||
@ -1215,6 +1224,9 @@ type
|
||||
procedure KOLControlRecreated; override;
|
||||
function NoDrawFrame: Boolean; override;
|
||||
public
|
||||
//dufa
|
||||
procedure Paint; override;
|
||||
function WYSIWIGPaintImplemented: Boolean; override;
|
||||
constructor Create( AOwner: TComponent ); override;
|
||||
function Pcode_Generate: Boolean; override;
|
||||
function SupportsFormCompact: Boolean; override;
|
||||
@ -1360,6 +1372,9 @@ type
|
||||
procedure SaveColCount( Writer: TWriter );
|
||||
procedure DoGenerateConstants( SL: TStringList ); override;
|
||||
public
|
||||
//dufa
|
||||
procedure Paint; override;
|
||||
function WYSIWIGPaintImplemented: Boolean; override;
|
||||
procedure Loaded; override; {YS}
|
||||
function NoDrawFrame: Boolean; override;
|
||||
procedure CreateKOLControl(Recreating: boolean); override;
|
||||
@ -1478,6 +1493,9 @@ type
|
||||
procedure CreateKOLControl(Recreating: boolean); override;
|
||||
function NoDrawFrame: Boolean; override;
|
||||
public
|
||||
//dufa
|
||||
procedure Paint; override;
|
||||
function WYSIWIGPaintImplemented: Boolean; override;
|
||||
constructor Create( AOwner: TComponent ); override;
|
||||
procedure NotifyLinkedComponent( Sender: TObject; Operation: TNotifyOperation ); override;
|
||||
destructor Destroy; override;
|
||||
@ -2436,7 +2454,7 @@ begin
|
||||
Canvas.Font.Color := clBtnText;
|
||||
Canvas.Brush.Color := clBtnFace;
|
||||
//dufa
|
||||
DrawButton(Canvas.Handle, ClientRect, Enabled, DefaultBtn,
|
||||
DrawButton(True, Canvas.Handle, ClientRect, Enabled, DefaultBtn,
|
||||
TextHFlags[KOL.TTextAlign(TextAlign)] or TextVFlags[KOL.TVerticalAlign(VerticalAlign)], Caption);
|
||||
end;
|
||||
inherited;
|
||||
@ -5003,6 +5021,15 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TKOLGroupBox.Paint;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawGroupBox(True, Canvas.Handle, ClientRect, Caption);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TKOLGroupBox.Pcode_Generate: Boolean;
|
||||
begin
|
||||
Result := TRUE;
|
||||
@ -5128,6 +5155,11 @@ begin
|
||||
Result := TRUE;
|
||||
end;
|
||||
|
||||
function TKOLGroupBox.WYSIWIGPaintImplemented: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{ TKOLCheckBox }
|
||||
|
||||
constructor TKOLCheckBox.Create(AOwner: TComponent);
|
||||
@ -5389,7 +5421,7 @@ end;
|
||||
procedure TKOLRadioBox.Paint;
|
||||
begin
|
||||
PrepareCanvasFontForWYSIWIGPaint( Canvas );
|
||||
DrawRadioBox(Canvas.Handle, ClientRect, Enabled, Checked, HasBorder, Caption);
|
||||
DrawRadioBox(True, Canvas.Handle, ClientRect, Enabled, Checked, HasBorder, Caption);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -5652,7 +5684,7 @@ begin
|
||||
//dufa
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawEditbox(Canvas.Handle, ClientRect, Enabled, (eoPassword in Options), TextHFlags[KOL.TTextAlign(TextAlign)], Caption);
|
||||
DrawEditbox(True, Canvas.Handle, ClientRect, Enabled, (eoPassword in Options), TextHFlags[KOL.TTextAlign(TextAlign)], Caption);
|
||||
end;
|
||||
{PrepareCanvasFontForWYSIWIGPaint( Canvas );
|
||||
|
||||
@ -6070,7 +6102,7 @@ procedure TKOLMemo.Paint;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawMemo(Canvas.Handle, ClientRect, Enabled, TextHFlags[KOL.TTextAlign(TextAlign)], Text.Text);
|
||||
DrawMemo(True, Canvas.Handle, ClientRect, Enabled, True, True, TextHFlags[KOL.TTextAlign(TextAlign)], Text.Text);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
@ -6476,6 +6508,15 @@ begin
|
||||
Result:=HasBorder;
|
||||
end;
|
||||
|
||||
procedure TKOLListBox.Paint;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawListBox(True, Canvas.Handle, ClientRect, Enabled, Items.Text);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TKOLListBox.Pcode_Generate: Boolean;
|
||||
begin
|
||||
Result := TRUE;
|
||||
@ -6812,6 +6853,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TKOLListBox.WYSIWIGPaintImplemented: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{ TKOLComboBox }
|
||||
|
||||
function TKOLComboBox.AutoHeight(Canvas: TCanvas): Integer;
|
||||
@ -8133,6 +8179,11 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TKOLListView.WYSIWIGPaintImplemented: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TKOLListView.CreateKOLControl(Recreating: boolean);
|
||||
var
|
||||
Opts: kol.TListViewOptions;
|
||||
@ -8407,6 +8458,25 @@ begin
|
||||
Result := Result + inherited P_GenerateTransparentInits();
|
||||
end;
|
||||
|
||||
procedure TKOLListView.Paint;
|
||||
var
|
||||
I: Integer;
|
||||
w: WideString;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
// cols
|
||||
w := '';
|
||||
if (Style = lvsDetail) then begin
|
||||
for I := 0 to Pred(Cols.Count) do
|
||||
w := w + Trim(TKOLListViewColumn(Cols[I]).Caption) + #13;
|
||||
end;
|
||||
// draw
|
||||
DrawListView(True, Canvas.Handle, ClientRect, Enabled, w);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TKOLListView.Pcode_Generate: Boolean;
|
||||
begin
|
||||
Result := TRUE;
|
||||
@ -8514,6 +8584,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TKOLTreeView.Paint;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawTreeView(True, Canvas.Handle, ClientRect, Enabled, Name);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TKOLTreeView.Pcode_Generate: Boolean;
|
||||
begin
|
||||
Result := TRUE;
|
||||
@ -8829,6 +8908,11 @@ begin
|
||||
Result := TRUE;
|
||||
end;
|
||||
|
||||
function TKOLTreeView.WYSIWIGPaintImplemented: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{ TKOLRichEdit }
|
||||
|
||||
function TKOLRichEdit.AdditionalUnits: String;
|
||||
@ -9020,6 +9104,15 @@ begin
|
||||
Result:=HasBorder;
|
||||
end;
|
||||
|
||||
procedure TKOLRichEdit.Paint;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawMemo(True, Canvas.Handle, ClientRect, Enabled, False, False, TextHFlags[KOL.TTextAlign(TextAlign)], Text.Text);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TKOLRichEdit.Pcode_Generate: Boolean;
|
||||
begin
|
||||
Result := TRUE;
|
||||
@ -9578,6 +9671,11 @@ begin
|
||||
Options := Options - [ eo_WantTab ];
|
||||
end;
|
||||
|
||||
function TKOLRichEdit.WYSIWIGPaintImplemented: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{ TKOLProgressBar }
|
||||
|
||||
constructor TKOLProgressBar.Create(AOwner: TComponent);
|
||||
@ -9633,6 +9731,15 @@ begin
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
procedure TKOLProgressBar.Paint;
|
||||
begin
|
||||
if not (Assigned(FKOLCtrl) and (PaintType in [ptWYSIWIG, ptWYSIWIGFrames])) then begin
|
||||
PrepareCanvasFontForWYSIWIGPaint(Canvas);
|
||||
DrawProgressBar(Canvas.Handle, ClientRect, Vertical, Progress, MaxProgress);
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TKOLProgressBar.Pcode_Generate: Boolean;
|
||||
begin
|
||||
Result := TRUE;
|
||||
@ -9878,6 +9985,11 @@ begin
|
||||
Result := 'ProgressBarEx';
|
||||
end;
|
||||
|
||||
function TKOLProgressBar.WYSIWIGPaintImplemented: Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{ TKOLTabControl }
|
||||
|
||||
procedure TKOLTabControl.AdjustPages;
|
||||
|
Reference in New Issue
Block a user