home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sibdemo3.zip / SOURCE.DAT / SOURCE / SPCC / EXTCTRLS.PAS < prev    next >
Pascal/Delphi Source File  |  1998-05-20  |  46KB  |  1,582 lines

  1.  
  2. {╔══════════════════════════════════════════════════════════════════════════╗
  3.  ║                                                                          ║
  4.  ║     Sibyl Portable Component Classes                                     ║
  5.  ║                                                                          ║
  6.  ║     Copyright (C) 1995,97 SpeedSoft Germany,   All rights reserved.      ║
  7.  ║                                                                          ║
  8.  ╚══════════════════════════════════════════════════════════════════════════╝}
  9.  
  10. Unit EXTCTRLS;
  11.  
  12.  
  13. Interface
  14.  
  15. Uses SysUtils,Classes,Forms,Graphics,Buttons,StdCtrls;
  16.  
  17.  
  18. Type
  19.     TShapeType=(stRectangle,stSquare,stRoundRect,stRoundSquare,
  20.                 stEllipse,stCircle,stTriangle);
  21.  
  22.     TShape=Class(TControl)
  23.       Private
  24.          FTempPen:TPen;
  25.          FTempBrush:TBrush;
  26.          FShape:TShapeType;
  27.          Function GetBrush:TBrush;
  28.          Function GetPen:TPen;
  29.          Procedure SetShape(NewShape:TShapeType);
  30.       Protected
  31.          Procedure SetupComponent;Override;
  32.          Procedure SetupShow;Override;
  33.          Property Canvas;
  34.       Public
  35.          Destructor Destroy;Override;
  36.          Procedure Redraw(Const rec:TRect);Override;
  37.          Property XAlign;
  38.          Property XStretch;
  39.          Property YAlign;
  40.          Property YStretch;
  41.       Published
  42.          Property Align;
  43.          Property Brush:TBrush Read GetBrush;
  44.          Property DragCursor;
  45.          Property DragMode;
  46.          Property Enabled;
  47.          Property ParentShowHint;
  48.          Property Pen:TPen Read GetPen;
  49.          Property Shape:TShapeType Read FShape Write SetShape;
  50.          Property ShowHint;
  51.          Property Visible;
  52.          Property ZOrder;
  53.  
  54.          Property OnCanDrag;
  55.          Property OnDragDrop;
  56.          Property OnDragOver;
  57.          Property OnEndDrag;
  58.          Property OnMouseClick;
  59.          Property OnMouseDblClick;
  60.          Property OnMouseDown;
  61.          Property OnMouseMove;
  62.          Property OnMouseUp;
  63.          Property OnSetupShow;
  64.          Property OnStartDrag;
  65.     End;
  66.  
  67.  
  68.     TPaintBox=Class(TControl)
  69.       Protected
  70.          Procedure SetupComponent;Override;
  71.       Public
  72.          Procedure Redraw(Const rec:TRect);Override;
  73.          Property XAlign;
  74.          Property XStretch;
  75.          Property YAlign;
  76.          Property YStretch;
  77.       Published
  78.          Property Align;
  79.          Property Color;
  80.          Property DragCursor;
  81.          Property DragMode;
  82.          Property Enabled;
  83.          Property Font;
  84.          Property ParentColor;
  85.          Property ParentPenColor;
  86.          Property ParentFont;
  87.          Property ParentShowHint;
  88.          Property PenColor;
  89.          Property ShowHint;
  90.          Property Visible;
  91.          Property ZOrder;
  92.  
  93.          Property OnCanDrag;
  94.          Property OnClick;
  95.          Property OnDblClick;
  96.          Property OnDragDrop;
  97.          Property OnDragOver;
  98.          Property OnEndDrag;
  99.          Property OnFontChange;
  100.          Property OnMouseClick;
  101.          Property OnMouseDblClick;
  102.          Property OnMouseDown;
  103.          Property OnMouseMove;
  104.          Property OnMouseUp;
  105.          Property OnPaint;
  106.          Property OnSetupShow;
  107.          Property OnStartDrag;
  108.     End;
  109.  
  110.  
  111.     TImage=Class(TControl)
  112.       Private
  113.          FPicture:TPicture;
  114.          FNeedBitmap:Boolean;
  115.          FAutoSize:Boolean;
  116.          FStretch:Boolean;
  117.          FCenter:Boolean;
  118.          FOnChange:TNotifyEvent;
  119.          Procedure SetStretch(NewValue:Boolean);
  120.          Procedure SetCenter(NewValue:Boolean);
  121.          Procedure SetBitmap(NewBitmap:TBitmap);
  122.          Function GetBitmap:TBitmap;
  123.          Function GetIcon:TIcon;
  124.          Procedure SetIcon(NewIcon:TIcon);
  125.          Function GetGraphic:TGraphic;
  126.          Procedure SetGraphic(NewGraphic:TGraphic);
  127.          Procedure PictureChanged(Sender:TObject);
  128.       Protected
  129.          Procedure Change;Virtual;
  130.          Procedure SetupComponent;Override;
  131.          Procedure SetupShow;Override;
  132.          Procedure MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
  133.          Property NeedBitmap:Boolean Read FNeedBitmap Write FNeedBitmap;
  134.       Public
  135.          Destructor Destroy;Override;
  136.          Procedure Redraw(Const rec:TRect);Override;
  137.          Procedure ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);Override;
  138.          Function WriteSCUResource(Stream:TResourceStream):Boolean;Override;
  139.       Public
  140.          Property XAlign;
  141.          Property XStretch;
  142.          Property YAlign;
  143.          Property YStretch;
  144.          Property Picture:TPicture Read {Get}FPicture;
  145.          Property Graphic:TGraphic read GetGraphic write SetGraphic;
  146.          Property Icon:TIcon Read GetIcon Write SetIcon;
  147.       Published
  148.          Property Align;
  149.          Property AutoSize:Boolean Read FAutoSize Write FAutoSize;
  150.          Property Center:Boolean Read FCenter Write SetCenter;
  151.          Property DragCursor;
  152.          Property DragMode;
  153.          Property Enabled;
  154.          Property ParentShowHint;
  155.          Property Bitmap:TBitmap Read GetBitmap Write SetBitmap;
  156.          Property PopupMenu;
  157.          Property ShowHint;
  158.          Property Stretch:Boolean Read FStretch Write SetStretch;
  159.          Property Visible;
  160.          Property ZOrder;
  161.  
  162.          Property OnCanDrag;
  163.          Property OnChange:TNotifyEvent read FOnChange write FOnChange;
  164.          Property OnClick;
  165.          Property OnDblClick;
  166.          Property OnDragDrop;
  167.          Property OnDragOver;
  168.          Property OnEndDrag;
  169.          Property OnMouseClick;
  170.          Property OnMouseDblClick;
  171.          Property OnMouseDown;
  172.          Property OnMouseMove;
  173.          Property OnMouseUp;
  174.          Property OnSetupShow;
  175.          Property OnStartDrag;
  176.     End;
  177.  
  178.  
  179.     {$M+}
  180.     TBevelShape=(bsBottomLine,bsBox,bsFrame,bsLeftLine,bsRightLine,bsTopLine,
  181.       bsBorder);
  182.  
  183.     TBevelStyle=(bsLowered,bsRaised);
  184.     {$M-}
  185.  
  186.     TBevel=Class(TControl)
  187.       Private
  188.          FShape:TBevelShape;
  189.          FStyle:TBevelStyle;
  190.          Procedure SetShape(NewShape:TBevelShape);
  191.          Procedure SetStyle(NewStyle:TBevelStyle);
  192.       Protected
  193.          Procedure SetupComponent;Override;
  194.          Procedure MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
  195.       Public
  196.          Procedure Redraw(Const rec:TRect);Override;
  197.          Property XAlign;
  198.          Property XStretch;
  199.          Property YAlign;
  200.          Property YStretch;
  201.       Published
  202.          Property Align;
  203.          Property ParentShowHint;
  204.          Property PopupMenu;
  205.          Property Shape:TBevelShape Read FShape Write SetShape;
  206.          Property ShowHint;
  207.          Property Style:TBevelStyle Read FStyle Write SetStyle;
  208.          Property Visible;
  209.          Property ZOrder;
  210.  
  211.          Property OnCommand;
  212.          Property OnResize;
  213.          Property OnSetupShow;
  214.     End;
  215.  
  216.  
  217.     {$M+}
  218.     TPanelBevel=(bvRaised,bvLowered,bvNone);
  219.     {$M-}
  220.  
  221.     TPanel=Class(TControl)
  222.       Private
  223.          FBevelInner:TPanelBevel;
  224.          FBevelOuter:TPanelBevel;
  225.          FBevelWidth:LongInt;
  226.          FBorderStyle:TBorderStyle;
  227.          FBorderWidth:LongInt;
  228.          FAlignment:TAlignment;
  229.          FInterior:TRect;
  230.          Procedure CMTextChanged(Var Msg:TMessage); Message CM_TEXTCHANGED;
  231.          Procedure SetBevelInner(NewBevel:TPanelBevel);
  232.          Procedure SetBevelOuter(NewBevel:TPanelBevel);
  233.          Procedure SetBevelWidth(NewWidth:LongInt);
  234.          Procedure SetBorderStyle(NewStyle:TBorderStyle);
  235.          Procedure SetBorderWidth(NewWidth:LongInt);
  236.          Procedure SetAlignment(ta:TAlignment);
  237.       Protected
  238.          Procedure SetupComponent;Override;
  239.          Procedure MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
  240.          Procedure DrawText(Const rec:TRect);Virtual;
  241.       Public
  242.          Procedure Redraw(Const rec:TRect);Override;
  243.          Property XAlign;
  244.          Property XStretch;
  245.          Property YAlign;
  246.          Property YStretch;
  247.       Published
  248.          Property Align;
  249.          Property Alignment:TAlignment Read FAlignment Write SetAlignment;
  250.          Property BevelInner:TPanelBevel Read FBevelInner Write SetBevelInner;
  251.          Property BevelOuter:TPanelBevel Read FBevelOuter Write SetBevelOuter;
  252.          Property BevelWidth:LongInt Read FBevelWidth Write SetBevelWidth;
  253.          Property BorderStyle:TBorderStyle Read FBorderStyle Write SetBorderStyle;
  254.          Property BorderWidth:LongInt Read FBorderWidth Write SetBorderWidth;
  255.          Property Caption;
  256.          Property Color;
  257.          Property DragCursor;
  258.          Property DragMode;
  259.          Property Enabled;
  260.          Property Font;
  261.          Property ParentColor;
  262.          Property ParentPenColor;
  263.          Property ParentFont;
  264.          Property ParentShowHint;
  265.          Property PenColor;
  266.          Property PopupMenu;
  267.          Property ShowHint;
  268.          Property TabOrder;
  269.          Property TabStop;
  270.          Property Visible;
  271.          Property ZOrder;
  272.  
  273.          Property OnCanDrag;
  274.          Property OnClick;
  275.          Property OnCommand;
  276.          Property OnDblClick;
  277.          Property OnDragDrop;
  278.          Property OnDragOver;
  279.          Property OnEndDrag;
  280.          Property OnFontChange;
  281.          Property OnMouseClick;
  282.          Property OnMouseDblClick;
  283.          Property OnMouseDown;
  284.          Property OnMouseMove;
  285.          Property OnMouseUp;
  286.          Property OnPaint;
  287.          Property OnResize;
  288.          Property OnSetupShow;
  289.          Property OnStartDrag;
  290.     End;
  291.  
  292.  
  293.     TRadioGroup=Class(TGroupBox)
  294.       Private
  295.          FItems:TStrings;
  296.          FRadios:TList;
  297.          FItemIndex:LongInt;
  298.          FColumns:LongInt;
  299.          FOnClick:TNotifyEvent;
  300.          Procedure SetItemIndex(Value:LongInt);
  301.          Procedure SetColumns(Value:LongInt);
  302.          Procedure SetItems(Value:TStrings);
  303.          Procedure SetRadioCount(Value:LongInt);
  304.          Function GetItemsEnabled(Index:LongInt):Boolean;
  305.          Procedure SetItemsEnabled(Index:LongInt;Value:Boolean);
  306.          Procedure UpdateRadios;
  307.          Procedure ArrangeRadios;
  308.          Procedure EvItemsChange(Sender:TObject);
  309.          Procedure EvRadioClick(Sender:TObject);
  310.       Protected
  311.          Procedure SetupComponent;Override;
  312.          Procedure SetupShow;Override;
  313.          Procedure Resize;Override;
  314.          Procedure FontChange;Override;
  315.          Procedure Click;Virtual;
  316.          Procedure ItemIndexChange;Virtual;
  317.       Public
  318.          Destructor Destroy;Override;
  319.          Procedure ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);Override;
  320.          Function WriteSCUResource(Stream:TResourceStream):Boolean;Override;
  321.          Property ItemsEnabled[Index:LongInt]:Boolean Read GetItemsEnabled Write SetItemsEnabled;
  322.          Property XAlign;
  323.          Property XStretch;
  324.          Property YAlign;
  325.          Property YStretch;
  326.       Published
  327.          Property Align;
  328.          Property Caption;
  329.          Property Color;
  330.          Property Columns:LongInt Read FColumns Write SetColumns;
  331.          Property DragCursor;
  332.          Property DragMode;
  333.          Property Enabled;
  334.          Property Font;
  335.          Property ItemIndex:LongInt Read FItemIndex Write SetItemIndex;
  336.          Property Items:TStrings Read FItems Write SetItems;
  337.          Property ParentColor;
  338.          Property ParentPenColor;
  339.          Property ParentFont;
  340.          Property ParentShowHint;
  341.          Property PenColor;
  342.          Property ShowHint;
  343.          Property TabOrder;
  344.          Property TabStop;
  345.          Property Visible;
  346.          Property ZOrder;
  347.  
  348.          Property OnCanDrag;
  349.          Property OnClick:TNotifyEvent Read FOnClick Write FOnClick;
  350.          Property OnDragDrop;
  351.          Property OnDragOver;
  352.          Property OnEndDrag;
  353.          Property OnEnter;
  354.          Property OnExit;
  355.          Property OnFontChange;
  356.          Property OnSetupShow;
  357.          Property OnStartDrag;
  358.     End;
  359.  
  360.  
  361.  
  362. Function InsertShape(parent:TControl;Left,Bottom,Width,Height:LongInt):TShape;
  363. Function InsertImage(parent:TControl;Left,Bottom,Width,Height:LongInt;BitmapId:LongWord):TImage;
  364. Function InsertImageName(parent:TControl;Left,Bottom,Width,Height:LongInt;Const BitmapId:String):TImage;
  365. Function InsertBevel(parent:TControl;Left,Bottom,Width,Height:LongInt;
  366.            Shape:TBevelShape;Style:TBevelStyle):TBevel;
  367. Function InsertPanel(parent:TControl;Left,Bottom,Width,Height:LongInt;
  368.            BevelInner:TPanelBevel;BevelOuter:TPanelBevel;BevelWidth:LongInt;
  369.            Caption:String):TPanel;
  370. Function InsertRadioGroup(parent:TControl;Left,Bottom,Width,Height:LongInt;
  371.            Caption:String):TRadioGroup;
  372.  
  373.  
  374. Implementation
  375.  
  376.  
  377. Function InsertShape(parent:TControl;Left,Bottom,Width,Height:LongInt):TShape;
  378. Begin
  379.      Result.Create(parent);
  380.      Result.SetWindowPos(Left,Bottom,Width,Height);
  381.      Result.parent := parent;
  382. End;
  383.  
  384.  
  385. Function InsertImage(Parent:TControl;Left,Bottom,Width,Height:LongInt;
  386.   BitmapId:LongWord):TImage;
  387. Var  Bitmap:TBitmap;
  388. Begin
  389.      Result.Create(parent);
  390.      Result.SetWindowPos(Left,Bottom,Width,Height);
  391.      Bitmap.Create;
  392.      Bitmap.LoadFromResourceId(BitmapId);
  393.      Result.Picture.Graphic:=Bitmap;
  394.      Bitmap.Destroy; {#}
  395.      Result.Parent := Parent;
  396. End;
  397.  
  398. Function InsertImageName(Parent:TControl;Left,Bottom,Width,Height:LongInt;
  399.   Const BitmapId:String):TImage;
  400. Var  Bitmap:TBitmap;
  401. Begin
  402.      Result.Create(parent);
  403.      Result.SetWindowPos(Left,Bottom,Width,Height);
  404.      Bitmap.Create;
  405.      Bitmap.LoadFromResourceName(BitmapId);
  406.      Result.Picture.Graphic:=Bitmap;
  407.      Bitmap.Destroy; {#}
  408.      Result.Parent := Parent;
  409. End;
  410.  
  411.  
  412. Function InsertBevel(parent:TControl;Left,Bottom,Width,Height:LongInt;
  413.   Shape:TBevelShape;Style:TBevelStyle):TBevel;
  414. Begin
  415.      Result.Create(parent);
  416.      Result.Shape := Shape;
  417.      Result.Style := Style;
  418.      Result.SetWindowPos(Left,Bottom,Width,Height);
  419.      Result.parent := parent;
  420. End;
  421.  
  422.  
  423. Function InsertPanel(parent:TControl;Left,Bottom,Width,Height:LongInt;
  424.   BevelInner:TPanelBevel;BevelOuter:TPanelBevel;BevelWidth:LongInt;
  425.   Caption:String):TPanel;
  426. Begin
  427.      Result.Create(parent);
  428.      Result.BevelInner:=BevelInner;
  429.      Result.BevelOuter:=BevelOuter;
  430.      Result.BevelWidth:=BevelWidth;
  431.      Result.SetWindowPos(Left,Bottom,Width,Height);
  432.      Result.Caption := Caption;
  433.      Result.parent := parent;
  434. End;
  435.  
  436.  
  437. Function InsertRadioGroup(parent:TControl;Left,Bottom,Width,Height:LongInt;
  438.   Caption:String):TRadioGroup;
  439. Begin
  440.      Result.Create(parent);
  441.      Result.SetWindowPos(Left,Bottom,Width,Height);
  442.      Result.Caption := Caption;
  443.      Result.parent := parent;
  444. End;
  445.  
  446.  
  447.  
  448. {
  449. ╔═══════════════════════════════════════════════════════════════════════════╗
  450. ║                                                                           ║
  451. ║ Speed-Pascal/2 Version 2.0                                                ║
  452. ║                                                                           ║
  453. ║ Speed-Pascal Component Classes (SPCC)                                     ║
  454. ║                                                                           ║
  455. ║ This section: TShape Class Implementation                                 ║
  456. ║                                                                           ║
  457. ║ (C) 1995,97 SpeedSoft. All rights reserved. Disclosure probibited !       ║
  458. ║                                                                           ║
  459. ╚═══════════════════════════════════════════════════════════════════════════╝
  460. }
  461.  
  462. Procedure TShape.SetupComponent;
  463. Begin
  464.      Inherited SetupComponent;
  465.  
  466.      Name:='Shape';
  467.      Height:=100;
  468.      Width:=100;
  469.      ParentPenColor:=False;
  470.      ParentColor:=True;
  471.      TabStop:=False;
  472.      ZOrder:=zoBottom;
  473.      FShape:=stRectangle;
  474.      FTempBrush.Create(Nil);
  475.      //FTempBrush.Color := clWhite;
  476.      FTempPen.Create(Nil);
  477. End;
  478.  
  479. Procedure TShape.SetupShow;
  480. Begin
  481.      Inherited SetupShow;
  482.  
  483.      Canvas.Brush:=FTempBrush;
  484.      Canvas.Pen:=FTempPen;
  485. End;
  486.  
  487. Destructor TShape.Destroy;
  488. Begin
  489.      Inherited Destroy;
  490.  
  491.      FTempBrush.Destroy;
  492.      FTempPen.Destroy;
  493. End;
  494.  
  495. Function TShape.GetBrush:TBrush;
  496. Begin
  497.      If Canvas <> Nil Then Result := Canvas.Brush
  498.      Else Result := FTempBrush;
  499. End;
  500.  
  501. Function TShape.GetPen:TPen;
  502. Begin
  503.      If Canvas <> Nil Then Result := Canvas.Pen
  504.      Else Result := FTempPen;
  505. End;
  506.  
  507. Procedure TShape.SetShape(NewShape:TShapeType);
  508. Begin
  509.      FShape:=NewShape;
  510.      Invalidate;
  511. End;
  512.  
  513. Procedure TShape.Redraw(Const rec:TRect);
  514. Var SaveColor:TColor;
  515.     OldPenColor,OldBrushColor:TColor;
  516.     SaveStyle:TBrushStyle;
  517.     Radius,middleX,MiddleY,W,H:LongInt;
  518.     rc:TRect;
  519.  
  520.     Procedure DrawTriangle;
  521.     Begin
  522.          Canvas.PenPos:=Point(0,0);
  523.          Canvas.LineTo(Width,0);
  524.          Canvas.LineTo(Width Div 2,Height);
  525.          Canvas.LineTo(0,0);
  526.     End;
  527. Begin
  528.      If Canvas = Nil Then exit;
  529.      OldPenColor := Canvas.Pen.Color;
  530.      OldBrushColor := Canvas.Brush.Color;
  531.  
  532.      SaveColor:=Canvas.Pen.color;
  533.  
  534.      If Canvas.Brush.Style=bsSolid Then Canvas.Pen.color:=Canvas.Brush.color;
  535.  
  536.      middleX := ClientWidth Div 2;
  537.      MiddleY := ClientHeight Div 2;
  538.  
  539.      Case FShape Of
  540.        stTriangle:
  541.        Begin
  542.             Canvas.BeginPath;
  543.             DrawTriangle;
  544.             Canvas.EndPath;
  545.             Canvas.FillPath;
  546.             Canvas.Pen.color:=SaveColor;
  547.  
  548.             Canvas.BeginPath;
  549.             DrawTriangle;
  550.             Canvas.EndPath;
  551.             Canvas.OutlinePath;
  552.  
  553.             Canvas.BeginPath;
  554.             DrawTriangle;
  555.             Canvas.EndPath;
  556.             Canvas.PathToClipRegion(paDiff);
  557.        End;
  558.        stRectangle,stSquare:
  559.        Begin
  560.             If FShape=stSquare Then
  561.             Begin
  562.                  If Width>Height Then
  563.                  Begin
  564.                       rc.Bottom:=0;
  565.                       rc.Top:=Height-1;
  566.                       rc.Left:=(Width-Height) Div 2;
  567.                       rc.Right:=rc.Left+Height;
  568.                  End
  569.                  Else
  570.                  Begin
  571.                       rc.Left:=0;
  572.                       rc.Right:=Width-1;
  573.                       rc.Bottom:=(Height-Width) Div 2;
  574.                       rc.Top:=rc.Bottom+Width;
  575.                  End;
  576.             End
  577.             Else rc:=ClientRect;
  578.  
  579.             Canvas.BeginPath;
  580.             Canvas.Rectangle(rc);
  581.             Canvas.EndPath;
  582.             Canvas.FillPath;
  583.             Canvas.Pen.color:=SaveColor;
  584.  
  585.             Canvas.BeginPath;
  586.             Canvas.Rectangle(rc);
  587.             Canvas.EndPath;
  588.             Canvas.OutlinePath;
  589.  
  590.             Canvas.BeginPath;
  591.             Canvas.Rectangle(rc);
  592.             Canvas.EndPath;
  593.             Canvas.PathToClipRegion(paDiff);
  594.        End;
  595.        stRoundRect,stRoundSquare:
  596.        Begin
  597.             If FShape=stRoundSquare Then
  598.             Begin
  599.                  If Width>Height Then
  600.                  Begin
  601.                       rc.Bottom:=0;
  602.                       rc.Top:=Height-1;
  603.                       rc.Left:=(Width-Height) Div 2;
  604.                       rc.Right:=rc.Left+Height;
  605.                  End
  606.                  Else
  607.                  Begin
  608.                       rc.Left:=0;
  609.                       rc.Right:=Width-1;
  610.                       rc.Bottom:=(Height-Width) Div 2;
  611.                       rc.Top:=rc.Bottom+Width;
  612.                  End;
  613.             End
  614.             Else rc:=ClientRect;
  615.  
  616.             W:=(rc.Right-rc.Left) Div 10;
  617.             H:=(rc.Top-rc.Bottom) Div 10;
  618.  
  619.             Canvas.BeginPath;
  620.             Canvas.RoundRect(rc,W,H);
  621.             Canvas.EndPath;
  622.             Canvas.FillPath;
  623.             Canvas.Pen.color:=SaveColor;
  624.  
  625.             Canvas.BeginPath;
  626.             Canvas.RoundRect(rc,W,H);
  627.             Canvas.EndPath;
  628.             Canvas.OutlinePath;
  629.  
  630.             Canvas.BeginPath;
  631.             Canvas.RoundRect(rc,W,H);
  632.             Canvas.EndPath;
  633.             Canvas.PathToClipRegion(paDiff);
  634.        End;
  635.        stEllipse:
  636.        Begin
  637.            Canvas.BeginPath;
  638.            Canvas.Ellipse(middleX,MiddleY,middleX-1,MiddleY-1);
  639.            Canvas.EndPath;
  640.            Canvas.FillPath;
  641.            Canvas.Pen.color:=SaveColor;
  642.  
  643.            Canvas.BeginPath;
  644.            Canvas.Ellipse(middleX,MiddleY,middleX-1,MiddleY-1);
  645.            Canvas.EndPath;
  646.            Canvas.OutlinePath;
  647.  
  648.            Canvas.BeginPath;
  649.            Canvas.Ellipse(middleX,MiddleY,middleX-1,MiddleY-1);
  650.            Canvas.EndPath;
  651.            Canvas.PathToClipRegion(paDiff);
  652.        End;
  653.        stCircle:
  654.        Begin
  655.            If ClientWidth>ClientHeight Then Radius:=MiddleY
  656.            Else Radius:=middleX;
  657.  
  658.            Canvas.BeginPath;
  659.            Canvas.Circle(middleX,MiddleY,Radius-1);
  660.            Canvas.EndPath;
  661.            Canvas.FillPath;
  662.            Canvas.Pen.color:=SaveColor;
  663.  
  664.            Canvas.BeginPath;
  665.            Canvas.Circle(middleX,MiddleY,Radius-1);
  666.            Canvas.EndPath;
  667.            Canvas.OutlinePath;
  668.  
  669.            Canvas.BeginPath;
  670.            Canvas.Circle(middleX,MiddleY,Radius-1);
  671.            Canvas.EndPath;
  672.            Canvas.PathToClipRegion(paDiff);
  673.        End;
  674.      End; //Case
  675.  
  676.      Canvas.Pen.Color := OldPenColor;
  677.      Canvas.Brush.Color := OldBrushColor;
  678.  
  679.      SaveColor:=Canvas.Pen.color;
  680.      SaveStyle:=Canvas.Brush.Style;
  681.  
  682.      Canvas.Pen.color:=color;
  683.      Canvas.Brush.Style:=bsSolid;
  684.      Canvas.Box(rec);
  685.  
  686.      Canvas.Pen.color:=SaveColor;
  687.      Canvas.Brush.Style:=SaveStyle;
  688. End;
  689.  
  690.  
  691. {
  692. ╔═══════════════════════════════════════════════════════════════════════════╗
  693. ║                                                                           ║
  694. ║ Speed-Pascal/2 Version 2.0                                                ║
  695. ║                                                                           ║
  696. ║ Speed-Pascal Component Classes (SPCC)                                     ║
  697. ║                                                                           ║
  698. ║ This section: TImage Class Implementation                                 ║
  699. ║                                                                           ║
  700. ║ (C) 1995,97 SpeedSoft. All rights reserved. Disclosure probibited !       ║
  701. ║                                                                           ║
  702. ╚═══════════════════════════════════════════════════════════════════════════╝
  703. }
  704.  
  705.  
  706. Procedure TImage.SetupComponent;
  707. Begin
  708.      Inherited SetupComponent;
  709.  
  710.      Name:='Image';
  711.      Caption:=Name;
  712.      Width:=50;
  713.      Height:=50;
  714.      ParentPenColor:=False;
  715.      ParentColor:=True;
  716.      CursorTabStop:=False;
  717.      TabStop:=False;
  718.      FNeedBitmap:=True;
  719.      ZOrder:=zoBottom;
  720.      FAutoSize:=False;
  721.      FStretch:=True;
  722.      FCenter:=False;
  723.  
  724.      FPicture.Create(Self);
  725.      FPicture.OnChange := PictureChanged;
  726. End;
  727.  
  728. Procedure TImage.Change;
  729. Begin
  730.      If FOnChange<>Nil Then FOnChange(Self);
  731. End;
  732.  
  733. Procedure TImage.PictureChanged(Sender:TObject);
  734. Begin
  735.     Change;
  736.     Invalidate;
  737. End;
  738.  
  739.  
  740. Procedure TImage.SetStretch(NewValue:Boolean);
  741. Begin
  742.      FStretch:=NewValue;
  743.      Invalidate;
  744. End;
  745.  
  746. Procedure TImage.SetCenter(NewValue:Boolean);
  747. Begin
  748.      FCenter:=NewValue;
  749.      Invalidate;
  750. End;
  751.  
  752. Procedure TImage.SetBitmap(NewBitmap:TBitmap);
  753. Begin
  754.      Picture.Bitmap := NewBitmap;
  755. End;
  756.  
  757. Function TImage.GetBitmap:TBitmap;
  758. Begin
  759.      If ((Picture.HasFormat(TBitmap))Or(Picture.Empty)) Then
  760.        Result := Picture.Bitmap
  761.      Else
  762.        Result:=Nil;
  763. End;
  764.  
  765. Function TImage.GetIcon:TIcon;
  766. Begin
  767.      If ((Picture.HasFormat(TIcon))Or(Picture.Empty)) Then
  768.        Result := Picture.Icon
  769.      Else
  770.        Result:=Nil;
  771. End;
  772.  
  773. Procedure TImage.SetIcon(NewIcon:TIcon);
  774. Begin
  775.      Picture.Icon:=NewIcon;
  776. End;
  777.  
  778. Function TImage.GetGraphic:TGraphic;
  779. Begin
  780.      Result:=Picture.Graphic;
  781. End;
  782.  
  783. Procedure TImage.SetGraphic(NewGraphic:TGraphic);
  784. Begin
  785.      Picture.Graphic:=NewGraphic;
  786. End;
  787.  
  788. Procedure TImage.MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
  789. Begin
  790.      Inherited MouseDown(Button,ShiftState,X,Y);
  791.  
  792.      If Button = mbLeft Then
  793.        If Form Is TForm Then
  794.      Begin
  795.           Form.BringToFront;
  796.  
  797.           LastMsg.Handled:=True; {!!}
  798.           LastMsg.Result:=0;
  799.      End;
  800. End;
  801.  
  802. Procedure TImage.Redraw(Const rec:TRect);
  803. Var  rc:TRect;
  804.      X,Y:LongInt;
  805.      aGraphic:TGraphic;
  806. Label proceed;
  807. Begin
  808.      If Canvas = Nil Then Exit;
  809.  
  810.      If FPicture.Graphic <> Nil Then
  811.        If not FPicture.Graphic.Empty Then
  812.        Begin
  813.             aGraphic := FPicture.Graphic;
  814.             //clear background for icons and pointers
  815.             If ((aGraphic Is TIcon)Or(aGraphic Is TPointer)) Then Inherited Redraw(rec);
  816.             goto proceed;
  817.        End;
  818.  
  819.      Inherited Redraw(rec);
  820.  
  821.      If Designed Then
  822.      Begin
  823.           Canvas.DeleteClipRegion;
  824.           Canvas.Brush.color:=color;
  825.           Canvas.Pen.color:=clBlack;
  826.           Canvas.TextOut(4,4,Name);
  827.           rc.Left:=1;
  828.           rc.Top:=Height-1;
  829.           rc.Bottom:=1;
  830.           rc.Right:=Width-1;
  831.           Canvas.Rectangle(rc);
  832.      End;
  833.      Exit;
  834.  
  835. proceed:
  836.      {If aGraphic Is TBitmap Then
  837.        Bitmap.RealizePalette(Canvas);}
  838.      If Stretch Then Canvas.StretchDraw(0,0,Width,Height,aGraphic)
  839.      Else If ((Center)And(aGraphic.Width<=Width)And(aGraphic.Height<=Height)) Then
  840.      Begin
  841.           X:=Width Div 2;
  842.           Y:=Height Div 2;
  843.           Dec(X,aGraphic.Width Div 2);
  844.           Dec(Y,aGraphic.Height Div 2);
  845.           Canvas.Draw(X,Y,aGraphic);
  846.           rc.Left:=X;
  847.           rc.Right:=X+aGraphic.Width-1;
  848.           rc.Bottom:=Y;
  849.           rc.Top:=Y+aGraphic.Height-1;
  850.           Canvas.ExcludeClipRect(rc);
  851.           Inherited Redraw(rec);
  852.      End
  853.      Else
  854.      Begin
  855.           Canvas.Draw(0,0,aGraphic);
  856.           rc.Left:=0;
  857.           rc.Right:=aGraphic.Width-1;
  858.           rc.Bottom:=0;
  859.           rc.Top:=aGraphic.Height-1;
  860.           Canvas.ExcludeClipRect(rc);
  861.           Inherited Redraw(rec);
  862.      End;
  863. End;
  864.  
  865. Procedure TImage.SetupShow;
  866. Var  needBMP:Boolean;
  867.      aBMP:TBitmap;
  868. Begin
  869.      needBmp := FALSE;
  870.  
  871.      If Designed Then
  872.        If FNeedBitmap Then
  873.          If ComponentState * [csDetail,csLoaded] = [] Then needBmp := TRUE;
  874.  
  875.      If FPicture.Graphic <> Nil Then
  876.        If not FPicture.Graphic.Empty Then needBMP := FALSE;
  877.  
  878.  
  879.      If needBMP Then
  880.      Begin
  881.           aBMP := Bitmap;
  882.  
  883.           If CallClassPropertyEditor(aBMP) = peOk Then
  884.           Begin
  885.                Width := aBMP.Width;
  886.                Height := aBMP.Height;
  887.           End
  888.           Else
  889.           Begin
  890.                //aBMP.Destroy;
  891.                Bitmap := Nil;
  892.           End;
  893.      End;
  894.  
  895.      {$IFDEF OS2}
  896.      If FPicture.Graphic Is TBitmap Then
  897.         Bitmap.RealizePalette(Canvas);
  898.      {$ENDIF}
  899.  
  900.      Inherited SetupShow;
  901. End;
  902.  
  903. Destructor TImage.Destroy;
  904. Begin
  905.      If FPicture <> Nil Then
  906.      Begin
  907.         FPicture.Destroy;
  908.         FPicture := Nil;
  909.      End;
  910.  
  911.      Inherited Destroy;
  912. End;
  913.  
  914. Procedure TImage.ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);
  915. Begin
  916.      If ResName = rnPicture Then
  917.      Begin
  918.           If DataLen <> 0 Then Bitmap.ReadSCUResource(rnBitmap,Data,DataLen);
  919.      End
  920.      Else Inherited ReadSCUResource(ResName,Data,DataLen);
  921. End;
  922.  
  923.  
  924. Function TImage.WriteSCUResource(Stream:TResourceStream):Boolean;
  925. Begin
  926.      Result := Inherited WriteSCUResource(Stream);
  927.      If Not Result Then Exit;
  928.  
  929.      If FPicture.Graphic Is TBitmap
  930.      Then Result := Bitmap.WriteSCUResourceName(Stream,rnPicture);
  931. End;
  932.  
  933.  
  934. {
  935. ╔═══════════════════════════════════════════════════════════════════════════╗
  936. ║                                                                           ║
  937. ║ Speed-Pascal/2 Version 2.0                                                ║
  938. ║                                                                           ║
  939. ║ Speed-Pascal Component Classes (SPCC)                                     ║
  940. ║                                                                           ║
  941. ║ This section: TBevel Class Implementation                                 ║
  942. ║                                                                           ║
  943. ║ (C) 1995,97 SpeedSoft. All rights reserved. Disclosure probibited !       ║
  944. ║                                                                           ║
  945. ╚═══════════════════════════════════════════════════════════════════════════╝
  946. }
  947.  
  948. Procedure TBevel.SetupComponent;
  949. Begin
  950.      Inherited SetupComponent;
  951.  
  952.      Name:='Bevel';
  953.      Height:=100;
  954.      Width:=100;
  955.      ParentPenColor:=True;
  956.      ParentColor:=True;
  957.      CursorTabStop:=False;
  958.      TabStop:=False;
  959.      ZOrder:=zoBottom;
  960.      FShape:=bsBox;
  961.      FStyle:=bsLowered;
  962.      Include(ComponentState, csAcceptsControls);
  963. End;
  964.  
  965. Procedure TBevel.MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
  966. Begin
  967.      Inherited MouseDown(Button,ShiftState,X,Y);
  968.  
  969.      If Button = mbLeft Then
  970.        If Form Is TForm Then
  971.      Begin
  972.           Form.BringToFront;
  973.  
  974.           LastMsg.Handled:=True; {!!}
  975.           LastMsg.Result:=0;
  976.      End;
  977. End;
  978.  
  979. Procedure TBevel.SetShape(NewShape:TBevelShape);
  980. Begin
  981.      FShape := NewShape;
  982.      If Handle <> 0 Then Invalidate;
  983. End;
  984.  
  985. Procedure TBevel.SetStyle(NewStyle:TBevelStyle);
  986. Begin
  987.      FStyle := NewStyle;
  988.      If Handle <> 0 Then Invalidate;
  989. End;
  990.  
  991. Procedure TBevel.Redraw(Const rec:TRect);
  992. Var  rc1:TRect;
  993.      RaisedColor:TColor;
  994.      LoweredColor:TColor;
  995. Begin
  996.      If Canvas = Nil Then Exit;
  997.      Inherited Redraw(rec);
  998.  
  999.      rc1 := ClientRect;
  1000.  
  1001.      If FStyle=bsRaised Then
  1002.      Begin
  1003.           RaisedColor:=clWhite;
  1004.           LoweredColor:=clDkGray;
  1005.      End
  1006.      Else
  1007.      Begin
  1008.           RaisedColor:=clDkGray;
  1009.           LoweredColor:=clWhite;
  1010.      End;
  1011.  
  1012.      Case FShape Of
  1013.          bsBottomLine:
  1014.          Begin
  1015.               Canvas.Pen.color:=LoweredColor;
  1016.               Canvas.Line(rc1.Left,rc1.Bottom,rc1.Right,rc1.Bottom);
  1017.               Inc(rc1.Bottom);
  1018.               Canvas.Pen.color:=RaisedColor;
  1019.               Canvas.Line(rc1.Left,rc1.Bottom,rc1.Right,rc1.Bottom);
  1020.          End;
  1021.          bsBox:
  1022.          Begin
  1023.               Canvas.ShadowedBorder(rc1,RaisedColor,LoweredColor);
  1024.          End;
  1025.          bsFrame:
  1026.          Begin
  1027.               DrawSystemFrame(Self,rc1,LoweredColor,RaisedColor);
  1028.          End;
  1029.          bsBorder:
  1030.          Begin
  1031.               DrawSystemBorder(Self,rc1,bsSingle);  {only lowered}
  1032.          End;
  1033.          bsLeftLine:
  1034.          Begin
  1035.               Canvas.Pen.color:=RaisedColor;
  1036.               Canvas.Line(rc1.Left,rc1.Top,rc1.Left,rc1.Bottom);
  1037.               Inc(rc1.Left);
  1038.               Canvas.Pen.color:=LoweredColor;
  1039.               Canvas.Line(rc1.Left,rc1.Top,rc1.Left,rc1.Bottom);
  1040.          End;
  1041.          bsRightLine:
  1042.          Begin
  1043.               Canvas.Pen.color:=LoweredColor;
  1044.               Canvas.Line(rc1.Right,rc1.Top,rc1.Right,rc1.Bottom);
  1045.               Dec(rc1.Right);
  1046.               Canvas.Pen.color:=RaisedColor;
  1047.               Canvas.Line(rc1.Right,rc1.Top,rc1.Right,rc1.Bottom);
  1048.          End;
  1049.          bsTopLine:
  1050.          Begin
  1051.               Canvas.Pen.color:=RaisedColor;
  1052.               Canvas.Line(rc1.Left,rc1.Top,rc1.Right,rc1.Top);
  1053.               Dec(rc1.Top);
  1054.               Canvas.Pen.color:=LoweredColor;
  1055.               Canvas.Line(rc1.Left,rc1.Top,rc1.Right,rc1.Top);
  1056.          End;
  1057.      End; {Case}
  1058. End;
  1059.  
  1060. {
  1061. ╔═══════════════════════════════════════════════════════════════════════════╗
  1062. ║                                                                           ║
  1063. ║ Speed-Pascal/2 Version 2.0                                                ║
  1064. ║                                                                           ║
  1065. ║ Speed-Pascal Component Classes (SPCC)                                     ║
  1066. ║                                                                           ║
  1067. ║ This section: TPanel Class Implementation                                 ║
  1068. ║                                                                           ║
  1069. ║ (C) 1995,97 SpeedSoft. All rights reserved. Disclosure probibited !       ║
  1070. ║                                                                           ║
  1071. ╚═══════════════════════════════════════════════════════════════════════════╝
  1072. }
  1073.  
  1074. Procedure TPanel.SetupComponent;
  1075. Begin
  1076.      Inherited SetupComponent;
  1077.  
  1078.      Name:='Panel';
  1079.      Caption:=Name;
  1080.      Height:=100;
  1081.      Width:=100;
  1082.      ParentPenColor:=True;
  1083.      ParentColor:=True;
  1084.      CursorTabStop:=False;
  1085.      TabStop:=False;
  1086.      ZOrder:=zoBottom;
  1087.      FBevelInner:=bvNone;
  1088.      FBevelOuter:=bvRaised;
  1089.      FBevelWidth:=1;
  1090.      FBorderStyle:=bsNone;
  1091.      FBorderWidth:=0;
  1092.      FAlignment:=taCenter;
  1093.      Include(ComponentState, csAcceptsControls);
  1094. End;
  1095.  
  1096. Procedure TPanel.Redraw(Const rec:TRect);
  1097. Var  OuterRaisedColor:TColor;
  1098.      OuterLoweredColor:TColor;
  1099.      InnerRaisedColor:TColor;
  1100.      InnerLoweredColor:TColor;
  1101.      rc1:TRect;
  1102.  
  1103.   Procedure DrawFrame(rc:TRect;FrameWidth:LongInt;HiColor,LoColor:TColor);
  1104.   Var  PointsArray:Array[0..5] Of TPoint;
  1105.        offs:LongInt;
  1106.   Begin
  1107.        offs := FrameWidth-1;
  1108.  
  1109.        If FrameWidth > 1 Then
  1110.        Begin
  1111.             PointsArray[0] := Point(rc.Left,rc.Bottom);
  1112.             PointsArray[1] := Point(rc.Left+offs,rc.Bottom+offs);
  1113.             PointsArray[2] := Point(rc.Left+offs,rc.Top-offs);
  1114.             PointsArray[3] := Point(rc.Right-offs,rc.Top-offs);
  1115.             PointsArray[4] := Point(rc.Right,rc.Top);
  1116.             PointsArray[5] := Point(rc.Left,rc.Top);
  1117.             Canvas.Pen.color := HiColor;
  1118.             Canvas.Polygon(PointsArray);
  1119.             PointsArray[2] := Point(rc.Right-offs,rc.Bottom+offs);
  1120.             PointsArray[3] := Point(rc.Right-offs,rc.Top-offs);
  1121.             PointsArray[4] := Point(rc.Right,rc.Top);
  1122.             PointsArray[5] := Point(rc.Right,rc.Bottom);
  1123.             Canvas.Pen.color := LoColor;
  1124.             Canvas.Polygon(PointsArray);
  1125.        End
  1126.        Else Canvas.ShadowedBorder(rc1,HiColor,LoColor);
  1127.   End;
  1128. Begin
  1129.      If Canvas = Nil Then Exit;
  1130.  
  1131.      If FBevelInner = bvRaised Then
  1132.      Begin
  1133.           InnerRaisedColor := clBtnHighlight;
  1134.           InnerLoweredColor := clBtnShadow;
  1135.      End
  1136.      Else
  1137.      Begin
  1138.           InnerRaisedColor := clBtnShadow;
  1139.           InnerLoweredColor := clBtnHighlight;
  1140.      End;
  1141.  
  1142.      If FBevelOuter = bvRaised Then
  1143.      Begin
  1144.           OuterRaisedColor := clBtnHighlight;
  1145.           OuterLoweredColor := clBtnShadow;
  1146.      End
  1147.      Else
  1148.      Begin
  1149.           OuterRaisedColor := clBtnShadow;
  1150.           OuterLoweredColor := clBtnHighlight;
  1151.      End;
  1152.  
  1153.      rc1 := ClientRect;
  1154.      DrawSystemBorder(Self,rc1,FBorderStyle);
  1155.  
  1156.      If FBevelOuter <> bvNone Then
  1157.        If FBevelWidth > 0 Then
  1158.      Begin
  1159.           DrawFrame(rc1,FBevelWidth,OuterRaisedColor,OuterLoweredColor);
  1160.           InflateRect(rc1,-FBevelWidth,-FBevelWidth);
  1161.      End;
  1162.  
  1163.      If FBorderWidth > 0 Then
  1164.      Begin
  1165.           DrawFrame(rc1,FBorderWidth,color,color);
  1166.           InflateRect(rc1,-FBorderWidth,-FBorderWidth);
  1167.      End;
  1168.  
  1169.      If FBevelInner <> bvNone Then
  1170.        If FBevelWidth > 0 Then
  1171.      Begin
  1172.           DrawFrame(rc1,FBevelWidth,InnerRaisedColor,InnerLoweredColor);
  1173.           InflateRect(rc1,-FBevelWidth,-FBevelWidth);
  1174.      End;
  1175.  
  1176.      FInterior := rc1;
  1177.      DrawText(rec);
  1178. End;
  1179.  
  1180. {$HINTS OFF}
  1181. Procedure TPanel.DrawText(Const rec:TRect);
  1182. Var  X,Y,CX,CY:LongInt;
  1183. Begin
  1184.      If Canvas = Nil Then Exit;
  1185.  
  1186.      Canvas.FillRect(FInterior,color);
  1187.      Canvas.SetClipRegion([FInterior]);
  1188.  
  1189.      {Draw Caption}
  1190.      If Caption <> '' Then
  1191.      Begin
  1192.           Canvas.GetTextExtent(Caption,CX,CY);
  1193.           Case FAlignment Of
  1194.             taLeftJustify:   X := FInterior.Left+1;
  1195.             taRightJustify:  X := FInterior.Right-CX;
  1196.             taCenter:        X := (Width-CX) Div 2;
  1197.           End;
  1198.           Y := (Height-CY) Div 2;
  1199.           Canvas.Pen.color := PenColor;
  1200.           Canvas.Brush.color := color;
  1201.           Canvas.TextOut(X,Y,Caption);
  1202.      End;
  1203.  
  1204.      Canvas.DeleteClipRegion;  {Win95!}
  1205. End;
  1206. {$HINTS ON}
  1207.  
  1208.  
  1209. Procedure TPanel.MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
  1210. Begin
  1211.      Inherited MouseDown(Button,ShiftState,X,Y);
  1212.  
  1213.      If Button = mbLeft Then
  1214.        If Form Is TForm Then
  1215.      Begin
  1216.           Form.BringToFront;
  1217.  
  1218.           LastMsg.Handled:=True; {!!}
  1219.           LastMsg.Result:=0;
  1220.      End;
  1221. End;
  1222.  
  1223.  
  1224. Procedure TPanel.SetBevelInner(NewBevel:TPanelBevel);
  1225. Begin
  1226.      FBevelInner:=NewBevel;
  1227.      If Handle<>0 Then Invalidate;
  1228. End;
  1229.  
  1230. Procedure TPanel.SetBevelOuter(NewBevel:TPanelBevel);
  1231. Begin
  1232.      FBevelOuter:=NewBevel;
  1233.      If Handle<>0 Then Invalidate;
  1234. End;
  1235.  
  1236. Procedure TPanel.SetBevelWidth(NewWidth:LongInt);
  1237. Begin
  1238.      If NewWidth<0 Then NewWidth:=0;
  1239.      FBevelWidth:=NewWidth;
  1240.      If Handle<>0 Then Invalidate;
  1241. End;
  1242.  
  1243. Procedure TPanel.SetBorderStyle(NewStyle:TBorderStyle);
  1244. Begin
  1245.      FBorderStyle:=NewStyle;
  1246.      If Handle<>0 Then Invalidate;
  1247. End;
  1248.  
  1249. Procedure TPanel.SetBorderWidth(NewWidth:LongInt);
  1250. Begin
  1251.      If NewWidth<0 Then NewWidth:=0;
  1252.      FBorderWidth:=NewWidth;
  1253.      If Handle<>0 Then Invalidate;
  1254. End;
  1255.  
  1256. Procedure TPanel.SetAlignment(ta:TAlignment);
  1257. Begin
  1258.      FAlignment:=ta;
  1259.      If Handle<>0 Then DrawText(ClientRect);
  1260. End;
  1261.  
  1262. {$HINTS OFF}
  1263. Procedure TPanel.CMTextChanged(Var Msg:TMessage);
  1264. Begin
  1265.      DrawText(ClientRect);
  1266. End;
  1267. {$HINTS ON}
  1268.  
  1269.  
  1270. {
  1271. ╔═══════════════════════════════════════════════════════════════════════════╗
  1272. ║                                                                           ║
  1273. ║ Speed-Pascal/2 Version 2.0                                                ║
  1274. ║                                                                           ║
  1275. ║ Speed-Pascal Component Classes (SPCC)                                     ║
  1276. ║                                                                           ║
  1277. ║ This section: TRadioGroup Class Implementation                            ║
  1278. ║                                                                           ║
  1279. ║ (C) 1995,97 SpeedSoft. All rights reserved. Disclosure probibited !       ║
  1280. ║                                                                           ║
  1281. ╚═══════════════════════════════════════════════════════════════════════════╝
  1282. }
  1283.  
  1284. Procedure TRadioGroup.SetupComponent;
  1285. Begin
  1286.      Inherited SetupComponent;
  1287.  
  1288.      Name := 'RadioGroup';
  1289.      Caption := Name;
  1290.  
  1291.      FRadios.Create;
  1292.      FItems := TStringList.Create;
  1293.      TStringList(FItems).OnChange := EvItemsChange;
  1294.      FItemIndex := -1;
  1295.      FColumns := 1;
  1296. End;
  1297.  
  1298.  
  1299. Procedure TRadioGroup.SetupShow;
  1300. Begin
  1301.      Inherited SetupShow;
  1302.  
  1303.      UpdateRadios;
  1304.      SetItemIndex(FItemIndex);
  1305.      ArrangeRadios;
  1306. End;
  1307.  
  1308.  
  1309. Destructor TRadioGroup.Destroy;
  1310. Begin
  1311.      SetRadioCount(0);
  1312.      FRadios.Destroy;
  1313.      FRadios := Nil;
  1314.      TStringList(FItems).OnChange := Nil;
  1315.      FItems.Destroy;
  1316.      FItems := Nil;
  1317.  
  1318.      Inherited Destroy;
  1319. End;
  1320.  
  1321.  
  1322. Procedure TRadioGroup.Resize;
  1323. Begin
  1324.      Inherited Resize;
  1325.  
  1326.      ArrangeRadios;
  1327. End;
  1328.  
  1329.  
  1330. Procedure TRadioGroup.FontChange;
  1331. Var  I:LongInt;
  1332.      Radio:TRadioButton;
  1333. Begin
  1334.      Inherited FontChange;
  1335.  
  1336.      For I := 0 To FRadios.Count-1 Do
  1337.      Begin
  1338.           Radio := TRadioButton(FRadios.Items[I]);
  1339.           Radio.Font := Font;
  1340.      End;
  1341.      ArrangeRadios;
  1342. End;
  1343.  
  1344.  
  1345. Procedure TRadioGroup.Click;
  1346. Begin
  1347.      If FOnClick <> Nil Then FOnClick(Self);
  1348. End;
  1349.  
  1350.  
  1351. Procedure TRadioGroup.SetItemIndex(Value:LongInt);
  1352. Begin
  1353.      If ComponentState * [csReading] <> [] Then
  1354.      Begin
  1355.           FItemIndex := Value;
  1356.           Exit;
  1357.      End;
  1358.  
  1359.      If Value < 0 Then Value := -1;
  1360.      If Value >= FRadios.Count Then Value := FRadios.Count-1;
  1361.  
  1362.      {deselect old because New Value can be < 0}
  1363.      If (FItemIndex >= 0) And (FItemIndex < FRadios.Count)
  1364.      Then TRadioButton(FRadios[FItemIndex]).Checked := False;
  1365.  
  1366.      FItemIndex := Value;
  1367.      If FItemIndex >= 0 {Select New}
  1368.      Then TRadioButton(FRadios[FItemIndex]).Checked := True;
  1369.  
  1370.      ItemIndexChange;
  1371. End;
  1372.  
  1373.  
  1374. Procedure TRadioGroup.ItemIndexChange;
  1375. Begin
  1376. End;
  1377.  
  1378.  
  1379. Procedure TRadioGroup.SetColumns(Value:LongInt);
  1380. Begin
  1381.      If Value <= 0 Then Value := 1;
  1382.      If FColumns <> Value Then
  1383.      Begin
  1384.           FColumns := Value;
  1385.           ArrangeRadios;
  1386.      End;
  1387. End;
  1388.  
  1389.  
  1390. Procedure TRadioGroup.SetItems(Value:TStrings);
  1391. Begin
  1392.      If Value <> FItems Then FItems.Assign(Value);
  1393. End;
  1394.  
  1395.  
  1396. Procedure TRadioGroup.SetRadioCount(Value:LongInt);
  1397. Var  Radio:TRadioButton;
  1398. Begin
  1399.      While FRadios.Count < Value Do
  1400.      Begin
  1401.           Radio.Create(Self);
  1402.           Include(Radio.ComponentState, csDetail);
  1403.           Radio.Font := Font;
  1404.           Radio.OnClick := EvRadioClick;
  1405.           FRadios.Add(Radio);
  1406.      End;
  1407.      While FRadios.Count > Value Do
  1408.      Begin
  1409.           Radio := TRadioButton(FRadios.Last);
  1410.           FRadios.Remove(Radio);
  1411.           Radio.Destroy;
  1412.      End;
  1413. End;
  1414.  
  1415.  
  1416. Function TRadioGroup.GetItemsEnabled(Index:LongInt):Boolean;
  1417. Var  Radio:TRadioButton;
  1418. Begin
  1419.      Radio := TRadioButton(FRadios.Items[Index]);
  1420.      Result := Radio.Enabled;
  1421. End;
  1422.  
  1423.  
  1424. Procedure TRadioGroup.SetItemsEnabled(Index:LongInt;Value:Boolean);
  1425. Var  Radio:TRadioButton;
  1426. Begin
  1427.      Radio := TRadioButton(FRadios.Items[Index]);
  1428.      Radio.Enabled := Value;
  1429. End;
  1430.  
  1431.  
  1432. Procedure TRadioGroup.UpdateRadios;
  1433. Var  I:LongInt;
  1434.      Radio:TRadioButton;
  1435. Begin
  1436.      SetRadioCount(FItems.Count);
  1437.      For I := 0 To FItems.Count- 1 Do
  1438.      Begin
  1439.           Radio := TRadioButton(FRadios.Items[I]);
  1440.           Radio.Caption := FItems[I];
  1441.      End;
  1442.      SetItemIndex(FItemIndex);
  1443.      ArrangeRadios;
  1444. End;
  1445.  
  1446.  
  1447. Procedure TRadioGroup.ArrangeRadios;
  1448. Const Margin=10;
  1449. Var  I:LongInt;
  1450.      Radio:TRadioButton;
  1451.      RadioWidth:LongInt;
  1452.      RadioHeight:LongInt;
  1453.      RadiosPerColumn:LongInt;
  1454.      XPos,YPos:LongInt;
  1455.      rc:TRect;
  1456. Begin
  1457.      If Handle = 0 Then Exit;
  1458.      If FRadios.Count = 0 Then Exit;
  1459.  
  1460.      rc := ClientRect;
  1461.      Inc(rc.Left,Margin);
  1462.      Inc(rc.Bottom,Margin);
  1463.      Dec(rc.Right,Margin);
  1464.      Dec(rc.Top,Margin+Font.Height);
  1465.  
  1466.      RadiosPerColumn :=  (FRadios.Count + FColumns - 1) Div FColumns;
  1467.      RadioWidth := (rc.Right - rc.Left) Div FColumns;
  1468.      RadioHeight := (rc.Top - rc.Bottom) Div RadiosPerColumn;
  1469.  
  1470.      XPos := rc.Left;
  1471.      YPos := rc.Top - RadioHeight;
  1472.      For I := 0 To FRadios.Count-1 Do
  1473.      Begin
  1474.           Radio := TRadioButton(FRadios[I]);
  1475.           Radio.SetWindowPos(XPos,YPos,RadioWidth,RadioHeight);
  1476.           If Radio.parent = Nil Then Radio.parent := Self;
  1477.  
  1478.           If ((I+1) Mod RadiosPerColumn) = 0 Then
  1479.           Begin
  1480.                YPos := rc.Top - RadioHeight;
  1481.                Inc(XPos,RadioWidth);
  1482.           End
  1483.           Else Dec(YPos,RadioHeight);
  1484.      End;
  1485. End;
  1486.  
  1487.  
  1488. {$HINTS OFF}
  1489. Procedure TRadioGroup.EvItemsChange(Sender:TObject);
  1490. Begin
  1491.      If ComponentState * [csReading] = [] Then
  1492.      Begin
  1493.           UpdateRadios;
  1494.      End;
  1495. End;
  1496. {$HINTS ON}
  1497.  
  1498.  
  1499. Procedure TRadioGroup.EvRadioClick(Sender:TObject);
  1500. Begin
  1501.      FItemIndex := FRadios.IndexOf(Sender);
  1502.      ItemIndexChange;
  1503.      Click;
  1504. End;
  1505.  
  1506.  
  1507. Function TRadioGroup.WriteSCUResource(Stream:TResourceStream):Boolean;
  1508. Var  aText:PChar;
  1509. Begin
  1510.      Result := Inherited WriteSCUResource(Stream);
  1511.      If Not Result Then Exit;
  1512.  
  1513.      aText := Items.GetText;
  1514.      If aText <> Nil Then
  1515.      Begin
  1516.           Result := Stream.NewResourceEntry(rnItems,aText^,Length(aText^)+1);
  1517.           StrDispose(aText);
  1518.      End;
  1519. End;
  1520.  
  1521.  
  1522. Procedure TRadioGroup.ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);
  1523. Var  aText:PChar;
  1524. Begin
  1525.      If ResName = rnItems Then
  1526.      Begin
  1527.           aText := @Data;
  1528.           Items.SetText(aText);
  1529.      End
  1530.      Else Inherited ReadSCUResource(ResName,Data,DataLen)
  1531. End;
  1532.  
  1533.  
  1534. {
  1535. ╔═══════════════════════════════════════════════════════════════════════════╗
  1536. ║                                                                           ║
  1537. ║ Speed-Pascal/2 Version 2.0                                                ║
  1538. ║                                                                           ║
  1539. ║ Speed-Pascal Component Classes (SPCC)                                     ║
  1540. ║                                                                           ║
  1541. ║ This section: TPaintBox Class Implementation                              ║
  1542. ║                                                                           ║
  1543. ║ (C) 1995,97 SpeedSoft. All rights reserved. Disclosure probibited !       ║
  1544. ║                                                                           ║
  1545. ╚═══════════════════════════════════════════════════════════════════════════╝
  1546. }
  1547.  
  1548. Procedure TPaintBox.SetupComponent;
  1549. Begin
  1550.      Inherited SetupComponent;
  1551.      Name:='PaintBox';
  1552.      Height:=200;
  1553.      Width:=200;
  1554.      ParentPenColor:=True;
  1555.      ParentColor:=True;
  1556.      TabStop:=False;
  1557.      ZOrder:=zoBottom;
  1558. End;
  1559.  
  1560.  
  1561. Procedure TPaintBox.Redraw(Const rec:TRect);
  1562. Var rc:TRect;
  1563. Begin
  1564.      Inherited Redraw(rec);
  1565.  
  1566.      If Designed Then
  1567.      Begin
  1568.           rc:=ClientRect;
  1569.           Canvas.Brush.color:=color;
  1570.           Canvas.Pen.color:=clBlack;
  1571.           Canvas.TextOut(20,20,'PaintBox');
  1572.           Canvas.Pen.Style := psDash;
  1573.           Canvas.Brush.Style := bsClear;
  1574.           Canvas.Rectangle(rc);
  1575.      End;
  1576. End;
  1577.  
  1578.  
  1579. Begin
  1580. End.
  1581.  
  1582.