diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-26 09:54:22 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-26 09:54:22 +0000 |
commit | 544f3d4974a01a1f4cd6621c112dcde84e541bbb (patch) | |
tree | 63c42f92e5fc8ebf705be6574f27e994713f33b3 /src | |
parent | 41c1e1d91857d95f2142c5a994b2ca0cb47f2259 (diff) | |
download | fpGUI-544f3d4974a01a1f4cd6621c112dcde84e541bbb.tar.xz |
* Added new composite images for radio buttons and checkbox buttons.
* Implemented and added a new widget TfpgRadioButton
* TfpgWidget now doesn't process MouseUp and MouseDown events when disabled.
* TfpcCheckBox now uses composite images to paint the check mark as well.
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/gfx_stdimages.pas | 56 | ||||
-rw-r--r-- | src/corelib/gfx_widget.pas | 6 | ||||
-rw-r--r-- | src/corelib/stdimages.inc | 291 | ||||
-rw-r--r-- | src/gui/fpgui_package.lpk | 6 | ||||
-rw-r--r-- | src/gui/fpgui_package.pas | 2 | ||||
-rw-r--r-- | src/gui/gui_checkbox.pas | 44 | ||||
-rw-r--r-- | src/gui/gui_radiobutton.pas | 238 |
7 files changed, 583 insertions, 60 deletions
diff --git a/src/corelib/gfx_stdimages.pas b/src/corelib/gfx_stdimages.pas index 27d0ab6c..7ed9fdb4 100644 --- a/src/corelib/gfx_stdimages.pas +++ b/src/corelib/gfx_stdimages.pas @@ -19,43 +19,26 @@ implementation Const // 60x12 pixel 4bpp bitmap - RadioBitmapData: array[0..359] of Byte = ( - $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, - $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, - $02, $11, $77, $77, $11, $50, $02, $11, $77, $77, $11, $50, $02, $11, $33, $33, $11, $50, $02, $11, $33, $33, $11, $50, $02, $11, $33, $33, $11, $50, - $02, $17, $77, $77, $74, $50, $02, $17, $77, $77, $74, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, - $21, $77, $77, $77, $77, $45, $21, $77, $76, $67, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $36, $63, $33, $45, $21, $33, $32, $23, $33, $45, - $21, $77, $77, $77, $77, $45, $21, $77, $66, $66, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $66, $66, $33, $45, $21, $33, $22, $22, $33, $45, - $21, $77, $77, $77, $77, $45, $21, $77, $66, $66, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $66, $66, $33, $45, $21, $33, $22, $22, $33, $45, - $21, $77, $77, $77, $77, $45, $21, $77, $76, $67, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $36, $63, $33, $45, $21, $33, $32, $23, $33, $45, - $02, $17, $77, $77, $74, $50, $02, $17, $77, $77, $74, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, - $02, $44, $77, $77, $44, $50, $02, $44, $77, $77, $44, $50, $02, $44, $33, $33, $44, $50, $02, $44, $33, $33, $44, $50, $02, $44, $33, $33, $44, $50, - $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, - $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00 - ); + //RadioBitmapData: array[0..359] of Byte = ( + //$00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, $00, $00, $22, $22, $00, $00, + //$00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, $00, $22, $11, $11, $22, $00, + //$02, $11, $77, $77, $11, $50, $02, $11, $77, $77, $11, $50, $02, $11, $33, $33, $11, $50, $02, $11, $33, $33, $11, $50, $02, $11, $33, $33, $11, $50, + //$02, $17, $77, $77, $74, $50, $02, $17, $77, $77, $74, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, + //$21, $77, $77, $77, $77, $45, $21, $77, $76, $67, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $36, $63, $33, $45, $21, $33, $32, $23, $33, $45, + //$21, $77, $77, $77, $77, $45, $21, $77, $66, $66, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $66, $66, $33, $45, $21, $33, $22, $22, $33, $45, + //$21, $77, $77, $77, $77, $45, $21, $77, $66, $66, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $66, $66, $33, $45, $21, $33, $22, $22, $33, $45, + //$21, $77, $77, $77, $77, $45, $21, $77, $76, $67, $77, $45, $21, $33, $33, $33, $33, $45, $21, $33, $36, $63, $33, $45, $21, $33, $32, $23, $33, $45, + //$02, $17, $77, $77, $74, $50, $02, $17, $77, $77, $74, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, $02, $13, $33, $33, $34, $50, + //$02, $44, $77, $77, $44, $50, $02, $44, $77, $77, $44, $50, $02, $44, $33, $33, $44, $50, $02, $44, $33, $33, $44, $50, $02, $44, $33, $33, $44, $50, + //$00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, $00, $55, $44, $44, $55, $00, + //$00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00, $00, $00, $55, $55, $00, $00 + //); // 12x12 pixel monochrome bitmap RadioMaskData: array[0..23] of Byte = ($0f, $00, $3f, $c0, $7f, $e0, $7f, $e0, $ff, $f0, $ff, $f0, $ff, $f0, $ff, $f0, $7f, $e0, $7f, $e0, $3f, $c0, $0f, $00); - // 65x13 pixel 4bpp bitmap - CheckBoxBitmapData: array[0..428] of Byte = ( - $22, $22, $22, $22, $22, $22, $52, $22, $22, $22, $22, $22, $25, $22, $22, $22, $22, $22, $22, $52, $22, $22, $22, $22, $22, $25, $22, $22, $22, $22, $22, $22, $50, - $21, $11, $11, $11, $11, $14, $52, $11, $11, $11, $11, $11, $45, $21, $11, $11, $11, $11, $14, $52, $11, $11, $11, $11, $11, $45, $21, $11, $11, $11, $11, $14, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $77, $77, $77, $77, $45, $21, $33, $33, $33, $33, $34, $52, $13, $33, $33, $33, $33, $45, $21, $33, $33, $33, $33, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $77, $77, $77, $67, $45, $21, $33, $33, $33, $33, $34, $52, $13, $33, $33, $33, $63, $45, $21, $33, $33, $33, $32, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $77, $77, $76, $67, $45, $21, $33, $33, $33, $33, $34, $52, $13, $33, $33, $36, $63, $45, $21, $33, $33, $33, $22, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $67, $77, $66, $67, $45, $21, $33, $33, $33, $33, $34, $52, $13, $63, $33, $66, $63, $45, $21, $32, $33, $32, $22, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $66, $76, $66, $77, $45, $21, $33, $33, $33, $33, $34, $52, $13, $66, $36, $66, $33, $45, $21, $32, $23, $22, $23, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $66, $66, $67, $77, $45, $21, $33, $33, $33, $33, $34, $52, $13, $66, $66, $63, $33, $45, $21, $32, $22, $22, $33, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $76, $66, $77, $77, $45, $21, $33, $33, $33, $33, $34, $52, $13, $36, $66, $33, $33, $45, $21, $33, $22, $23, $33, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $77, $67, $77, $77, $45, $21, $33, $33, $33, $33, $34, $52, $13, $33, $63, $33, $33, $45, $21, $33, $32, $33, $33, $34, $50, - $21, $77, $77, $77, $77, $74, $52, $17, $77, $77, $77, $77, $45, $21, $33, $33, $33, $33, $34, $52, $13, $33, $33, $33, $33, $45, $21, $33, $33, $33, $33, $34, $50, - $24, $44, $44, $44, $44, $44, $52, $44, $44, $44, $44, $44, $45, $24, $44, $44, $44, $44, $44, $52, $44, $44, $44, $44, $44, $45, $24, $44, $44, $44, $44, $44, $50, - $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $55, $50 - ); - // 64x8 pixel 4bpp bitmap ArrowBitmapData: array[0..255] of Byte = ( $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $13, $33, $33, $31, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $23, $33, $33, $23, $33, $33, @@ -96,7 +79,16 @@ begin @stdimg_arrow_right, sizeof(stdimg_arrow_right) ); - // Add RadioButton, CheckBox images as well. + img := fpgImages.AddMaskedBMP( // 60x12 in total. 5 images of 12x12 each. + 'sys.radiobuttons', + @stdimg_radiobuttons, + sizeof(stdimg_radiobuttons), + 0,0); + + img := fpgImages.AddBMP( // 65x13 pixels. 5 images of 13x13 each. + 'sys.checkboxes', + @stdimg_checkboxes, + sizeof(stdimg_checkboxes)); // General purpose images: diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index 221c2686..0323eb40 100644 --- a/src/corelib/gfx_widget.pas +++ b/src/corelib/gfx_widget.pas @@ -274,6 +274,9 @@ procedure TfpgWidget.MsgMouseDown(var msg: TfpgMessageRec); var mb: TMouseButton; begin + if not FEnabled then + exit; // Do we want this here? + case msg.Params.mouse.Buttons of MOUSE_LEFT: begin @@ -299,6 +302,9 @@ procedure TfpgWidget.MsgMouseUp(var msg: TfpgMessageRec); var mb: TMouseButton; begin + if not FEnabled then + exit; // Do we want this here? + case msg.Params.mouse.Buttons of MOUSE_LEFT: begin diff --git a/src/corelib/stdimages.inc b/src/corelib/stdimages.inc index b195625c..a063d5b3 100644 --- a/src/corelib/stdimages.inc +++ b/src/corelib/stdimages.inc @@ -851,6 +851,163 @@ Const 255,255,255,255,255,255); Const + stdimg_checkboxes : Array[0..2601] of byte = ( + 66, 77, 42, 10, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 65, 0, 0, 0, 13, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 244, 9, 0, 0,196, 14, 0, 0,196, 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255, 0,127,127,127,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,191,191,255,255,255, + 127,127,127,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 191,191,255,255,255,127,127,127,191,191,191,191,191,191,191,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 191,191,191,191,191,191,191,255,255,255,127,127,127,191,191,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,255,255,255,127,127, + 127,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, + 255,255,255, 0,127,127,127, 0, 0, 0,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,191,191,191,255,255,255,127,127,127, + 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,191,191,191,255, + 255,255,127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,191,191,191,255,255,255, 0,127,127,127, 0, + 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,191,191,191,255,255, + 255,127,127,127, 0, 0, 0,255,255,255,255,255,255, 0, 0, 0,255, + 255,255,255,255,255,255,255,255, 0, 0, 0,255,255,255,255,255,255, + 191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0, + 127,127,127,127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127, + 127, 0, 0, 0,127,127,127,127,127,127,191,191,191,255,255,255,127, + 127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191,191, + 191,255,255,255, 0,127,127,127, 0, 0, 0,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0,255, + 255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255, 0, 0, 0, + 0, 0, 0, 0, 0, 0,255,255,255,191,191,191,255,255,255,127,127, + 127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,191,191,191, + 255,255,255,127,127,127, 0, 0, 0,127,127,127, 0, 0, 0, 0, 0, + 0, 0, 0, 0,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0,127, + 127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,191,191,191,255,255,255, 0,127,127,127, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,191,191,191,255, + 255,255,127,127,127, 0, 0, 0,255,255,255,255,255,255, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255, + 255,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, + 0,127,127,127,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0,127,127,127,127,127,127,191,191,191,255,255,255, + 127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191, + 191,191,255,255,255, 0,127,127,127, 0, 0, 0,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0, + 255,255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, + 0,255,255,255,255,255,255,255,255,255,191,191,191,255,255,255,127, + 127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191,191, + 191,255,255,255,127,127,127, 0, 0, 0,127,127,127,127,127,127,127, + 127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127, + 127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,191,191,191,255,255,255, 0,127,127, + 127, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,191,191,191, + 255,255,255,127,127,127, 0, 0, 0,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255, + 255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, + 0, 0,127,127,127,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0,127,127,127,127,127,127,191,191,191,255,255, + 255,127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 191,191,191,255,255,255, 0,127,127,127, 0, 0, 0,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, + 0,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255, 0, + 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,191,191,191,255,255,255, + 127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191, + 191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127, 0, 0, 0, + 0, 0, 0, 0, 0, 0,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, + 0,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,191,191,191,255,255,255, 0,127, + 127,127, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,191,191, + 191,255,255,255,127,127,127, 0, 0, 0,255,255,255,255,255,255, 0, + 0, 0,255,255,255,255,255,255,255,255,255, 0, 0, 0,255,255,255, + 255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,191,191,191,255,255,255,127,127,127, + 0, 0, 0,127,127,127,127,127,127, 0, 0, 0,127,127,127,127,127, + 127,127,127,127, 0, 0, 0,127,127,127,127,127,127,191,191,191,255, + 255,255,127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,191,191,191,255,255,255, 0,127,127,127, 0, 0, 0,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,191,191,191,255,255,255,127,127,127, 0, + 0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,191,191,191,255,255, + 255,127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,191,191,191,255,255,255, 0, + 127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,191, + 191,191,255,255,255,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0,191,191,191,255,255,255,127,127,127, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0,191,191,191,255,255,255,127,127, + 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,191,191,191, + 255,255,255,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0,191,191,191,255,255,255, 0,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,255,255,255,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,255, + 255,255,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,255,255,255,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,255,255,255,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,255,255,255, + 0); + +Const stdimg_arrow_left : Array[0..89] of byte = ( 66, 77, 90, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 40, 0, 0, 0, 4, 0, 0, 0, 7, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, @@ -972,6 +1129,140 @@ Const 255,255,255,255,255,255); Const + stdimg_radiobuttons : Array[0..2213] of byte = ( + 66, 77,166, 8, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, + 0, 60, 0, 0, 0, 12, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, + 112, 8, 0, 0,196, 14, 0, 0,196, 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255,255,255,255,255,255,191,191,191,191,191,191,191,191,191, + 191,191,191,255,255,255,255,255,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255,255,255,255,255,255,191,191,191,191,191,191,191, + 191,191,191,191,191,255,255,255,255,255,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255,255,255,255,255,255,191,191,191,191,191, + 191,191,191,191,191,191,191,255,255,255,255,255,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255,255,255,255,255,255,191,191,191, + 191,191,191,191,191,191,191,191,191,255,255,255,255,255,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,255,255,255,255,255,255,191, + 191,191,191,191,191,191,191,191,191,191,191,255,255,255,255,255,255, + 255, 0,255,255, 0,255,255, 0,255,127,127,127,191,191,191,191,191, + 191,255,255,255,255,255,255,255,255,255,255,255,255,191,191,191,191, + 191,191,255,255,255,255, 0,255,255, 0,255,127,127,127,191,191,191, + 191,191,191,255,255,255,255,255,255,255,255,255,255,255,255,191,191, + 191,191,191,191,255,255,255,255, 0,255,255, 0,255,127,127,127,191, + 191,191,191,191,191,127,127,127,127,127,127,127,127,127,127,127,127, + 191,191,191,191,191,191,255,255,255,255, 0,255,255, 0,255,127,127, + 127,191,191,191,191,191,191,127,127,127,127,127,127,127,127,127,127, + 127,127,191,191,191,191,191,191,255,255,255,255, 0,255,255, 0,255, + 127,127,127,191,191,191,191,191,191,127,127,127,127,127,127,127,127, + 127,127,127,127,191,191,191,191,191,191,255,255,255,255, 0,255,255, + 0,255,127,127,127, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,191,191,191,255,255,255,255, 0, + 255,255, 0,255,127,127,127, 0, 0, 0,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,191,191,191,255,255,255, + 255, 0,255,255, 0,255,127,127,127, 0, 0, 0,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,191,191,191,255, + 255,255,255, 0,255,255, 0,255,127,127,127, 0, 0, 0,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191,191, + 191,255,255,255,255, 0,255,255, 0,255,127,127,127, 0, 0, 0,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 191,191,191,255,255,255,255, 0,255,127,127,127, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0, + 255,255,255,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0,255,255, + 255,255,255,255,255,255,255,191,191,191,255,255,255,127,127,127, 0, + 0, 0,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,191,191,191,255,255,255,127,127, + 127, 0, 0, 0,127,127,127,127,127,127,127,127,127, 0, 0, 0, 0, + 0, 0,127,127,127,127,127,127,127,127,127,191,191,191,255,255,255, + 127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,191,191,191,255, + 255,255,127,127,127, 0, 0, 0,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,191,191, + 191,255,255,255,127,127,127, 0, 0, 0,255,255,255,255,255,255, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255, + 191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127,127, + 127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127, + 127,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, + 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,191,191,191,255,255,255,127,127,127, + 0, 0, 0,255,255,255,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0,255,255,255,255,255,255,191,191,191,255,255,255,127, + 127,127, 0, 0, 0,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,191,191,191,255,255, + 255,127,127,127, 0, 0, 0,127,127,127,127,127,127, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127,191,191,191, + 255,255,255,127,127,127, 0, 0, 0,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191, + 191,191,255,255,255,127,127,127, 0, 0, 0,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,191,191,191,255,255,255,127,127,127, 0, 0, 0,255,255,255,255, + 255,255,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255, + 255,255,255,191,191,191,255,255,255,127,127,127, 0, 0, 0,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, 0, 0, + 127,127,127,127,127,127,127,127,127, 0, 0, 0, 0, 0, 0,127,127, + 127,127,127,127,127,127,127,191,191,191,255,255,255,127,127,127, 0, + 0, 0,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,191,191,191,255,255,255,255, 0, + 255,127,127,127, 0, 0, 0,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,191,191,191,255,255,255,255, 0,255, + 255, 0,255,127,127,127, 0, 0, 0,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,191,191,191,255,255,255,255, + 0,255,255, 0,255,127,127,127, 0, 0, 0,127,127,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,191,191,191,255,255, + 255,255, 0,255,255, 0,255,127,127,127, 0, 0, 0,127,127,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,191,191,191, + 255,255,255,255, 0,255,255, 0,255,127,127,127, 0, 0, 0,127,127, + 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,191, + 191,191,255,255,255,255, 0,255,255, 0,255,127,127,127, 0, 0, 0, + 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, 0, 0, + 0, 0, 0, 0,255,255,255,255, 0,255,255, 0,255,127,127,127, 0, + 0, 0, 0, 0, 0,255,255,255,255,255,255,255,255,255,255,255,255, + 0, 0, 0, 0, 0, 0,255,255,255,255, 0,255,255, 0,255,127,127, + 127, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127,127,127,127,127, + 127,127, 0, 0, 0, 0, 0, 0,255,255,255,255, 0,255,255, 0,255, + 127,127,127, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127,127,127, + 127,127,127,127, 0, 0, 0, 0, 0, 0,255,255,255,255, 0,255,255, + 0,255,127,127,127, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127, + 127,127,127,127,127,127, 0, 0, 0, 0, 0, 0,255,255,255,255, 0, + 255,255, 0,255,255, 0,255,127,127,127,127,127,127, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,127,127,127,127,127,127, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,127,127,127,127,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,127,127,127,127,127,127, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,127,127,127, + 127,255, 0,255,255, 0,255,255, 0,255,255, 0,255,127,127,127,127, + 127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,127, + 127,127,127,255, 0,255,255, 0,255,255, 0,255,255, 0,255,127,127, + 127,127,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127, + 127,127,127,127,127,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,127,127,127,127,127,127,127,127,127,127,127, + 127,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,127,127,127,127,127,127,127,127,127, + 127,127,127,255, 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255,255, 0,255,255, 0,255,127,127,127,127,127,127,127, + 127,127,127,127,127,255, 0,255,255, 0,255,255, 0,255,255, 0,255, + 255, 0,255,255, 0,255,255, 0,255,255, 0,255,127,127,127,127,127, + 127,127,127,127,127,127,127,255, 0,255,255, 0,255,255, 0,255,255, + 0,255,255, 0,255,255, 0,255,255, 0,255,255, 0,255,127,127,127, + 127,127,127,127,127,127,127,127,127,255, 0,255,255, 0,255,255, 0, + 255,255, 0,255); + +Const stdimg_edit : Array[0..821] of byte = ( 66, 77, 54, 3, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, diff --git a/src/gui/fpgui_package.lpk b/src/gui/fpgui_package.lpk index cbd1dbe6..acc1e43b 100644 --- a/src/gui/fpgui_package.lpk +++ b/src/gui/fpgui_package.lpk @@ -18,7 +18,7 @@ <Description Value="fpGUI - multi-handle redesign"/> <License Value="Modified LGPL"/> <Version Minor="5"/> - <Files Count="12"> + <Files Count="13"> <Item1> <Filename Value="gui_button.pas"/> <UnitName Value="gui_button"/> @@ -67,6 +67,10 @@ <Filename Value="gui_checkbox.pas"/> <UnitName Value="gui_checkbox"/> </Item12> + <Item13> + <Filename Value="gui_radiobutton.pas"/> + <UnitName Value="gui_radiobutton"/> + </Item13> </Files> <RequiredPkgs Count="2"> <Item1> diff --git a/src/gui/fpgui_package.pas b/src/gui/fpgui_package.pas index 0c9d2c4d..5903ea3e 100644 --- a/src/gui/fpgui_package.pas +++ b/src/gui/fpgui_package.pas @@ -9,7 +9,7 @@ interface uses gui_button, gui_combobox, gui_dialogs, gui_edit, gui_form, gui_label, gui_listbox, gui_memo, gui_popupwindow, gui_scrollbar, gui_bevel, - gui_checkbox; + gui_checkbox, gui_radiobutton; implementation 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); diff --git a/src/gui/gui_radiobutton.pas b/src/gui/gui_radiobutton.pas new file mode 100644 index 00000000..db3a8e16 --- /dev/null +++ b/src/gui/gui_radiobutton.pas @@ -0,0 +1,238 @@ +unit gui_radiobutton; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, + SysUtils, + fpgfx, + gfxbase, + gfx_widget; + +type + + TfpgRadioButton = class(TfpgWidget) + private + FBackgroundColor: TfpgColor; + FChecked: boolean; + FFont: TfpgFont; + FGroupIndex: integer; + FOnChange: TNotifyEvent; + FText: string; + FBoxSize: integer; + FIsPressed: boolean; + function GetFontName: string; + procedure SetBackgroundColor(const AValue: TfpgColor); + procedure SetChecked(const AValue: boolean); + procedure SetFontName(const AValue: string); + procedure SetText(const AValue: string); + protected + procedure HandlePaint; override; + procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; + procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; + procedure HandleKeyRelease(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + property Font: TfpgFont read FFont; + published + property Checked: boolean read FChecked write SetChecked; + property Text: string read FText write SetText; + property FontName: string read GetFontName write SetFontName; + property BackgroundColor: TfpgColor read FBackgroundColor write SetBackgroundColor; + property GroupIndex: integer read FGroupIndex write FGroupIndex; + property OnChange: TNotifyEvent read FOnChange write FOnChange; + end; + + +function CreateRadioButton(AOwner: TComponent; x, y: TfpgCoord; AText: string): TfpgRadioButton; + +implementation + +function CreateRadioButton(AOwner: TComponent; x, y: TfpgCoord; AText: string): TfpgRadioButton; +begin + Result := TfpgRadioButton.Create(AOwner); + Result.Top := y; + Result.Left := x; + Result.Text := AText; + Result.Width := Result.Font.TextWidth(Result.Text) + 24; +end; + +{ TfpgRadioButton } + +function TfpgRadioButton.GetFontName: string; +begin + Result := FFont.FontDesc; +end; + +procedure TfpgRadioButton.SetBackgroundColor(const AValue: TfpgColor); +begin + if FBackgroundColor = AValue then + Exit; //==> + FBackgroundColor := AValue; + RePaint; +end; + +procedure TfpgRadioButton.SetChecked(const AValue: boolean); +var + i: integer; + wg: TfpgWidget; +begin + if FChecked = AValue then + Exit; //==> + FChecked := AValue; + + // Clear other radio buttons in the same group + if FChecked and (Parent <> nil) then + begin + for i := 0 to Parent.ComponentCount-1 do + begin + wg := TfpgWidget(Parent.Components[i]); + if (wg <> nil) and (wg <> self) and (wg is TfpgRadioButton) and + (TfpgRadioButton(wg).GroupIndex = GroupIndex) then + begin + TfpgRadioButton(wg).Checked := False; + end; + end; { for } + end; { if } + + RePaint; +end; + +procedure TfpgRadioButton.SetFontName(const AValue: string); +begin + FFont.Free; + FFont := fpgGetFont(AValue); + RePaint; +end; + +procedure TfpgRadioButton.SetText(const AValue: string); +begin + if FText = AValue then + Exit; //==> + FText := AValue; + RePaint; +end; + +procedure TfpgRadioButton.HandlePaint; +var + r: TfpgRect; + ty: integer; + tx: integer; + img: TfpgImage; + ix: integer; +begin + Canvas.BeginDraw; + inherited HandlePaint; + + Canvas.SetColor(FBackgroundColor); + Canvas.FillRectangle(0, 0, Width, Height); + Canvas.SetFont(Font); + + if FFocused then + begin + Canvas.SetColor(clText1); + Canvas.SetLineStyle(1, lsDot); + Canvas.DrawRectangle(1, 1, Width-1, Height-1); + end; + Canvas.SetLineStyle(1, lsSolid); + + r.SetRect(2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize); + if r.top < 0 then + r.top := 0; + + // calculate which image to paint. + if Enabled then + begin + ix := Ord(FChecked); + if FIsPressed then + Inc(ix, 2); + end + else + ix := (2 + (Ord(FChecked) * 2)) - Ord(FChecked); + + // paint the radio button + tx := r.right + 8; + inc(r.left, 2); + inc(r.top, 1); + img := fpgImages.GetImage('sys.radiobuttons'); + Canvas.DrawImagePart(r.Left, r.Top, img, ix*12, 0, 12, 12); + + ty := (Height div 2) - (Font.Height div 2); + if ty < 0 then + ty := 0; + if Enabled then + Canvas.SetTextColor(clText1) + else + Canvas.SetTextColor(clShadow1); + Canvas.DrawString(tx, ty, FText); + + Canvas.EndDraw; +end; + +procedure TfpgRadioButton.HandleLMouseDown(x, y: integer; + shiftstate: TShiftState); +begin + inherited HandleLMouseDown(x, y, shiftstate); + FIsPressed := True; + Repaint; +end; + +procedure TfpgRadioButton.HandleLMouseUp(x, y: integer; shiftstate: TShiftState); +begin + inherited HandleLMouseUp(x, y, shiftstate); + FIsPressed := False; + if not Checked then + begin + Checked := not FChecked; + if Assigned(FOnChange) then + FOnChange(self); + end + else + RePaint; +end; + +procedure TfpgRadioButton.HandleKeyRelease(var keycode: word; + var shiftstate: TShiftState; var consumed: boolean); +begin + if (keycode = keySpace) then + begin + consumed := True; + Checked := not FChecked; + if Assigned(FOnChange) then + FOnChange(self); + end; + + if consumed then + Exit; //==> + + inherited HandleKeyRelease(keycode, shiftstate, consumed); +end; + +constructor TfpgRadioButton.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FText := 'RadioButton'; + FFont := fpgGetFont('#Label1'); + FHeight := FFont.Height + 4; + FWidth := 120; + + FBackgroundColor := clWindowBackground; + FFocusable := True; + FBoxSize := 12; + FChecked := False; + FGroupIndex := 0; + FIsPressed := False; + FOnChange := nil; +end; + +destructor TfpgRadioButton.Destroy; +begin + FFont.Free; + inherited Destroy; +end; + +end. + |