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
|
{ $Id: FpGuiwsforms.pp 5319 2004-03-17 20:11:29Z marc $}
{
*****************************************************************************
* FpGuiWSForms.pp *
* ------------ *
* *
* *
*****************************************************************************
*****************************************************************************
This file is part of the Lazarus Component Library (LCL)
See the file COPYING.LCL, included in this distribution,
for details about the license.
*****************************************************************************
}
unit FpGuiWSForms;
{$mode objfpc}{$H+}
interface
uses
// Bindings
fpg_base, fpg_main, fpg_form, fpguiwsprivate, fpguiproc,
// LCL
Classes, Forms, LCLType, Controls, Graphics,
// Widgetset
WSForms, WSLCLClasses;
type
{ TFpGuiWSScrollingWinControl }
TFpGuiWSScrollingWinControl = class(TWSScrollingWinControl)
private
protected
published
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLHandle; override;
class procedure SetColor(const AWinControl: TWinControl); override;
end;
{ TFpGuiWSScrollBox }
TFpGuiWSScrollBox = class(TWSScrollBox)
private
protected
public
end;
{ TFpGuiWSCustomFrame }
TFpGuiWSCustomFrame = class(TWSCustomFrame)
private
protected
public
end;
{ TFpGuiWSFrame }
TFpGuiWSFrame = class(TWSFrame)
private
protected
public
end;
{ TFpGuiWSCustomForm }
TFpGuiWSCustomForm = class(TWSCustomForm)
private
protected
published
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class procedure SetFormBorderStyle(const AForm: Forms.TCustomForm;
const AFormBorderStyle: TFormBorderStyle); override;
class procedure SetFont(const AWinControl: TWinControl;
const AFont: TFont); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure Repaint(const AWinControl: TWinControl); override;
class procedure ShowModal(const ACustomForm: TCustomForm); override;
class procedure SetModalResult(const ACustomForm: TCustomForm; ANewValue: TModalResult); override;
end;
{ TFpGuiWSForm }
TFpGuiWSForm = class(TWSForm)
private
protected
public
end;
{ TFpGuiWSHintWindow }
TFpGuiWSHintWindow = class(TWSHintWindow)
private
protected
public
end;
{ TFpGuiWSScreen }
TFpGuiWSScreen = class(TWSScreen)
private
protected
public
end;
{ TFpGuiWSApplicationProperties }
TFpGuiWSApplicationProperties = class(TWSApplicationProperties)
private
protected
public
end;
implementation
{ TFpGuiWSScrollingWinControl }
class function TFpGuiWSScrollingWinControl.CreateHandle(
const AWinControl: TWinControl; const AParams: TCreateParams): TLCLHandle;
var
FPForm: TFPGUIPrivateScrollingWinControl;
begin
{$ifdef VerboseFPGUIIntf}
WriteLn(Self.ClassName,'.CreateHandle ',AWinControl.Name);
{$endif}
FPForm := TFPGUIPrivateScrollingWinControl.Create(AWinControl, AParams);
Result := TLCLHandle(FPForm);
end;
class procedure TFpGuiWSScrollingWinControl.SetColor(
const AWinControl: TWinControl);
var
FPForm: TFPGUIPrivateScrollingWinControl;
begin
FPForm := TFPGUIPrivateScrollingWinControl(AWinControl.Handle);
FPForm.ScrollFrame.ContentFrame.BackgroundColor:=TColorToTfpgColor(AWinControl.Color);
Inherited;
end;
{ TFpGuiWSCustomForm }
{------------------------------------------------------------------------------
Method: TFpGuiWSCustomForm.CreateHandle
Params: None
Returns: Nothing
Allocates memory and resources for the control and shows it
------------------------------------------------------------------------------}
class function TFpGuiWSCustomForm.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLHandle;
var
FPForm: TFPGUIPrivateWindow;
begin
{$ifdef VerboseFPGUIIntf}
WriteLn(Self.ClassName,'.CreateHandle ',AWinControl.Name);
{$endif}
FPForm := TFPGUIPrivateWindow.Create(AWinControl, AParams);
FPForm.SetFormBorderStyle(TForm(AWinControl).BorderStyle);
{ This fixes the AV error when trying to use TLabel components }
TfpgForm(FPForm.Widget).Show;
Result := TLCLHandle(FPForm);
end;
{------------------------------------------------------------------------------
Method: TFpGuiWSCustomForm.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TFpGuiWSCustomForm.DestroyHandle(const AWinControl: TWinControl);
begin
{$ifdef VerboseFPGUIIntf}
WriteLn(Self.ClassName,'.DestroyHandle ',AWinControl.Name);
{$endif}
TFPGUIPrivateWindow(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TFpGuiWSCustomForm.GetText
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class function TFpGuiWSCustomForm.GetText(const AWinControl: TWinControl;
var AText: String): Boolean;
var
FPForm: TFPGUIPrivateWindow;
begin
Result := True;
FPForm := TFPGUIPrivateWindow(AWinControl.Handle);
AText := FPForm.GetText;
end;
{------------------------------------------------------------------------------
Method: TFpGuiWSCustomForm.SetFormBorderStyle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TFpGuiWSCustomForm.SetFormBorderStyle(const AForm: Forms.TCustomForm;
const AFormBorderStyle: TFormBorderStyle);
var
FPForm: TFPGUIPrivateWindow;
begin
FPForm := TFPGUIPrivateWindow(AForm.Handle);
FPForm.SetFormBorderStyle(AFormBorderStyle);
end;
class procedure TFpGuiWSCustomForm.SetFont(const AWinControl: TWinControl;
const AFont: TFont);
var
FPForm: TFPGUIPrivateWindow;
begin
FPForm := TFPGUIPrivateWindow(AWinControl.Handle);
FPForm.Font:=AFont;
end;
class procedure TFpGuiWSCustomForm.ShowHide(const AWinControl: TWinControl);
var
FPForm: TfpgForm;
AForm: TCustomForm;
begin
FPForm := TFPGUIPrivateWindow(AWincontrol.Handle).Form;
AForm:=TCustomForm(AWinControl);
if AWinControl.Visible then begin
if not FPForm.Visible then begin
if (fsModal in AForm.FormState) and AForm.HandleObjectShouldBeVisible then begin
FPForm.ShowModal;
end else begin
FPForm.Show;
end;
end;
end else begin
if FPForm.Visible then begin
FPForm.Hide;
end;
end;
if AWinControl.Visible then begin
Invalidate(AWinControl);
end;
end;
class procedure TFpGuiWSCustomForm.SetColor(const AWinControl: TWinControl);
var
FPForm: TFPGUIPrivateWindow;
begin
FPForm := TFPGUIPrivateWindow(AWinControl.Handle);
FPForm.Widget.BackgroundColor:=TColorToTfpgColor(AWinControl.Color);
end;
class procedure TFpGuiWSCustomForm.Repaint(const AWinControl: TWinControl);
var
FPForm: TFPGUIPrivateWindow;
begin
FPForm := TFPGUIPrivateWindow(AWinControl.Handle);
FPForm.Paint;
end;
class procedure TFpGuiWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
begin
// Modal is handled in ShowHide to avoid double show (flicker).
(*
FPForm := TFPGUIPrivateWindow(ACustomForm.Handle);
TfpgForm(FPForm.Widget).ShowModal;
*)
end;
class procedure TFpGuiWSCustomForm.SetModalResult(
const ACustomForm: TCustomForm; ANewValue: TModalResult);
var
FPForm: TFPGUIPrivateWindow;
begin
FPForm := TFPGUIPrivateWindow(ACustomForm.Handle);
case ANewValue of
Controls.mrOK : TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrOK;
Controls.mrCancel : TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrCancel;
Controls.mrAbort: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrAbort;
Controls.mrRetry: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrRetry;
Controls.mrIgnore: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrIgnore;
Controls.mrYes: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrYes;
Controls.mrNo: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrNo;
Controls.mrAll: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrAll;
Controls.mrNoToAll: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrNoToAll;
Controls.mrYesToAll: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrYesToAll;
Controls.mrClose: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrCancel;
Controls.mrNone: TfpgForm(FPForm.Widget).ModalResult:=TfpgModalResult.mrNone;
end;
end;
{------------------------------------------------------------------------------
Method: TFpGuiWSCustomForm.SetText
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TFpGuiWSCustomForm.SetText(const AWinControl: TWinControl;
const AText: String);
var
FPForm: TFPGUIPrivateWindow;
begin
FPForm := TFPGUIPrivateWindow(AWincontrol.Handle);
FPForm.SetText(AText);
end;
end.
|