summaryrefslogtreecommitdiff
path: root/src/gui/gui_checkbox.pas
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui_checkbox.pas')
-rw-r--r--src/gui/gui_checkbox.pas44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/gui/gui_checkbox.pas b/src/gui/gui_checkbox.pas
index 85149b71..4bfc18c0 100644
--- a/src/gui/gui_checkbox.pas
+++ b/src/gui/gui_checkbox.pas
@@ -29,7 +29,7 @@ type
protected
procedure HandlePaint; override;
procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override;
- procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override;
+ procedure HandleKeyRelease(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@@ -50,10 +50,10 @@ implementation
function CreateCheckBox(AOwner: TComponent; x, y: TfpgCoord; AText: string): TfpgCheckBox;
begin
Result := TfpgCheckBox.Create(AOwner);
- Result.Top := y;
- Result.Left := x;
- Result.Text := AText;
- Result.Width := Result.Font.TextWidth(Result.Text) + 24;
+ Result.Top := y;
+ Result.Left := x;
+ Result.Text := AText;
+ Result.Width := Result.Font.TextWidth(Result.Text) + 24;
end;
{ TfpgCheckBox }
@@ -99,6 +99,8 @@ var
r: TfpgRect;
ty: integer;
tx: integer;
+ ix: integer;
+ img: TfpgImage;
begin
Canvas.BeginDraw;
inherited HandlePaint;
@@ -119,27 +121,17 @@ begin
if r.top < 0 then
r.top := 0;
- // paint box for check mark
- Canvas.SetColor(clBoxColor);
- Canvas.FillRectangle(r);
- Canvas.DrawControlFrame(r.Left, r.Top, r.width, r.height);
-
- // set colors and paint the check (in this case a X)
- Canvas.SetColor(clText1);
+ // paint the check (in this case a X)
tx := r.right + 8;
- inc(r.left, 3);
- inc(r.top, 3);
- dec(r.width, 6);
- dec(r.height, 6);
- Canvas.SetLineStyle(2, lsSolid);
- if FChecked then
- begin
- {$Note We will replace this with a image soon. }
- Canvas.DrawLine(r.left, r.top, r.right, r.bottom);
- Canvas.DrawLine(r.Right, r.top, r.left, r.bottom);
- end;
+ inc(r.left, 2);
+ inc(r.top, 1);
+ img := fpgImages.GetImage('sys.checkboxes');
+ if FChecked then // which image index?
+ ix := 1
+ else
+ ix := 0;
+ Canvas.DrawImagePart(r.Left, r.Top, img, ix*13, 0, 13, 13);
- Canvas.SetLineStyle(1, lsSolid);
ty := (Height div 2) - (Font.Height div 2);
if ty < 0 then
ty := 0;
@@ -156,7 +148,7 @@ begin
FOnChange(self);
end;
-procedure TfpgCheckBox.HandleKeyPress(var keycode: word;
+procedure TfpgCheckBox.HandleKeyRelease(var keycode: word;
var shiftstate: TShiftState; var consumed: boolean);
begin
if (keycode = keySpace) or (keycode = keyReturn) then
@@ -170,7 +162,7 @@ begin
if consumed then
Exit; //==>
- inherited HandleKeyPress(keycode, shiftstate, consumed);
+ inherited HandleKeyRelease(keycode, shiftstate, consumed);
end;
constructor TfpgCheckBox.Create(AOwner: TComponent);