mainunit.pp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. unit MainUnit;
  2. {$mode ObjFPC}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Fresnel.Forms, Fresnel.Controls, Fresnel.Events,
  6. FCL.Events, Fresnel.Edit, Fresnel.Classes;
  7. type
  8. { TMainForm }
  9. TMainForm = class(TFresnelForm)
  10. Body1: TBody;
  11. Div1: TDiv;
  12. Label1: TLabel;
  13. Edit1 : TEdit;
  14. procedure Label1Click(Event: TAbstractEvent);
  15. private
  16. FBlocked : Boolean;
  17. public
  18. constructor CreateNew(aOwner: TComponent); override;
  19. end;
  20. var
  21. MainForm: TMainForm;
  22. implementation
  23. { TMainForm }
  24. procedure TMainForm.Label1Click(Event: TAbstractEvent);
  25. begin
  26. FBlocked:=Not FBlocked;
  27. if FBlocked then
  28. Label1.Caption:='Allow typing'
  29. else
  30. Label1.Caption:='Block typing';
  31. end;
  32. constructor TMainForm.CreateNew(aOwner: TComponent);
  33. begin
  34. inherited CreateNew(aOWner);
  35. Caption:='Edit demo';
  36. FormBounds:=BoundsRectFre(450,300,350,255);
  37. Stylesheet.Text:=
  38. 'div {'+
  39. ' padding: 3px; '+
  40. ' border: 2px solid black; '+
  41. ' margin: 6px;'+
  42. '}'+sLineBreak+
  43. 'input::selection { color: red; background-color: white } ' ;
  44. Body1:=TBody.Create(Self);
  45. Body1.Parent:=Self;
  46. Body1.Style:='border: 2px solid blue;'#10;
  47. Body1.Name:='Body1';
  48. Div1:=TDiv.Create(Self);
  49. Div1.Parent:=Body1;
  50. Div1.Style:='background-color: blue;'#10'border-color: black;'#10'height:30px;';
  51. Div1.Name:='Div1';
  52. Label1:=TLabel.Create(Self);
  53. Label1.Parent:=Div1;
  54. With Label1 do
  55. begin
  56. Name:='Label1';
  57. Style := 'color: red;';
  58. Caption := 'Block typing';
  59. OnClick := @Label1Click;
  60. end;
  61. Stylesheet.Add('div {'
  62. //+' background:#44cc66;'
  63. +' background:linear-gradient(#ededed, #bab1ba);'
  64. +' border:7px solid #18ab29;'
  65. +' padding:16px 31px;'
  66. +' font-size:15px; '
  67. +' font-family:Arial; '
  68. + ' font-weight:bold;'
  69. +' text-shadow: 0 1 1 #333;'
  70. +' color:#fff;'
  71. +'}'
  72. +'div:hover {'
  73. +' background:#88bb22;'
  74. +'};');
  75. Edit1:=TEdit.Create(Self);
  76. Edit1.Name:='Edit1';
  77. Edit1.Value:='Edit1';
  78. Edit1.Parent:=Body1;
  79. Edit1.Style:='font-size:15px; family:Arial; background-color: yellow;'#10
  80. +'border-color: black;'#10
  81. +'height:30px;'#10
  82. +'width: 100px;'#10;
  83. Edit1.Focus;
  84. Visible:=true;
  85. end;
  86. end.