1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
|
{
*****************************************************************************
* MuiWSControls.pp *
* --------------- *
* *
* *
*****************************************************************************
*****************************************************************************
* *
* This file is part of the Lazarus Component Library (LCL) *
* *
* See the file COPYING.LCL, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
unit MuiWSControls;
{$mode objfpc}{$H+}
interface
uses
// FCL
Classes, sysutils,
// LCL
Controls, LCLType, Graphics, tagsparamshelper,
// Widgetset
MUIBaseUnit, WSControls, WSLCLClasses, Utility, Mui;
type
{ TMuiWSDragImageList }
//TMuiWSDragImageList = class(TWSDragImageList)
//private
//protected
//public
//end;
{ TMuiWSControl }
TMuiWSControl = class(TWSControl)
private
protected
public
end;
{ TMuiWSWinControl }
TMuiWSWinControl = class(TWSWinControl)
private
protected
published
class procedure AddControl(const AControl: TControl); override;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure Invalidate(const AWinControl: TWinControl); override;
class function GetClientRect(const AWincontrol: TWinControl;
var ARect: TRect): Boolean; override;
class function GetDefaultClientRect(const AWinControl: TWinControl;
const aLeft, aTop, aWidth, aHeight: integer;
var aClientRect: TRect): Boolean; override;
class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean); override;
class procedure PaintTo(const AWinControl: TWinControl; ADC: HDC; X, Y: Integer); override;
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetPos(const AWinControl: TWinControl; const ALeft, ATop: Integer); override;
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
class procedure SetColor(const AWinControl: TWinControl); override;
//class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
//class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
{ class procedure AddControl(const AControl: TControl); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;}
//class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
{ class procedure ConstraintsChange(const AWinControl: TWinControl); override;}
end;
{ TMuiWSGraphicControl }
TMuiWSGraphicControl = class(TWSGraphicControl)
private
protected
published
end;
{ TMuiWSCustomControl }
TMuiWSCustomControl = class(TWSCustomControl)
private
protected
public
published
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
end;
{ TMuiWSImageList }
TMuiWSImageList = class(TWSImageList)
private
protected
public
end;
implementation
{ TMuiWSWinControl }
class procedure TMuiWSWinControl.AddControl(const AControl: TControl);
begin
inherited;
//writeln('AddControl ', AControl.classname);
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.CreateHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class function TMuiWSWinControl.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
var
MuiPanel: TMuiArea;
TagList: TATagList;
begin
//writeln(AWinControl.classname,' create');
TagList.Clear;
//TagList.AddTags([
// MUIA_FillArea, NativeUInt(False)
// ]);
MuiPanel := TMuiArea.Create(LCLGroupClass, TagList);
With MuiPanel do
begin
Left := AParams.X;
Top := AParams.Y;
Width := AParams.Width;
Height := AParams.Height;
PasObject := AWinControl;
Caption := PChar(AParams.Caption);
end;
if AWinControl.Parent <> NIL then
begin
MuiPanel.Parent := TMuiObject(AWinControl.Parent.Handle);
end;
//
Result := TLCLIntfHandle(MuiPanel);
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TMuiWSWinControl.DestroyHandle(const AWinControl: TWinControl);
begin
//TMuiPrivateWidget(AWinControl.Handle).Free;
if Assigned(AWinControl) then
begin
if AWinControl.Handle <> 0 then
TMuiObject(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.Invalidate
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TMuiWSWinControl.Invalidate(const AWinControl: TWinControl);
var
Widget: TMuiObject;
begin
Widget := TMuiObject(AWinControl.Handle);
if Assigned(Widget) then
begin
if MUIApp.InsidePaint then
MUIApp.AddInvalidatedObject(Widget)
else
Widget.DoMUIdraw;
end;
end;
class function TMuiWSWinControl.GetClientRect(const AWincontrol: TWinControl;
var ARect: TRect): Boolean;
begin
ARect := TMuiObject(AWinControl.Handle).GetClientRect;
Result:=True;
end;
class function TMuiWSWinControl.GetDefaultClientRect(
const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
var aClientRect: TRect): Boolean;
begin
{AClientRect.top := ALeft;
AClientRect.Left := ATop;
AClientRect.Right := AWidth;
AClientRect.Bottom := AHeight;}
//writeln(AWincontrol.classname,' Get client Default Rect ',ALeft,', ', ATop,' -' , AWidth,' x ', AHeight);
Result:=False;
end;
class procedure TMuiWSWinControl.GetPreferredSize(
const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean);
begin
if Assigned(AWinControl) then
begin
PreferredHeight:=20;//AWinControl.Height;
PreferredWidth:=20;//AWinControl.Width;
end;
//writeln('Prefered Size',PreferredHeight,',',PreferredWidth);
end;
class procedure TMuiWSWinControl.PaintTo(const AWinControl: TWinControl;
ADC: HDC; X, Y: Integer);
//var
// AADC: TMuiDeviceContext absolute ADC;
begin
inherited;
//writeln('PaintTo: ', X,', ',y);
//TMuiPrivateWidget(AWinControl.Handle).PaintTo(AADC.fpgCanvas,X,Y);
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.SetBounds
Params: AWinControl - the calling object
ALeft, ATop - Position
AWidth, AHeight - Size
Returns: Nothing
Sets the position and size of a widget
------------------------------------------------------------------------------}
class procedure TMuiWSWinControl.SetBounds(const AWinControl: TWinControl;
const ALeft, ATop, AWidth, AHeight: Integer);
var
MuiObj: TMuiObject;
begin
if not Assigned(AWincontrol) then
Exit;
if TObject(AWinControl.Handle) is TMuiObject then
begin
MuiObj := TMuiObject(AWinControl.Handle);
MuiObj.BlockRedraw := True;
MuiObj.Left := ALeft;
MuiObj.Top := ATop;
MuiObj.Width := AWidth;
MuiObj.BlockRedraw := False;
MuiObj.Height := AHeight;
end;
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.SetPos
Params: AWinControl - the calling object
ALeft, ATop - Position
Returns: Nothing
Sets the position of a widget
------------------------------------------------------------------------------}
class procedure TMuiWSWinControl.SetPos(const AWinControl: TWinControl;
const ALeft, ATop: Integer);
var
MuiObj: TMuiObject;
begin
if not Assigned(AWincontrol) then
Exit;
if TObject(AWinControl.Handle) is TMuiObject then
begin
MuiObj := TMuiObject(AWinControl.Handle);
MuiObj.BlockRedraw := True;
MuiObj.Left := ALeft;
MuiObj.BlockRedraw := False;
MuiObj.Top := ATop;
end;
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.SetSize
Params: AWinControl - the calling object
AWidth, AHeight - Size
Returns: Nothing
Sets the size of a widget
------------------------------------------------------------------------------}
class procedure TMuiWSWinControl.SetSize(const AWinControl: TWinControl;
const AWidth, AHeight: Integer);
var
MuiObj: TMuiObject;
begin
if not Assigned(AWincontrol) then
Exit;
//writeln(AWincontrol.classname,' got resize: ', AWidth);
if TObject(AWinControl.Handle) is TMuiObject then
begin
MuiObj := TMuiObject(AWinControl.Handle);
MuiObj.BlockRedraw := True;
MuiObj.Width := AWidth;
MuiObj.BlockRedraw := False;
MuiObj.Height := AHeight;
end;
end;
{------------------------------------------------------------------------------
Method: TMuiWSWinControl.ShowHide
Params: AWinControl - the calling object
Returns: Nothing
Shows or hides a widget.
------------------------------------------------------------------------------}
class procedure TMuiWSWinControl.ShowHide(const AWinControl: TWinControl);
var
MuiObject: TMUIObject;
begin
if not Assigned(AWincontrol) then
Exit;
if TObject(AWinControl.Handle) is TMuiObject then
begin
MuiObject := TMuiObject(AWinControl.Handle);
MuiObject.Visible := AWinControl.Visible;
end;
end;
class procedure TMuiWSWinControl.SetColor(const AWinControl: TWinControl);
var
MUIObject: TMUIArea;
begin
if not Assigned(AWincontrol) then
Exit;
if TObject(AWinControl.Handle) is TMUIArea then
begin
MuiObject := TMUIArea(AWinControl.Handle);
MuiObject.Color := AWinControl.Color;
end;
end;
(*
class procedure TMuiWSWinControl.SetColor(const AWinControl: TWinControl);
//var
// FPWidget: TfpgWidget;
begin
// FPWidget := TMuiPrivateWidget(AWinControl.Handle).Widget;
// FPWidget.BackgroundColor := TColorToTfpgColor(AWinControl.Color);
end;
class function TMuiWSWinControl.GetText(const AWinControl: TWinControl;
var AText: String): Boolean;
//var
// FPPrivateWidget: TMuiPrivateWidget;
begin
// FPPrivateWidget := TMuiPrivateWidget(AWinControl.Handle);
// Result := FPPrivateWidget.HasStaticText;
// if Result then AText := FPPrivateWidget.GetText;
end;
class procedure TMuiWSWinControl.SetText(const AWinControl: TWinControl;
const AText: string);
//var
// FPPrivateWidget: TMuiPrivateWidget;
begin
// FPPrivateWidget := TMuiPrivateWidget(AWinControl.Handle);
// FPPrivateWidget.SetText(AText);
end;
class procedure TMuiWSWinControl.SetFont(const AWinControl: TWinControl;
const AFont: TFont);
//var
// FPPrivateWidget: TMuiPrivateWindow;
begin
// FPPrivateWidget := TMuiPrivateWindow(AWinControl.Handle);
// FPPrivateWidget.Font:=AFont;
end; *)
class function TMuiWSCustomControl.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
begin
writeln('create Custom Control');
Result := 0;
end;
class procedure TMuiWSCustomControl.DestroyHandle(const AWinControl: TWinControl);
begin
writeln('Destroy Customcontrol');
end;
end.
|