| 1 | unit Dpi.ComCtrls;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, ComCtrls, Graphics, Dpi.Controls;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | TDpiCustomListView = class(TWinControl)
|
|---|
| 10 | end;
|
|---|
| 11 |
|
|---|
| 12 | TDpiLVCustomDrawItemEvent = procedure(Sender: TDpiCustomListView; Item: TListItem;
|
|---|
| 13 | State: TCustomDrawState; var DefaultDraw: Boolean) of object;
|
|---|
| 14 |
|
|---|
| 15 | { TDpiListView }
|
|---|
| 16 |
|
|---|
| 17 | TDpiListView = class(TDpiCustomListView)
|
|---|
| 18 | private
|
|---|
| 19 | FOnCustomDrawItem: TDpiLVCustomDrawItemEvent;
|
|---|
| 20 | NativeListView: TListView;
|
|---|
| 21 | function GetCanvas: TCanvas;
|
|---|
| 22 | function GetColumns: TListColumns;
|
|---|
| 23 | function GetItems: TListItems;
|
|---|
| 24 | function GetOnChange: TLVChangeEvent;
|
|---|
| 25 | function GetOnColumnClick: TLVColumnClickEvent;
|
|---|
| 26 | function GetOnCustomDrawItem: TDpiLVCustomDrawItemEvent;
|
|---|
| 27 | function GetProperty(AIndex: Integer): Boolean;
|
|---|
| 28 | function GetViewStyle: TViewStyle;
|
|---|
| 29 | procedure SetColumns(AValue: TListColumns);
|
|---|
| 30 | procedure SetItems(AValue: TListItems);
|
|---|
| 31 | procedure SetOnChange(AValue: TLVChangeEvent);
|
|---|
| 32 | procedure SetOnColumnClick(AValue: TLVColumnClickEvent);
|
|---|
| 33 | procedure SetOnCustomDrawItem(AValue: TDpiLVCustomDrawItemEvent);
|
|---|
| 34 | procedure SetProperty(AIndex: Integer; AValue: Boolean);
|
|---|
| 35 | procedure SetViewStyle(AValue: TViewStyle);
|
|---|
| 36 | procedure DoCustomDrawItem(Sender: TCustomListView; Item: TListItem;
|
|---|
| 37 | State: TCustomDrawState; var DefaultDraw: Boolean);
|
|---|
| 38 | public
|
|---|
| 39 | function GetItemAt(x,y: integer): TListItem;
|
|---|
| 40 | function GetNativeListView: TListView;
|
|---|
| 41 | constructor Create(TheOwner: TComponent); override;
|
|---|
| 42 | destructor Destroy; override;
|
|---|
| 43 | property Columns: TListColumns read GetColumns write SetColumns;
|
|---|
| 44 | property Items: TListItems read GetItems write SetItems;
|
|---|
| 45 | property Canvas: TCanvas read GetCanvas;
|
|---|
| 46 | property Checkboxes: Boolean index Ord(lvpCheckboxes) read GetProperty write SetProperty default False;
|
|---|
| 47 | published
|
|---|
| 48 | property OnColumnClick: TLVColumnClickEvent read GetOnColumnClick
|
|---|
| 49 | write SetOnColumnClick;
|
|---|
| 50 | property OnCustomDrawItem: TDpiLVCustomDrawItemEvent read GetOnCustomDrawItem
|
|---|
| 51 | write SetOnCustomDrawItem;
|
|---|
| 52 | property ViewStyle: TViewStyle read GetViewStyle write SetViewStyle default vsList;
|
|---|
| 53 | property OnChange: TLVChangeEvent read GetOnChange write SetOnChange;
|
|---|
| 54 | end;
|
|---|
| 55 |
|
|---|
| 56 | { TDpiToolBar }
|
|---|
| 57 |
|
|---|
| 58 | TDpiToolBar = class(TCustomControl)
|
|---|
| 59 | private
|
|---|
| 60 | NativeToolBar: TToolBar;
|
|---|
| 61 | function ButtonHeightIsStored: Boolean;
|
|---|
| 62 | function ButtonWidthIsStored: Boolean;
|
|---|
| 63 | function GetButtonHeight: Integer;
|
|---|
| 64 | function GetButtonWidth: Integer;
|
|---|
| 65 | procedure SetButtonHeight(AValue: Integer);
|
|---|
| 66 | procedure SetButtonWidth(AValue: Integer);
|
|---|
| 67 | public
|
|---|
| 68 | function GetNativeToolBar: TToolBar;
|
|---|
| 69 | constructor Create(TheOwner: TComponent); override;
|
|---|
| 70 | destructor Destroy; override;
|
|---|
| 71 | property ButtonHeight: Integer read GetButtonHeight write SetButtonHeight stored ButtonHeightIsStored;
|
|---|
| 72 | property ButtonWidth: Integer read GetButtonWidth write SetButtonWidth stored ButtonWidthIsStored;
|
|---|
| 73 | end;
|
|---|
| 74 |
|
|---|
| 75 | { TDpiCoolBand }
|
|---|
| 76 |
|
|---|
| 77 | TDpiCoolBand = class(TCustomControl)
|
|---|
| 78 | private
|
|---|
| 79 | NativeCoolBand: TCoolBand;
|
|---|
| 80 | function GetMinHeight: Integer;
|
|---|
| 81 | function GetMinWidth: Integer;
|
|---|
| 82 | procedure SetMinHeight(AValue: Integer);
|
|---|
| 83 | procedure SetMinWidth(AValue: Integer);
|
|---|
| 84 | protected const
|
|---|
| 85 | cDefMinHeight = 25;
|
|---|
| 86 | cDefMinWidth = 100;
|
|---|
| 87 | public
|
|---|
| 88 | function GetNativeCoolBand: TCoolBand;
|
|---|
| 89 | constructor Create(TheOwner: TComponent); override;
|
|---|
| 90 | destructor Destroy; override;
|
|---|
| 91 | property MinHeight: Integer read GetMinHeight write SetMinHeight default cDefMinHeight;
|
|---|
| 92 | property MinWidth: Integer read GetMinWidth write SetMinWidth default cDefMinWidth;
|
|---|
| 93 | end;
|
|---|
| 94 |
|
|---|
| 95 | { TDpiCoolBands }
|
|---|
| 96 |
|
|---|
| 97 | TDpiCoolBands = class(TCollection)
|
|---|
| 98 | private
|
|---|
| 99 | procedure SetItem(Index: Integer; AValue: TDpiCoolBand);
|
|---|
| 100 | function GetItem(Index: Integer): TDpiCoolBand;
|
|---|
| 101 | public
|
|---|
| 102 | property Items[Index: Integer]: TDpiCoolBand read GetItem write SetItem; default;
|
|---|
| 103 | end;
|
|---|
| 104 |
|
|---|
| 105 | { TDpiCoolBar }
|
|---|
| 106 |
|
|---|
| 107 | TDpiCoolBar = class(TCustomControl)
|
|---|
| 108 | private
|
|---|
| 109 | NativeCoolBar: TCoolBar;
|
|---|
| 110 | function GetBands: TDpiCoolBands;
|
|---|
| 111 | function GetThemed: Boolean;
|
|---|
| 112 | procedure SetBands(AValue: TDpiCoolBands);
|
|---|
| 113 | procedure SetThemed(AValue: Boolean);
|
|---|
| 114 | public
|
|---|
| 115 | procedure BeginUpdate;
|
|---|
| 116 | procedure EndUpdate;
|
|---|
| 117 | function GetNativeCoolBar: TCoolBar;
|
|---|
| 118 | constructor Create(TheOwner: TComponent); override;
|
|---|
| 119 | destructor Destroy; override;
|
|---|
| 120 | property Bands: TDpiCoolBands read GetBands write SetBands;
|
|---|
| 121 | property Themed: Boolean read GetThemed write SetThemed default True;
|
|---|
| 122 | end;
|
|---|
| 123 |
|
|---|
| 124 | { TDpiPageControl }
|
|---|
| 125 |
|
|---|
| 126 | TDpiPageControl = class(TWinControl)
|
|---|
| 127 | private
|
|---|
| 128 | NativePageControl: TPageControl;
|
|---|
| 129 | function GetPageCount: Integer;
|
|---|
| 130 | function GetTabSheet(Index: Integer): TTabSheet;
|
|---|
| 131 | public
|
|---|
| 132 | function GetNativePageControl: TPageControl;
|
|---|
| 133 | constructor Create(TheOwner: TComponent); override;
|
|---|
| 134 | destructor Destroy; override;
|
|---|
| 135 | property PageCount: Integer read GetPageCount;
|
|---|
| 136 | property Pages[Index: Integer]: TTabSheet read GetTabSheet;
|
|---|
| 137 | end;
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | implementation
|
|---|
| 142 |
|
|---|
| 143 | uses
|
|---|
| 144 | Dpi.Common;
|
|---|
| 145 |
|
|---|
| 146 | { TDpiListView }
|
|---|
| 147 |
|
|---|
| 148 | function TDpiListView.GetItems: TListItems;
|
|---|
| 149 | begin
|
|---|
| 150 | Result := GetNativeListView.Items;
|
|---|
| 151 | end;
|
|---|
| 152 |
|
|---|
| 153 | function TDpiListView.GetOnChange: TLVChangeEvent;
|
|---|
| 154 | begin
|
|---|
| 155 | Result := GetNativeListView.OnChange;
|
|---|
| 156 | end;
|
|---|
| 157 |
|
|---|
| 158 | function TDpiListView.GetOnColumnClick: TLVColumnClickEvent;
|
|---|
| 159 | begin
|
|---|
| 160 | Result := GetNativeListView.OnColumnClick;
|
|---|
| 161 | end;
|
|---|
| 162 |
|
|---|
| 163 | function TDpiListView.GetOnCustomDrawItem: TDpiLVCustomDrawItemEvent;
|
|---|
| 164 | begin
|
|---|
| 165 | Result := FOnCustomDrawItem;
|
|---|
| 166 | end;
|
|---|
| 167 |
|
|---|
| 168 | function TDpiListView.GetProperty(AIndex: Integer): Boolean;
|
|---|
| 169 | begin
|
|---|
| 170 | Result := GetNativeListView.Checkboxes;
|
|---|
| 171 | end;
|
|---|
| 172 |
|
|---|
| 173 | function TDpiListView.GetViewStyle: TViewStyle;
|
|---|
| 174 | begin
|
|---|
| 175 | Result := GetNativeListView.ViewStyle;
|
|---|
| 176 | end;
|
|---|
| 177 |
|
|---|
| 178 | function TDpiListView.GetColumns: TListColumns;
|
|---|
| 179 | begin
|
|---|
| 180 | Result := GetNativeListView.Columns;
|
|---|
| 181 | end;
|
|---|
| 182 |
|
|---|
| 183 | function TDpiListView.GetCanvas: TCanvas;
|
|---|
| 184 | begin
|
|---|
| 185 | Result := GetNativeListView.Canvas;
|
|---|
| 186 | end;
|
|---|
| 187 |
|
|---|
| 188 | procedure TDpiListView.SetColumns(AValue: TListColumns);
|
|---|
| 189 | begin
|
|---|
| 190 | GetNativeListView.Columns := AValue;
|
|---|
| 191 | end;
|
|---|
| 192 |
|
|---|
| 193 | procedure TDpiListView.SetItems(AValue: TListItems);
|
|---|
| 194 | begin
|
|---|
| 195 | GetNativeListView.Items := AValue;
|
|---|
| 196 | end;
|
|---|
| 197 |
|
|---|
| 198 | procedure TDpiListView.SetOnChange(AValue: TLVChangeEvent);
|
|---|
| 199 | begin
|
|---|
| 200 | GetNativeListView.OnChange := AValue;
|
|---|
| 201 | end;
|
|---|
| 202 |
|
|---|
| 203 | procedure TDpiListView.SetOnColumnClick(AValue: TLVColumnClickEvent);
|
|---|
| 204 | begin
|
|---|
| 205 | GetNativeListView.OnColumnClick := AValue;
|
|---|
| 206 | end;
|
|---|
| 207 |
|
|---|
| 208 | procedure TDpiListView.SetOnCustomDrawItem(AValue: TDpiLVCustomDrawItemEvent);
|
|---|
| 209 | begin
|
|---|
| 210 | FOnCustomDrawItem := AValue;
|
|---|
| 211 | end;
|
|---|
| 212 |
|
|---|
| 213 | procedure TDpiListView.SetProperty(AIndex: Integer; AValue: Boolean);
|
|---|
| 214 | begin
|
|---|
| 215 | GetNativeListView.Checkboxes := AValue;
|
|---|
| 216 | end;
|
|---|
| 217 |
|
|---|
| 218 | procedure TDpiListView.SetViewStyle(AValue: TViewStyle);
|
|---|
| 219 | begin
|
|---|
| 220 | GetNativeListView.ViewStyle := AValue;
|
|---|
| 221 | end;
|
|---|
| 222 |
|
|---|
| 223 | procedure TDpiListView.DoCustomDrawItem(Sender: TCustomListView; Item: TListItem;
|
|---|
| 224 | State: TCustomDrawState; var DefaultDraw: Boolean);
|
|---|
| 225 | begin
|
|---|
| 226 | if Assigned(FOnCustomDrawItem) then
|
|---|
| 227 | FOnCustomDrawItem(Self, Item, State, DefaultDraw);
|
|---|
| 228 | end;
|
|---|
| 229 |
|
|---|
| 230 | function TDpiListView.GetItemAt(x, y: integer): TListItem;
|
|---|
| 231 | begin
|
|---|
| 232 | Result := GetNativeListView.GetItemAt(X, Y);
|
|---|
| 233 | end;
|
|---|
| 234 |
|
|---|
| 235 | function TDpiListView.GetNativeListView: TListView;
|
|---|
| 236 | begin
|
|---|
| 237 | if not Assigned(NativeListView) then begin
|
|---|
| 238 | NativeListView := TListView.Create(nil);
|
|---|
| 239 | NativeListView.OnCustomDrawItem := DoCustomDrawItem;
|
|---|
| 240 | end;
|
|---|
| 241 | Result := NativeListView;
|
|---|
| 242 | end;
|
|---|
| 243 |
|
|---|
| 244 | constructor TDpiListView.Create(TheOwner: TComponent);
|
|---|
| 245 | begin
|
|---|
| 246 | inherited Create(TheOwner);
|
|---|
| 247 | end;
|
|---|
| 248 |
|
|---|
| 249 | destructor TDpiListView.Destroy;
|
|---|
| 250 | begin
|
|---|
| 251 | FreeAndNil(NativeListView);
|
|---|
| 252 | inherited;
|
|---|
| 253 | end;
|
|---|
| 254 |
|
|---|
| 255 | { TDpiToolBar }
|
|---|
| 256 |
|
|---|
| 257 | function TDpiToolBar.ButtonHeightIsStored: Boolean;
|
|---|
| 258 | begin
|
|---|
| 259 |
|
|---|
| 260 | end;
|
|---|
| 261 |
|
|---|
| 262 | function TDpiToolBar.ButtonWidthIsStored: Boolean;
|
|---|
| 263 | begin
|
|---|
| 264 |
|
|---|
| 265 | end;
|
|---|
| 266 |
|
|---|
| 267 | function TDpiToolBar.GetButtonHeight: Integer;
|
|---|
| 268 | begin
|
|---|
| 269 | Result := ScaleFromNative(GetNativeToolBar.ButtonHeight);
|
|---|
| 270 | end;
|
|---|
| 271 |
|
|---|
| 272 | function TDpiToolBar.GetButtonWidth: Integer;
|
|---|
| 273 | begin
|
|---|
| 274 | Result := ScaleFromNative(GetNativeToolBar.ButtonWidth);
|
|---|
| 275 | end;
|
|---|
| 276 |
|
|---|
| 277 | procedure TDpiToolBar.SetButtonHeight(AValue: Integer);
|
|---|
| 278 | begin
|
|---|
| 279 | GetNativeToolBar.ButtonHeight := ScaleToNative(AValue);
|
|---|
| 280 | end;
|
|---|
| 281 |
|
|---|
| 282 | procedure TDpiToolBar.SetButtonWidth(AValue: Integer);
|
|---|
| 283 | begin
|
|---|
| 284 | GetNativeToolBar.ButtonWidth := ScaleToNative(AValue);
|
|---|
| 285 | end;
|
|---|
| 286 |
|
|---|
| 287 | function TDpiToolBar.GetNativeToolBar: TToolBar;
|
|---|
| 288 | begin
|
|---|
| 289 | if not Assigned(NativeToolBar) then NativeToolBar := TToolBar.Create(nil);
|
|---|
| 290 | Result := NativeToolBar;
|
|---|
| 291 | end;
|
|---|
| 292 |
|
|---|
| 293 | constructor TDpiToolBar.Create(TheOwner: TComponent);
|
|---|
| 294 | begin
|
|---|
| 295 | inherited Create(TheOwner);
|
|---|
| 296 | end;
|
|---|
| 297 |
|
|---|
| 298 | destructor TDpiToolBar.Destroy;
|
|---|
| 299 | begin
|
|---|
| 300 | FreeAndNil(NativeToolBar);
|
|---|
| 301 | inherited;
|
|---|
| 302 | end;
|
|---|
| 303 |
|
|---|
| 304 | { TDpiCoolBar }
|
|---|
| 305 |
|
|---|
| 306 | function TDpiCoolBar.GetBands: TDpiCoolBands;
|
|---|
| 307 | begin
|
|---|
| 308 |
|
|---|
| 309 | end;
|
|---|
| 310 |
|
|---|
| 311 | function TDpiCoolBar.GetThemed: Boolean;
|
|---|
| 312 | begin
|
|---|
| 313 | Result := GetNativeCoolBar.Themed;
|
|---|
| 314 | end;
|
|---|
| 315 |
|
|---|
| 316 | procedure TDpiCoolBar.SetBands(AValue: TDpiCoolBands);
|
|---|
| 317 | begin
|
|---|
| 318 |
|
|---|
| 319 | end;
|
|---|
| 320 |
|
|---|
| 321 | procedure TDpiCoolBar.SetThemed(AValue: Boolean);
|
|---|
| 322 | begin
|
|---|
| 323 | GetNativeCoolBar.Themed := AValue
|
|---|
| 324 | end;
|
|---|
| 325 |
|
|---|
| 326 | procedure TDpiCoolBar.BeginUpdate;
|
|---|
| 327 | begin
|
|---|
| 328 | GetNativeCoolBar.BeginUpdate;
|
|---|
| 329 | end;
|
|---|
| 330 |
|
|---|
| 331 | procedure TDpiCoolBar.EndUpdate;
|
|---|
| 332 | begin
|
|---|
| 333 | GetNativeCoolBar.EndUpdate;
|
|---|
| 334 | end;
|
|---|
| 335 |
|
|---|
| 336 | function TDpiCoolBar.GetNativeCoolBar: TCoolBar;
|
|---|
| 337 | begin
|
|---|
| 338 | if not Assigned(NativeCoolBar) then NativeCoolBar := TCoolBar.Create(nil);
|
|---|
| 339 | Result := NativeCoolBar;
|
|---|
| 340 | end;
|
|---|
| 341 |
|
|---|
| 342 | constructor TDpiCoolBar.Create(TheOwner: TComponent);
|
|---|
| 343 | begin
|
|---|
| 344 | inherited Create(TheOwner);
|
|---|
| 345 | end;
|
|---|
| 346 |
|
|---|
| 347 | destructor TDpiCoolBar.Destroy;
|
|---|
| 348 | begin
|
|---|
| 349 | FreeAndNil(NativeCoolBar);
|
|---|
| 350 | inherited Destroy;
|
|---|
| 351 | end;
|
|---|
| 352 |
|
|---|
| 353 | { TDpiCoolBands }
|
|---|
| 354 |
|
|---|
| 355 | procedure TDpiCoolBands.SetItem(Index: Integer; AValue: TDpiCoolBand);
|
|---|
| 356 | begin
|
|---|
| 357 |
|
|---|
| 358 | end;
|
|---|
| 359 |
|
|---|
| 360 | function TDpiCoolBands.GetItem(Index: Integer): TDpiCoolBand;
|
|---|
| 361 | begin
|
|---|
| 362 |
|
|---|
| 363 | end;
|
|---|
| 364 |
|
|---|
| 365 | { TDpiCoolBand }
|
|---|
| 366 |
|
|---|
| 367 | function TDpiCoolBand.GetMinWidth: Integer;
|
|---|
| 368 | begin
|
|---|
| 369 |
|
|---|
| 370 | end;
|
|---|
| 371 |
|
|---|
| 372 | function TDpiCoolBand.GetMinHeight: Integer;
|
|---|
| 373 | begin
|
|---|
| 374 |
|
|---|
| 375 | end;
|
|---|
| 376 |
|
|---|
| 377 | procedure TDpiCoolBand.SetMinHeight(AValue: Integer);
|
|---|
| 378 | begin
|
|---|
| 379 |
|
|---|
| 380 | end;
|
|---|
| 381 |
|
|---|
| 382 | procedure TDpiCoolBand.SetMinWidth(AValue: Integer);
|
|---|
| 383 | begin
|
|---|
| 384 |
|
|---|
| 385 | end;
|
|---|
| 386 |
|
|---|
| 387 | function TDpiCoolBand.GetNativeCoolBand: TCoolBand;
|
|---|
| 388 | begin
|
|---|
| 389 |
|
|---|
| 390 | end;
|
|---|
| 391 |
|
|---|
| 392 | constructor TDpiCoolBand.Create(TheOwner: TComponent);
|
|---|
| 393 | begin
|
|---|
| 394 | inherited Create(TheOwner);
|
|---|
| 395 | end;
|
|---|
| 396 |
|
|---|
| 397 | destructor TDpiCoolBand.Destroy;
|
|---|
| 398 | begin
|
|---|
| 399 | inherited Destroy;
|
|---|
| 400 | end;
|
|---|
| 401 |
|
|---|
| 402 | { TDpiPageControl }
|
|---|
| 403 |
|
|---|
| 404 | function TDpiPageControl.GetPageCount: Integer;
|
|---|
| 405 | begin
|
|---|
| 406 | Result := GetNativePageControl.PageCount;
|
|---|
| 407 | end;
|
|---|
| 408 |
|
|---|
| 409 | function TDpiPageControl.GetTabSheet(Index: Integer): TTabSheet;
|
|---|
| 410 | begin
|
|---|
| 411 | Result := GetNativePageControl.Pages[Index];
|
|---|
| 412 | end;
|
|---|
| 413 |
|
|---|
| 414 | function TDpiPageControl.GetNativePageControl: TPageControl;
|
|---|
| 415 | begin
|
|---|
| 416 | if not Assigned(NativePageControl) then NativePageControl := TPageControl.Create(nil);
|
|---|
| 417 | Result := NativePageControl;
|
|---|
| 418 | end;
|
|---|
| 419 |
|
|---|
| 420 | constructor TDpiPageControl.Create(TheOwner: TComponent);
|
|---|
| 421 | begin
|
|---|
| 422 | inherited Create(TheOwner);
|
|---|
| 423 | end;
|
|---|
| 424 |
|
|---|
| 425 | destructor TDpiPageControl.Destroy;
|
|---|
| 426 | begin
|
|---|
| 427 | FreeAndNil(NativePageControl);
|
|---|
| 428 | inherited;
|
|---|
| 429 | end;
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 | end.
|
|---|
| 433 |
|
|---|