diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-10-05 12:59:49 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-10-05 12:59:49 +0000 |
commit | 6c72999051b20a306d7e40a55f5df5a48253799f (patch) | |
tree | 8afe8d755d2017bd662aa0c54bcf261cd53f4314 /src/gui | |
parent | 433fbe8a1810882eda822e4cf4ccdefdbd8de959 (diff) | |
download | fpGUI-6c72999051b20a306d7e40a55f5df5a48253799f.tar.xz |
* Implemented a UTF8Insert() and UTF8Delete() procedures
* Fixed up TfpgEdit to now use the UTF-8 versions of Insert() and Delete()
which fixes some of the keyboard input issue.
* Removed stacks of compiler warnings all over the place.
* Fixed up the TfpgMemo to now use the UTF-8 versions of Insert() and Delete()
which fixes some of the keyboard input issues.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui_edit.pas | 25 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 6 | ||||
-rw-r--r-- | src/gui/gui_memo.pas | 10 | ||||
-rw-r--r-- | src/gui/gui_menu.pas | 1 |
4 files changed, 19 insertions, 23 deletions
diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas index 1d11b6c4..018ecc38 100644 --- a/src/gui/gui_edit.pas +++ b/src/gui/gui_edit.pas @@ -176,8 +176,9 @@ end; procedure TfpgEdit.SetPasswordMode(const AValue: boolean); begin - if FPasswordMode=AValue then exit; - FPasswordMode:=AValue; + if FPasswordMode = AValue then + Exit; //==> + FPasswordMode := AValue; end; procedure TfpgEdit.DeleteSelection; @@ -186,12 +187,12 @@ begin begin if FSelOffset < 0 then begin - Delete(FText, 1 + FSelStart + FSelOffset, -FSelOffset); + UTF8Delete(FText, 1 + FSelStart + FSelOffset, -FSelOffset); FCurSorPos := FSelStart + FSelOffset; end else begin - Delete(FText, 1 + FSelStart, FSelOffset); + UTF8Delete(FText, 1 + FSelStart, FSelOffset); FCurSorPos := FSelStart; end; FSelOffset := 0; @@ -202,7 +203,7 @@ end; procedure TfpgEdit.DoCopy; begin if FSelOffset = 0 then - Exit; + Exit; //==> fpgClipboard.Text := SelectionText; end; @@ -219,8 +220,8 @@ begin if UTF8Length(s) < 1 then Exit; //==> - {$Note Is Insert() UTF-8 safe? } - Insert(s, FText, FCursorPos + 1); + + UTF8Insert(s, FText, FCursorPos + 1); FCursorPos := FCursorPos + UTF8Length(s); AdjustCursor; Repaint; @@ -323,7 +324,7 @@ begin if (FMaxLength <= 0) or (UTF8Length(FText) < FMaxLength) then begin DeleteSelection; - Insert(s, FText, FCursorPos + 1); + UTF8Insert(s, FText, FCursorPos + 1); Inc(FCursorPos); FSelStart := FCursorPos; AdjustCursor; @@ -453,7 +454,7 @@ begin begin if FCursorPos > 0 then begin - Delete(FText, FCursorPos, 1); + UTF8Delete(FText, FCursorPos, 1); Dec(FCursorPos); hasChanged := True; end;// backspace @@ -465,7 +466,7 @@ begin if FSelOffset <> 0 then DeleteSelection else if FCursorPos < UTF8Length(FText) then - Delete(FText, FCursorPos + 1, 1); + UTF8Delete(FText, FCursorPos + 1, 1); hasChanged := True; end; else @@ -491,7 +492,6 @@ end; procedure TfpgEdit.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); var - s: string; n: integer; cpx: integer; cp: integer; @@ -504,7 +504,6 @@ begin dtext := GetDrawText; cpx := FFont.TextWidth(UTF8Copy(dtext, 1, FCursorPos)) - FDrawOffset + FSideMargin; cp := FCursorPos; - s := ''; for n := 0 to UTF8Length(dtext) do begin @@ -531,7 +530,6 @@ end; procedure TfpgEdit.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); var - s: string; n: integer; cpx: integer; cp: integer; @@ -545,7 +543,6 @@ begin dtext := GetDrawText; cpx := FFont.TextWidth(UTF8Copy(dtext, 1, FCursorPos)) - FDrawOffset + FSideMargin; cp := FCursorPos; - s := ''; for n := 0 to UTF8Length(dtext) do begin diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index c4bbd0b6..c35be4bf 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -150,13 +150,13 @@ begin end; function TfpgListBoxStrings.Add(const s: String): Integer; -var - ItemWidth: Integer; +//var +// ItemWidth: Integer; begin Result := inherited Add(s); if Assigned(ListBox) and (ListBox.HasHandle) then begin - ItemWidth := ListBox.Font.TextWidth(s) + 4; +// ItemWidth := ListBox.Font.TextWidth(s) + 4; // if ItemWidth > ListBox.FMaxItemWidth then // ListBox.FMaxItemWidth := ItemWidth; ListBox.UpdateScrollBar; diff --git a/src/gui/gui_memo.pas b/src/gui/gui_memo.pas index 75cc4965..f151203e 100644 --- a/src/gui/gui_memo.pas +++ b/src/gui/gui_memo.pas @@ -302,7 +302,7 @@ begin else len := selep - st; - Delete(ls, st + 1, len); + UTF8Delete(ls, st + 1, len); SetLineText(n, ls); end; @@ -798,7 +798,7 @@ begin begin DeleteSelection; ls := GetLineText(FCursorLine); - insert(s, ls, FCursorPos + 1); + UTF8Insert(s, ls, FCursorPos + 1); SetLineText(FCursorLine, ls); Inc(FCursorPos); FSelStartPos := FCursorPos; @@ -991,7 +991,7 @@ begin if FCursorPos > 0 then begin ls := GetLineText(FCursorLine); - Delete(ls, FCursorPos, 1); + UTF8Delete(ls, FCursorPos, 1); SetLineText(FCursorLine, ls); Dec(FCursorPos); end @@ -1013,7 +1013,7 @@ begin DeleteSelection else if FCursorPos < UTF8Length(ls) then begin - Delete(ls, FCursorPos + 1, 1); + UTF8Delete(ls, FCursorPos + 1, 1); SetLineText(FCursorLine, ls); end else if FCursorLine < LineCount then @@ -1033,7 +1033,7 @@ begin DeleteSelection else} if FCursorPos < UTF8Length(ls) then begin - Insert(#9, ls, FCursorPos); + UTF8Insert(#9, ls, FCursorPos); SetLineText(FCursorLine, ls); end; { diff --git a/src/gui/gui_menu.pas b/src/gui/gui_menu.pas index 2aad7394..58aacda6 100644 --- a/src/gui/gui_menu.pas +++ b/src/gui/gui_menu.pas @@ -458,7 +458,6 @@ var n: integer; r: TfpgRect; mi: TfpgMenuItem; - r2: TfpgRect; begin Canvas.BeginDraw; r.SetRect(2, 1, 1, fpgStyle.MenuFont.Height+1); |