diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-30 14:18:03 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-30 14:18:03 +0000 |
commit | 5e28b873d852f64020ac991d64f8c1dd0e21b0f6 (patch) | |
tree | 9fd3b98302838af1d8bb538af6533d03e5950785 | |
parent | 37a180859483a5a6bdd49c55c4a2eeaaa2c36e3c (diff) | |
download | fpGUI-5e28b873d852f64020ac991d64f8c1dd0e21b0f6.tar.xz |
* Memo: OnUpdate now fires at correct times.
* Memo: Scrollbars now stay in sync with mouse wheel scroll.
-rw-r--r-- | prototypes/fpgui2/tests/edittest.dpr | 1 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/edittest.lpi | 7 | ||||
-rw-r--r-- | src/gui/gui_edit.pas | 13 | ||||
-rw-r--r-- | src/gui/gui_memo.pas | 103 |
4 files changed, 63 insertions, 61 deletions
diff --git a/prototypes/fpgui2/tests/edittest.dpr b/prototypes/fpgui2/tests/edittest.dpr index 20a53b33..422d9c56 100644 --- a/prototypes/fpgui2/tests/edittest.dpr +++ b/prototypes/fpgui2/tests/edittest.dpr @@ -399,6 +399,7 @@ begin memo.Left := 250; memo.Width := 200; memo.Height := 80; + memo.Anchors := [anLeft, anTop, anRight, anBottom]; listbox := TfpgListBox.Create(self); listbox.Top := 100; diff --git a/prototypes/fpgui2/tests/edittest.lpi b/prototypes/fpgui2/tests/edittest.lpi index b609d403..1ecb384f 100644 --- a/prototypes/fpgui2/tests/edittest.lpi +++ b/prototypes/fpgui2/tests/edittest.lpi @@ -1,7 +1,7 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="\"/> + <PathDelim Value="/"/> <Version Value="5"/> <General> <Flags> @@ -9,7 +9,7 @@ </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value=".\"/> + <IconPath Value="./"/> <TargetFileExt Value=""/> </General> <VersionInfo> @@ -23,7 +23,7 @@ <RunParams> <local> <FormatVersion Value="1"/> - <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> + <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> </local> </RunParams> <RequiredPackages Count="1"> @@ -42,7 +42,6 @@ </ProjectOptions> <CompilerOptions> <Version Value="5"/> - <PathDelim Value="\"/> <CodeGeneration> <Generate Value="Faster"/> </CodeGeneration> diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas index c67edaca..484da030 100644 --- a/src/gui/gui_edit.pas +++ b/src/gui/gui_edit.pas @@ -17,6 +17,7 @@ type TfpgEdit = class(TfpgCustomEdit) private + FOnChange: TNotifyEvent; FText: string; FMaxLength: integer; FCursorPos: integer; @@ -49,7 +50,7 @@ type destructor Destroy; override; function SelectionText: string; property Font: TfpgFont read FFont; - OnChange: TNotifyEvent; + property OnChange: TNotifyEvent read FOnChange write FOnChange; published property Text: string read FText write SetText; property FontDesc: string read GetFontDesc write SetFontDesc; @@ -97,7 +98,7 @@ begin FDrawOffset := 0; PasswordMode := False; - OnChange := nil; + FOnChange := nil; end; destructor TfpgEdit.Destroy; @@ -306,8 +307,8 @@ begin end; if prevval <> Text then - if Assigned(OnChange) then - OnChange(self); + if Assigned(FOnChange) then + FOnChange(self); if consumed then RePaint @@ -459,8 +460,8 @@ begin inherited; if hasChanged then - if Assigned(OnChange) then - OnChange(self); + if Assigned(FOnChange) then + FOnChange(self); end; procedure TfpgEdit.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); diff --git a/src/gui/gui_memo.pas b/src/gui/gui_memo.pas index a6c737f1..04ce67d6 100644 --- a/src/gui/gui_memo.pas +++ b/src/gui/gui_memo.pas @@ -75,7 +75,7 @@ type public constructor Create(AOwner: TComponent); override; destructor Destroy; override; - procedure UpdateScrollBar; + procedure UpdateScrollBars; function SelectionText: string; property LineHeight: integer read FLineHeight; property CursorLine: integer read FCursorLine write SetCursorLine; @@ -437,10 +437,10 @@ begin FFirstLine := 1; end; - UpdateScrollbar; + UpdateScrollbars; end; -procedure TfpgMemo.UpdateScrollBar; +procedure TfpgMemo.UpdateScrollBars; var vlines: integer; vsbw, x: integer; @@ -480,6 +480,7 @@ begin else FHScrollBar.SliderSize := VisibleWidth / FLongestLineWidth; FHScrollBar.Position := FDrawOffset; + FHScrollBar.RepaintSlider; end; if FVScrollBar.Visible then @@ -488,6 +489,7 @@ begin FVScrollBar.SliderSize := VisibleLines / LineCount; FVScrollBar.Max := LineCount - VisibleLines + 1; FVScrollBar.Position := FFirstLine; + FVScrollBar.RepaintSlider; end; if (hsbwas <> FHScrollBar.Visible) or (vsbwas <> FVScrollBar.Visible) then @@ -589,7 +591,7 @@ procedure TfpgMemo.HandleShow; begin inherited HandleShow; RecalcLongestLine; - UpdateScrollBar; + UpdateScrollBars; UpdateScrollBarCoords; end; @@ -728,21 +730,6 @@ begin inherited; prevval := Text; s := AText; - Consumed := False; -{ - Consumed := true; - case pgfCheckClipBoardKey(keycode, shiftstate) of - ckCopy: DoCopy; - ckPaste: DoPaste; - ckCut: //if FSelEndLine > 0 then - begin - DoCopy; - DeleteSelection; - end; - else - Consumed := false; - end; -} // Printable characters only // Note: This is not UTF-8 compliant! @@ -781,6 +768,7 @@ var cx: integer; ls: string; ls2: string; + hasChanged: boolean; procedure StopSelection; begin @@ -790,21 +778,27 @@ var end; begin - Consumed := False; - (* - Consumed := true; - case pgfCheckClipBoardKey(keycode, shiftstate) of - ckCopy: DoCopy; - ckPaste: DoPaste; - ckCut: //if FSelEndLine > 0 then - begin - DoCopy; - DeleteSelection; - end; + Consumed := True; + hasChanged := False; + case CheckClipBoardKey(keycode, shiftstate) of + ckCopy: + begin + DoCopy; + end; + ckPaste: + begin + DoPaste; + hasChanged := True; + end; + ckCut: + begin + DoCopy; + DeleteSelection; + hasChanged := True; + end; else - Consumed := false; + Consumed := False; end; -*) if not Consumed then begin @@ -934,22 +928,26 @@ begin Inc(FCursorLine); SetLineText(FCursorLine, ls2); FCursorPos := 0; + hasChanged := True; end; keyBackSpace: - if FCursorPos > 0 then begin - ls := GetLineText(FCursorLine); - Delete(ls, FCursorPos, 1); - SetLineText(FCursorLine, ls); - Dec(FCursorPos); - end - else if FCursorLine > 1 then - begin - ls := CurrentLine; - FLines.Delete(FCursorLine - 1); - Dec(FCursorLine); - FCursorPos := UTF8Length(FLines.Strings[FCursorLine - 1]); - FLines.Strings[FCursorLine - 1] := FLines.Strings[FCursorLine - 1] + ls; + if FCursorPos > 0 then + begin + ls := GetLineText(FCursorLine); + Delete(ls, FCursorPos, 1); + SetLineText(FCursorLine, ls); + Dec(FCursorPos); + end + else if FCursorLine > 1 then + begin + ls := CurrentLine; + FLines.Delete(FCursorLine - 1); + Dec(FCursorLine); + FCursorPos := UTF8Length(FLines.Strings[FCursorLine - 1]); + FLines.Strings[FCursorLine - 1] := FLines.Strings[FCursorLine - 1] + ls; + end; + hasChanged := True; end; keyDelete: @@ -968,6 +966,7 @@ begin FLines.Delete(FCursorLine); FLines.Strings[FCursorLine - 1] := ls + ls2; end; + hasChanged := True; end; else consumed := False; @@ -984,6 +983,10 @@ begin RePaint else inherited; + + if hasChanged then + if Assigned(FOnChange) then + FOnChange(self); end; procedure TfpgMemo.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); @@ -1149,7 +1152,7 @@ begin if (pfl <> FFirstLine) or (pdo <> FDrawOffset) then begin - UpdateScrollBar; + UpdateScrollBars; Repaint; end; @@ -1160,8 +1163,8 @@ procedure TfpgMemo.HandleResize(dwidth, dheight: integer); begin inherited HandleResize(dwidth, dheight); - //UpdateScrollBarCoords; - UpdateScrollBar; + UpdateScrollBarCoords; + UpdateScrollBars; end; procedure TfpgMemo.HandleMouseScroll(x, y: integer; shiftstate: TShiftState; @@ -1171,8 +1174,6 @@ var begin inherited HandleMouseScroll(x, y, shiftstate, delta); -// inherited HandleWindowScroll(direction, amount); - pfl := FFirstLine; pdo := FDrawOffset; @@ -1196,7 +1197,7 @@ begin if (pfl <> FFirstLine) or (pdo <> FDrawOffset) then begin - UpdateScrollBar; + UpdateScrollBars; Repaint; end; end; |