Gtk2: implemented themed draw of combobox.issue #25151

git-svn-id: trunk@43156 -
This commit is contained in:
zeljko 2013-10-07 12:08:08 +00:00
parent 3db67cfb00
commit 8fd5d00b1b
3 changed files with 72 additions and 3 deletions

View File

@ -68,6 +68,7 @@ type
lgsToolButton, // button placed on toolbar
lgsCalendar, // button placed on toolbar
lgsScrolledWindow,
lgsComboBox,
// user defined
lgsUserDefined
);
@ -100,6 +101,7 @@ const
'toolbutton',
'calendar',
'scrolled window',
'combobox',
''
);

View File

@ -7055,7 +7055,7 @@ var
begin
if Widget=nil then exit;
if not (Lgs in [lgsButton, lgsWindow, lgsMenuBar, lgsMenuitem,
lgsVerticalScrollbar, lgsHorizontalScrollbar, lgsTooltip]) then exit;
lgsVerticalScrollbar, lgsHorizontalScrollbar, lgsTooltip, lgsComboBox]) then exit;
{$IFDEF NoStyle}
exit;
@ -7144,7 +7144,7 @@ begin
// this map is taken from this research:
// http://www.endolith.com/wordpress/2008/08/03/wine-colors/
case Lgs of
lgsButton:
lgsButton, lgsComboBox:
begin
SysColorMap[COLOR_ACTIVEBORDER] := TGDKColorToTColor(bg[GTK_STATE_INSENSITIVE]);
SysColorMap[COLOR_INACTIVEBORDER] := TGDKColorToTColor(bg[GTK_STATE_INSENSITIVE]);
@ -7757,6 +7757,11 @@ begin
lgs:=lgsCheckbox;
StyleObject^.Widget := GTK_CHECK_BUTTON_NEW;
end
else
If CompareText(WName,LazGtkStyleNames[lgsComboBox])=0 then begin
lgs:=lgsComboBox;
StyleObject^.Widget := gtk_combo_box_new;
end
else
If CompareText(WName,LazGtkStyleNames[lgsRadiobutton])=0 then begin
lgs:=lgsRadiobutton;

View File

@ -34,7 +34,8 @@ type
gptResizeGrip,
gptFocus,
gptArrow,
gptPixmap
gptPixmap,
gptComboBox
);
TGtkStyleParams = record
@ -132,6 +133,7 @@ const
);
implementation
uses math;
{$I gtk2stdpixmaps.inc}
@ -304,6 +306,25 @@ begin
end;
end;
end;
teComboBox:
begin
Result.Widget := GetStyleWidget(lgsComboBox);
if Result.Style = nil then
Result.Style := GetStyle(lgsComboBox);
Result.Detail := 'button';
Result.State := GTK_STATE_NORMAL;
if Details.State = CBXS_DISABLED then
Result.State := GTK_STATE_INSENSITIVE
else
if Details.State = CBXS_HOT then
Result.State := GTK_STATE_PRELIGHT
else
if Details.State = CBXS_PRESSED then
Result.State := GTK_STATE_ACTIVE;
Result.Painter := gptComboBox;
end;
teHeader:
begin
Result.Widget := GetColumnButtonFromTreeView(GetStyleWidget(lgsTreeView), Details.Part);
@ -690,6 +711,8 @@ var
StyleParams: TGtkStyleParams;
i: integer;
RDest: TRect;
ComboBoxHeight: gint;
ComboBoxWidth: gint;
begin
if IsRectEmpty(R) then
Exit;
@ -745,6 +768,45 @@ begin
end;
case Painter of
gptDefault: inherited DrawElement(DC, Details, R, ClipRect);
gptComboBox:
begin
{this is hack to paint combobox under gtk2}
if Details.State = CBXS_PRESSED then
gtk_paint_focus(Style, Window, GTK_STATE_ACTIVE, @ClipArea, Widget, 'button', Area.X + 2, Area.y + 2, Area.Width - 4, Area.Height - 4);
gtk_paint_box(
Style, Window,
State, Shadow,
@ClipArea, Widget, PChar(Detail),
Area.x, Area.y,
Area.Width, Area.Height);
// now we draw box with arrows
RDest := RectFromGdkRect(Area);
if Area.width > 17 then
RDest.Left := RDest.Right - 16
else
RDest.Left := RDest.Right - (Area.Width div 2);
ComboBoxHeight := Area.Height;
ComboBoxWidth := Area.Width;
if RDest.Left < 0 then
RDest.Left := 0;
gtk_paint_vline(Style, Window, State, @ClipArea, Widget,'', Area.y + (ComboBoxHeight div 10), Area.Y + Area.Height - (ComboBoxHeight div 10), (RDest.Right - Min(23, (ComboBoxWidth div 2) + 1)) + 1);
ComboBoxHeight := (RDest.Right - Min(23, (ComboBoxWidth div 2) + 1)) + 2;
if RDest.Right - ComboBoxHeight < 8 then
ComboBoxHeight := Area.X + (Area.Width div 4);
with RDest do
begin
gtk_paint_arrow(Style, Window, State, Shadow, @ClipArea, Widget,
PChar(Detail), GTK_ARROW_UP, True, ComboBoxHeight + 4, Top + ((Bottom - Top) div 2) - 7, Min(8, Right - Left), Min(8, Bottom - Top));
gtk_paint_arrow(Style, Window, State, Shadow, @ClipArea, Widget,
PChar(Detail), GTK_ARROW_DOWN, True, ComboBoxHeight + 4, Top + ((Bottom - Top) div 2), Min(8, Right - Left), Min(8,Bottom - Top));
end;
end;
gptBox:
gtk_paint_box(
Style, Window,