MainUnit.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. unit MainUnit;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Fresnel.Forms, Fresnel.DOM, Fresnel.Controls, Fresnel.Events, FCL.Events,
  6. Fresnel.DemoRadioButton;
  7. type
  8. { TMainForm }
  9. TMainForm = class(TFresnelForm)
  10. procedure MainFormCreate(Sender: TObject);
  11. private
  12. public
  13. OuterDiv, InnerDiv, BoxDiv: TDiv;
  14. Label1: TLabel;
  15. end;
  16. var
  17. MainForm: TMainForm;
  18. implementation
  19. {$R *.lfm}
  20. { TMainForm }
  21. procedure TMainForm.MainFormCreate(Sender: TObject);
  22. function AddDiv(aName: string; aParent: TFresnelElement): TDiv;
  23. begin
  24. Result:=TDiv.Create(Self);
  25. Result.Name:=aName;
  26. Result.Parent:=aParent;
  27. end;
  28. function AddLabel(aName, aCaption: string; aParent: TFresnelElement): TLabel;
  29. begin
  30. Result:=TLabel.Create(Self);
  31. Result.Name:=aName;
  32. Result.Caption:=aCaption;
  33. Result.Parent:=aParent;
  34. end;
  35. { function AddRadioButton(aName, aCaption: string; aParent: TFresnelElement;
  36. const OnClick: TFresnelEventHandler = nil): TDemoRadioButton;
  37. begin
  38. Result:=TDemoRadioButton.Create(Self);
  39. Result.Name:=aName;
  40. Result.Caption:=aCaption;
  41. Result.Parent:=aParent;
  42. Result.AddEventListener(evtClick,OnClick);
  43. end;}
  44. begin
  45. Stylesheet.Text:=':root { font-size: 15px; }'+LineEnding;
  46. OuterDiv:=AddDiv('OuterDiv',Self);
  47. OuterDiv.Style:='padding: 6px; border: 1px solid black; width: 200px; height: 200px; position: relative; overflow: scroll;';
  48. InnerDiv:=AddDiv('InnerDiv',OuterDiv);
  49. InnerDiv.Style:='border: 1px solid blue; width: 180px; height: 400px; position: absolute; left: 2px; top: 2px; overflow: scroll;';
  50. BoxDiv:=AddDiv('BoxDiv',InnerDiv);
  51. BoxDiv.Style:='border: 1px solid red; width: 160px; height: 600px; position: absolute; left: 2px; top: 2px;';
  52. Label1:=AddLabel('Label1','Fresnel',BoxDiv);
  53. Label1.Style:='color: #800;';
  54. end;
  55. end.