summaryrefslogtreecommitdiff
path: root/prototypes
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-17 14:58:33 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-17 14:58:33 +0000
commit040727bf28aaf3eb282df3156298fd0c95c7c6c9 (patch)
treea9a2f3882a7020e32cd69b038db135afc64bdfcc /prototypes
parent1472dbbcf69d076942161edd4061ca832bb4581f (diff)
downloadfpGUI-040727bf28aaf3eb282df3156298fd0c95c7c6c9.tar.xz
* Minor fixes to how the ButtonFace gets painted.
* ButtonFace painting now supports btnIsDefault flag * TfpgMemo now has MouseScroll support.
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/fpgui2/examples/core/canvastest/fpgcanvas.lpr6
-rw-r--r--prototypes/fpgui2/source/core/fpgfx.pas46
-rw-r--r--prototypes/fpgui2/source/core/x11/gfx_x11.pas9
-rw-r--r--prototypes/fpgui2/source/gui/gui_button.pas2
-rw-r--r--prototypes/fpgui2/source/gui/gui_memo.pas39
-rw-r--r--prototypes/fpgui2/tests/edittest.lpi7
6 files changed, 83 insertions, 26 deletions
diff --git a/prototypes/fpgui2/examples/core/canvastest/fpgcanvas.lpr b/prototypes/fpgui2/examples/core/canvastest/fpgcanvas.lpr
index c36ec2b1..19646056 100644
--- a/prototypes/fpgui2/examples/core/canvastest/fpgcanvas.lpr
+++ b/prototypes/fpgui2/examples/core/canvastest/fpgcanvas.lpr
@@ -66,7 +66,7 @@ begin
r.Left := 240;
Canvas.SetColor(clBlue);
- Canvas.SetLineStyle(1, lsSolid);
+// Canvas.SetLineStyle(1, lsSolid);
Canvas.FillRectangle(r);
@@ -96,8 +96,8 @@ begin
Canvas.DrawString(385, 50, '= [btnIsDefault]');
Canvas.DrawButtonFace(300, 80, 75, 25, [btnIsPressed]);
Canvas.DrawString(385, 80, '= [btnIsPressed]');
- Canvas.DrawButtonFace(300, 110, 75, 25, [btnHasFocus]);
- Canvas.DrawString(385, 110, '= [btnHasFocus]');
+ Canvas.DrawButtonFace(300, 110, 75, 25, [btnIsEmbedded, btnIsPressed]);
+ Canvas.DrawString(385, 110, '= [embedded & pressed]');
Canvas.DrawButtonFace(300, 140, 75, 25, [btnIsEmbedded]);
Canvas.DrawString(385, 140, '= [btnIsEmbedded]');
diff --git a/prototypes/fpgui2/source/core/fpgfx.pas b/prototypes/fpgui2/source/core/fpgfx.pas
index 78198cb2..e62e0c3f 100644
--- a/prototypes/fpgui2/source/core/fpgfx.pas
+++ b/prototypes/fpgui2/source/core/fpgfx.pas
@@ -755,6 +755,7 @@ end;
procedure TfpgStyle.DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags);
begin
ACanvas.SetColor(clButtonFace);
+ ACanvas.SetLineStyle(1, lsSolid);
ACanvas.FillRectangle(x, y, w, h);
// Left and Top (outer)
@@ -767,16 +768,16 @@ begin
end
else
ACanvas.SetColor(clHilite1);
- ACanvas.DrawLine(x, y + h - 2, x, y); // left
- ACanvas.DrawLine(x, y, x + w - 1, y); // top
+ ACanvas.DrawLine(x, y+h, x, y); // left
+ ACanvas.DrawLine(x, y, x+w, y); // top
// Left and Top (inner)
- if btnIsPressed in AFlags then
- begin
- ACanvas.SetColor(clShadow1);
- ACanvas.DrawLine(x + 1, y + h - 3, x + 1, y + 1); // left
- ACanvas.DrawLine(x + 1, y + 1, x + w - 2, y + 1); // top
- end;
+ //if btnIsPressed in AFlags then
+ //begin
+ //ACanvas.SetColor(clShadow1);
+ //ACanvas.DrawLine(x + 1, y + h - 3, x + 1, y + 1); // left
+ //ACanvas.DrawLine(x + 1, y + 1, x + w - 2, y + 1); // top
+ //end;
// Right and Bottom (outer)
if (btnIsPressed in AFlags) then
@@ -787,17 +788,32 @@ begin
ACanvas.SetColor(clShadow2);
end
else
- ACanvas.SetColor(clShadow2);
- ACanvas.DrawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); // right
- ACanvas.DrawLine(x, y + h - 1, x + w - 1, y + h - 1); // bottom
+ begin
+ if (btnIsDefault in AFlags) then
+ ACanvas.SetColor(clBlack)
+ else
+ ACanvas.SetColor(clShadow2);
+ end;
+ ACanvas.DrawLine(x+w-1, y, x+w-1, y+h-1); // right
+ ACanvas.DrawLine(x, y+h-1, x+w, y+h-1); // bottom
// Right and Bottom (inner)
if btnIsPressed in AFlags then
- ACanvas.SetColor(clHilite1)
+ begin
+ if (btnIsEmbedded in AFlags) then
+ ACanvas.SetColor(clButtonFace)
+ else
+ ACanvas.SetColor(clHilite1);
+ end
else
- ACanvas.SetColor(clShadow1);
- ACanvas.DrawLine(x + w - 2, y + 2, x + w - 2, y + h - 2); // right
- ACanvas.DrawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); // bottom
+ begin
+ if (btnIsDefault in AFlags) then
+ ACanvas.SetColor(clShadow2)
+ else
+ ACanvas.SetColor(clShadow1);
+ end;
+ ACanvas.DrawLine(x+w-2, y+1, x+w-2, y+h-2); // right
+ ACanvas.DrawLine(x+1, y+h-2, x+w-1, y+h-2); // bottom
end;
procedure TfpgStyle.DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord);
diff --git a/prototypes/fpgui2/source/core/x11/gfx_x11.pas b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
index 17ba47ed..21266354 100644
--- a/prototypes/fpgui2/source/core/x11/gfx_x11.pas
+++ b/prototypes/fpgui2/source/core/x11/gfx_x11.pas
@@ -1344,7 +1344,12 @@ end;
procedure TfpgCanvasImpl.DoFillRectangle(x, y, w, h: TfpgCoord);
begin
- XFillRectangle(xapplication.display, FDrawHandle, Fgc, x, y, w, h);
+ // Remember this for when we add Canvas.Pen support!
+ { Note: By default XFillRectangle doesn't paint the same size rectangle that
+ XDrawRectangle does - given the same coordinates! In this case we enlarge
+ the Width and Height to paint consistant rectangle sizes, even thought it
+ might repaint the same (only a few) pixels twice. }
+ XFillRectangle(xapplication.display, FDrawHandle, Fgc, x, y, w{+1}, h{+1});
end;
procedure TfpgCanvasImpl.DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord);
@@ -1372,7 +1377,7 @@ end;
procedure TfpgCanvasImpl.DoDrawRectangle(x, y, w, h: TfpgCoord);
begin
- XDrawRectangle(xapplication.display, FDrawHandle, Fgc, x, y, w - 1, h - 1); // transformed into polyline requests!
+ XDrawRectangle(xapplication.display, FDrawHandle, Fgc, x, y, w - 1, h - 1);
end;
procedure TfpgCanvasImpl.DoDrawLine(x1, y1, x2, y2: TfpgCoord);
diff --git a/prototypes/fpgui2/source/gui/gui_button.pas b/prototypes/fpgui2/source/gui/gui_button.pas
index 3867cbb8..296818bc 100644
--- a/prototypes/fpgui2/source/gui/gui_button.pas
+++ b/prototypes/fpgui2/source/gui/gui_button.pas
@@ -201,7 +201,7 @@ begin
if FEmbedded then
Include(lBtnFlags, btnIsEmbedded);
- fpgStyle.DrawButtonFace(Canvas, 0, 0, Width, Height, lBtnFlags);
+ Canvas.DrawButtonFace(0, 0, Width, Height, lBtnFlags);
if FFocused and (not FEmbedded) then
begin
diff --git a/prototypes/fpgui2/source/gui/gui_memo.pas b/prototypes/fpgui2/source/gui/gui_memo.pas
index ef45b4ff..8736ec6d 100644
--- a/prototypes/fpgui2/source/gui/gui_memo.pas
+++ b/prototypes/fpgui2/source/gui/gui_memo.pas
@@ -67,7 +67,7 @@ type
procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override;
procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override;
procedure HandleResize(dwidth, dheight: integer); override;
- //procedure HandleWindowScroll(direction, amount : integer); override;
+ procedure HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override;
procedure HandlePaint; override;
procedure HandleShow; override;
public
@@ -1159,6 +1159,43 @@ begin
UpdateScrollBar;
end;
+procedure TfpgMemo.HandleMouseScroll(x, y: integer; shiftstate: TShiftState;
+ delta: smallint);
+var
+ pfl, pdo : integer;
+begin
+ inherited HandleMouseScroll(x, y, shiftstate, delta);
+
+// inherited HandleWindowScroll(direction, amount);
+
+ pfl := FFirstLine;
+ pdo := FDrawOffset;
+
+ if delta < 0 then
+ dec(FFirstLine, abs(delta)) // scroll up
+ else
+ inc(FFirstLine, abs(delta)); // scroll down
+
+ if FFirstLine > LineCount - VisibleLines + 1 then
+ FFirstLine := LineCount - VisibleLines + 1;
+ if FFirstLine < 1 then
+ FFirstLine := 1;
+
+ if FHScrollBar.Visible then
+ begin
+ if FDrawOffset > FHScrollBar.Max then
+ FDrawOffset := FHScrollBar.Max;
+ if FDrawOffset < 0 then
+ FDrawOffset := 0;
+ end;
+
+ if (pfl <> FFirstLine) or (pdo <> FDrawOffset) then
+ begin
+ UpdateScrollBar;
+ Repaint;
+ end;
+end;
+
function TfpgMemo.SelectionText: string;
begin
{
diff --git a/prototypes/fpgui2/tests/edittest.lpi b/prototypes/fpgui2/tests/edittest.lpi
index 269ce784..3e9244a7 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">
@@ -46,7 +46,6 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
- <PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>