Changeset 14 for trunk/Components/ButtonN.pas
- Timestamp:
- Jan 7, 2017, 8:54:23 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/ButtonN.pas
r10 r14 12 12 FPossible, FLit: boolean; 13 13 FGraphic, FMask, FBackGraphic: TBitmap; 14 FIndex, BackIndex: integer;14 FIndex, BackIndex: integer; 15 15 FSmartHint: string; 16 16 ChangeProc: TNotifyEvent; … … 40 40 procedure Register; 41 41 begin 42 RegisterComponents('Samples', [TButtonN]);42 RegisterComponents('Samples', [TButtonN]); 43 43 end; 44 44 45 45 constructor TButtonN.Create(aOwner: TComponent); 46 46 begin 47 inherited Create(aOwner);48 ShowHint:=true;49 FGraphic:=nil;50 FBackGraphic:=nil;51 FPossible:=true;52 FLit:=false;53 FIndex:=-1;54 ChangeProc:=nil;55 SetBounds(0,0,42,42);47 inherited Create(aOwner); 48 ShowHint := true; 49 FGraphic := nil; 50 FBackGraphic := nil; 51 FPossible := true; 52 FLit := false; 53 FIndex := -1; 54 ChangeProc := nil; 55 SetBounds(0, 0, 42, 42); 56 56 end; 57 57 58 58 procedure TButtonN.Paint; 59 59 begin 60 with Canvas do60 with Canvas do 61 61 begin 62 if FGraphic<>nil then62 if FGraphic <> nil then 63 63 begin 64 BitBlt(Canvas.Handle,1,1,40,40,FBackGraphic.Canvas.Handle,65 1+80*BackIndex+40*byte(FPossible and FLit),176,SRCCOPY);66 if FPossible then64 BitBlt(Canvas.Handle, 1, 1, 40, 40, FBackGraphic.Canvas.Handle, 65 1 + 80 * BackIndex + 40 * byte(FPossible and FLit), 176, SRCCOPY); 66 if FPossible then 67 67 begin 68 BitBlt(Canvas.Handle,3,3,36,36,FMask.Canvas.Handle,69 195+37*(FIndex mod 3),21+37*(FIndex div 3),SRCAND);70 BitBlt(Canvas.Handle,3,3,36,36,FGraphic.Canvas.Handle,71 195+37*(FIndex mod 3),21+37*(FIndex div 3),SRCPAINT);68 BitBlt(Canvas.Handle, 3, 3, 36, 36, FMask.Canvas.Handle, 69 195 + 37 * (FIndex mod 3), 21 + 37 * (FIndex div 3), SRCAND); 70 BitBlt(Canvas.Handle, 3, 3, 36, 36, FGraphic.Canvas.Handle, 71 195 + 37 * (FIndex mod 3), 21 + 37 * (FIndex div 3), SRCPAINT); 72 72 end 73 73 end; 74 MoveTo(0,41); 75 Pen.Color:=$B0B0B0;LineTo(0,0);LineTo(41,0); 76 Pen.Color:=$FFFFFF;LineTo(41,41);LineTo(0,41); 74 MoveTo(0, 41); 75 Pen.Color := $B0B0B0; 76 LineTo(0, 0); 77 LineTo(41, 0); 78 Pen.Color := $FFFFFF; 79 LineTo(41, 41); 80 LineTo(0, 41); 77 81 end 78 82 end; 79 83 80 84 procedure TButtonN.MouseDown(Button: TMouseButton; Shift: TShiftState; 81 85 x, y: integer); 82 86 begin 83 if FPossible and (Button=mbLeft) and (@ChangeProc<>nil) then84 ChangeProc(Self)87 if FPossible and (Button = mbLeft) and (@ChangeProc <> nil) then 88 ChangeProc(Self) 85 89 end; 86 90 87 91 procedure TButtonN.SetPossible(x: boolean); 88 92 begin 89 if x<>FPossible then93 if x <> FPossible then 90 94 begin 91 FPossible:=x; 92 if x then Hint:=FSmartHint 93 else Hint:=''; 94 Invalidate 95 FPossible := x; 96 if x then 97 Hint := FSmartHint 98 else 99 Hint := ''; 100 Invalidate 95 101 end 96 102 end; … … 98 104 procedure TButtonN.SetLit(x: boolean); 99 105 begin 100 if x<>FLit then106 if x <> FLit then 101 107 begin 102 FLit:=x;103 Invalidate108 FLit := x; 109 Invalidate 104 110 end 105 111 end; … … 107 113 procedure TButtonN.SetIndex(x: integer); 108 114 begin 109 if x<>FIndex then115 if x <> FIndex then 110 116 begin 111 FIndex:=x; 112 if x<6 then BackIndex:=1 113 else BackIndex:=0; 114 Invalidate 117 FIndex := x; 118 if x < 6 then 119 BackIndex := 1 120 else 121 BackIndex := 0; 122 Invalidate 115 123 end 116 124 end; … … 118 126 procedure TButtonN.SetSmartHint(x: string); 119 127 begin 120 if x<>FSmartHint then128 if x <> FSmartHint then 121 129 begin 122 FSmartHint:=x; 123 if FPossible then Hint:=x; 130 FSmartHint := x; 131 if FPossible then 132 Hint := x; 124 133 end 125 134 end; 126 135 127 136 end. 128
Note:
See TracChangeset
for help on using the changeset viewer.