| 1 |
|
|---|
| 2 | {ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 3 | º º
|
|---|
| 4 | º Sibyl Portable Component Classes º
|
|---|
| 5 | º º
|
|---|
| 6 | º Copyright (C) 1995,97 SpeedSoft Germany, All rights reserved. º
|
|---|
| 7 | º º
|
|---|
| 8 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ}
|
|---|
| 9 |
|
|---|
| 10 | Unit Buttons;
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | Interface
|
|---|
| 14 |
|
|---|
| 15 | {$IFDEF OS2}
|
|---|
| 16 | Uses PmWin,BseDos;
|
|---|
| 17 | {$ENDIF}
|
|---|
| 18 |
|
|---|
| 19 | {$IFDEF Win95}
|
|---|
| 20 | Uses WinUser,CommCtrl;
|
|---|
| 21 | {$ENDIF}
|
|---|
| 22 |
|
|---|
| 23 | Uses SysUtils,Messages,Classes,Forms,Graphics;
|
|---|
| 24 |
|
|---|
| 25 | Type
|
|---|
| 26 | TButtonControl=Class(TControl)
|
|---|
| 27 | Private
|
|---|
| 28 | FOnClick:TNotifyEvent;
|
|---|
| 29 | Protected
|
|---|
| 30 | Procedure SetupComponent;Override;
|
|---|
| 31 | Procedure GetClassData(Var ClassData:TClassData);Override;
|
|---|
| 32 | Procedure ParentNotification(Var Msg:TMessage);Override;
|
|---|
| 33 | Function EvaluateShortCut(KeyCode:TKeyCode):Boolean;Override;
|
|---|
| 34 | Public
|
|---|
| 35 | Procedure Click;Virtual;
|
|---|
| 36 | Property OnClick:TNotifyEvent Read FOnClick Write FOnClick;
|
|---|
| 37 | End;
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | TRadioButton=Class(TButtonControl)
|
|---|
| 41 | Private
|
|---|
| 42 | FInitChecked:Boolean;
|
|---|
| 43 | Function GetChecked:Boolean;
|
|---|
| 44 | Procedure SetChecked(NewState:Boolean);
|
|---|
| 45 | Protected
|
|---|
| 46 | Procedure SetupComponent;Override;
|
|---|
| 47 | Procedure CreateParams(Var Params:TCreateParams);Override;
|
|---|
| 48 | Procedure CreateWnd;Override;
|
|---|
| 49 | Public
|
|---|
| 50 | Procedure Click;Override;
|
|---|
| 51 | Procedure SetFocus;Override;
|
|---|
| 52 | Published
|
|---|
| 53 | Property Align;
|
|---|
| 54 | Property Color;
|
|---|
| 55 | Property Caption;
|
|---|
| 56 | Property Checked:Boolean Read GetChecked Write SetChecked;
|
|---|
| 57 | Property DragCursor;
|
|---|
| 58 | Property DragMode;
|
|---|
| 59 | Property Enabled;
|
|---|
| 60 | Property Font;
|
|---|
| 61 | Property ParentColor;
|
|---|
| 62 | Property ParentFont;
|
|---|
| 63 | Property ParentPenColor;
|
|---|
| 64 | Property ParentShowHint;
|
|---|
| 65 | Property PenColor;
|
|---|
| 66 | Property PopupMenu;
|
|---|
| 67 | Property ShowHint;
|
|---|
| 68 | Property TabOrder;
|
|---|
| 69 | Property TabStop;
|
|---|
| 70 | Property Visible;
|
|---|
| 71 | Property ZOrder;
|
|---|
| 72 |
|
|---|
| 73 | Property OnCanDrag;
|
|---|
| 74 | Property OnClick;
|
|---|
| 75 | Property OnDragDrop;
|
|---|
| 76 | Property OnDragOver;
|
|---|
| 77 | Property OnEndDrag;
|
|---|
| 78 | Property OnEnter;
|
|---|
| 79 | Property OnExit;
|
|---|
| 80 | Property OnFontChange;
|
|---|
| 81 | Property OnKeyPress;
|
|---|
| 82 | Property OnMouseDown;
|
|---|
| 83 | Property OnMouseMove;
|
|---|
| 84 | Property OnMouseUp;
|
|---|
| 85 | Property OnScan;
|
|---|
| 86 | Property OnSetupShow;
|
|---|
| 87 | Property OnStartDrag;
|
|---|
| 88 | End;
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | TCheckBoxState=(cbUnchecked,cbChecked,cbGrayed);
|
|---|
| 92 |
|
|---|
| 93 | TCheckBox=Class(TButtonControl)
|
|---|
| 94 | Private
|
|---|
| 95 | FInitState:TCheckBoxState;
|
|---|
| 96 | FAllowGrayed:Boolean;
|
|---|
| 97 | Function GetChecked:Boolean;
|
|---|
| 98 | Procedure SetChecked(NewState:Boolean);
|
|---|
| 99 | Function GetState:TCheckBoxState;
|
|---|
| 100 | Procedure SetState(NewState:TCheckBoxState);
|
|---|
| 101 | Protected
|
|---|
| 102 | Procedure SetupComponent;Override;
|
|---|
| 103 | Procedure CreateParams(Var Params:TCreateParams);Override;
|
|---|
| 104 | Procedure CreateWnd;Override;
|
|---|
| 105 | Procedure Toggle;Virtual;
|
|---|
| 106 | Public
|
|---|
| 107 | Procedure Click;Override;
|
|---|
| 108 | Published
|
|---|
| 109 | Property Align;
|
|---|
| 110 | Property AllowGrayed:Boolean Read FAllowGrayed Write FAllowGrayed;
|
|---|
| 111 | Property Color;
|
|---|
| 112 | Property Caption;
|
|---|
| 113 | Property Checked:Boolean Read GetChecked Write SetChecked;
|
|---|
| 114 | Property PenColor;
|
|---|
| 115 | Property DragCursor;
|
|---|
| 116 | Property DragMode;
|
|---|
| 117 | Property Enabled;
|
|---|
| 118 | Property Font;
|
|---|
| 119 | Property ParentColor;
|
|---|
| 120 | Property ParentPenColor;
|
|---|
| 121 | Property ParentFont;
|
|---|
| 122 | Property ParentShowHint;
|
|---|
| 123 | Property PopupMenu;
|
|---|
| 124 | Property ShowHint;
|
|---|
| 125 | Property State:TCheckBoxState Read GetState Write SetState;
|
|---|
| 126 | Property TabOrder;
|
|---|
| 127 | Property TabStop;
|
|---|
| 128 | Property Visible;
|
|---|
| 129 | Property ZOrder;
|
|---|
| 130 |
|
|---|
| 131 | Property OnCanDrag;
|
|---|
| 132 | Property OnClick;
|
|---|
| 133 | Property OnDragDrop;
|
|---|
| 134 | Property OnDragOver;
|
|---|
| 135 | Property OnEndDrag;
|
|---|
| 136 | Property OnEnter;
|
|---|
| 137 | Property OnExit;
|
|---|
| 138 | Property OnFontChange;
|
|---|
| 139 | Property OnKeyPress;
|
|---|
| 140 | Property OnMouseDown;
|
|---|
| 141 | Property OnMouseMove;
|
|---|
| 142 | Property OnMouseUp;
|
|---|
| 143 | Property OnScan;
|
|---|
| 144 | Property OnSetupShow;
|
|---|
| 145 | Property OnStartDrag;
|
|---|
| 146 | End;
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 | TButton=Class(TButtonControl)
|
|---|
| 150 | Private
|
|---|
| 151 | FCancel:Boolean;
|
|---|
| 152 | FDefault:Boolean;
|
|---|
| 153 | FModalResult:TCommand;
|
|---|
| 154 | Procedure SetDefault(Value:Boolean);Virtual;
|
|---|
| 155 | Procedure SetCancel(Value:Boolean);
|
|---|
| 156 | Function GetFormButton(Default:Boolean):TButton;
|
|---|
| 157 | Procedure SetFormButton(Default:Boolean;Button:TButton);
|
|---|
| 158 | Protected
|
|---|
| 159 | Procedure SetupComponent;Override;
|
|---|
| 160 | Procedure CreateParams(Var Params:TCreateParams);Override;
|
|---|
| 161 | Procedure SetupShow;Override;
|
|---|
| 162 | Procedure SetFocus;Override;
|
|---|
| 163 | Public
|
|---|
| 164 | Destructor Destroy;Override;
|
|---|
| 165 | Procedure Click;Override;
|
|---|
| 166 | Property XAlign;
|
|---|
| 167 | Property XStretch;
|
|---|
| 168 | Property YAlign;
|
|---|
| 169 | Property YStretch;
|
|---|
| 170 | Published
|
|---|
| 171 | Property Align;
|
|---|
| 172 | Property Color;
|
|---|
| 173 | Property Cancel:Boolean Read FCancel Write SetCancel;
|
|---|
| 174 | Property Caption;
|
|---|
| 175 | Property PenColor;
|
|---|
| 176 | Property Command;
|
|---|
| 177 | Property Default:Boolean Read FDefault Write SetDefault;
|
|---|
| 178 | Property DragCursor;
|
|---|
| 179 | Property DragMode;
|
|---|
| 180 | Property Enabled;
|
|---|
| 181 | Property Font;
|
|---|
| 182 | Property ModalResult:TCommand Read FModalResult Write FModalResult;
|
|---|
| 183 | Property ParentColor;
|
|---|
| 184 | Property ParentPenColor;
|
|---|
| 185 | Property ParentFont;
|
|---|
| 186 | Property ParentShowHint;
|
|---|
| 187 | Property PopupMenu;
|
|---|
| 188 | Property ShowHint;
|
|---|
| 189 | Property TabOrder;
|
|---|
| 190 | Property TabStop;
|
|---|
| 191 | Property Visible;
|
|---|
| 192 | Property ZOrder;
|
|---|
| 193 |
|
|---|
| 194 | Property OnCanDrag;
|
|---|
| 195 | Property OnClick;
|
|---|
| 196 | Property OnDragDrop;
|
|---|
| 197 | Property OnDragOver;
|
|---|
| 198 | Property OnEndDrag;
|
|---|
| 199 | Property OnEnter;
|
|---|
| 200 | Property OnExit;
|
|---|
| 201 | Property OnFontChange;
|
|---|
| 202 | Property OnKeyPress;
|
|---|
| 203 | Property OnMouseDown;
|
|---|
| 204 | Property OnMouseMove;
|
|---|
| 205 | Property OnMouseUp;
|
|---|
| 206 | Property OnScan;
|
|---|
| 207 | Property OnSetupShow;
|
|---|
| 208 | Property OnStartDrag;
|
|---|
| 209 | End;
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 | TPosSize=Record
|
|---|
| 213 | Left,Bottom,Width,Height:LongInt;
|
|---|
| 214 | End;
|
|---|
| 215 |
|
|---|
| 216 | {$M+}
|
|---|
| 217 | TButtonLayout=(blGlyphLeft,blGlyphRight,blGlyphTop,blGlyphBottom);
|
|---|
| 218 |
|
|---|
| 219 | TBitBtnKind=(bkCustom,bkOk,bkCancel,bkHelp,bkYes,bkNo,bkClose,
|
|---|
| 220 | bkAbort,bkRetry,bkIgnore,bkAll,bkOpen);
|
|---|
| 221 | {$M-}
|
|---|
| 222 |
|
|---|
| 223 | TNumGlyphs=LongInt;
|
|---|
| 224 |
|
|---|
| 225 | TBitBtn=Class(TButton)
|
|---|
| 226 | Private
|
|---|
| 227 | bmp:TPosSize;
|
|---|
| 228 | txt:TPosSize;
|
|---|
| 229 | Int:TPosSize;
|
|---|
| 230 | IsBmp:Boolean;
|
|---|
| 231 | IsTxt:Boolean;
|
|---|
| 232 | IsMnemo:Boolean;
|
|---|
| 233 | InRedraw:Boolean;
|
|---|
| 234 | FDragging:Boolean;
|
|---|
| 235 | FDown:Boolean;
|
|---|
| 236 | FSpaceDown:Boolean;
|
|---|
| 237 | FLayout:TButtonLayout;
|
|---|
| 238 | FMargin:LongInt;
|
|---|
| 239 | FSpacing:LongInt;
|
|---|
| 240 | FKind:TBitBtnKind;
|
|---|
| 241 | FBitmap:TBitmap;
|
|---|
| 242 | FMaskBitmap:TBitmap;
|
|---|
| 243 | FMaskedBitmap:TBitmap;
|
|---|
| 244 | FNumGlyphs:TNumGlyphs;
|
|---|
| 245 | Private
|
|---|
| 246 | Procedure CMTextChanged(Var Msg:TMessage);Message CM_TEXTCHANGED;
|
|---|
| 247 | {$IFDEF Win95}
|
|---|
| 248 | Procedure WMKeyDown(Var Msg:TMessage); Message WM_KEYDOWN;
|
|---|
| 249 | Procedure WMKeyUp(Var Msg:TMessage); Message WM_KEYUP;
|
|---|
| 250 | {$ENDIF}
|
|---|
| 251 | Procedure SetDefault(Value:Boolean);Override;
|
|---|
| 252 | Function GetDown:Boolean;Virtual;
|
|---|
| 253 | Procedure SetDown(Value:Boolean);Virtual;
|
|---|
| 254 | Procedure SetLayout(Value:TButtonLayout);
|
|---|
| 255 | Procedure SetMargin(Value:LongInt);
|
|---|
| 256 | Procedure SetSpacing(Value:LongInt);
|
|---|
| 257 | Procedure SetKind(Value:TBitBtnKind);
|
|---|
| 258 | Function GetGlyph:TBitmap;
|
|---|
| 259 | Procedure SetGlyph(NewBitmap:TBitmap);Virtual;
|
|---|
| 260 | Procedure CreateBitmaps;
|
|---|
| 261 | Procedure SetNumGlyphs(NewValue:TNumGlyphs);
|
|---|
| 262 | Protected
|
|---|
| 263 | Procedure SetupComponent;Override;
|
|---|
| 264 | Procedure GetClassData(Var ClassData:TClassData);Override;
|
|---|
| 265 | Procedure CreateParams(Var Params:TCreateParams);Override;
|
|---|
| 266 | Procedure SetupShow;Override;
|
|---|
| 267 | Procedure RealignControls;Override;
|
|---|
| 268 | Procedure FontChange;Override;
|
|---|
| 269 | {$IFDEF OS2}
|
|---|
| 270 | Procedure ParentNotification(Var Msg:TMessage);Override;
|
|---|
| 271 | {$ENDIF}
|
|---|
| 272 | Procedure DrawFrame(Down:Boolean);Virtual;
|
|---|
| 273 | Procedure DrawText(Const Caption:String;Down:Boolean);Virtual;
|
|---|
| 274 | Procedure DrawBitmap(Bitmap:TBitmap;Mask:TBitmap;Down:Boolean);Virtual;
|
|---|
| 275 | Procedure Arrange;Virtual;
|
|---|
| 276 | Procedure MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 277 | Procedure MouseUp(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 278 | Procedure MouseMove(ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 279 | Procedure MouseDblClick(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 280 | Property Down:Boolean Read GetDown Write SetDown;
|
|---|
| 281 | Public
|
|---|
| 282 | Destructor Destroy;Override;
|
|---|
| 283 | Procedure Redraw(Const rec:TRect);Override;
|
|---|
| 284 | Procedure ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);Override;
|
|---|
| 285 | Function WriteSCUResource(Stream:TResourceStream):Boolean;Override;
|
|---|
| 286 | Procedure Click;Override;
|
|---|
| 287 | Published
|
|---|
| 288 | Property Glyph:TBitmap Read GetGlyph Write SetGlyph;
|
|---|
| 289 | Property Kind:TBitBtnKind Read FKind Write SetKind;
|
|---|
| 290 | Property Layout:TButtonLayout Read FLayout Write SetLayout;
|
|---|
| 291 | Property Margin:LongInt Read FMargin Write SetMargin;
|
|---|
| 292 | Property Spacing:LongInt Read FSpacing Write SetSpacing;
|
|---|
| 293 | Property NumGlyphs:TNumGlyphs read FNumGlyphs write SetNumGlyphs;
|
|---|
| 294 | Property OnPaint;
|
|---|
| 295 | End;
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 | TAnimatedButton=Class(TBitBtn)
|
|---|
| 299 | Private
|
|---|
| 300 | FSaveBitmap:TBitmap;
|
|---|
| 301 | FBitmapList:TBitmapList;
|
|---|
| 302 | FAnimationTimer:TTimer;
|
|---|
| 303 | FLastPlayItem:LongInt;
|
|---|
| 304 | FInterval:LongInt;
|
|---|
| 305 | Procedure SetInterval(Value:LongInt);
|
|---|
| 306 | Procedure SetGlyph(NewBitmap:TBitmap);Override;
|
|---|
| 307 | Procedure EvTimer(Sender:TObject);
|
|---|
| 308 | Protected
|
|---|
| 309 | Procedure SetupComponent;Override;
|
|---|
| 310 | Public
|
|---|
| 311 | Destructor Destroy;Override;
|
|---|
| 312 | Procedure SetupShow;Override;
|
|---|
| 313 | Procedure StartAnimation;
|
|---|
| 314 | Procedure StopAnimation;
|
|---|
| 315 | Procedure ResetAnimation;
|
|---|
| 316 | Property BitmapList:TBitmapList Read FBitmapList;
|
|---|
| 317 | Published
|
|---|
| 318 | Property Interval:LongInt Read FInterval Write SetInterval;
|
|---|
| 319 | End;
|
|---|
| 320 |
|
|---|
| 321 | TButtonState=(bsNormal,bsUp,bsDown,bsDisabled,bsExclusive);
|
|---|
| 322 |
|
|---|
| 323 | TSpeedButton=Class(TBitBtn)
|
|---|
| 324 | Private
|
|---|
| 325 | FIgnoreClick:Boolean;
|
|---|
| 326 | FState:TButtonState;
|
|---|
| 327 | FAllowAllUp:Boolean;
|
|---|
| 328 | FGroupIndex:LongInt;
|
|---|
| 329 | Private
|
|---|
| 330 | Function GetState:TButtonState;
|
|---|
| 331 | Procedure SetState(NewValue:TButtonState);
|
|---|
| 332 | {$IFDEF OS2}
|
|---|
| 333 | Procedure WMChar(Var Msg:TWMChar); Message WM_CHAR;
|
|---|
| 334 | {$ENDIF}
|
|---|
| 335 | Procedure UpdateExclusive;
|
|---|
| 336 | Procedure cmButtonPressed(Var Msg:TMessage);Message CM_BUTTONPRESSED;
|
|---|
| 337 | Function GetDown:Boolean;Override;
|
|---|
| 338 | Procedure SetDown(Value:Boolean);Override;
|
|---|
| 339 | Procedure SetAllowAllUp(Value:Boolean);
|
|---|
| 340 | Procedure SetGroupIndex(Value:LongInt);
|
|---|
| 341 | Property ModalResult;
|
|---|
| 342 | Protected
|
|---|
| 343 | Procedure SetupComponent;Override;
|
|---|
| 344 | Procedure CreateParams(Var Params:TCreateParams);Override;
|
|---|
| 345 | {$IFDEF OS2}
|
|---|
| 346 | Procedure ParentNotification(Var Msg:TMessage);Override;
|
|---|
| 347 | {$ENDIF}
|
|---|
| 348 | Procedure DrawFrame(Down:Boolean);Override;
|
|---|
| 349 | Procedure MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 350 | Procedure MouseUp(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 351 | Procedure MouseMove(ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 352 | Procedure MouseDblClick(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);Override;
|
|---|
| 353 | Property State:TButtonState Read GetState Write SetState;
|
|---|
| 354 | Public
|
|---|
| 355 | Procedure Click;Override;
|
|---|
| 356 | Published
|
|---|
| 357 | Property AllowAllUp:Boolean Read FAllowAllUp Write SetAllowAllUp;
|
|---|
| 358 | Property GroupIndex:LongInt Read FGroupIndex Write SetGroupIndex;
|
|---|
| 359 | Property Down; {after Property GroupIndex!}
|
|---|
| 360 | End;
|
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 | Function InsertButton(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 364 | Caption,Hint:String):TButton;
|
|---|
| 365 | Function InsertRadioButton(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 366 | Caption,Hint:String):TRadioButton;
|
|---|
| 367 | Function InsertCheckBox(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 368 | Caption,Hint:String):TCheckBox;
|
|---|
| 369 | Function InsertBitBtn(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 370 | Kind:TBitBtnKind;Caption,Hint:String):TBitBtn;
|
|---|
| 371 | Function InsertAnimatedButton(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 372 | BitmapId:LongWord;Caption,Hint:String):TAnimatedButton;
|
|---|
| 373 | Function InsertAnimatedButtonName(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 374 | Const BitmapId:String;Caption,Hint:String):TAnimatedButton;
|
|---|
| 375 | Function InsertSpeedButton(parent:TControl;Left,Bottom,Width,Height:LongInt;
|
|---|
| 376 | BitmapId:LongWord;Caption,Hint:String):TSpeedButton;
|
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 | Procedure SetPackedCheckBoxList(aList:Array Of TCheckBox;Value:LongWord);
|
|---|
| 380 | Function GetPackedCheckBoxList(aList:Array Of TCheckBox):LongWord;
|
|---|
| 381 | Procedure SetPackedRadioButtonList(aList:Array Of TRadioButton;Value:LongWord);
|
|---|
| 382 | Function GetPackedRadioButtonList(aList:Array Of TRadioButton):LongWord;
|
|---|
| 383 |
|
|---|
| 384 | Var
|
|---|
| 385 | ShowBitBtnGlyph:Boolean; //Show Glyphs In BitBtns
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 | Implementation
|
|---|
| 389 |
|
|---|
| 390 | {$R Buttons}
|
|---|
| 391 |
|
|---|
| 392 | Const
|
|---|
| 393 | StdBtnCaptionIds:Array[TBitBtnKind] Of LongWord=
|
|---|
| 394 | (SError, SOkButton, SCancelButton, SHelpButton, SYesButton, SNoButton, SCloseButton,
|
|---|
| 395 | SAbortButton, SRetryButton, SIgnoreButton, SAllButton, SOpenButton);
|
|---|
| 396 |
|
|---|
| 397 | StdBtnCmds:Array[TBitBtnKind] Of LongWord=
|
|---|
| 398 | (0, cmOk, cmCancel, 0, cmYes, cmNo, 0, cmAbort, cmRetry, cmIgnore,
|
|---|
| 399 | cmAll, cmOpen);
|
|---|
| 400 |
|
|---|
| 401 | StdBtnBmpIds:Array[TBitBtnKind] Of String[20]=
|
|---|
| 402 | ('', 'StdBmpOk', 'StdBmpCancel', 'StdBmpHelp', 'StdBmpYes', 'StdBmpNo',
|
|---|
| 403 | 'StdBmpClose', 'StdBmpAbort', 'StdBmpRetry', 'StdBmpIgnore', 'StdBmpAll',
|
|---|
| 404 | 'StdBmpOpen');
|
|---|
| 405 |
|
|---|
| 406 | btDefault:Boolean=True;
|
|---|
| 407 | btCancel:Boolean=False;
|
|---|
| 408 |
|
|---|
| 409 | Var
|
|---|
| 410 | StdBtnBitmapMasks:Array[TBitBtnKind] Of TBitmap;
|
|---|
| 411 | StdBtnBitmapsMasked:Array[TBitBtnKind] Of TBitmap;
|
|---|
| 412 |
|
|---|
| 413 |
|
|---|
| 414 | Function GetStdBtnBitmap(Kind:TBitBtnKind):TBitmap;
|
|---|
| 415 | Var ResId:String;
|
|---|
| 416 | Bitmap: TBitmap;
|
|---|
| 417 | Begin
|
|---|
| 418 | Result := StdBtnBitmapsMasked[Kind];
|
|---|
| 419 | If Result = Nil Then
|
|---|
| 420 | Begin
|
|---|
| 421 | ResId := StdBtnBmpIds[Kind];
|
|---|
| 422 | If ResId = '' Then Exit;
|
|---|
| 423 |
|
|---|
| 424 | Bitmap := TBitmap.Create;
|
|---|
| 425 | Bitmap.LoadFromResourceName(ResId);
|
|---|
| 426 |
|
|---|
| 427 | StdBtnBitmapMasks[Kind] := Bitmap.CreateAutoMask;
|
|---|
| 428 | StdBtnBitmapsMasked[Kind] := Bitmap.CopyMasked(StdBtnBitmapMasks[Kind]);
|
|---|
| 429 |
|
|---|
| 430 | // don't need the original resource bitmap, only the masked copy.
|
|---|
| 431 | Bitmap.Destroy;
|
|---|
| 432 |
|
|---|
| 433 | Result := StdBtnBitmapsMasked[Kind];
|
|---|
| 434 | End;
|
|---|
| 435 | End;
|
|---|
| 436 |
|
|---|
| 437 | Function GetStdBtnBitmapMask(Kind:TBitBtnKind):TBitmap;
|
|---|
| 438 | Var ResId:String;
|
|---|
| 439 | Bitmap: TBitmap;
|
|---|
| 440 | Begin
|
|---|
| 441 | Result := StdBtnBitmapMasks[Kind];
|
|---|
| 442 | If Result = Nil Then
|
|---|
| 443 | Begin
|
|---|
| 444 | GetStdBtnBitmap(Kind);
|
|---|
| 445 | Result := StdBtnBitmapMasks[Kind];
|
|---|
| 446 | End;
|
|---|
| 447 | End;
|
|---|
| 448 |
|
|---|
| 449 | {
|
|---|
| 450 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 451 | º º
|
|---|
| 452 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 453 | º º
|
|---|
| 454 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 455 | º º
|
|---|
| 456 | º This section: Some useful FUNCTIONs º
|
|---|
| 457 | º º
|
|---|
| 458 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 459 | º º
|
|---|
| 460 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | Procedure SetPackedCheckBoxList(aList:Array Of TCheckBox;Value:LongWord);
|
|---|
| 464 | Var T:LongWord;
|
|---|
| 465 | Begin
|
|---|
| 466 | For T := Low(aList) To High(aList) Do
|
|---|
| 467 | Begin
|
|---|
| 468 | aList[T].Checked := (Value And (1 Shl T)) <> 0;
|
|---|
| 469 | End;
|
|---|
| 470 | End;
|
|---|
| 471 |
|
|---|
| 472 | Function GetPackedCheckBoxList(aList:Array Of TCheckBox):LongWord;
|
|---|
| 473 | Var T:LongWord;
|
|---|
| 474 | Begin
|
|---|
| 475 | Result := 0;
|
|---|
| 476 | For T := Low(aList) To High(aList) Do
|
|---|
| 477 | If aList[T].Checked Then Result := Result Or (1 Shl T);
|
|---|
| 478 | End;
|
|---|
| 479 |
|
|---|
| 480 | Procedure SetPackedRadioButtonList(aList:Array Of TRadioButton;Value:LongWord);
|
|---|
| 481 | Var T:LongWord;
|
|---|
| 482 | Begin
|
|---|
| 483 | For T := Low(aList) To High(aList) Do
|
|---|
| 484 | Begin
|
|---|
| 485 | aList[T].Checked := Value = T;
|
|---|
| 486 | End;
|
|---|
| 487 | End;
|
|---|
| 488 |
|
|---|
| 489 | Function GetPackedRadioButtonList(aList:Array Of TRadioButton):LongWord;
|
|---|
| 490 | Var T:LongWord;
|
|---|
| 491 | Begin
|
|---|
| 492 | Result := 0;
|
|---|
| 493 | For T := Low(aList) To High(aList) Do
|
|---|
| 494 | If aList[T].Checked Then Result := T;
|
|---|
| 495 | End;
|
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 | Function InsertButton(parent:TControl;Left,Bottom,Width,Height:LongInt;Caption,Hint:String):TButton;
|
|---|
| 499 | Begin
|
|---|
| 500 | Result.Create(parent);
|
|---|
| 501 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 502 | Result.Caption := Caption;
|
|---|
| 503 | Result.TabStop := True;
|
|---|
| 504 | Result.Hint := Hint;
|
|---|
| 505 | Result.parent := parent;
|
|---|
| 506 | End;
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 | Function InsertRadioButton(parent:TControl;Left,Bottom,Width,Height:LongInt;Caption,Hint:String):TRadioButton;
|
|---|
| 510 | Begin
|
|---|
| 511 | Result.Create(parent);
|
|---|
| 512 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 513 | Result.Caption := Caption;
|
|---|
| 514 | Result.TabStop := True;
|
|---|
| 515 | Result.Hint := Hint;
|
|---|
| 516 | Result.parent := parent;
|
|---|
| 517 | End;
|
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 | Function InsertCheckBox(parent:TControl;Left,Bottom,Width,Height:LongInt;Caption,Hint:String):TCheckBox;
|
|---|
| 521 | Begin
|
|---|
| 522 | Result.Create(parent);
|
|---|
| 523 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 524 | Result.Caption := Caption;
|
|---|
| 525 | Result.TabStop := True;
|
|---|
| 526 | Result.Hint := Hint;
|
|---|
| 527 | Result.parent := parent;
|
|---|
| 528 | End;
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 | Function InsertBitBtn(parent:TControl;Left,Bottom,Width,Height:LongInt;Kind:TBitBtnKind;Caption,Hint:String):TBitBtn;
|
|---|
| 532 | Begin
|
|---|
| 533 | Result.Create(parent);
|
|---|
| 534 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 535 | Result.TabStop := True;
|
|---|
| 536 | Result.Hint := Hint;
|
|---|
| 537 | Result.parent := parent;
|
|---|
| 538 | Result.Kind := Kind;
|
|---|
| 539 | Result.Caption := Caption;
|
|---|
| 540 | End;
|
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 | Function InsertAnimatedButton(parent:TControl;Left,Bottom,Width,Height:LongInt;BitmapId:LongWord;Caption,Hint:String):TAnimatedButton;
|
|---|
| 544 | Begin
|
|---|
| 545 | Result.Create(parent);
|
|---|
| 546 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 547 | Result.Caption := Caption;
|
|---|
| 548 | Result.TabStop := True;
|
|---|
| 549 | Result.Hint := Hint;
|
|---|
| 550 | If BitmapId <> 0 Then Result.Glyph.LoadFromResourceId(BitmapId);
|
|---|
| 551 | Result.parent := parent;
|
|---|
| 552 | End;
|
|---|
| 553 |
|
|---|
| 554 | Function InsertAnimatedButtonName(parent:TControl;Left,Bottom,Width,Height:LongInt;Const BitmapId:String;Caption,Hint:String):TAnimatedButton;
|
|---|
| 555 | Begin
|
|---|
| 556 | Result.Create(parent);
|
|---|
| 557 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 558 | Result.Caption := Caption;
|
|---|
| 559 | Result.TabStop := True;
|
|---|
| 560 | Result.Hint := Hint;
|
|---|
| 561 | If BitmapId <> '' Then Result.Glyph.LoadFromResourceName(BitmapId);
|
|---|
| 562 | Result.parent := parent;
|
|---|
| 563 | End;
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 | Function InsertSpeedButton(parent:TControl;Left,Bottom,Width,Height:LongInt;BitmapId:LongWord;Caption,Hint:String):TSpeedButton;
|
|---|
| 567 | Begin
|
|---|
| 568 | Result.Create(parent);
|
|---|
| 569 | Result.SetWindowPos(Left,Bottom,Width,Height);
|
|---|
| 570 | Result.Caption := Caption;
|
|---|
| 571 | Result.TabStop := False;
|
|---|
| 572 | Result.Hint := Hint;
|
|---|
| 573 | If BitmapId <> 0 Then Result.Glyph.LoadFromResourceId(BitmapId);
|
|---|
| 574 | Result.parent := parent;
|
|---|
| 575 | End;
|
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 | {
|
|---|
| 579 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 580 | º º
|
|---|
| 581 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 582 | º º
|
|---|
| 583 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 584 | º º
|
|---|
| 585 | º This section: TButtonControl Class Implementation º
|
|---|
| 586 | º º
|
|---|
| 587 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 588 | º º
|
|---|
| 589 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | Procedure TButtonControl.SetupComponent;
|
|---|
| 593 | Begin
|
|---|
| 594 | Inherited SetupComponent;
|
|---|
| 595 |
|
|---|
| 596 | Name := 'ButtonControl';
|
|---|
| 597 | Height := 30;
|
|---|
| 598 | Width := 80;
|
|---|
| 599 | Ownerdraw := False;
|
|---|
| 600 | PenColor := clBtnText;
|
|---|
| 601 | color := clBtnFace;
|
|---|
| 602 | ParentPenColor := False;
|
|---|
| 603 | ParentColor := False;
|
|---|
| 604 | End;
|
|---|
| 605 |
|
|---|
| 606 |
|
|---|
| 607 | Procedure TButtonControl.GetClassData(Var ClassData:TClassData);
|
|---|
| 608 | Begin
|
|---|
| 609 | Inherited GetClassData(ClassData);
|
|---|
| 610 |
|
|---|
| 611 | {$IFDEF OS2}
|
|---|
| 612 | ClassData.ClassULong := WC_BUTTON;
|
|---|
| 613 | {$ENDIF}
|
|---|
| 614 | {$IFDEF Win95}
|
|---|
| 615 | CreateSubClass(ClassData,'BUTTON');
|
|---|
| 616 | {$ENDIF}
|
|---|
| 617 | End;
|
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 | Procedure TButtonControl.ParentNotification(Var Msg:TMessage);
|
|---|
| 621 | Begin
|
|---|
| 622 | Inherited ParentNotification(Msg);
|
|---|
| 623 |
|
|---|
| 624 | If Designed Then Exit;
|
|---|
| 625 |
|
|---|
| 626 | {$IFDEF OS2}
|
|---|
| 627 | If Msg.Param1Hi In [BN_CLICKED,BN_DBLCLICKED] Then
|
|---|
| 628 | {$ENDIF}
|
|---|
| 629 | {$IFDEF Win95}
|
|---|
| 630 | If Msg.Param1Hi In [BN_CLICKED,BN_DOUBLECLICKED] Then
|
|---|
| 631 | {$ENDIF}
|
|---|
| 632 | Begin
|
|---|
| 633 | Click;
|
|---|
| 634 | Msg.Handled := True;
|
|---|
| 635 | Msg.Result := 0;
|
|---|
| 636 | End;
|
|---|
| 637 | End;
|
|---|
| 638 |
|
|---|
| 639 |
|
|---|
| 640 | Procedure TButtonControl.Click;
|
|---|
| 641 | Begin
|
|---|
| 642 | If FOnClick <> Nil Then FOnClick(Self);
|
|---|
| 643 | End;
|
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 | Function TButtonControl.EvaluateShortCut(KeyCode:TKeyCode):Boolean;
|
|---|
| 647 | Var S:String;
|
|---|
| 648 | P:Integer;
|
|---|
| 649 | key:TKeyCode;
|
|---|
| 650 | Begin
|
|---|
| 651 | S := Caption;
|
|---|
| 652 | P := Pos(MnemoChar,S); { & }
|
|---|
| 653 | If (P > 0) And (P < Length(S)) Then
|
|---|
| 654 | Begin
|
|---|
| 655 | key := (Ord(S[P+1]) Or $20) + kb_Alt + kb_Char;
|
|---|
| 656 | If key = KeyCode Then
|
|---|
| 657 | Begin
|
|---|
| 658 | Click;
|
|---|
| 659 | Result := True;
|
|---|
| 660 | Exit;
|
|---|
| 661 | End;
|
|---|
| 662 | End;
|
|---|
| 663 | Result := Inherited EvaluateShortCut(KeyCode);
|
|---|
| 664 | End;
|
|---|
| 665 |
|
|---|
| 666 |
|
|---|
| 667 | {
|
|---|
| 668 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 669 | º º
|
|---|
| 670 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 671 | º º
|
|---|
| 672 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 673 | º º
|
|---|
| 674 | º This section: TRadioButton Class Implementation º
|
|---|
| 675 | º º
|
|---|
| 676 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 677 | º º
|
|---|
| 678 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 679 | }
|
|---|
| 680 |
|
|---|
| 681 | Procedure TRadioButton.SetupComponent;
|
|---|
| 682 | Begin
|
|---|
| 683 | Inherited SetupComponent;
|
|---|
| 684 |
|
|---|
| 685 | Name := 'RadioButton';
|
|---|
| 686 | Caption := Name;
|
|---|
| 687 | Height := 20;
|
|---|
| 688 | Width := 130;
|
|---|
| 689 | PenColor := clWindowText;
|
|---|
| 690 | ParentPenColor := False;
|
|---|
| 691 | ParentColor := True;
|
|---|
| 692 | FInitChecked := False;
|
|---|
| 693 | End;
|
|---|
| 694 |
|
|---|
| 695 |
|
|---|
| 696 | Procedure TRadioButton.CreateParams(Var Params:TCreateParams);
|
|---|
| 697 | Begin
|
|---|
| 698 | Inherited CreateParams(Params);
|
|---|
| 699 |
|
|---|
| 700 | {$IFDEF OS2}
|
|---|
| 701 | Params.Style := Params.Style Or BS_RADIOBUTTON;
|
|---|
| 702 | {$ENDIF}
|
|---|
| 703 | {$IFDEF Win95}
|
|---|
| 704 | Params.Style := Params.Style Or BS_AUTORADIOBUTTON;
|
|---|
| 705 | {$ENDIF}
|
|---|
| 706 | End;
|
|---|
| 707 |
|
|---|
| 708 |
|
|---|
| 709 | Procedure TRadioButton.CreateWnd;
|
|---|
| 710 | Begin
|
|---|
| 711 | Inherited CreateWnd;
|
|---|
| 712 |
|
|---|
| 713 | SetChecked(FInitChecked);
|
|---|
| 714 | End;
|
|---|
| 715 |
|
|---|
| 716 |
|
|---|
| 717 | Function TRadioButton.GetChecked:Boolean;
|
|---|
| 718 | Var res:Word;
|
|---|
| 719 | Begin
|
|---|
| 720 | Result := FInitChecked;
|
|---|
| 721 | If Handle = 0 Then Exit;
|
|---|
| 722 |
|
|---|
| 723 | {$IFDEF OS2}
|
|---|
| 724 | res := WinSendMsg(Handle,BM_QUERYCHECK,0,0);
|
|---|
| 725 | {$ENDIF}
|
|---|
| 726 | {$IFDEF Win95}
|
|---|
| 727 | res := SendMessage(Handle,BM_GETCHECK,0,0);
|
|---|
| 728 | {$ENDIF}
|
|---|
| 729 | Result := (res = 1);
|
|---|
| 730 | End;
|
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 | {$IFDEF OS2}
|
|---|
| 734 | Function GetGroup(Radio:TControl):TControl;
|
|---|
| 735 | Var ARadioRec,AChildRec:TRect;
|
|---|
| 736 | AChild:TControl;
|
|---|
| 737 | I:LongInt;
|
|---|
| 738 | Begin
|
|---|
| 739 | Result := Radio.parent;
|
|---|
| 740 | If Result = Nil Then Exit;
|
|---|
| 741 |
|
|---|
| 742 | ARadioRec := Radio.WindowRect;
|
|---|
| 743 |
|
|---|
| 744 | For I := 0 To Radio.parent.ControlCount-1 Do
|
|---|
| 745 | Begin
|
|---|
| 746 | AChild := Radio.parent.Controls[I];
|
|---|
| 747 | AChildRec := AChild.WindowRect;
|
|---|
| 748 |
|
|---|
| 749 | If RectInRect(ARadioRec,AChildRec) Then
|
|---|
| 750 | Begin
|
|---|
| 751 | If Result <> Radio.parent Then {Select the smallest group}
|
|---|
| 752 | Begin
|
|---|
| 753 | If RectInRect(AChildRec,Result.WindowRect)
|
|---|
| 754 | Then Result := AChild;
|
|---|
| 755 | End
|
|---|
| 756 | Else Result := AChild;
|
|---|
| 757 | End;
|
|---|
| 758 | End;
|
|---|
| 759 | End;
|
|---|
| 760 |
|
|---|
| 761 |
|
|---|
| 762 | Procedure DeCheckAllRadiosInGroup(actual:TControl);
|
|---|
| 763 | Var T:LongInt;
|
|---|
| 764 | group:TControl;
|
|---|
| 765 | Radio:TRadioButton;
|
|---|
| 766 | Begin
|
|---|
| 767 | group := GetGroup(actual);
|
|---|
| 768 | If group = Nil Then Exit;
|
|---|
| 769 |
|
|---|
| 770 | For T := 0 To actual.parent.ControlCount-1 Do
|
|---|
| 771 | Begin
|
|---|
| 772 | Radio := TRadioButton(actual.parent.Controls[T]);
|
|---|
| 773 | If Radio Is TRadioButton Then
|
|---|
| 774 | If Radio <> actual Then
|
|---|
| 775 | If GetGroup(Radio) = group Then Radio.SetChecked(False);
|
|---|
| 776 | End;
|
|---|
| 777 | End;
|
|---|
| 778 | {$ENDIF}
|
|---|
| 779 |
|
|---|
| 780 |
|
|---|
| 781 | Procedure TRadioButton.SetChecked(NewState:Boolean);
|
|---|
| 782 | Begin
|
|---|
| 783 | FInitChecked := NewState;
|
|---|
| 784 | If Handle = 0 Then Exit;
|
|---|
| 785 | If NewState = GetChecked Then Exit;
|
|---|
| 786 |
|
|---|
| 787 | If NewState = True Then
|
|---|
| 788 | Begin
|
|---|
| 789 | {$IFDEF OS2}
|
|---|
| 790 | DeCheckAllRadiosInGroup(Self);
|
|---|
| 791 | {$ENDIF}
|
|---|
| 792 | SendMsg(Handle,BM_SETCHECK,1,0);
|
|---|
| 793 | End
|
|---|
| 794 | Else SendMsg(Handle,BM_SETCHECK,0,0)
|
|---|
| 795 | End;
|
|---|
| 796 |
|
|---|
| 797 |
|
|---|
| 798 | Procedure TRadioButton.Click;
|
|---|
| 799 | Begin
|
|---|
| 800 | SetChecked(True);
|
|---|
| 801 |
|
|---|
| 802 | Inherited Click;
|
|---|
| 803 | End;
|
|---|
| 804 |
|
|---|
| 805 | Procedure TRadioButton.SetFocus;
|
|---|
| 806 | Begin
|
|---|
| 807 | Click;
|
|---|
| 808 | End;
|
|---|
| 809 |
|
|---|
| 810 | {
|
|---|
| 811 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 812 | º º
|
|---|
| 813 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 814 | º º
|
|---|
| 815 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 816 | º º
|
|---|
| 817 | º This section: TCheckBox Class Implementation º
|
|---|
| 818 | º º
|
|---|
| 819 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 820 | º º
|
|---|
| 821 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 822 | }
|
|---|
| 823 |
|
|---|
| 824 | Procedure TCheckBox.SetupComponent;
|
|---|
| 825 | Begin
|
|---|
| 826 | Inherited SetupComponent;
|
|---|
| 827 |
|
|---|
| 828 | Name := 'CheckBox';
|
|---|
| 829 | Caption := Name;
|
|---|
| 830 | Height := 20;
|
|---|
| 831 | Width := 130;
|
|---|
| 832 | PenColor := clWindowText;
|
|---|
| 833 | ParentPenColor := False;
|
|---|
| 834 | ParentColor := True;
|
|---|
| 835 | FInitState := cbUnchecked;
|
|---|
| 836 | End;
|
|---|
| 837 |
|
|---|
| 838 |
|
|---|
| 839 | Procedure TCheckBox.CreateParams(Var Params:TCreateParams);
|
|---|
| 840 | Begin
|
|---|
| 841 | Inherited CreateParams(Params);
|
|---|
| 842 |
|
|---|
| 843 | Params.Style := Params.Style Or BS_3STATE;
|
|---|
| 844 | End;
|
|---|
| 845 |
|
|---|
| 846 |
|
|---|
| 847 | Procedure TCheckBox.CreateWnd;
|
|---|
| 848 | Begin
|
|---|
| 849 | Inherited CreateWnd;
|
|---|
| 850 |
|
|---|
| 851 | SetState(FInitState);
|
|---|
| 852 | End;
|
|---|
| 853 |
|
|---|
| 854 |
|
|---|
| 855 | Procedure TCheckBox.Click;
|
|---|
| 856 | Begin
|
|---|
| 857 | Toggle;
|
|---|
| 858 |
|
|---|
| 859 | Inherited Click;
|
|---|
| 860 | End;
|
|---|
| 861 |
|
|---|
| 862 |
|
|---|
| 863 | Procedure TCheckBox.Toggle;
|
|---|
| 864 | Begin
|
|---|
| 865 | Case State Of
|
|---|
| 866 | cbUnchecked: If AllowGrayed Then State := cbGrayed
|
|---|
| 867 | Else State := cbChecked;
|
|---|
| 868 | cbChecked: State := cbUnchecked;
|
|---|
| 869 | cbGrayed: State := cbChecked;
|
|---|
| 870 | End;
|
|---|
| 871 | End;
|
|---|
| 872 |
|
|---|
| 873 |
|
|---|
| 874 | Procedure TCheckBox.SetChecked(NewState:Boolean);
|
|---|
| 875 | Begin
|
|---|
| 876 | If NewState Then State := cbChecked
|
|---|
| 877 | Else State := cbUnchecked;
|
|---|
| 878 | End;
|
|---|
| 879 |
|
|---|
| 880 |
|
|---|
| 881 | Function TCheckBox.GetChecked:Boolean;
|
|---|
| 882 | Begin
|
|---|
| 883 | Result := State = cbChecked;
|
|---|
| 884 | End;
|
|---|
| 885 |
|
|---|
| 886 |
|
|---|
| 887 | Procedure TCheckBox.SetState(NewState:TCheckBoxState);
|
|---|
| 888 | Begin
|
|---|
| 889 | FInitState := NewState;
|
|---|
| 890 | If NewState = GetState Then Exit;
|
|---|
| 891 | If Handle = 0 Then Exit;
|
|---|
| 892 |
|
|---|
| 893 | SendMsg(Handle,BM_SETCHECK,LongWord(FInitState),0);
|
|---|
| 894 | End;
|
|---|
| 895 |
|
|---|
| 896 |
|
|---|
| 897 | Function TCheckBox.GetState:TCheckBoxState;
|
|---|
| 898 | Var res:Word;
|
|---|
| 899 | Begin
|
|---|
| 900 | Result := FInitState;
|
|---|
| 901 | If Handle = 0 Then Exit;
|
|---|
| 902 |
|
|---|
| 903 | {$IFDEF OS2}
|
|---|
| 904 | res := WinSendMsg(Handle,BM_QUERYCHECK,0,0);
|
|---|
| 905 | {$ENDIF}
|
|---|
| 906 | {$IFDEF Win95}
|
|---|
| 907 | res := SendMessage(Handle,BM_GETCHECK,0,0);
|
|---|
| 908 | {$ENDIF}
|
|---|
| 909 | Result := TCheckBoxState(res);
|
|---|
| 910 | End;
|
|---|
| 911 |
|
|---|
| 912 |
|
|---|
| 913 | {
|
|---|
| 914 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 915 | º º
|
|---|
| 916 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 917 | º º
|
|---|
| 918 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 919 | º º
|
|---|
| 920 | º This section: TButton Class Implementation º
|
|---|
| 921 | º º
|
|---|
| 922 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 923 | º º
|
|---|
| 924 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | Procedure TButton.SetupComponent;
|
|---|
| 928 | Begin
|
|---|
| 929 | Inherited SetupComponent;
|
|---|
| 930 |
|
|---|
| 931 | Name := 'Button';
|
|---|
| 932 | Caption := Name;
|
|---|
| 933 | Height := 30;
|
|---|
| 934 | Width := 80;
|
|---|
| 935 | PenColor := clBtnText;
|
|---|
| 936 | color := clBtnFace;
|
|---|
| 937 | ParentPenColor := False;
|
|---|
| 938 | ParentColor := False;
|
|---|
| 939 | FDefault := False;
|
|---|
| 940 | End;
|
|---|
| 941 |
|
|---|
| 942 |
|
|---|
| 943 | Procedure TButton.CreateParams(Var Params:TCreateParams);
|
|---|
| 944 | Begin
|
|---|
| 945 | Inherited CreateParams(Params);
|
|---|
| 946 |
|
|---|
| 947 | {$IFDEF OS2}
|
|---|
| 948 | Params.Style := Params.Style Or BS_PUSHBUTTON;
|
|---|
| 949 | If FDefault Then Params.Style := Params.Style Or BS_DEFAULT;
|
|---|
| 950 | {$ENDIF}
|
|---|
| 951 | {$IFDEF Win95}
|
|---|
| 952 | If FDefault Then Params.Style := Params.Style Or BS_DEFPUSHBUTTON
|
|---|
| 953 | Else Params.Style := Params.Style Or BS_PUSHBUTTON;
|
|---|
| 954 | {$ENDIF}
|
|---|
| 955 | End;
|
|---|
| 956 |
|
|---|
| 957 |
|
|---|
| 958 | Procedure TButton.SetupShow;
|
|---|
| 959 | Begin
|
|---|
| 960 | Inherited SetupShow;
|
|---|
| 961 | SetDefault(FDefault); {Update the Form}
|
|---|
| 962 | SetCancel(FCancel); {Update the Form}
|
|---|
| 963 | End;
|
|---|
| 964 |
|
|---|
| 965 |
|
|---|
| 966 | Procedure TButton.SetFocus;
|
|---|
| 967 | Begin
|
|---|
| 968 | Inherited SetFocus;
|
|---|
| 969 | SetDefault(True);
|
|---|
| 970 | End;
|
|---|
| 971 |
|
|---|
| 972 |
|
|---|
| 973 | Procedure TButton.SetDefault(Value:Boolean);
|
|---|
| 974 | Var DefBtn:TButton;
|
|---|
| 975 | Begin
|
|---|
| 976 | FDefault := Value;
|
|---|
| 977 | If Handle <> 0 Then
|
|---|
| 978 | Begin
|
|---|
| 979 | {$IFDEF OS2}
|
|---|
| 980 | WinSendMsg(Handle,BM_SETDEFAULT,LongWord(FDefault),0);
|
|---|
| 981 | {$ENDIF}
|
|---|
| 982 | {$IFDEF Win95}
|
|---|
| 983 | If FDefault Then SendMessage(Handle,BM_SETSTYLE,BS_DEFPUSHBUTTON,1)
|
|---|
| 984 | Else SendMessage(Handle,BM_SETSTYLE,BS_PUSHBUTTON,1);
|
|---|
| 985 | {$ENDIF}
|
|---|
| 986 | End;
|
|---|
| 987 |
|
|---|
| 988 | If Form Is TForm Then
|
|---|
| 989 | Begin
|
|---|
| 990 | DefBtn := GetFormButton(btDefault);
|
|---|
| 991 | If FDefault Then
|
|---|
| 992 | Begin
|
|---|
| 993 | If DefBtn Is TButton Then
|
|---|
| 994 | If DefBtn <> Self Then DefBtn.Default := False;
|
|---|
| 995 |
|
|---|
| 996 | SetFormButton(btDefault,Self);
|
|---|
| 997 | End
|
|---|
| 998 | Else If DefBtn = Self Then SetFormButton(btDefault,Nil);
|
|---|
| 999 | End;
|
|---|
| 1000 | End;
|
|---|
| 1001 |
|
|---|
| 1002 |
|
|---|
| 1003 | Procedure TButton.SetCancel(Value:Boolean);
|
|---|
| 1004 | Var EscBtn:TButton;
|
|---|
| 1005 | Begin
|
|---|
| 1006 | FCancel := Value;
|
|---|
| 1007 |
|
|---|
| 1008 | If Form Is TForm Then
|
|---|
| 1009 | Begin
|
|---|
| 1010 | EscBtn := GetFormButton(btCancel);
|
|---|
| 1011 | If FCancel Then
|
|---|
| 1012 | Begin
|
|---|
| 1013 | If EscBtn Is TButton Then
|
|---|
| 1014 | If EscBtn <> Self Then EscBtn.Cancel := False;
|
|---|
| 1015 |
|
|---|
| 1016 | SetFormButton(btCancel,Self);
|
|---|
| 1017 | End
|
|---|
| 1018 | Else If EscBtn = Self Then SetFormButton(btCancel,Nil);;
|
|---|
| 1019 | End;
|
|---|
| 1020 | End;
|
|---|
| 1021 |
|
|---|
| 1022 |
|
|---|
| 1023 | Destructor TButton.Destroy;
|
|---|
| 1024 | Begin
|
|---|
| 1025 | If Form Is TForm Then
|
|---|
| 1026 | Begin
|
|---|
| 1027 | If GetFormButton(btDefault) = Self Then SetFormButton(btDefault,Nil);
|
|---|
| 1028 | If GetFormButton(btCancel) = Self Then SetFormButton(btCancel,Nil);
|
|---|
| 1029 | End;
|
|---|
| 1030 | Inherited Destroy;
|
|---|
| 1031 | End;
|
|---|
| 1032 |
|
|---|
| 1033 |
|
|---|
| 1034 | Procedure TButton.Click;
|
|---|
| 1035 | Begin
|
|---|
| 1036 | Inherited Click;
|
|---|
| 1037 |
|
|---|
| 1038 | If parent <> Nil Then
|
|---|
| 1039 | Begin
|
|---|
| 1040 | If ComponentState * [csDetail] = [] Then
|
|---|
| 1041 | Begin
|
|---|
| 1042 | If Form <> Nil Then
|
|---|
| 1043 | Begin
|
|---|
| 1044 | If ModalResult<>cmNull Then
|
|---|
| 1045 | Form.ModalResult := ModalResult;
|
|---|
| 1046 | {force To Handle the modal Result}
|
|---|
| 1047 | SendMsg(Form.Handle,CM_COMMAND,Command{cmNull},0);
|
|---|
| 1048 | End;
|
|---|
| 1049 | End
|
|---|
| 1050 | Else SendMsg(parent.Handle,CM_COMMAND,Command,0)
|
|---|
| 1051 | End;
|
|---|
| 1052 | End;
|
|---|
| 1053 |
|
|---|
| 1054 |
|
|---|
| 1055 | Function TButton.GetFormButton(Default:Boolean):TButton;
|
|---|
| 1056 | Var mp1:LongWord;
|
|---|
| 1057 | Begin
|
|---|
| 1058 | Result := Nil;
|
|---|
| 1059 | If Form <> Nil Then
|
|---|
| 1060 | Begin
|
|---|
| 1061 | If Default Then mp1 := 3
|
|---|
| 1062 | Else mp1 := 4;
|
|---|
| 1063 | Result := TButton(Form.Perform(CM_UPDATEBUTTONS,mp1,0));
|
|---|
| 1064 | End;
|
|---|
| 1065 | End;
|
|---|
| 1066 |
|
|---|
| 1067 |
|
|---|
| 1068 | Procedure TButton.SetFormButton(Default:Boolean;Button:TButton);
|
|---|
| 1069 | Var mp1:LongWord;
|
|---|
| 1070 | Begin
|
|---|
| 1071 | If Form <> Nil Then
|
|---|
| 1072 | Begin
|
|---|
| 1073 | If Default Then mp1 := 1
|
|---|
| 1074 | Else mp1 := 2;
|
|---|
| 1075 | Form.Perform(CM_UPDATEBUTTONS,mp1,LongWord(Button));
|
|---|
| 1076 | End;
|
|---|
| 1077 | End;
|
|---|
| 1078 |
|
|---|
| 1079 |
|
|---|
| 1080 | {
|
|---|
| 1081 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 1082 | º º
|
|---|
| 1083 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 1084 | º º
|
|---|
| 1085 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 1086 | º º
|
|---|
| 1087 | º This section: TBitBtn Class Implementation º
|
|---|
| 1088 | º º
|
|---|
| 1089 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 1090 | º º
|
|---|
| 1091 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 1092 | }
|
|---|
| 1093 |
|
|---|
| 1094 | Procedure TBitBtn.SetupComponent;
|
|---|
| 1095 | Begin
|
|---|
| 1096 | Inherited SetupComponent;
|
|---|
| 1097 |
|
|---|
| 1098 | Name := 'BitBtn';
|
|---|
| 1099 | Caption := Name;
|
|---|
| 1100 | Height := 30;
|
|---|
| 1101 | Width := 100;
|
|---|
| 1102 | PenColor := clBtnText;
|
|---|
| 1103 | color := clBtnFace;
|
|---|
| 1104 | Ownerdraw := True;
|
|---|
| 1105 | FBitmap := Nil;
|
|---|
| 1106 | FDown := False;
|
|---|
| 1107 | FSpaceDown := False;
|
|---|
| 1108 | FLayout := blGlyphLeft;
|
|---|
| 1109 | FMargin := -1;
|
|---|
| 1110 | FSpacing := 4;
|
|---|
| 1111 | FKind := bkCustom;
|
|---|
| 1112 | InRedraw := False;
|
|---|
| 1113 | FNumGlyphs:=1;
|
|---|
| 1114 | End;
|
|---|
| 1115 |
|
|---|
| 1116 |
|
|---|
| 1117 | Procedure TBitBtn.SetNumGlyphs(NewValue:TNumGlyphs);
|
|---|
| 1118 | Begin
|
|---|
| 1119 | If NewValue<0 Then NewValue:=1
|
|---|
| 1120 | Else If NewValue>4 Then NewValue:=4;
|
|---|
| 1121 | If NewValue=FNumGlyphs Then exit;
|
|---|
| 1122 | FNumGlyphs:=NewValue;
|
|---|
| 1123 | Arrange;
|
|---|
| 1124 | Invalidate;
|
|---|
| 1125 | End;
|
|---|
| 1126 |
|
|---|
| 1127 |
|
|---|
| 1128 | Procedure TBitBtn.GetClassData(Var ClassData:TClassData);
|
|---|
| 1129 | Begin
|
|---|
| 1130 | {$IFDEF OS2}
|
|---|
| 1131 | Inherited GetClassData(ClassData);
|
|---|
| 1132 | {$ENDIF}
|
|---|
| 1133 | {$IFDEF Win95}
|
|---|
| 1134 | TControl.GetClassData(ClassData); {no WC_BUTTON !}
|
|---|
| 1135 | {$ENDIF}
|
|---|
| 1136 | End;
|
|---|
| 1137 |
|
|---|
| 1138 |
|
|---|
| 1139 | Procedure TBitBtn.CreateParams(Var Params:TCreateParams);
|
|---|
| 1140 | Begin
|
|---|
| 1141 | TControl.CreateParams(Params);
|
|---|
| 1142 |
|
|---|
| 1143 | {$IFDEF OS2}
|
|---|
| 1144 | Params.Style := Params.Style Or BS_USERBUTTON;
|
|---|
| 1145 | {$ENDIF}
|
|---|
| 1146 | End;
|
|---|
| 1147 |
|
|---|
| 1148 |
|
|---|
| 1149 | Procedure TBitBtn.SetupShow;
|
|---|
| 1150 | Begin
|
|---|
| 1151 | Inherited SetupShow;
|
|---|
| 1152 |
|
|---|
| 1153 | Arrange;
|
|---|
| 1154 | {force To send the Window Message}
|
|---|
| 1155 | If FDown Then
|
|---|
| 1156 | Begin
|
|---|
| 1157 | FDown := False; {dont ignore SetDown}
|
|---|
| 1158 | SetDown(True);
|
|---|
| 1159 | End;
|
|---|
| 1160 | End;
|
|---|
| 1161 |
|
|---|
| 1162 |
|
|---|
| 1163 | Destructor TBitBtn.Destroy;
|
|---|
| 1164 | Begin
|
|---|
| 1165 | If FBitmap <> Nil Then FBitmap.Destroy;
|
|---|
| 1166 | FBitmap := Nil;
|
|---|
| 1167 |
|
|---|
| 1168 | Inherited Destroy;
|
|---|
| 1169 | End;
|
|---|
| 1170 |
|
|---|
| 1171 |
|
|---|
| 1172 | Procedure TBitBtn.RealignControls;
|
|---|
| 1173 | Begin
|
|---|
| 1174 | Arrange;
|
|---|
| 1175 | Invalidate;
|
|---|
| 1176 | End;
|
|---|
| 1177 |
|
|---|
| 1178 |
|
|---|
| 1179 | Procedure TBitBtn.FontChange;
|
|---|
| 1180 | Begin
|
|---|
| 1181 | RealignControls;
|
|---|
| 1182 |
|
|---|
| 1183 | Inherited FontChange;
|
|---|
| 1184 | End;
|
|---|
| 1185 |
|
|---|
| 1186 |
|
|---|
| 1187 | {$IFDEF Win95}
|
|---|
| 1188 | Procedure TBitBtn.WMKeyDown(Var Msg:TMessage);
|
|---|
| 1189 | Var KeyCode:LongInt;
|
|---|
| 1190 | Begin
|
|---|
| 1191 | Inherited;
|
|---|
| 1192 |
|
|---|
| 1193 | Msg.Handled := True;
|
|---|
| 1194 | If IsControlLocked(Self) Then Exit;
|
|---|
| 1195 |
|
|---|
| 1196 | KeyCode := Msg.Param1;
|
|---|
| 1197 | If KeyCode = VK_SPACE Then
|
|---|
| 1198 | If Not FSpaceDown Then
|
|---|
| 1199 | Begin
|
|---|
| 1200 | FSpaceDown := True;
|
|---|
| 1201 | MouseDown(mbLeft,[],0,0);
|
|---|
| 1202 | End;
|
|---|
| 1203 | End;
|
|---|
| 1204 |
|
|---|
| 1205 |
|
|---|
| 1206 | Procedure TBitBtn.WMKeyUp(Var Msg:TMessage);
|
|---|
| 1207 | Var KeyCode:LongInt;
|
|---|
| 1208 | Begin
|
|---|
| 1209 | Inherited;
|
|---|
| 1210 |
|
|---|
| 1211 | Msg.Handled := True;
|
|---|
| 1212 | If IsControlLocked(Self) Then Exit;
|
|---|
| 1213 |
|
|---|
| 1214 | KeyCode := Msg.Param1;
|
|---|
| 1215 | If KeyCode = VK_SPACE Then
|
|---|
| 1216 | If FSpaceDown Then
|
|---|
| 1217 | Begin
|
|---|
| 1218 | FSpaceDown := False;
|
|---|
| 1219 | MouseUp(mbLeft,[],0,0);
|
|---|
| 1220 | End;
|
|---|
| 1221 |
|
|---|
| 1222 | If KeyCode = VK_ESCAPE Then
|
|---|
| 1223 | If FSpaceDown Then
|
|---|
| 1224 | Begin
|
|---|
| 1225 | FSpaceDown := False;
|
|---|
| 1226 | MouseUp(mbLeft,[],-1,-1); {no Click}
|
|---|
| 1227 | End;
|
|---|
| 1228 | End;
|
|---|
| 1229 | {$ENDIF}
|
|---|
| 1230 |
|
|---|
| 1231 |
|
|---|
| 1232 | {$IFDEF OS2}
|
|---|
| 1233 | Procedure TBitBtn.ParentNotification(Var Msg:TMessage);
|
|---|
| 1234 | Var pUserBtn:PUSERBUTTON;
|
|---|
| 1235 | Begin
|
|---|
| 1236 | TControl.ParentNotification(Msg);
|
|---|
| 1237 |
|
|---|
| 1238 | If Designed Then Exit;
|
|---|
| 1239 |
|
|---|
| 1240 | Case Msg.Param1Hi Of
|
|---|
| 1241 | BN_CLICKED:
|
|---|
| 1242 | Begin
|
|---|
| 1243 | {OS2: Param2 Contains the Handle, If the Message was WM_CONTROL
|
|---|
| 1244 | To avoid duplicate Click only Use the WM_COMMAND event}
|
|---|
| 1245 | If Msg.Param2 <> 0 Then Exit;
|
|---|
| 1246 | Click;
|
|---|
| 1247 | End;
|
|---|
| 1248 | BN_PAINT:
|
|---|
| 1249 | Begin
|
|---|
| 1250 | pUserBtn := Pointer(Msg.Param2);
|
|---|
| 1251 | FDefault := (pUserBtn^.fsState And BDS_DEFAULT) <> 0;
|
|---|
| 1252 | Paint(ClientRect);
|
|---|
| 1253 | End;
|
|---|
| 1254 | End;
|
|---|
| 1255 | Msg.Handled := True;
|
|---|
| 1256 | Msg.Result := 0;
|
|---|
| 1257 | End;
|
|---|
| 1258 | {$ENDIF}
|
|---|
| 1259 |
|
|---|
| 1260 | Procedure TBitBtn.Arrange;
|
|---|
| 1261 | Var space:LongInt;
|
|---|
| 1262 | rc1:TRect;
|
|---|
| 1263 | S,S1,S2:String;
|
|---|
| 1264 | P:Integer;
|
|---|
| 1265 | FBmp:TBitmap;
|
|---|
| 1266 | CX,CY:LongInt;
|
|---|
| 1267 | Begin
|
|---|
| 1268 | If Canvas = Nil Then Exit;
|
|---|
| 1269 | rc1 := ClientRect;
|
|---|
| 1270 | Inc(rc1.Right);
|
|---|
| 1271 | Inc(rc1.Top);
|
|---|
| 1272 | {Size Of the Output String}
|
|---|
| 1273 | S := ReplaceMnemo(Caption);
|
|---|
| 1274 | P := Pos(MnemoChar,S);
|
|---|
| 1275 | IsMnemo := (P > 0) And (P < Length(S));
|
|---|
| 1276 | If IsMnemo Then
|
|---|
| 1277 | Begin
|
|---|
| 1278 | s1 := S;
|
|---|
| 1279 | {Draw normal portion}
|
|---|
| 1280 | s2 := Copy(s1,1,P-1);
|
|---|
| 1281 | Delete(s1,1,P); {incl. MnemoChar}
|
|---|
| 1282 | Canvas.GetTextExtent(s2,CX,CY);
|
|---|
| 1283 | txt.Width:=CX;
|
|---|
| 1284 | txt.Height:=CY;
|
|---|
| 1285 |
|
|---|
| 1286 | {Draw underlines portion}
|
|---|
| 1287 | s2 := Copy(s1,1,1); {Mnemo}
|
|---|
| 1288 | Delete(s1,1,1);
|
|---|
| 1289 | Canvas.GetTextExtent(s2,CX,CY);
|
|---|
| 1290 | inc(txt.Width,CX);
|
|---|
| 1291 | If CY>txt.Height Then txt.Height:=CY;
|
|---|
| 1292 |
|
|---|
| 1293 | {Draw rest portion}
|
|---|
| 1294 | s2 := s1;
|
|---|
| 1295 | Canvas.GetTextExtent(s2,CX,CY);
|
|---|
| 1296 | inc(txt.Width,CX);
|
|---|
| 1297 | If CY>txt.Height Then txt.Height:=CY;
|
|---|
| 1298 |
|
|---|
| 1299 | Delete(S,P,1); {Delete Mnemo}
|
|---|
| 1300 | End
|
|---|
| 1301 | Else Canvas.GetTextExtent(S,txt.Width,txt.Height);
|
|---|
| 1302 | IsTxt := S <> '';
|
|---|
| 1303 |
|
|---|
| 1304 | If FKind = bkCustom Then FBmp := FBitmap
|
|---|
| 1305 | Else FBmp := GetStdBtnBitmap(FKind);
|
|---|
| 1306 |
|
|---|
| 1307 | IsBmp := False;
|
|---|
| 1308 | bmp.Width := 0;
|
|---|
| 1309 | bmp.Height := 0;
|
|---|
| 1310 | If ShowBitBtnGlyph Or (ClassType <> TBitBtn) Or Designed Then
|
|---|
| 1311 | If FBmp <> Nil Then
|
|---|
| 1312 | If Not FBmp.Empty Then
|
|---|
| 1313 | Begin
|
|---|
| 1314 | IsBmp := True;
|
|---|
| 1315 | bmp.Width := FBmp.Width Div NumGlyphs;
|
|---|
| 1316 | bmp.Height := FBmp.Height;
|
|---|
| 1317 | End;
|
|---|
| 1318 |
|
|---|
| 1319 | If IsBmp And IsTxt Then space := FSpacing
|
|---|
| 1320 | Else space := 0;
|
|---|
| 1321 |
|
|---|
| 1322 | If IsBmp Or IsTxt Then
|
|---|
| 1323 | Case FLayout Of
|
|---|
| 1324 | blGlyphLeft:
|
|---|
| 1325 | Begin
|
|---|
| 1326 | {determine full Size}
|
|---|
| 1327 | Int.Width := bmp.Width + space + txt.Width;
|
|---|
| 1328 |
|
|---|
| 1329 | If bmp.Height > txt.Height Then Int.Height := bmp.Height
|
|---|
| 1330 | Else Int.Height := txt.Height;
|
|---|
| 1331 |
|
|---|
| 1332 | Int.Bottom := ((rc1.Top - rc1.Bottom) - Int.Height) Div 2;
|
|---|
| 1333 |
|
|---|
| 1334 | If FMargin >= 0 Then Int.Left := FMargin
|
|---|
| 1335 | Else Int.Left := ((rc1.Right - rc1.Left) - Int.Width) Div 2;
|
|---|
| 1336 |
|
|---|
| 1337 | If IsBmp Then
|
|---|
| 1338 | Begin
|
|---|
| 1339 | bmp.Left := Int.Left;
|
|---|
| 1340 | bmp.Bottom := Int.Bottom;
|
|---|
| 1341 | If bmp.Height < txt.Height
|
|---|
| 1342 | Then Inc(bmp.Bottom, (txt.Height - bmp.Height) Div 2);
|
|---|
| 1343 | End;
|
|---|
| 1344 | If IsTxt Then
|
|---|
| 1345 | Begin
|
|---|
| 1346 | txt.Left := Int.Left + bmp.Width + space;
|
|---|
| 1347 | txt.Bottom := Int.Bottom;
|
|---|
| 1348 | If txt.Height < bmp.Height
|
|---|
| 1349 | Then Inc(txt.Bottom, (bmp.Height - txt.Height) Div 2);
|
|---|
| 1350 | End;
|
|---|
| 1351 | End;
|
|---|
| 1352 | blGlyphRight:
|
|---|
| 1353 | Begin
|
|---|
| 1354 | {determine full Size}
|
|---|
| 1355 | Int.Width := bmp.Width + space + txt.Width;
|
|---|
| 1356 |
|
|---|
| 1357 | If bmp.Height > txt.Height Then Int.Height := bmp.Height
|
|---|
| 1358 | Else Int.Height := txt.Height;
|
|---|
| 1359 |
|
|---|
| 1360 | Int.Bottom := ((rc1.Top - rc1.Bottom) - Int.Height) Div 2;
|
|---|
| 1361 |
|
|---|
| 1362 | If FMargin >= 0 Then Int.Left := rc1.Right - Int.Width - FMargin
|
|---|
| 1363 | Else Int.Left := ((rc1.Right - rc1.Left) - Int.Width) Div 2;
|
|---|
| 1364 |
|
|---|
| 1365 | If IsTxt Then
|
|---|
| 1366 | Begin
|
|---|
| 1367 | txt.Left := Int.Left;
|
|---|
| 1368 | txt.Bottom := Int.Bottom;
|
|---|
| 1369 | If txt.Height < bmp.Height
|
|---|
| 1370 | Then Inc(txt.Bottom, (bmp.Height - txt.Height) Div 2);
|
|---|
| 1371 | End;
|
|---|
| 1372 | If IsBmp Then
|
|---|
| 1373 | Begin
|
|---|
| 1374 | bmp.Left := Int.Left + txt.Width + space;
|
|---|
| 1375 | bmp.Bottom := Int.Bottom;
|
|---|
| 1376 | If bmp.Height < txt.Height
|
|---|
| 1377 | Then Inc(bmp.Bottom, (txt.Height - bmp.Height) Div 2);
|
|---|
| 1378 | End;
|
|---|
| 1379 | End;
|
|---|
| 1380 | blGlyphTop:
|
|---|
| 1381 | Begin
|
|---|
| 1382 | {determine full Size}
|
|---|
| 1383 | Int.Height := bmp.Height + space + txt.Height;
|
|---|
| 1384 |
|
|---|
| 1385 | If bmp.Width > txt.Width Then Int.Width := bmp.Width
|
|---|
| 1386 | Else Int.Width := txt.Width;
|
|---|
| 1387 |
|
|---|
| 1388 | Int.Left := ((rc1.Right - rc1.Left) - Int.Width) Div 2;
|
|---|
| 1389 |
|
|---|
| 1390 | If FMargin >= 0 Then Int.Bottom := rc1.Top - Int.Height - FMargin
|
|---|
| 1391 | Else Int.Bottom := ((rc1.Top - rc1.Bottom) - Int.Height) Div 2;
|
|---|
| 1392 |
|
|---|
| 1393 | If IsTxt Then
|
|---|
| 1394 | Begin
|
|---|
| 1395 | txt.Left := Int.Left;
|
|---|
| 1396 | txt.Bottom := Int.Bottom;
|
|---|
| 1397 | If txt.Width < bmp.Width
|
|---|
| 1398 | Then Inc(txt.Left, (bmp.Width - txt.Width) Div 2);
|
|---|
| 1399 | End;
|
|---|
| 1400 | If IsBmp Then
|
|---|
| 1401 | Begin
|
|---|
| 1402 | bmp.Left := Int.Left;
|
|---|
| 1403 | bmp.Bottom := Int.Bottom + txt.Height + space;
|
|---|
| 1404 | If bmp.Width < txt.Width
|
|---|
| 1405 | Then Inc(bmp.Left, (txt.Width - bmp.Width) Div 2);
|
|---|
| 1406 | End;
|
|---|
| 1407 | End;
|
|---|
| 1408 | blGlyphBottom:
|
|---|
| 1409 | Begin
|
|---|
| 1410 | {determine full Size}
|
|---|
| 1411 | Int.Height := bmp.Height + space + txt.Height;
|
|---|
| 1412 |
|
|---|
| 1413 | If bmp.Width > txt.Width Then Int.Width := bmp.Width
|
|---|
| 1414 | Else Int.Width := txt.Width;
|
|---|
| 1415 |
|
|---|
| 1416 | Int.Left := ((rc1.Right - rc1.Left) - Int.Width) Div 2;
|
|---|
| 1417 |
|
|---|
| 1418 | If FMargin >= 0 Then Int.Bottom := FMargin
|
|---|
| 1419 | Else Int.Bottom := ((rc1.Top - rc1.Bottom) - Int.Height) Div 2;
|
|---|
| 1420 |
|
|---|
| 1421 | If IsBmp Then
|
|---|
| 1422 | Begin
|
|---|
| 1423 | bmp.Left := Int.Left;
|
|---|
| 1424 | bmp.Bottom := Int.Bottom;
|
|---|
| 1425 | If bmp.Width < txt.Width
|
|---|
| 1426 | Then Inc(bmp.Left, (txt.Width - bmp.Width) Div 2);
|
|---|
| 1427 | End;
|
|---|
| 1428 | If IsTxt Then
|
|---|
| 1429 | Begin
|
|---|
| 1430 | txt.Left := Int.Left;
|
|---|
| 1431 | txt.Bottom := Int.Bottom + bmp.Height + space;
|
|---|
| 1432 | If txt.Width < bmp.Width
|
|---|
| 1433 | Then Inc(txt.Left, (bmp.Width - txt.Width) Div 2);
|
|---|
| 1434 | End;
|
|---|
| 1435 | End;
|
|---|
| 1436 | End;
|
|---|
| 1437 | End;
|
|---|
| 1438 |
|
|---|
| 1439 |
|
|---|
| 1440 | Procedure TBitBtn.Redraw(Const rec:TRect);
|
|---|
| 1441 | Var Bitmap:TBitmap;
|
|---|
| 1442 | Begin
|
|---|
| 1443 | If Canvas = Nil Then Exit;
|
|---|
| 1444 | If InRedraw Then Exit;
|
|---|
| 1445 | InRedraw := True; {MnemoString causes recursive Redraw}
|
|---|
| 1446 |
|
|---|
| 1447 | If Canvas.ClipRect <> rec Then Canvas.ClipRect := rec; {manual call}
|
|---|
| 1448 |
|
|---|
| 1449 | DrawFrame(Down);
|
|---|
| 1450 |
|
|---|
| 1451 | If IsTxt Then DrawText(ReplaceMnemo(Caption),Down);
|
|---|
| 1452 |
|
|---|
| 1453 | If IsBmp Then
|
|---|
| 1454 | Begin
|
|---|
| 1455 | If FKind = bkCustom Then
|
|---|
| 1456 | DrawBitmap( FMaskedBitmap,
|
|---|
| 1457 | FMaskBitmap,
|
|---|
| 1458 | Down )
|
|---|
| 1459 | Else
|
|---|
| 1460 | DrawBitmap( GetStdBtnBitmap( FKind ),
|
|---|
| 1461 | GetStdBtnBitmapMask( FKind ),
|
|---|
| 1462 | Down );
|
|---|
| 1463 | End;
|
|---|
| 1464 |
|
|---|
| 1465 | Inherited Redraw(rec);
|
|---|
| 1466 |
|
|---|
| 1467 | Canvas.DeleteClipRegion;
|
|---|
| 1468 | InRedraw := False;
|
|---|
| 1469 | End;
|
|---|
| 1470 |
|
|---|
| 1471 |
|
|---|
| 1472 | Procedure TBitBtn.DrawFrame(Down:Boolean);
|
|---|
| 1473 | Var rc1:TRect;
|
|---|
| 1474 | PBG:TColor;
|
|---|
| 1475 | {$IFDEF OS2}
|
|---|
| 1476 | offs:LongInt;
|
|---|
| 1477 | {$ENDIF}
|
|---|
| 1478 | Label Warp;
|
|---|
| 1479 | Begin
|
|---|
| 1480 | rc1 := ClientRect;
|
|---|
| 1481 |
|
|---|
| 1482 | If Application<>Nil Then
|
|---|
| 1483 | Begin
|
|---|
| 1484 | Case Application.Platform Of
|
|---|
| 1485 | {$IFDEF OS2}
|
|---|
| 1486 | OS2Ver20, OS2Ver30: {WARP}
|
|---|
| 1487 | Begin
|
|---|
| 1488 | Warp:
|
|---|
| 1489 | {typecast To have access To BackColor}
|
|---|
| 1490 | If parent <> Nil Then PBG := TForm(parent).color
|
|---|
| 1491 | Else PBG := clBackGround;
|
|---|
| 1492 |
|
|---|
| 1493 | If Default Then Canvas.Pen.color := clBtnDefault
|
|---|
| 1494 | Else Canvas.Pen.color := PBG;
|
|---|
| 1495 | Canvas.Rectangle(rc1);
|
|---|
| 1496 | InflateRect(rc1,-1,-1);
|
|---|
| 1497 |
|
|---|
| 1498 | Canvas.Pen.color := clWindowFrame;
|
|---|
| 1499 | Canvas.Rectangle(rc1);
|
|---|
| 1500 | InflateRect(rc1,-1,-1);
|
|---|
| 1501 | If Down
|
|---|
| 1502 | Then Canvas.ShadowedBorder(rc1,clBtnShadow,clBtnHighlight)
|
|---|
| 1503 | Else Canvas.ShadowedBorder(rc1,clBtnHighlight,clBtnShadow);
|
|---|
| 1504 | InflateRect(rc1,-1,-1);
|
|---|
| 1505 |
|
|---|
| 1506 | //{$IFDEF OS2}
|
|---|
| 1507 | Canvas.Pen.color := PBG;
|
|---|
| 1508 | If Default Then offs := 3
|
|---|
| 1509 | Else offs := 2;
|
|---|
| 1510 | Canvas.Pixels[rc1.Left-offs,rc1.Bottom-offs]:=Canvas.Pen.color;
|
|---|
| 1511 | Canvas.Pixels[rc1.Left-offs,rc1.Top+offs]:=Canvas.Pen.color;
|
|---|
| 1512 | Canvas.Pixels[rc1.Right+offs,rc1.Bottom-offs]:=Canvas.Pen.color;
|
|---|
| 1513 | Canvas.Pixels[rc1.Right+offs,rc1.Top+offs]:=Canvas.Pen.color;
|
|---|
| 1514 | //{$ENDIF}
|
|---|
| 1515 | End;
|
|---|
| 1516 | OS2Ver40: {MERLIN}
|
|---|
| 1517 | Begin
|
|---|
| 1518 | {typecast To have access To BackColor}
|
|---|
| 1519 | If parent <> Nil Then PBG := TForm(parent).color
|
|---|
| 1520 | Else PBG := clBackGround;
|
|---|
| 1521 |
|
|---|
| 1522 | If Default Then Canvas.Pen.color := clBtnDefault
|
|---|
| 1523 | Else Canvas.Pen.color := PBG;
|
|---|
| 1524 | Canvas.Rectangle(rc1);
|
|---|
| 1525 | InflateRect(rc1,-1,-1);
|
|---|
| 1526 | If Default Then
|
|---|
| 1527 | Begin
|
|---|
| 1528 | Canvas.Rectangle(rc1);
|
|---|
| 1529 | InflateRect(rc1,-1,-1);
|
|---|
| 1530 | End
|
|---|
| 1531 | Else
|
|---|
| 1532 | Begin
|
|---|
| 1533 | Canvas.ShadowedBorder(rc1,clBtnShadow,clBtnHighlight);
|
|---|
| 1534 | InflateRect(rc1,-1,-1);
|
|---|
| 1535 | End;
|
|---|
| 1536 |
|
|---|
| 1537 | If Down Then
|
|---|
| 1538 | Begin
|
|---|
| 1539 | Canvas.ShadowedBorder(rc1,clBtnShadow,clBtnHighlight);
|
|---|
| 1540 | InflateRect(rc1,-1,-1);
|
|---|
| 1541 | Canvas.ShadowedBorder(rc1,clBtnShadow,clBtnHighlight);
|
|---|
| 1542 | End
|
|---|
| 1543 | Else
|
|---|
| 1544 | Begin
|
|---|
| 1545 | Canvas.ShadowedBorder(rc1,clBtnHighlight,clBtnShadow);
|
|---|
| 1546 | InflateRect(rc1,-1,-1);
|
|---|
| 1547 | Canvas.ShadowedBorder(rc1,clBtnHighlight,clBtnShadow);
|
|---|
| 1548 | End;
|
|---|
| 1549 | InflateRect(rc1,-1,-1);
|
|---|
| 1550 | End;
|
|---|
| 1551 | {$ENDIF}
|
|---|
| 1552 | {$IFDEF Win95}
|
|---|
| 1553 | Win32:
|
|---|
| 1554 | Begin
|
|---|
| 1555 | Warp:
|
|---|
| 1556 | If Default Then
|
|---|
| 1557 | Begin
|
|---|
| 1558 | Canvas.Pen.color := clBtnDefault;
|
|---|
| 1559 | Canvas.Rectangle(rc1);
|
|---|
| 1560 | InflateRect(rc1,-1,-1);
|
|---|
| 1561 | End;
|
|---|
| 1562 |
|
|---|
| 1563 | If Down Then
|
|---|
| 1564 | Begin
|
|---|
| 1565 | Canvas.Pen.color := clBtnShadow;
|
|---|
| 1566 | Canvas.Rectangle(rc1);
|
|---|
| 1567 | InflateRect(rc1,-1,-1);
|
|---|
| 1568 | End
|
|---|
| 1569 | Else
|
|---|
| 1570 | Begin
|
|---|
| 1571 | Canvas.ShadowedBorder(rc1,clBtnHighlight,cl3DDkShadow);
|
|---|
| 1572 | InflateRect(rc1,-1,-1);
|
|---|
| 1573 | Canvas.ShadowedBorder(rc1,cl3DLight,clBtnShadow);
|
|---|
| 1574 | InflateRect(rc1,-1,-1);
|
|---|
| 1575 | End;
|
|---|
| 1576 | End;
|
|---|
| 1577 | {$ENDIF}
|
|---|
| 1578 | End; //case
|
|---|
| 1579 | End
|
|---|
| 1580 | Else goto Warp;
|
|---|
| 1581 |
|
|---|
| 1582 | Canvas.ClipRect := IntersectRect(Canvas.ClipRect,rc1);
|
|---|
| 1583 | End;
|
|---|
| 1584 |
|
|---|
| 1585 |
|
|---|
| 1586 | Procedure TBitBtn.DrawText(Const Caption:String;Down:Boolean);
|
|---|
| 1587 | Var rc1:TRect;
|
|---|
| 1588 | Begin
|
|---|
| 1589 | Canvas.Brush.color := color;
|
|---|
| 1590 | If Enabled Then Canvas.Pen.color := PenColor
|
|---|
| 1591 | Else Canvas.Pen.color := clDkGray;
|
|---|
| 1592 |
|
|---|
| 1593 | rc1.Left := txt.Left;
|
|---|
| 1594 | rc1.Bottom := txt.Bottom;
|
|---|
| 1595 | If Down Then
|
|---|
| 1596 | Begin
|
|---|
| 1597 | Inc(rc1.Left);
|
|---|
| 1598 | Dec(rc1.Bottom);
|
|---|
| 1599 | End;
|
|---|
| 1600 |
|
|---|
| 1601 | rc1.Right := rc1.Left + txt.Width -1;
|
|---|
| 1602 | {$IFDEF WIN32}
|
|---|
| 1603 | inc(rc1.Right);
|
|---|
| 1604 | {$ENDIF}
|
|---|
| 1605 | rc1.Top := rc1.Bottom + txt.Height -1;
|
|---|
| 1606 | If IsMnemo Then Canvas.MnemoTextOut(rc1.Left,rc1.Bottom,Caption)
|
|---|
| 1607 | Else Canvas.TextOut(rc1.Left,rc1.Bottom,Caption);
|
|---|
| 1608 | Canvas.ExcludeClipRect(rc1);
|
|---|
| 1609 | End;
|
|---|
| 1610 |
|
|---|
| 1611 |
|
|---|
| 1612 | Procedure TBitBtn.DrawBitmap( Bitmap: TBitmap;
|
|---|
| 1613 | Mask: TBitmap;
|
|---|
| 1614 | Down: Boolean );
|
|---|
| 1615 | Var Src,Dest:TRect;
|
|---|
| 1616 | Begin
|
|---|
| 1617 | Dest.Left := bmp.Left;
|
|---|
| 1618 | Dest.Bottom := bmp.Bottom;
|
|---|
| 1619 | If Down Then If NumGlyphs<3 Then
|
|---|
| 1620 | Begin
|
|---|
| 1621 | Inc(Dest.Left);
|
|---|
| 1622 | Dec(Dest.Bottom);
|
|---|
| 1623 | End;
|
|---|
| 1624 | Dest.Right := Dest.Left + bmp.Width;
|
|---|
| 1625 | Dest.Top := Dest.Bottom + bmp.Height;
|
|---|
| 1626 | Canvas.FillRect(Dest,Color);
|
|---|
| 1627 | If Bitmap = nil Then
|
|---|
| 1628 | Exit;
|
|---|
| 1629 |
|
|---|
| 1630 | // default source is whole bitmap.
|
|---|
| 1631 | Src.Left := 0;
|
|---|
| 1632 | Src.Bottom := 0;
|
|---|
| 1633 | Src.Right := bmp.Width;
|
|---|
| 1634 | Src.Top := bmp.Height;
|
|---|
| 1635 |
|
|---|
| 1636 | If Enabled Then
|
|---|
| 1637 | Begin
|
|---|
| 1638 | If ((NumGlyphs>2)And(Down)) Then
|
|---|
| 1639 | Begin
|
|---|
| 1640 | // use third position in bitmap
|
|---|
| 1641 | Src.Left:=bmp.Width*2;
|
|---|
| 1642 | Src.Bottom:=0;
|
|---|
| 1643 | Src.Right:=Src.Left+bmp.Width;
|
|---|
| 1644 | Src.Top:=bmp.Height;
|
|---|
| 1645 | if Mask <> nil then
|
|---|
| 1646 | Bitmap.DrawMasked(Canvas,Mask,Src,Dest.Left,Dest.Bottom)
|
|---|
| 1647 | else
|
|---|
| 1648 | Bitmap.PartialDraw(Canvas,Dest,Src);
|
|---|
| 1649 | End
|
|---|
| 1650 | Else
|
|---|
| 1651 | Begin
|
|---|
| 1652 | if Mask <> nil then
|
|---|
| 1653 | Bitmap.DrawMaskedDisabled(Canvas,Mask,Src,Dest.Left,Dest.Bottom)
|
|---|
| 1654 | else
|
|---|
| 1655 | Bitmap.DrawDisabled(Canvas,Dest);
|
|---|
| 1656 | End;
|
|---|
| 1657 | End
|
|---|
| 1658 | Else
|
|---|
| 1659 | Begin
|
|---|
| 1660 | If NumGlyphs>1 Then
|
|---|
| 1661 | Begin
|
|---|
| 1662 | // use second position in bitmap
|
|---|
| 1663 | Src.Left:=bmp.Width;
|
|---|
| 1664 | Src.Bottom:=0;
|
|---|
| 1665 | Src.Right:=Dest.Left+bmp.Width;
|
|---|
| 1666 | Src.Top:=bmp.Height;
|
|---|
| 1667 | if Mask <> nil then
|
|---|
| 1668 | Bitmap.DrawMasked(Canvas,Mask,Src,Dest.Left,Dest.Bottom)
|
|---|
| 1669 | else
|
|---|
| 1670 | Bitmap.PartialDraw(Canvas,Dest,Src);
|
|---|
| 1671 | End
|
|---|
| 1672 | Else
|
|---|
| 1673 | Begin
|
|---|
| 1674 | if Mask <> nil then
|
|---|
| 1675 | Bitmap.DrawMaskedDisabled(Canvas,Mask,Src,Dest.Left,Dest.Bottom)
|
|---|
| 1676 | else
|
|---|
| 1677 | Bitmap.DrawDisabled(Canvas,Dest);
|
|---|
| 1678 | End;
|
|---|
| 1679 | End;
|
|---|
| 1680 |
|
|---|
| 1681 | Dec(Dest.Right);
|
|---|
| 1682 | Dec(Dest.Top);
|
|---|
| 1683 | Canvas.ExcludeClipRect(Dest);
|
|---|
| 1684 | End;
|
|---|
| 1685 |
|
|---|
| 1686 |
|
|---|
| 1687 | Procedure TBitBtn.SetDefault(Value:Boolean);
|
|---|
| 1688 | Begin
|
|---|
| 1689 | Inherited SetDefault(Value);
|
|---|
| 1690 |
|
|---|
| 1691 | Refresh;
|
|---|
| 1692 | // Paint(ClientRect);
|
|---|
| 1693 | End;
|
|---|
| 1694 |
|
|---|
| 1695 |
|
|---|
| 1696 | Function TBitBtn.GetDown:Boolean;
|
|---|
| 1697 | Begin
|
|---|
| 1698 | Result := FDown;
|
|---|
| 1699 | {$IFDEF OS2}
|
|---|
| 1700 | If Handle <> 0 Then Result := Boolean(WinSendMsg(Handle,BM_QUERYHILITE,0,0));
|
|---|
| 1701 | {$ENDIF}
|
|---|
| 1702 | End;
|
|---|
| 1703 |
|
|---|
| 1704 |
|
|---|
| 1705 | Procedure TBitBtn.SetDown(Value:Boolean);
|
|---|
| 1706 | Begin
|
|---|
| 1707 | If FDown = Value Then Exit;
|
|---|
| 1708 | FDown := Value;
|
|---|
| 1709 | {$IFDEF OS2}
|
|---|
| 1710 | If Handle <> 0 Then WinSendMsg(Handle,BM_SETHILITE,LongWord(FDown),0);
|
|---|
| 1711 | {$ENDIF}
|
|---|
| 1712 | {$IFDEF Win95}
|
|---|
| 1713 | Paint(ClientRect);
|
|---|
| 1714 | {$ENDIF}
|
|---|
| 1715 | End;
|
|---|
| 1716 |
|
|---|
| 1717 |
|
|---|
| 1718 | Procedure TBitBtn.SetLayout(Value:TButtonLayout);
|
|---|
| 1719 | Begin
|
|---|
| 1720 | If FLayout <> Value Then
|
|---|
| 1721 | Begin
|
|---|
| 1722 | FLayout := Value;
|
|---|
| 1723 | Arrange;
|
|---|
| 1724 | Invalidate;
|
|---|
| 1725 | End;
|
|---|
| 1726 | End;
|
|---|
| 1727 |
|
|---|
| 1728 |
|
|---|
| 1729 | Procedure TBitBtn.SetMargin(Value:LongInt);
|
|---|
| 1730 | Begin
|
|---|
| 1731 | If FMargin <> Value Then
|
|---|
| 1732 | Begin
|
|---|
| 1733 | FMargin := Value;
|
|---|
| 1734 | Arrange;
|
|---|
| 1735 | Invalidate;
|
|---|
| 1736 | End;
|
|---|
| 1737 | End;
|
|---|
| 1738 |
|
|---|
| 1739 |
|
|---|
| 1740 | Procedure TBitBtn.SetSpacing(Value:LongInt);
|
|---|
| 1741 | Begin
|
|---|
| 1742 | If FSpacing <> Value Then
|
|---|
| 1743 | If FSpacing >= 0 Then
|
|---|
| 1744 | Begin
|
|---|
| 1745 | FSpacing := Value;
|
|---|
| 1746 | Arrange;
|
|---|
| 1747 | Invalidate;
|
|---|
| 1748 | End;
|
|---|
| 1749 | End;
|
|---|
| 1750 |
|
|---|
| 1751 |
|
|---|
| 1752 | Procedure TBitBtn.SetKind(Value:TBitBtnKind);
|
|---|
| 1753 | Begin
|
|---|
| 1754 | If FKind <> Value Then
|
|---|
| 1755 | Begin
|
|---|
| 1756 | FKind := Value;
|
|---|
| 1757 | If FKind <> bkCustom Then
|
|---|
| 1758 | Begin
|
|---|
| 1759 | If ComponentState * [csReading] = [] Then
|
|---|
| 1760 | Begin
|
|---|
| 1761 | If FKind=bkCustom Then Caption:=''
|
|---|
| 1762 | Else Caption := LoadNLSStr(StdBtnCaptionIds[FKind]);
|
|---|
| 1763 | Command := StdBtnCmds[FKind]; {For SpeedButtons}
|
|---|
| 1764 | ModalResult := StdBtnCmds[FKind]; {For Buttons...}
|
|---|
| 1765 |
|
|---|
| 1766 | Default := FKind In [bkOk,bkYes];
|
|---|
| 1767 | Cancel := FKind In [bkCancel,bkNo];
|
|---|
| 1768 | End;
|
|---|
| 1769 |
|
|---|
| 1770 | If FBitmap <> Nil Then FBitmap.Destroy; {!}
|
|---|
| 1771 | FBitmap := Nil;
|
|---|
| 1772 | End;
|
|---|
| 1773 | Arrange;
|
|---|
| 1774 | Invalidate;
|
|---|
| 1775 | End;
|
|---|
| 1776 | End;
|
|---|
| 1777 |
|
|---|
| 1778 | Procedure TBitBtn.CreateBitmaps;
|
|---|
| 1779 | Var
|
|---|
| 1780 | TransparentColor: TColor;
|
|---|
| 1781 | Begin
|
|---|
| 1782 | FMaskBitmap.Free;
|
|---|
| 1783 | FMaskedBitmap.Free;
|
|---|
| 1784 |
|
|---|
| 1785 | If FBitmap <> Nil Then
|
|---|
| 1786 | Begin
|
|---|
| 1787 | TransparentColor := FBitmap.Canvas.Pixels[ 0, 0 ];
|
|---|
| 1788 | FMaskBitmap := TBitmap( FBitmap.CreateMask( TransparentColor ) );
|
|---|
| 1789 | FMaskedBitmap := FBitmap.CopyMasked( FMaskBitmap );
|
|---|
| 1790 | End;
|
|---|
| 1791 | End;
|
|---|
| 1792 |
|
|---|
| 1793 | Procedure TBitBtn.SetGlyph(NewBitmap:TBitmap);
|
|---|
| 1794 | Var OldBitmap:TBitmap;
|
|---|
| 1795 | Begin
|
|---|
| 1796 | OldBitmap := FBitmap;
|
|---|
| 1797 |
|
|---|
| 1798 | {Create internal Copy}
|
|---|
| 1799 | If NewBitmap <> Nil Then FBitmap := NewBitmap.Copy
|
|---|
| 1800 | Else FBitmap := Nil;
|
|---|
| 1801 |
|
|---|
| 1802 | If FBitmap <> Nil Then Include(FBitmap.ComponentState, csDetail);
|
|---|
| 1803 |
|
|---|
| 1804 | If OldBitmap <> Nil Then
|
|---|
| 1805 | If OldBitmap <> NewBitmap Then OldBitmap.Destroy;
|
|---|
| 1806 |
|
|---|
| 1807 | CreateBitmaps;
|
|---|
| 1808 |
|
|---|
| 1809 | Kind := bkCustom; {!}
|
|---|
| 1810 |
|
|---|
| 1811 | Arrange;
|
|---|
| 1812 | Invalidate;
|
|---|
| 1813 | End;
|
|---|
| 1814 |
|
|---|
| 1815 |
|
|---|
| 1816 | Function TBitBtn.GetGlyph:TBitmap;
|
|---|
| 1817 | Begin
|
|---|
| 1818 | If FBitmap = Nil Then
|
|---|
| 1819 | Begin
|
|---|
| 1820 | FBitmap.Create;
|
|---|
| 1821 | Include(FBitmap.ComponentState, csDetail);
|
|---|
| 1822 | End;
|
|---|
| 1823 | Result := FBitmap;
|
|---|
| 1824 | End;
|
|---|
| 1825 |
|
|---|
| 1826 |
|
|---|
| 1827 | {$HINTS OFF}
|
|---|
| 1828 | Procedure TBitBtn.MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 1829 | Begin
|
|---|
| 1830 | Inherited MouseDown(Button,ShiftState,X,Y);
|
|---|
| 1831 |
|
|---|
| 1832 | {$IFDEF Win95}
|
|---|
| 1833 | If Self Is TSpeedButton Then exit;
|
|---|
| 1834 | If Button = mbLeft Then
|
|---|
| 1835 | Begin
|
|---|
| 1836 | Focus;
|
|---|
| 1837 | FDown := True;
|
|---|
| 1838 | Default := True;
|
|---|
| 1839 | Paint(ClientRect);
|
|---|
| 1840 | FDragging := True;
|
|---|
| 1841 | MouseCapture := True;
|
|---|
| 1842 | End;
|
|---|
| 1843 | {$ENDIF}
|
|---|
| 1844 | End;
|
|---|
| 1845 |
|
|---|
| 1846 |
|
|---|
| 1847 | Procedure TBitBtn.MouseMove(ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 1848 | {$IFDEF Win95}
|
|---|
| 1849 | Var NewDown:Boolean;
|
|---|
| 1850 | {$ENDIF}
|
|---|
| 1851 | Begin
|
|---|
| 1852 | Inherited MouseMove(ShiftState,X,Y);
|
|---|
| 1853 |
|
|---|
| 1854 | {$IFDEF Win95}
|
|---|
| 1855 | If Self Is TSpeedButton Then exit;
|
|---|
| 1856 | If Not FDragging Then Exit;
|
|---|
| 1857 | NewDown := PointInRect(Point(X,Y),ClientRect);
|
|---|
| 1858 |
|
|---|
| 1859 | If NewDown <> FDown Then
|
|---|
| 1860 | Begin
|
|---|
| 1861 | FDown := NewDown;
|
|---|
| 1862 | Paint(ClientRect);
|
|---|
| 1863 | End;
|
|---|
| 1864 | {$ENDIF}
|
|---|
| 1865 | End;
|
|---|
| 1866 |
|
|---|
| 1867 |
|
|---|
| 1868 | Procedure TBitBtn.MouseUp(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 1869 | Begin
|
|---|
| 1870 | Inherited MouseUp(Button,ShiftState,X,Y);
|
|---|
| 1871 |
|
|---|
| 1872 | {$IFDEF Win95}
|
|---|
| 1873 | If Self Is TSpeedButton Then exit;
|
|---|
| 1874 | If Button = mbLeft Then
|
|---|
| 1875 | Begin
|
|---|
| 1876 | If Not FDragging Then Exit;
|
|---|
| 1877 | FDragging := False;
|
|---|
| 1878 | FDown := False;
|
|---|
| 1879 | Paint(ClientRect);
|
|---|
| 1880 | MouseCapture := False;
|
|---|
| 1881 | If PointInRect(Point(X,Y),ClientRect) Then Click;
|
|---|
| 1882 | End;
|
|---|
| 1883 | {$ENDIF}
|
|---|
| 1884 | End;
|
|---|
| 1885 |
|
|---|
| 1886 |
|
|---|
| 1887 | Procedure TBitBtn.MouseDblClick(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 1888 | Begin
|
|---|
| 1889 | Inherited MouseDblClick(Button,ShiftState,X,Y);
|
|---|
| 1890 |
|
|---|
| 1891 | {$IFDEF Win95}
|
|---|
| 1892 | If Button = mbLeft Then
|
|---|
| 1893 | Begin
|
|---|
| 1894 | MouseDown(Button,ShiftState,X,Y);
|
|---|
| 1895 | End;
|
|---|
| 1896 | {$ENDIF}
|
|---|
| 1897 | End;
|
|---|
| 1898 |
|
|---|
| 1899 |
|
|---|
| 1900 | Procedure TBitBtn.CMTextChanged(Var Msg:TMessage);
|
|---|
| 1901 | Begin
|
|---|
| 1902 | Arrange;
|
|---|
| 1903 | Invalidate;
|
|---|
| 1904 | End;
|
|---|
| 1905 | {$HINTS ON}
|
|---|
| 1906 |
|
|---|
| 1907 |
|
|---|
| 1908 | Procedure TBitBtn.ReadSCUResource(Const ResName:TResourceName;Var Data;DataLen:LongInt);
|
|---|
| 1909 | Begin
|
|---|
| 1910 | If ResName = rnGlyph Then
|
|---|
| 1911 | Begin
|
|---|
| 1912 | If DataLen <> 0 Then
|
|---|
| 1913 | Begin
|
|---|
| 1914 | Glyph.ReadSCUResource(rnBitmap,Data,DataLen);
|
|---|
| 1915 | CreateBitmaps;
|
|---|
| 1916 | End
|
|---|
| 1917 | End
|
|---|
| 1918 | Else Inherited ReadSCUResource(ResName,Data,DataLen);
|
|---|
| 1919 | End;
|
|---|
| 1920 |
|
|---|
| 1921 |
|
|---|
| 1922 | Function TBitBtn.WriteSCUResource(Stream:TResourceStream):Boolean;
|
|---|
| 1923 | Begin
|
|---|
| 1924 | Result := Inherited WriteSCUResource(Stream);
|
|---|
| 1925 | If Not Result Then Exit;
|
|---|
| 1926 |
|
|---|
| 1927 | If (FBitmap <> Nil) And (ComponentState * [csDetail] = [])
|
|---|
| 1928 | Then Result := FBitmap.WriteSCUResourceName(Stream,rnGlyph);
|
|---|
| 1929 | End;
|
|---|
| 1930 |
|
|---|
| 1931 |
|
|---|
| 1932 | Procedure TBitBtn.Click;
|
|---|
| 1933 | Var Control:TControl;
|
|---|
| 1934 | Begin
|
|---|
| 1935 | Case FKind Of {they have Not A modal Result automatically}
|
|---|
| 1936 | bkClose:
|
|---|
| 1937 | Begin
|
|---|
| 1938 | If (Form <> Nil) And Not Designed Then Form.Close
|
|---|
| 1939 | Else Inherited Click;
|
|---|
| 1940 | End;
|
|---|
| 1941 | bkHelp:
|
|---|
| 1942 | Begin
|
|---|
| 1943 | Control := Self;
|
|---|
| 1944 | While (Control <> Nil) And (Control.HelpContext = 0)
|
|---|
| 1945 | Do Control := Control.parent;
|
|---|
| 1946 |
|
|---|
| 1947 | If Control <> Nil Then Application.HelpContext(Control.HelpContext)
|
|---|
| 1948 | Else Inherited Click;
|
|---|
| 1949 | End;
|
|---|
| 1950 | Else Inherited Click;
|
|---|
| 1951 | End;
|
|---|
| 1952 | End;
|
|---|
| 1953 |
|
|---|
| 1954 |
|
|---|
| 1955 | {
|
|---|
| 1956 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 1957 | º º
|
|---|
| 1958 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 1959 | º º
|
|---|
| 1960 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 1961 | º º
|
|---|
| 1962 | º This section: TAnimatedButton Class Implementation º
|
|---|
| 1963 | º º
|
|---|
| 1964 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 1965 | º º
|
|---|
| 1966 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 1967 | }
|
|---|
| 1968 |
|
|---|
| 1969 | Procedure TAnimatedButton.SetupComponent;
|
|---|
| 1970 | Begin
|
|---|
| 1971 | Inherited SetupComponent;
|
|---|
| 1972 |
|
|---|
| 1973 | Name := 'AnimatedButton';
|
|---|
| 1974 | Caption := Name;
|
|---|
| 1975 | FBitmapList.Create;
|
|---|
| 1976 | FBitmapList.Duplicates := True;
|
|---|
| 1977 | FInterval := 200;
|
|---|
| 1978 | FSaveBitmap := Nil;
|
|---|
| 1979 | End;
|
|---|
| 1980 |
|
|---|
| 1981 |
|
|---|
| 1982 | Destructor TAnimatedButton.Destroy;
|
|---|
| 1983 | Begin
|
|---|
| 1984 | StopAnimation;
|
|---|
| 1985 | FBitmapList.Destroy;
|
|---|
| 1986 | FBitmapList := Nil;
|
|---|
| 1987 | FBitmap := Nil;
|
|---|
| 1988 |
|
|---|
| 1989 | Inherited Destroy;
|
|---|
| 1990 | End;
|
|---|
| 1991 |
|
|---|
| 1992 |
|
|---|
| 1993 | Procedure TAnimatedButton.SetupShow;
|
|---|
| 1994 | Begin
|
|---|
| 1995 | Inherited SetupShow;
|
|---|
| 1996 |
|
|---|
| 1997 | If FBitmapList.Count > 0 Then
|
|---|
| 1998 | If FBitmap = Nil Then Glyph := FBitmapList.First
|
|---|
| 1999 | Else If FBitmap.Empty Then Glyph := FBitmapList.First;
|
|---|
| 2000 | End;
|
|---|
| 2001 |
|
|---|
| 2002 |
|
|---|
| 2003 | Procedure TAnimatedButton.SetGlyph(NewBitmap:TBitmap);
|
|---|
| 2004 | Begin
|
|---|
| 2005 | Inherited SetGlyph(NewBitmap);
|
|---|
| 2006 |
|
|---|
| 2007 | FSaveBitmap := FBitmap;
|
|---|
| 2008 | End;
|
|---|
| 2009 |
|
|---|
| 2010 |
|
|---|
| 2011 | Procedure TAnimatedButton.StartAnimation;
|
|---|
| 2012 | Begin
|
|---|
| 2013 | If FBitmapList.Count = 0 Then Exit;
|
|---|
| 2014 |
|
|---|
| 2015 | If FAnimationTimer=Nil Then
|
|---|
| 2016 | Begin
|
|---|
| 2017 | FAnimationTimer.Create(Self);
|
|---|
| 2018 | Include(FAnimationTimer.ComponentState, csDetail);
|
|---|
| 2019 | FAnimationTimer.OnTimer := EvTimer;
|
|---|
| 2020 | FAnimationTimer.Interval := FInterval;
|
|---|
| 2021 | End;
|
|---|
| 2022 | FAnimationTimer.Start;
|
|---|
| 2023 | End;
|
|---|
| 2024 |
|
|---|
| 2025 |
|
|---|
| 2026 | Procedure TAnimatedButton.StopAnimation;
|
|---|
| 2027 | Begin
|
|---|
| 2028 | If FAnimationTimer <> Nil Then FAnimationTimer.Stop;
|
|---|
| 2029 | End;
|
|---|
| 2030 |
|
|---|
| 2031 |
|
|---|
| 2032 | Procedure TAnimatedButton.ResetAnimation;
|
|---|
| 2033 | Begin
|
|---|
| 2034 | StopAnimation;
|
|---|
| 2035 | FLastPlayItem := 0;
|
|---|
| 2036 |
|
|---|
| 2037 | FBitmap := FSaveBitmap;
|
|---|
| 2038 | If FBitmapList.Count > 0 Then
|
|---|
| 2039 | If FBitmap = Nil Then Glyph := FBitmapList.First
|
|---|
| 2040 | Else If FBitmap.Empty Then Glyph := FBitmapList.First;
|
|---|
| 2041 | Arrange;
|
|---|
| 2042 | Paint(ClientRect);
|
|---|
| 2043 | End;
|
|---|
| 2044 |
|
|---|
| 2045 |
|
|---|
| 2046 | Procedure TAnimatedButton.SetInterval(Value:LongInt);
|
|---|
| 2047 | Var WasRunning:Boolean;
|
|---|
| 2048 | Begin
|
|---|
| 2049 | FInterval := Value;
|
|---|
| 2050 | If FAnimationTimer <> Nil Then
|
|---|
| 2051 | Begin
|
|---|
| 2052 | WasRunning:=FAnimationTimer.Running;
|
|---|
| 2053 | FAnimationTimer.Stop;
|
|---|
| 2054 | FAnimationTimer.Interval := FInterval;
|
|---|
| 2055 | If WasRunning Then FAnimationTimer.Start;
|
|---|
| 2056 | End;
|
|---|
| 2057 | End;
|
|---|
| 2058 |
|
|---|
| 2059 |
|
|---|
| 2060 | Procedure TAnimatedButton.EvTimer(Sender:TObject);
|
|---|
| 2061 | Var CompleteRedraw:Boolean;
|
|---|
| 2062 | FLastBitmap:TBitmap;
|
|---|
| 2063 | Begin
|
|---|
| 2064 | If Sender = FAnimationTimer Then
|
|---|
| 2065 | Begin
|
|---|
| 2066 | If FLastPlayItem >= FBitmapList.Count Then FLastPlayItem := 0;
|
|---|
| 2067 | FLastBitmap := FBitmap;
|
|---|
| 2068 | FBitmap := FBitmapList.Bitmaps[FLastPlayItem];
|
|---|
| 2069 |
|
|---|
| 2070 | CompleteRedraw := False;
|
|---|
| 2071 | If (FLastBitmap <> Nil) And (FBitmap <> Nil) Then
|
|---|
| 2072 | Begin
|
|---|
| 2073 | If (FLastBitmap.Width <> FBitmap.Width) Or
|
|---|
| 2074 | (FLastBitmap.Height <> FBitmap.Height)
|
|---|
| 2075 | Then CompleteRedraw := True;
|
|---|
| 2076 | End
|
|---|
| 2077 | Else
|
|---|
| 2078 | If (FLastBitmap = Nil) Xor (FBitmap = Nil) {mutex Nil}
|
|---|
| 2079 | Then CompleteRedraw := True;
|
|---|
| 2080 |
|
|---|
| 2081 | If CompleteRedraw Then
|
|---|
| 2082 | Begin
|
|---|
| 2083 | Arrange;
|
|---|
| 2084 | Paint(ClientRect);
|
|---|
| 2085 | End
|
|---|
| 2086 | Else
|
|---|
| 2087 | Begin
|
|---|
| 2088 | If FKind = bkCustom Then
|
|---|
| 2089 | DrawBitmap( FMaskedBitmap,
|
|---|
| 2090 | FMaskBitmap,
|
|---|
| 2091 | Down )
|
|---|
| 2092 | Else
|
|---|
| 2093 | DrawBitmap( GetStdBtnBitmap( FKind ),
|
|---|
| 2094 | GetStdBtnBitmapMask( FKind ),
|
|---|
| 2095 | Down );
|
|---|
| 2096 | End;
|
|---|
| 2097 | Update;
|
|---|
| 2098 | Inc(FLastPlayItem);
|
|---|
| 2099 | End;
|
|---|
| 2100 | End;
|
|---|
| 2101 |
|
|---|
| 2102 |
|
|---|
| 2103 | {
|
|---|
| 2104 | ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
|
|---|
| 2105 | º º
|
|---|
| 2106 | º Speed-Pascal/2 Version 2.0 º
|
|---|
| 2107 | º º
|
|---|
| 2108 | º Speed-Pascal Component Classes (SPCC) º
|
|---|
| 2109 | º º
|
|---|
| 2110 | º This section: TBitBtn Class Implementation º
|
|---|
| 2111 | º º
|
|---|
| 2112 | º (C) 1997 SpeedSoft. All rights reserved. Disclosure probibited ! º
|
|---|
| 2113 | º º
|
|---|
| 2114 | ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍŒ
|
|---|
| 2115 | }
|
|---|
| 2116 |
|
|---|
| 2117 | Procedure TSpeedButton.SetupComponent;
|
|---|
| 2118 | Begin
|
|---|
| 2119 | Inherited SetupComponent;
|
|---|
| 2120 |
|
|---|
| 2121 | Name := 'SpeedButton';
|
|---|
| 2122 | Caption := '';
|
|---|
| 2123 | Height := 30;
|
|---|
| 2124 | Width := 30;
|
|---|
| 2125 | FAllowAllUp := False;
|
|---|
| 2126 | CursorTabStop := False;
|
|---|
| 2127 | TabStop := False;
|
|---|
| 2128 | FGroupIndex := 0;
|
|---|
| 2129 | FState := bsNormal;
|
|---|
| 2130 | FDragging := False;
|
|---|
| 2131 | FIgnoreClick := False;
|
|---|
| 2132 | End;
|
|---|
| 2133 |
|
|---|
| 2134 |
|
|---|
| 2135 | Function TSpeedButton.GetState:TButtonState;
|
|---|
| 2136 | Begin
|
|---|
| 2137 | If not Enabled Then Result:=bsDisabled
|
|---|
| 2138 | Else Result:=FState;
|
|---|
| 2139 | End;
|
|---|
| 2140 |
|
|---|
| 2141 |
|
|---|
| 2142 | Procedure TSpeedButton.SetState(NewValue:TButtonState);
|
|---|
| 2143 | Begin
|
|---|
| 2144 | If NewValue=FState Then exit;
|
|---|
| 2145 | If NewValue=bsDisabled Then Enabled:=False
|
|---|
| 2146 | Else FState:=NewValue;
|
|---|
| 2147 | End;
|
|---|
| 2148 |
|
|---|
| 2149 |
|
|---|
| 2150 | Procedure TSpeedButton.CreateParams(Var Params:TCreateParams);
|
|---|
| 2151 | Begin
|
|---|
| 2152 | Inherited CreateParams(Params);
|
|---|
| 2153 |
|
|---|
| 2154 | {$IFDEF OS2}
|
|---|
| 2155 | Params.Style := Params.Style Or BS_NOPOINTERFOCUS;
|
|---|
| 2156 | {$ENDIF}
|
|---|
| 2157 | End;
|
|---|
| 2158 |
|
|---|
| 2159 |
|
|---|
| 2160 | {$IFDEF OS2}
|
|---|
| 2161 | Procedure TSpeedButton.WMChar(Var Msg:TWMChar);
|
|---|
| 2162 | Var KeyCode:Word;
|
|---|
| 2163 | Begin
|
|---|
| 2164 | Inherited;
|
|---|
| 2165 |
|
|---|
| 2166 | Msg.Handled := True;
|
|---|
| 2167 | If IsControlLocked(Self) Then Exit;
|
|---|
| 2168 |
|
|---|
| 2169 | If Msg.KeyData And KC_VIRTUALKEY <> 0 Then {Virtual key}
|
|---|
| 2170 | Begin
|
|---|
| 2171 | KeyCode := Msg.VirtualKeyCode;
|
|---|
| 2172 | If Msg.KeyData And KC_KEYUP <> 0 Then
|
|---|
| 2173 | Begin
|
|---|
| 2174 | If KeyCode = VK_SPACE Then
|
|---|
| 2175 | If FSpaceDown Then
|
|---|
| 2176 | Begin
|
|---|
| 2177 | FSpaceDown := False;
|
|---|
| 2178 | MouseUp(mbLeft,[],0,0);
|
|---|
| 2179 | End;
|
|---|
| 2180 |
|
|---|
| 2181 | If KeyCode = VK_ESC Then
|
|---|
| 2182 | If FSpaceDown Then
|
|---|
| 2183 | Begin
|
|---|
| 2184 | FSpaceDown := False;
|
|---|
| 2185 | MouseUp(mbLeft,[],-1,-1);
|
|---|
| 2186 | End;
|
|---|
| 2187 | End
|
|---|
| 2188 | Else
|
|---|
| 2189 | Begin
|
|---|
| 2190 | If KeyCode = VK_SPACE Then
|
|---|
| 2191 | If Not FSpaceDown Then
|
|---|
| 2192 | Begin
|
|---|
| 2193 | FSpaceDown := True;
|
|---|
| 2194 | MouseDown(mbLeft,[],0,0);
|
|---|
| 2195 | End;
|
|---|
| 2196 | End;
|
|---|
| 2197 | End;
|
|---|
| 2198 | End;
|
|---|
| 2199 | {$ENDIF}
|
|---|
| 2200 |
|
|---|
| 2201 |
|
|---|
| 2202 | {$IFDEF OS2}
|
|---|
| 2203 | Procedure TSpeedButton.ParentNotification(Var Msg:TMessage);
|
|---|
| 2204 | Var pUserBtn:PUSERBUTTON;
|
|---|
| 2205 | Begin
|
|---|
| 2206 | TControl.ParentNotification(Msg);
|
|---|
| 2207 |
|
|---|
| 2208 | If Designed Then Exit;
|
|---|
| 2209 |
|
|---|
| 2210 | Case Msg.Param1Hi Of
|
|---|
| 2211 | BN_CLICKED:
|
|---|
| 2212 | Begin
|
|---|
| 2213 | {OS2: Param2 Contains the Handle, If the Message was WM_CONTROL
|
|---|
| 2214 | To avoid duplicate Click only Use the WM_COMMAND event}
|
|---|
| 2215 | If Msg.Param2 <> 0 Then Exit;
|
|---|
| 2216 | If Not FIgnoreClick Then Click;
|
|---|
| 2217 | FIgnoreClick := False;
|
|---|
| 2218 | End;
|
|---|
| 2219 | BN_PAINT:
|
|---|
| 2220 | Begin
|
|---|
| 2221 | pUserBtn := Pointer(Msg.Param2);
|
|---|
| 2222 | FDefault := (pUserBtn^.fsState And BDS_DEFAULT) <> 0;
|
|---|
| 2223 | Paint(ClientRect);
|
|---|
| 2224 | End;
|
|---|
| 2225 | End;
|
|---|
| 2226 | Msg.Handled := True;
|
|---|
| 2227 | Msg.Result := 0;
|
|---|
| 2228 | End;
|
|---|
| 2229 | {$ENDIF}
|
|---|
| 2230 |
|
|---|
| 2231 |
|
|---|
| 2232 | Procedure TSpeedButton.DrawFrame(Down:Boolean);
|
|---|
| 2233 | Var rc1:TRect;
|
|---|
| 2234 | Begin
|
|---|
| 2235 | rc1 := ClientRect;
|
|---|
| 2236 |
|
|---|
| 2237 | If Down Then
|
|---|
| 2238 | Begin
|
|---|
| 2239 | Canvas.ShadowedBorder(rc1,clBtnShadow,clBtnHighlight);
|
|---|
| 2240 | InflateRect(rc1,-1,-1);
|
|---|
| 2241 | Canvas.ShadowedBorder(rc1,cl3DDkShadow,clBtnHighlight);
|
|---|
| 2242 | End
|
|---|
| 2243 | Else
|
|---|
| 2244 | Begin
|
|---|
| 2245 | Canvas.ShadowedBorder(rc1,clBtnHighlight,cl3DDkShadow);
|
|---|
| 2246 | InflateRect(rc1,-1,-1);
|
|---|
| 2247 | Canvas.ShadowedBorder(rc1,clBtnHighlight,clBtnShadow);
|
|---|
| 2248 | End;
|
|---|
| 2249 | InflateRect(rc1,-1,-1);
|
|---|
| 2250 |
|
|---|
| 2251 | Canvas.ClipRect := IntersectRect(Canvas.ClipRect,rc1);
|
|---|
| 2252 | End;
|
|---|
| 2253 |
|
|---|
| 2254 |
|
|---|
| 2255 | Procedure TSpeedButton.UpdateExclusive;
|
|---|
| 2256 | Var Msg:TMessage;
|
|---|
| 2257 | Begin
|
|---|
| 2258 | If parent = Nil Then Exit;
|
|---|
| 2259 | If FGroupIndex = 0 Then Exit;
|
|---|
| 2260 |
|
|---|
| 2261 | FillChar(Msg,SizeOf(Msg),0);
|
|---|
| 2262 | Msg.Msg := CM_BUTTONPRESSED;
|
|---|
| 2263 | Msg.Param1 := LongInt(Self);
|
|---|
| 2264 | Msg.Param2 := FGroupIndex;
|
|---|
| 2265 | Msg.Result := 0;
|
|---|
| 2266 |
|
|---|
| 2267 | Parent.BroadCast(Msg);
|
|---|
| 2268 | End;
|
|---|
| 2269 |
|
|---|
| 2270 |
|
|---|
| 2271 | Procedure TSpeedButton.cmButtonPressed(Var Msg:TMessage);
|
|---|
| 2272 | Var Sender:TSpeedButton;
|
|---|
| 2273 | Begin
|
|---|
| 2274 | Sender := TSpeedButton(Msg.Param1);
|
|---|
| 2275 | If Not (Sender Is TSpeedButton) Then Exit;
|
|---|
| 2276 | If Sender = Self Then Exit;
|
|---|
| 2277 | If Msg.Param2 <> FGroupIndex Then Exit;
|
|---|
| 2278 |
|
|---|
| 2279 | If Sender.FDown And FDown Then
|
|---|
| 2280 | Begin
|
|---|
| 2281 | FDown := False;
|
|---|
| 2282 | FState := bsNormal;
|
|---|
| 2283 | {$IFDEF OS2}
|
|---|
| 2284 | If Handle <> 0 Then WinSendMsg(Handle,BM_SETHILITE,LongWord(FDown),0);
|
|---|
| 2285 | {$ENDIF}
|
|---|
| 2286 | Paint(ClientRect);
|
|---|
| 2287 | End;
|
|---|
| 2288 | FAllowAllUp := Sender.AllowAllUp;
|
|---|
| 2289 | End;
|
|---|
| 2290 |
|
|---|
| 2291 |
|
|---|
| 2292 | Function TSpeedButton.GetDown:Boolean;
|
|---|
| 2293 | Begin
|
|---|
| 2294 | Case FState Of {Painting State}
|
|---|
| 2295 | bsDown: Result := True;
|
|---|
| 2296 | bsUp: Result := False;
|
|---|
| 2297 | Else Result := Inherited GetDown;
|
|---|
| 2298 | End;
|
|---|
| 2299 | End;
|
|---|
| 2300 |
|
|---|
| 2301 |
|
|---|
| 2302 | Procedure TSpeedButton.SetDown(Value:Boolean);
|
|---|
| 2303 | Begin
|
|---|
| 2304 | If FGroupIndex = 0 Then Value := False;
|
|---|
| 2305 | If FDown <> Value Then
|
|---|
| 2306 | Begin
|
|---|
| 2307 | If FDown And (Not FAllowAllUp) Then Exit;
|
|---|
| 2308 | FDown := Value;
|
|---|
| 2309 | If Value Then UpdateExclusive
|
|---|
| 2310 | Else FState := bsNormal;
|
|---|
| 2311 | {$IFDEF OS2}
|
|---|
| 2312 | If Handle <> 0 Then WinSendMsg(Handle,BM_SETHILITE,LongWord(FDown),0);
|
|---|
| 2313 | {$ENDIF}
|
|---|
| 2314 | Paint(ClientRect); {!}
|
|---|
| 2315 | {prevent up Redraw With mouse Click}
|
|---|
| 2316 | If FDown And (Not FAllowAllUp) Then FState := bsDown;
|
|---|
| 2317 | End;
|
|---|
| 2318 | End;
|
|---|
| 2319 |
|
|---|
| 2320 |
|
|---|
| 2321 | Procedure TSpeedButton.SetAllowAllUp(Value:Boolean);
|
|---|
| 2322 | Begin
|
|---|
| 2323 | If FAllowAllUp <> Value Then
|
|---|
| 2324 | Begin
|
|---|
| 2325 | FAllowAllUp := Value;
|
|---|
| 2326 | UpdateExclusive;
|
|---|
| 2327 | End;
|
|---|
| 2328 | End;
|
|---|
| 2329 |
|
|---|
| 2330 |
|
|---|
| 2331 | Procedure TSpeedButton.SetGroupIndex(Value:LongInt);
|
|---|
| 2332 | Begin
|
|---|
| 2333 | If FGroupIndex <> Value Then
|
|---|
| 2334 | Begin
|
|---|
| 2335 | FGroupIndex := Value;
|
|---|
| 2336 | UpdateExclusive;
|
|---|
| 2337 | End;
|
|---|
| 2338 | End;
|
|---|
| 2339 |
|
|---|
| 2340 |
|
|---|
| 2341 | {$HINTS OFF}
|
|---|
| 2342 | Procedure TSpeedButton.MouseDown(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 2343 | Begin
|
|---|
| 2344 | Inherited MouseDown(Button,ShiftState,X,Y);
|
|---|
| 2345 |
|
|---|
| 2346 | If Button = mbLeft Then
|
|---|
| 2347 | Begin
|
|---|
| 2348 | {$IFDEF OS2}
|
|---|
| 2349 | If FGroupIndex = 0 Then Exit;
|
|---|
| 2350 | {$ENDIF}
|
|---|
| 2351 | If FDown And (Not FAllowAllUp) Then
|
|---|
| 2352 | Begin
|
|---|
| 2353 | FState := bsDown; {sonst bringt OS/2 den Button up}
|
|---|
| 2354 | Exit; {cannot switch OFF}
|
|---|
| 2355 | End;
|
|---|
| 2356 |
|
|---|
| 2357 | If Not FDown Then
|
|---|
| 2358 | Begin
|
|---|
| 2359 | FState := bsDown;
|
|---|
| 2360 | Paint(ClientRect);
|
|---|
| 2361 | End;
|
|---|
| 2362 | FDragging := True;
|
|---|
| 2363 | {$IFDEF Win95}
|
|---|
| 2364 | MouseCapture := True;
|
|---|
| 2365 | {$ENDIF}
|
|---|
| 2366 | End;
|
|---|
| 2367 | End;
|
|---|
| 2368 |
|
|---|
| 2369 |
|
|---|
| 2370 | Procedure TSpeedButton.MouseMove(ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 2371 | Var NewState:TButtonState;
|
|---|
| 2372 | Begin
|
|---|
| 2373 | Inherited MouseMove(ShiftState,X,Y);
|
|---|
| 2374 |
|
|---|
| 2375 | If Not FDragging Then Exit;
|
|---|
| 2376 |
|
|---|
| 2377 | If Not FDown Then
|
|---|
| 2378 | Begin
|
|---|
| 2379 | If PointInRect(Point(X,Y),ClientRect) Then NewState := bsDown
|
|---|
| 2380 | Else NewState := bsUp;
|
|---|
| 2381 | End
|
|---|
| 2382 | Else NewState := bsDown;
|
|---|
| 2383 |
|
|---|
| 2384 | If NewState <> FState Then
|
|---|
| 2385 | Begin
|
|---|
| 2386 | FState := NewState;
|
|---|
| 2387 | Paint(ClientRect);
|
|---|
| 2388 | End;
|
|---|
| 2389 | End;
|
|---|
| 2390 |
|
|---|
| 2391 |
|
|---|
| 2392 | Procedure TSpeedButton.MouseUp(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 2393 | Begin
|
|---|
| 2394 | Inherited MouseUp(Button,ShiftState,X,Y);
|
|---|
| 2395 |
|
|---|
| 2396 | If Button = mbLeft Then
|
|---|
| 2397 | Begin
|
|---|
| 2398 | If Not FDragging Then Exit;
|
|---|
| 2399 | FDragging := False;
|
|---|
| 2400 | {$IFDEF Win95}
|
|---|
| 2401 | MouseCapture := False;
|
|---|
| 2402 | {$ENDIF}
|
|---|
| 2403 | If PointInRect(Point(X,Y),ClientRect) Then
|
|---|
| 2404 | Begin
|
|---|
| 2405 | If FDown Then
|
|---|
| 2406 | Begin
|
|---|
| 2407 | If FAllowAllUp Then
|
|---|
| 2408 | Begin
|
|---|
| 2409 | FState := bsNormal;
|
|---|
| 2410 | SetDown(False);
|
|---|
| 2411 | {manually because no ParentNotification occurs}
|
|---|
| 2412 | Click;
|
|---|
| 2413 | End
|
|---|
| 2414 | Else FIgnoreClick := True;
|
|---|
| 2415 | End
|
|---|
| 2416 | Else
|
|---|
| 2417 | Begin
|
|---|
| 2418 | If FGroupIndex = 0 Then
|
|---|
| 2419 | Begin
|
|---|
| 2420 | FState := bsNormal;
|
|---|
| 2421 | Paint(ClientRect);
|
|---|
| 2422 | End;
|
|---|
| 2423 | SetDown(True);
|
|---|
| 2424 | End;
|
|---|
| 2425 | {$IFDEF Win95}
|
|---|
| 2426 | If Not FIgnoreClick Then Click;
|
|---|
| 2427 |
|
|---|
| 2428 | FIgnoreClick := False;
|
|---|
| 2429 | {$ENDIF}
|
|---|
| 2430 | End;
|
|---|
| 2431 | End;
|
|---|
| 2432 | End;
|
|---|
| 2433 |
|
|---|
| 2434 |
|
|---|
| 2435 | Procedure TSpeedButton.MouseDblClick(Button:TMouseButton;ShiftState:TShiftState;X,Y:LongInt);
|
|---|
| 2436 | Begin
|
|---|
| 2437 | Inherited MouseDblClick(Button,ShiftState,X,Y);
|
|---|
| 2438 |
|
|---|
| 2439 | If Button = mbLeft Then
|
|---|
| 2440 | Begin
|
|---|
| 2441 | MouseDown(Button,ShiftState,X,Y);
|
|---|
| 2442 | {$IFDEF OS2}
|
|---|
| 2443 | MouseUp(Button,ShiftState,X,Y); {Win95 sends it Self}
|
|---|
| 2444 | {$ENDIF}
|
|---|
| 2445 | End;
|
|---|
| 2446 | End;
|
|---|
| 2447 | {$HINTS OFF}
|
|---|
| 2448 |
|
|---|
| 2449 |
|
|---|
| 2450 | Procedure TSpeedButton.Click; {Do Not send A modal Result}
|
|---|
| 2451 | Begin
|
|---|
| 2452 | If parent <> Nil Then
|
|---|
| 2453 | Begin
|
|---|
| 2454 | If ComponentState * [csDetail] = [] Then
|
|---|
| 2455 | Begin
|
|---|
| 2456 | If Form <> Nil
|
|---|
| 2457 | Then SendMsg(Form.Handle,CM_COMMAND,Command{cmNull},0);
|
|---|
| 2458 | End
|
|---|
| 2459 | Else SendMsg(parent.Handle,CM_COMMAND,Command,0)
|
|---|
| 2460 | End;
|
|---|
| 2461 |
|
|---|
| 2462 | TButtonControl.Click;
|
|---|
| 2463 | End;
|
|---|
| 2464 |
|
|---|
| 2465 |
|
|---|
| 2466 | Begin
|
|---|
| 2467 | FillChar( StdBtnBitmapMasks, SizeOf( StdBtnBitmapMasks ), 0 );
|
|---|
| 2468 | FillChar( StdBtnBitmapsMasked, SizeOf( StdBtnBitmapsMasked ), 0 );
|
|---|
| 2469 | ShowBitBtnGlyph := True;
|
|---|
| 2470 | End.
|
|---|
| 2471 |
|
|---|
| 2472 |
|
|---|
| 2473 |
|
|---|
| 2474 |
|
|---|
| 2475 |
|
|---|
| 2476 |
|
|---|
| 2477 |
|
|---|
| 2478 |
|
|---|
| 2479 |
|
|---|
| 2480 |
|
|---|
| 2481 |
|
|---|
| 2482 |
|
|---|
| 2483 |
|
|---|
| 2484 |
|
|---|
| 2485 |
|
|---|
| 2486 |
|
|---|
| 2487 |
|
|---|
| 2488 |
|
|---|
| 2489 |
|
|---|
| 2490 |
|
|---|
| 2491 |
|
|---|