mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 12:19:20 +02:00
Patch from zaher dirkey: fixes combobox height under wince
git-svn-id: trunk@21228 -
This commit is contained in:
parent
867297cbb7
commit
3478d0c10b
@ -42,18 +42,6 @@ Begin
|
|||||||
Result := WideCompareStr(widestring(AStr), widestring(BStr));//roozbeh:does this work?!
|
Result := WideCompareStr(widestring(AStr), widestring(BStr));//roozbeh:does this work?!
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetComboHeight(Sender: TWinControl; AHeight:Integer);
|
|
||||||
var
|
|
||||||
Left, Top, Width: integer;
|
|
||||||
begin
|
|
||||||
Left := Sender.Left;
|
|
||||||
Top := Sender.Top;
|
|
||||||
Width := Sender.Width;
|
|
||||||
LCLBoundsToWin32Bounds(Sender, Left, Top, Width, AHeight);
|
|
||||||
MoveWindow(Sender.Handle, Left, Top, Width, AHeight, true);//roozbeh check if this works!
|
|
||||||
LCLControlSizeNeedsUpdate(Sender, true);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{*************************************************************}
|
{*************************************************************}
|
||||||
{ TWinCEListStringList methods }
|
{ TWinCEListStringList methods }
|
||||||
{*************************************************************}
|
{*************************************************************}
|
||||||
@ -324,6 +312,19 @@ begin
|
|||||||
FDropDownCount := 8;
|
FDropDownCount := 8;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TWinCEComboBoxStringList.UpdateComboHeight;
|
||||||
|
var
|
||||||
|
Left, Top, Width, Height: integer;
|
||||||
|
begin
|
||||||
|
Left := FSender.Left;
|
||||||
|
Top := FSender.Top;
|
||||||
|
Width := FSender.Width;
|
||||||
|
Height := ComboHeight;
|
||||||
|
LCLBoundsToWin32Bounds(FSender, Left, Top, Width, Height);
|
||||||
|
MoveWindow(FSender.Handle, Left, Top, Width, Height, true);
|
||||||
|
LCLControlSizeNeedsUpdate(FSender, true);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TWinCEComboBoxStringList.Assign(Source: TPersistent);
|
procedure TWinCEComboBoxStringList.Assign(Source: TPersistent);
|
||||||
var
|
var
|
||||||
EditText: string;
|
EditText: string;
|
||||||
@ -337,7 +338,7 @@ begin
|
|||||||
inherited Assign(Source);
|
inherited Assign(Source);
|
||||||
|
|
||||||
// restore text in edit box
|
// restore text in edit box
|
||||||
SetComboHeight(FSender, ComboHeight);
|
UpdateComboHeight;
|
||||||
TWinCEWSCustomComboBox.SetText(FSender, EditText);
|
TWinCEWSCustomComboBox.SetText(FSender, EditText);
|
||||||
lItemIndex := IndexOf(EditText);
|
lItemIndex := IndexOf(EditText);
|
||||||
if lItemIndex <> -1 then
|
if lItemIndex <> -1 then
|
||||||
@ -348,32 +349,47 @@ end;
|
|||||||
|
|
||||||
function TWinCEComboBoxStringList.GetComboHeight: integer;
|
function TWinCEComboBoxStringList.GetComboHeight: integer;
|
||||||
begin
|
begin
|
||||||
if Count = 0 then
|
if (FSender is TCustomComboBox) and (TCustomComboBox(FSender).Style = csSimple) then
|
||||||
begin
|
begin
|
||||||
Result := FEditHeight + FItemHeight + 2;
|
// combobox workaround:
|
||||||
end else begin
|
// if style = csSimple follow the LCL height.
|
||||||
Result := FEditHeight + FDropDownCount*FItemHeight + 2;
|
Result := FSender.Height;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
if Count = 0 then
|
||||||
|
begin
|
||||||
|
Result := FEditHeight + FItemHeight + 2;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result := FEditHeight + FDropDownCount * FItemHeight + 2;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWinCEComboBoxStringList.Clear;
|
procedure TWinCEComboBoxStringList.Clear;
|
||||||
|
var
|
||||||
|
SaveText: String;
|
||||||
begin
|
begin
|
||||||
SetComboHeight(FSender, FEditHeight + FItemHeight + 2);
|
if not TCustomComboBox(FSender).ReadOnly then
|
||||||
|
SaveText := TCustomComboBox(FSender).Text;
|
||||||
inherited;
|
inherited;
|
||||||
|
UpdateComboHeight;
|
||||||
|
if not TCustomComboBox(FSender).ReadOnly then
|
||||||
|
TCustomComboBox(FSender).Text := SaveText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWinCEComboBoxStringList.Delete(Index: integer);
|
procedure TWinCEComboBoxStringList.Delete(Index: integer);
|
||||||
begin
|
begin
|
||||||
if GetCount <= 1 then
|
|
||||||
SetComboHeight(FSender, FEditHeight + FItemHeight + 2);
|
|
||||||
inherited Delete(Index);
|
inherited Delete(Index);
|
||||||
|
if Count <= 1 then
|
||||||
|
UpdateComboHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWinCEComboBoxStringList.Insert(Index: integer; const S: string);
|
procedure TWinCEComboBoxStringList.Insert(Index: integer; const S: string);
|
||||||
begin
|
begin
|
||||||
if GetCount = 0 then
|
|
||||||
SetComboHeight(FSender, FEditHeight + FDropDownCount*FItemHeight + 2);
|
|
||||||
inherited Insert(Index, S);
|
inherited Insert(Index, S);
|
||||||
|
if GetCount = 1 then
|
||||||
|
UpdateComboHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +69,8 @@ type
|
|||||||
property Sorted: Boolean Read FSorted Write SetSorted;
|
property Sorted: Boolean Read FSorted Write SetSorted;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TWinCEComboBoxStringList }
|
||||||
|
|
||||||
TWinCEComboBoxStringList = class(TWinCEListStringList)
|
TWinCEComboBoxStringList = class(TWinCEListStringList)
|
||||||
private
|
private
|
||||||
FEditHeight: Integer;
|
FEditHeight: Integer;
|
||||||
@ -77,6 +79,7 @@ type
|
|||||||
protected
|
protected
|
||||||
function GetComboHeight: integer;
|
function GetComboHeight: integer;
|
||||||
procedure InitFlags; override;
|
procedure InitFlags; override;
|
||||||
|
procedure UpdateComboHeight;
|
||||||
public
|
public
|
||||||
procedure Assign(Source: TPersistent); override;
|
procedure Assign(Source: TPersistent); override;
|
||||||
procedure Clear; override;
|
procedure Clear; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user