RxFPC: fix drawing RxDBLookupCombo on mac - path from lainz

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6188 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2018-02-08 11:08:07 +00:00
parent 0d2b3a9cb4
commit 205edb6dab
2 changed files with 178 additions and 36 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<Version Value="11"/>
<General>
<MainUnit Value="0"/>
<ResourceType Value="res"/>
@ -22,9 +22,10 @@
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default"/>
</Modes>
</RunParams>
<RequiredPackages Count="3">
<Item1>
@ -44,8 +45,8 @@
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos Y="11"/>
<UsageCount Value="22"/>
<CursorPos Y="18"/>
<UsageCount Value="24"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@ -55,8 +56,8 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<TopLine Value="57"/>
<CursorPos X="11" Y="67"/>
<UsageCount Value="22"/>
<CursorPos X="14" Y="62"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -122,10 +123,12 @@
</Unit9>
<Unit10>
<Filename Value="../../rxdb/rxlookup.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="957"/>
<CursorPos X="25" Y="978"/>
<UsageCount Value="10"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="1552"/>
<CursorPos Y="1566"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
<Filename Value="../../registerrx.pas"/>
@ -135,33 +138,32 @@
<Unit12>
<Filename Value="../../registerrxdb.pas"/>
<UnitName Value="RegisterRxDB"/>
<EditorIndex Value="1"/>
<TopLine Value="34"/>
<EditorIndex Value="-1"/>
<TopLine Value="118"/>
<CursorPos X="36" Y="155"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="../../rxdb/rxdbgridexportpdf.pas"/>
<UnitName Value="RxDBGridExportPdf"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="183"/>
<CursorPos X="3" Y="196"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="../../rxdb/rxdbgridexportpdfsetupunit.pas"/>
<ComponentName Value="RxDBGridExportPdfSetupForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridExportPdfSetupUnit"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<EditorIndex Value="-1"/>
<TopLine Value="83"/>
<CursorPos X="31" Y="98"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit14>
</Units>
<JumpHistory Count="17" HistoryIndex="16">
<JumpHistory Count="16" HistoryIndex="15">
<Position1>
<Filename Value="unit1.pas"/>
<Caret Line="47" TopLine="34"/>
@ -211,25 +213,21 @@
<Caret Line="52" Column="38" TopLine="41"/>
</Position12>
<Position13>
<Filename Value="../../registerrxdb.pas"/>
<Caret Line="142" Column="15" TopLine="130"/>
<Filename Value="unit1.pas"/>
<Caret Line="62" Column="14" TopLine="57"/>
</Position13>
<Position14>
<Filename Value="../../registerrxdb.pas"/>
<Caret Line="154" Column="31" TopLine="146"/>
<Filename Value="../../rxdb/rxlookup.pas"/>
<Caret Line="283" Column="26" TopLine="272"/>
</Position14>
<Position15>
<Filename Value="../../registerrxdb.pas"/>
<Caret Line="155" Column="36" TopLine="34"/>
<Filename Value="../../rxdb/rxlookup.pas"/>
<Caret Line="1522" Column="6" TopLine="1499"/>
</Position15>
<Position16>
<Filename Value="../../rxdb/rxdbgridexportpdf.pas"/>
<Caret Line="194" Column="31" TopLine="186"/>
<Filename Value="../../rxdb/rxlookup.pas"/>
<Caret Line="1675" Column="141" TopLine="1645"/>
</Position16>
<Position17>
<Filename Value="../../rxdb/rxdbgridexportpdf.pas"/>
<Caret Line="846" Column="84" TopLine="833"/>
</Position17>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -710,10 +710,11 @@ end;
procedure TRxCustomDBLookupCombo.CheckButtonVisible;
begin
if Assigned(FButton) then
FButton.Visible:=((FStyle = rxcsDropDown) or (not ThemeServices.ThemesEnabled)) and
FButton.Visible:=(
(FStyle = rxcsDropDown) or (not ThemeServices.ThemesEnabled) {and (csDesigning in ComponentState)}
)
and
(
(csdesigning in ComponentState)
or
(Visible and (Focused or not FButtonNeedsFocus))
);
end;
@ -1518,6 +1519,147 @@ end;
procedure TRxCustomDBLookupCombo.Paint;
const
padding {: Integer} = 1;
var
Selected:boolean;
R, R1, R2: TRect;
AText: string;
border : Integer;
Details, DetailsBtn: TThemedElementDetails;
BtnSize: TSize;
pr: PRect;
begin
R := Rect(0, 0, ClientWidth, ClientHeight);
if ThemeServices.ThemesEnabled and (FStyle = rxcsDropDownList) then
begin
Canvas.Brush.Color := Parent.Color;
Canvas.FillRect(R);
if Enabled then
begin
if MouseInClient then
begin
if FMouseDown then
begin
Details := ThemeServices.GetElementDetails({$IFDEF DARWIN}tcDropDownButtonPressed{$ELSE}tbPushButtonPressed{$ENDIF});
DetailsBtn := ThemeServices.GetElementDetails(tcDropDownButtonPressed);
end
else
begin
Details := ThemeServices.GetElementDetails({$IFDEF DARWIN}tcDropDownButtonNormal{$ELSE}tbPushButtonHot{$ENDIF});
DetailsBtn := ThemeServices.GetElementDetails(tcDropDownButtonNormal);
end;
end
else
begin
Details := ThemeServices.GetElementDetails({$IFDEF DARWIN}tcDropDownButtonNormal{$ELSE}tbPushButtonNormal{$ENDIF});
DetailsBtn := ThemeServices.GetElementDetails(tcDropDownButtonNormal);
end;
end
else
begin
Details := ThemeServices.GetElementDetails({$IFDEF DARWIN}tcDropDownButtonDisabled{$ELSE}tbPushButtonDisabled{$ENDIF});
DetailsBtn := ThemeServices.GetElementDetails(tcDropDownButtonDisabled);
end;
ThemeServices.DrawElement(Canvas.Handle, Details, R, nil);
BtnSize.Width:=20;
{$IFDEF DARWIN}
{$ELSE}
//BtnSize:=ThemeServices.GetDetailSize(DetailsBtn);
// adjust this for each OS, on windows looks fine
R1 := Rect(ClientWidth - BtnSize.Width, 1, ClientWidth, ClientHeight - 1);
R2 := Rect(r1.Left+1, r1.Top+1, r1.Right-2, r1.Bottom-1);
pr := @R2;
ThemeServices.DrawElement(Canvas.Handle, DetailsBtn, R1, pr);
{$ENDIF}
R.Right:=R.Right - BtnSize.Width;
if FDisplayAll then
PaintDisplayValues(Canvas, R, TextMargin, @Details)
else
begin
if Assigned(FDataField) and FDataField.IsNull then
AText:=FEmptyValue
else
if FValuesList.Count > 0 then
AText:=FValuesList[FLookupDisplayIndex]
else
AText:='';
R.Left:=R.Left + TextMargin;
ThemeServices.DrawText(Canvas, Details, AText, R, DT_LEFT or DT_VCENTER or DT_SINGLELINE, 0);
end;
end
else
begin
Canvas.Font := Font;
Canvas.Brush.Color := Color;
Selected := Focused and (not (csPaintCopy in ControlState)) and (not PopupVisible);
if Selected then
begin
Canvas.Font.Color := clHighlightText;
Canvas.Brush.Color := clHighlight;
end
else
if not Enabled {and NewStyleControls }then
begin
Canvas.Font.Color := clInactiveCaption;
end;
if BorderStyle = bsNone then
begin
border := 3;
if Flat then
begin
Canvas.Frame3d(R, border, bvLowered);
end
else
begin
RxFrame3D(Canvas, R, clWindowFrame, clBtnHighlight, 1);
RxFrame3D(Canvas, R, clBtnShadow, clBtnFace, 1);
end;
end
else
begin
border := 1;
end;
if ClientWidth > 2*border then
begin
R1 := Rect(border, border, ClientWidth - border, ClientHeight - border);
Canvas.FillRect(R1);
R.Right := R.Right - GetButtonWidth;
if PopupVisible and (Caption<>'') then
begin
AText := Caption;
Canvas.TextRect(R, TextMargin, Max(0, (HeightOf(R) - Canvas.TextHeight('Wg')) div 2), AText);
end
else
if FDisplayAll then
PaintDisplayValues(Canvas, R, TextMargin, nil)
else
begin
if Assigned(FDataField) and FDataField.IsNull then
begin
R1 := Rect(border + padding, border + padding, ClientWidth - (border + padding) - GetButtonWidth, ClientHeight - (border + padding));
Canvas.Brush.Color:=FEmptyItemColor;
Canvas.FillRect(R1);
AText:=FEmptyValue
end
else
if FValuesList.Count > 0 then
AText:=FValuesList[FLookupDisplayIndex]
else
AText:='';
Canvas.TextRect(R, TextMargin, Max(0, (HeightOf(R) - Canvas.TextHeight('Wg')) div 2), AText);
end
end;
end;
end;
(*const
padding : Integer = 1;
var
Selected:boolean;
@ -1655,6 +1797,8 @@ begin
end;
end;
end;
*)
procedure TRxCustomDBLookupCombo.LookupDataSetChanged(Sender: TObject);
begin