mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +02:00
Finishes implementing Spin Edit for wince
git-svn-id: trunk@19460 -
This commit is contained in:
parent
8e845b1091
commit
97bbdab0c8
@ -816,42 +816,38 @@ Var
|
||||
Result := WindowInfo^.isComboEdit and (ComboBoxHandleSizeWindow = Windows.GetParent(Window));
|
||||
end;
|
||||
|
||||
{ procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit);
|
||||
procedure HandleSpinEditChange(ASpinEdit: TCustomFloatSpinEdit);
|
||||
var
|
||||
lWindowInfo: PWindowInfo;
|
||||
lNewValue: Double;
|
||||
begin
|
||||
lWindowInfo := GetWindowInfo(ASpinEdit.Handle);
|
||||
if lWindowInfo = @DefaultWindowInfo then exit;
|
||||
lNewValue := StrToFloatDef(ASpinEdit.Text, lWindowInfo^.spinValue);
|
||||
if lNewValue <> lWindowInfo^.spinValue then
|
||||
begin
|
||||
lWindowInfo^.spinValue := lNewValue;
|
||||
LMessage.Msg := CM_TEXTCHANGED;
|
||||
end;
|
||||
|
||||
lWindowInfo^.spinValue := ASpinEdit.StrToValue(ASpinEdit.Text);
|
||||
|
||||
LMessage.Msg := CM_TEXTCHANGED;
|
||||
end;
|
||||
|
||||
procedure HandleSpinEditDeltaPos(AUpDownMsg: PNMUpDown);
|
||||
var
|
||||
lSpinEdit: TCustomFloatSpinEdit;
|
||||
SpinEdit: TCustomFloatSpinEdit;
|
||||
spinHandle: HWND;
|
||||
newValue: Double;
|
||||
begin
|
||||
lSpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl);
|
||||
newValue := WindowInfo^.spinValue + AUpDownMsg^.iDelta * lSpinEdit.Increment;
|
||||
if (lSpinEdit.MinValue <> 0) or (lSpinEdit.MaxValue <> 0) then
|
||||
SpinEdit := TCustomFloatSpinEdit(WindowInfo^.WinControl);
|
||||
|
||||
if not SpinEdit.ReadOnly then
|
||||
begin
|
||||
if newValue > lSpinEdit.MaxValue then
|
||||
newValue := lSpinEdit.MaxValue;
|
||||
if newValue < lSpinEdit.MinValue then
|
||||
newValue := lSpinEdit.MinValue;
|
||||
NewValue := SpinEdit.GetLimitedValue(
|
||||
WindowInfo^.spinValue + AUpDownMsg^.iDelta * SpinEdit.Increment);
|
||||
WindowInfo^.spinValue := NewValue;
|
||||
|
||||
spinHandle := AUpDownMsg^.hdr.hwndFrom;
|
||||
UpdateFloatSpinEditText(SpinEdit, NewValue);
|
||||
Windows.SendMessage(spinHandle, UDM_SETPOS32, 0, 500);
|
||||
end;
|
||||
spinHandle := AUpDownMsg^.hdr.hwndFrom;
|
||||
UpdateFloatSpinEditText(spinHandle, NewValue, lSpinEdit.DecimalPlaces);
|
||||
Windows.SendMessage(spinHandle, UDM_SETPOS32, 0, 500);
|
||||
WindowInfo^.spinValue := newValue;
|
||||
end;
|
||||
}
|
||||
|
||||
procedure SetMinMaxInfo(var MinMaxInfo: TMINMAXINFO);
|
||||
procedure SetWin32SizePoint(AWidth, AHeight: integer; var pt: TPoint);
|
||||
var
|
||||
@ -1161,10 +1157,10 @@ begin
|
||||
case Hi(WParam) of
|
||||
EN_CHANGE: LMessage.Msg := CM_TEXTCHANGED;
|
||||
end
|
||||
{ else if (lWinControl is TCustomFloatSpinEdit) then
|
||||
else if (lWinControl is TCustomFloatSpinEdit) then
|
||||
case Hi(WParam) of
|
||||
EN_CHANGE: HandleSpinEditChange(TCustomFloatSpinEdit(lWinControl));
|
||||
end}
|
||||
end
|
||||
else if (lWinControl is TCustomMemo) then
|
||||
case Hi(WParam) of
|
||||
// multiline edit doesn't send EN_CHANGE, so use EN_UPDATE
|
||||
@ -1707,17 +1703,17 @@ begin
|
||||
{$endif}
|
||||
case PNMHdr(LParam)^.code of
|
||||
0 :;
|
||||
{ MCN_SELCHANGE:
|
||||
MCN_SELCHANGE:
|
||||
begin
|
||||
LMessage.Msg := LM_CHANGED;
|
||||
if WindowInfo^.WinControl <> nil then
|
||||
lWinControl := WindowInfo^.WinControl;
|
||||
end;}
|
||||
{ UDN_DELTAPOS:
|
||||
end;
|
||||
UDN_DELTAPOS:
|
||||
begin
|
||||
if WindowInfo^.WinControl <> nil then
|
||||
HandleSpinEditDeltaPos(PNMUpDown(LParam));
|
||||
end;}
|
||||
end;
|
||||
else
|
||||
PLMsg:=@LMNotify;
|
||||
with LMNotify Do
|
||||
|
@ -33,6 +33,7 @@ uses
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
Spin, Controls, StdCtrls, LCLType, commctrl,
|
||||
LCLProc,
|
||||
////////////////////////////////////////////////////
|
||||
WSSpin, WSLCLClasses, Windows, WinCEInt, WinCEProc,
|
||||
WinCEWSStdCtrls, WinCEWSControls;
|
||||
@ -52,8 +53,10 @@ type
|
||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override;
|
||||
|
||||
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||
|
||||
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
|
||||
@ -67,8 +70,8 @@ function SpinBuddyWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||
LParam: Windows.LParam): LResult; cdecl;
|
||||
procedure UpdateFloatSpinEditControl(const Handle: HWND;
|
||||
const AFloatSpinEdit: TCustomFloatSpinEdit);
|
||||
procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: Double;
|
||||
const ADecimalPlaces: integer);
|
||||
procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit;
|
||||
const ANewValue: Double);
|
||||
|
||||
implementation
|
||||
|
||||
@ -124,21 +127,21 @@ begin
|
||||
if lWindowInfo <> @DefaultWindowInfo then
|
||||
begin
|
||||
lWindowInfo^.spinValue := AFloatSpinEdit.Value;
|
||||
UpdateFloatSpinEditText(Handle, AFloatSpinEdit.Value, AFloatSpinEdit.DecimalPlaces);
|
||||
UpdateFloatSpinEditText(AFloatSpinEdit, AFloatSpinEdit.Value);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure UpdateFloatSpinEditText(const ASpinHandle: HWND; const ANewValue: Double;
|
||||
const ADecimalPlaces: integer);
|
||||
procedure UpdateFloatSpinEditText(const ASpinEdit: TCustomFloatSpinEdit;
|
||||
const ANewValue: Double);
|
||||
var
|
||||
editHandle: HWND;
|
||||
newValueText: string;
|
||||
newValueText: widestring;
|
||||
begin
|
||||
editHandle := GetBuddyWindow(ASpinHandle);
|
||||
newValueText := FloatToStrF(ANewValue, ffFixed, 20, ADecimalPlaces);
|
||||
Windows.SendMessageW(editHandle, WM_SETTEXT, 0, Windows.LPARAM(PWideChar(UTF8Decode(newValueText))));
|
||||
editHandle := GetBuddyWindow(ASpinEdit.Handle);
|
||||
newValueText := UTF8Decode(ASpinEdit.ValueToStr(ANewValue));
|
||||
Windows.SendMessageW(editHandle, WM_SETTEXT, 0, Windows.LPARAM(PWideChar(newValueText)));
|
||||
end;
|
||||
|
||||
|
||||
class function TWinCEWSCustomFloatSpinEdit.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND;
|
||||
var
|
||||
@ -168,6 +171,9 @@ begin
|
||||
Params.SubClassWndProc := @SpinBuddyWindowProc;
|
||||
WindowCreateInitBuddy(AWinControl, Params);
|
||||
Params.BuddyWindowInfo^.isChildEdit := true;
|
||||
// make possible LCL Wincontrol identification by Buddy handle
|
||||
// TODO: should move to widget specific SetProp method
|
||||
SetProp(Params.Buddy, 'WinControl', PtrUInt(AWinControl));
|
||||
Result := Params.Window;
|
||||
end;
|
||||
|
||||
@ -218,6 +224,13 @@ begin
|
||||
Result := GetWindowInfo(ACustomFloatSpinEdit.Handle)^.spinValue;
|
||||
end;
|
||||
|
||||
class procedure TWinCEWSCustomFloatSpinEdit.SetReadOnly(
|
||||
const ACustomEdit: TCustomEdit; NewReadOnly: boolean);
|
||||
begin
|
||||
Windows.SendMessage(GetBuddyWindow(ACustomEdit.Handle), EM_SETREADONLY,
|
||||
Windows.WPARAM(NewReadOnly), 0);
|
||||
end;
|
||||
|
||||
class procedure TWinCEWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;
|
||||
NewStart: integer);
|
||||
begin
|
||||
@ -230,6 +243,14 @@ begin
|
||||
EditSetSelLength(GetBuddyWindow(ACustomEdit.Handle), NewLength);
|
||||
end;
|
||||
|
||||
class procedure TWinCEWSCustomFloatSpinEdit.SetText(
|
||||
const AWinControl: TWinControl; const AText: string);
|
||||
begin
|
||||
Windows.SetWindowTextW(
|
||||
GetBuddyWindow(AWinControl.Handle),
|
||||
PWideChar(UTF8ToUTF16(AText)));
|
||||
end;
|
||||
|
||||
class procedure TWinCEWSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl);
|
||||
var
|
||||
Buddy: HWND;
|
||||
|
Loading…
Reference in New Issue
Block a user