Changeset 436
- Timestamp:
- Nov 19, 2012, 2:32:37 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolBar/UCoolBar.pas
r422 r436 6 6 7 7 uses 8 Classes, SysUtils, Cont nrs, Controls, SpecializedList;8 Classes, SysUtils, Controls, SpecializedList, Dialogs, ComCtrls, Forms; 9 9 10 10 type … … 36 36 FBands: TListObject; 37 37 FRowSize: Integer; 38 DisableResize: Boolean; 38 39 function GetBand(Index: Integer): TCoolBand; 39 40 procedure SetBand(Index: Integer; AValue: TCoolBand); 40 41 procedure BandsUpdate(Sender: TObject); 42 procedure AsyncResize(Param: PtrInt); 43 procedure ControlResize(Sender: TObject); 41 44 procedure SetRowSize(AValue: Integer); 45 function SearchBand(Control: TControl): TCoolBand; 46 protected 42 47 procedure Paint; override; 43 function SearchBand(Control: TControl): TCoolBand;44 48 procedure Resize; override; 45 49 public … … 56 60 property Color; 57 61 property RowSize: Integer read FRowSize write SetRowSize; 62 property OnResize; 58 63 end; 59 64 … … 116 121 end; 117 122 123 procedure TCoolBar.AsyncResize(Param: PtrInt); 124 begin 125 Arrange; 126 end; 127 128 procedure TCoolBar.ControlResize(Sender: TObject); 129 begin 130 Application.QueueAsyncCall(AsyncResize, 0); 131 end; 132 118 133 procedure TCoolBar.SetRowSize(AValue: Integer); 119 134 begin … … 133 148 begin 134 149 inherited InsertControl(AControl, Index); 135 NewBand := TCoolBand(FBands.AddNew(TCoolBand.Create)); 150 AControl.Align := alCustom; 151 NewBand := TCoolBand.Create; 136 152 NewBand.FCoolBar := Self; 137 153 NewBand.Control := AControl; 154 NewBand.Control.OnResize := ControlResize; 155 FBands.Insert(Index, NewBand); 138 156 Arrange; 139 157 end; … … 145 163 Band := SearchBand(AControl); 146 164 FBands.Remove(Band); 165 AControl.OnResize := nil; 147 166 inherited RemoveControl(AControl); 148 167 Arrange; … … 162 181 begin 163 182 inherited Resize; 164 //Arrange;183 //if not DisableResize then Arrange; 165 184 end; 166 185 … … 178 197 destructor TCoolBar.Destroy; 179 198 begin 180 F Bands.Free;199 FreeAndNil(FBands); 181 200 inherited; 182 201 end; … … 188 207 NewHeight: Integer; 189 208 begin 209 try 210 DisableResize := True; 190 211 X := 0; 191 212 Y := 0; … … 194 215 if Assigned(Control) and Control.Visible then begin 195 216 if (CoolBar.Width - X) > Control.Width then begin 217 // Place CoolBand right to the previous 196 218 if (Control.Left <> X) or (Control.Top <> Y) or 197 219 (Control.Width <> Control.Width) or (Control.Height <> RowSize) then … … 199 221 Inc(X, Control.Width); 200 222 end else begin 223 // CoolBand do not fit in gap, place to next row 224 if I > 0 then begin 225 // Enlarge previous band 226 with TCoolBand(FBands[I - 1]).Control do begin 227 SetBounds(Left, Top, CoolBar.Width - Left, Height); 228 end; 229 end; 201 230 Inc(Y, RowSize); 202 231 X := 0; … … 212 241 else NewHeight := RowSize; 213 242 if NewHeight <> Height then Height := NewHeight; 243 finally 244 DisableResize := False; 245 end; 214 246 end; 215 247
Note:
See TracChangeset
for help on using the changeset viewer.