summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@users.sourceforge.net>2007-04-25 15:08:52 +0000
committerGraeme Geldenhuys <graemeg@users.sourceforge.net>2007-04-25 15:08:52 +0000
commit55825e0ebbe83c960478600f37858fdb8df2cf82 (patch)
tree9e3646af2da5fb67dcbe5e53afd557ed4459f9a1 /gui
parent314decc7aecb7efb2e12d41814a2a09408939f76 (diff)
downloadfpGUI-55825e0ebbe83c960478600f37858fdb8df2cf82.tar.xz
* After the last patch of the TEdit it broke the PasswordChar feature which is now fixed again.
* Removed the anoying feature when you drag a scrollbar and move out of bounds, the scrollbar jumps back to the original position. Maybe we can keep that behaviour, but enabled via a property. * Busy implementing a SaveForm function, but still experimental and mostly for debugging only.
Diffstat (limited to 'gui')
-rw-r--r--gui/fpgui.pas20
-rw-r--r--gui/fpguiedit.inc27
-rw-r--r--gui/fpguiscrollbar.inc37
3 files changed, 50 insertions, 34 deletions
diff --git a/gui/fpgui.pas b/gui/fpgui.pas
index cac0c8cc..111521b2 100644
--- a/gui/fpgui.pas
+++ b/gui/fpgui.pas
@@ -151,6 +151,7 @@ function ClipMinMax(val, min, max: Integer): Integer; //inline;
{ This will change at a later date! }
procedure LoadForm(AForm: TComponent);
+procedure SaveForm(AForm: TComponent);
implementation
@@ -203,6 +204,25 @@ begin
BinStream.Free;
end;
+// graeme: still work in progress (2007-04-25)
+procedure SaveForm(AForm: TComponent);
+var
+ f, f2: TStream;
+ Filename: string;
+ TextStream, BinStream: TStream;
+begin
+ Filename := LowerCase(Copy(AForm.ClassName, 2, 255)) + '.frm';
+// Filename := 'test.frm';
+ BinStream := TMemoryStream.Create;
+ TextStream := TFileStream.Create(Filename, fmCreate);
+ BinStream.WriteComponent(AForm);
+ BinStream.Position := 0;
+ ObjectBinaryToText(BinStream, TextStream);
+
+ TextStream.Free;
+ BinStream.Free;
+end;
+
{$IFDEF LAYOUTTRACES}
procedure LAYOUTTRACE(const Position: String; const args: array of const);
{$IFDEF TraceEvents}
diff --git a/gui/fpguiedit.inc b/gui/fpguiedit.inc
index 9e850403..aad82846 100644
--- a/gui/fpguiedit.inc
+++ b/gui/fpguiedit.inc
@@ -18,6 +18,7 @@
{$IFDEF read_interface}
+
{ TFCustomEdit }
TBorderStyle = (bsNone, bsSingle);
@@ -36,7 +37,7 @@
procedure SetCursorPos(ACursorPos: Integer);
procedure SetBorderStyle(ABorderStyle: TBorderStyle);
procedure DoMousePressed(pEvent: TMousePressedEventObj);
- function GetFirstVisibleIndex: Integer;
+ function GetFirstVisibleIndex(AText: string): Integer;
protected
procedure Paint(Canvas: TFCanvas); override;
function ProcessEvent(Event: TEventObj): Boolean; override;
@@ -140,6 +141,7 @@ begin
else
Canvas.SetColor(Style.GetUIColor(clGrayText));
+ // If PasswordChar is set we need to use different text
if PasswordChar = #0 then
s := PChar(Text)
else
@@ -163,16 +165,7 @@ begin
ItemRect.Top := 0;
ItemRect.Right := Canvas.TextWidth(Copy(s, 1, CursorPos));
ItemRect.Bottom := Height;
-{
- ItemRect := Rect(0, 0, Width, Height);
- ItemRect.TopLeft := ItemRect.TopLeft + 1;
- ItemRect.BottomRight := ItemRect.BottomRight - 2;
-}
-// InflateRect(ItemRect, -1, -1);
-
-// Style.SetUIColor(Canvas, clWindowText);
- {$Note Start here: Refine the selection rect}
Style.DrawItemBefore(Canvas, ItemRect, ItemFlags);
Style.DrawText(Canvas, (Borders.TopLeft + Point(1, 1)), s, WidgetState);
Style.DrawItemAfter(Canvas, ItemRect, ItemFlags);
@@ -180,13 +173,13 @@ begin
else
begin
x := 1;
- y := GetFirstVisibleIndex;
+ y := GetFirstVisibleIndex(s);
{$ifdef debug}
writeln(y);
{$endif debug}
- while (x <= Length(Text)) and (Canvas.TextWidth(Copy(Text, y, x)) < Width - 8) do
+ while (x <= Length(Text)) and (Canvas.TextWidth(Copy(s, y, x)) < Width - 8) do
Inc(x);
- s := Copy(Text, y, x);
+ s := Copy(s, y, x);
{$ifdef debug}
writeln(s);
writeln(FCursorPos, ':', y);
@@ -420,18 +413,18 @@ begin
end;
end;
-function TFCustomEdit.GetFirstVisibleIndex: Integer;
+function TFCustomEdit.GetFirstVisibleIndex(AText: string): Integer;
var
Canvas: TFCustomCanvas;
function GetFirstPosition(maxlength: Integer): Integer;
begin
- if Canvas.TextWidth(Copy(Text, 1, maxlength)) < Width-8 then
+ if Canvas.TextWidth(Copy(AText, 1, maxlength)) < Width-8 then
Result := 1
else
begin
Result := maxlength;
- while (Result > 1) and (Canvas.TextWidth(Copy(Text,
+ while (Result > 1) and (Canvas.TextWidth(Copy(AText,
Result-1, maxlength-Result+2)) < Width-8) do
Dec(Result);
end;
@@ -439,7 +432,7 @@ var
begin
Canvas := FindForm.Wnd.Canvas;
- Result := GetFirstPosition(Length(Text));
+ Result := GetFirstPosition(Length(AText));
if Result > FCursorPos then
Result := FCursorPos;
FOldVisibleIndex := Result;
diff --git a/gui/fpguiscrollbar.inc b/gui/fpguiscrollbar.inc
index 3a5f1e66..08e1ecc8 100644
--- a/gui/fpguiscrollbar.inc
+++ b/gui/fpguiscrollbar.inc
@@ -48,7 +48,7 @@
procedure SetPageSize(APageSize: Integer);
procedure SetPosition(APosition: Integer);
// Helpers
- function GeTFButtonSize: Integer;
+ function GetButtonSize: Integer;
function ClipPosition(APosition: Integer): Integer;
procedure UpdateBar;
protected
@@ -192,7 +192,7 @@ begin
ButtonPos := (Position - Min) *
(Size - ButtonSize) div (Max - Min - PageSize + 1);
end;
- ButtonSize := GeTFButtonSize;
+ ButtonSize := GetButtonSize;
end;
Redraw;
end;
@@ -278,7 +278,7 @@ begin
Result := inherited ProcessEvent(Event); // For mouse grabbing support
if Event.Button <> mbLeft then
- exit;
+ Exit; //==>
if TFCustomScrollBar(Owner).Orientation = Horizontal then
Pos := Event.Position.x
@@ -312,7 +312,7 @@ begin
Result := inherited ProcessEvent(Event); // For mouse grabbing support
if Event.Button <> mbLeft then
- exit;
+ Exit; //==>
if IsDraggingButton then
begin
@@ -348,8 +348,10 @@ var
begin
if IsDraggingButton then
begin
- if wsMouseInside in WidgetState then
- begin
+// We can maybe make this a scrollbar option. Reset scrollbar thumb when
+// mouse moves out of bounds of scrollbar. For now it is just anoying.
+// if wsMouseInside in WidgetState then
+// begin
if TFCustomScrollBar(Owner).Orientation = Horizontal then
begin
Pos := Event.Position.x;
@@ -359,15 +361,15 @@ begin
Pos := Event.Position.y;
Size := Height;
end;
- end
- else
- begin
- Pos := DragStartMousePos;
- if TFCustomScrollBar(Owner).Orientation = Horizontal then
- Size := Width
- else
- Size := Height;
- end; { if/else }
+// end
+// else
+// begin
+// Pos := DragStartMousePos;
+// if TFCustomScrollBar(Owner).Orientation = Horizontal then
+// Size := Width
+// else
+// Size := Height;
+// end; { if/else }
ButtonPos := ClipMinMax(DragStarTFButtonPos + Pos - DragStartMousePos,
0, Size - ButtonSize);
@@ -382,7 +384,8 @@ begin
Redraw;
Result := True
- end else
+ end
+ else
Result := False;
end;
@@ -669,7 +672,7 @@ begin
end;
-function TFCustomScrollBar.GeTFButtonSize: Integer;
+function TFCustomScrollBar.GetButtonSize: Integer;
var
Size: Integer;
begin