SHARE
TWEET

MyItemMenu

jpfassis Jun 25th, 2019 (edited) 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unit UnitMyItemMenu;
  2.  
  3. interface
  4.  
  5. uses
  6. SysUtils, Classes, Graphics, Buttons, StdCtrls, ExtCtrls, Controls, Types,
  7.   Messages;
  8. type
  9.  
  10. TMyItemMenu = class(TCustomControl)
  11.   private
  12.     Panel_Fundo : TPanel;
  13.     Shape_Lateral : TShape;
  14.     Image_Menu_Item : TImage;
  15.     Label_Menu_Item : TLabel;
  16.     //SpeedButton_Menu_Item : TSpeedButton;
  17.     FShapeWidth : Integer;
  18.     FShapeColor : TColor;
  19.     FPanelColor : TColor;
  20.     FPanelOverColor : TColor;
  21.     FTextMenu : String;
  22.     FTextMenuFont : TFont;
  23.     FImagem : TPicture;
  24.     procedure configuracao;
  25.     procedure SetTextMenu(const Value: string);
  26.     procedure SetImagem(const Value: TPicture);
  27.     procedure SetPanelColor(const Value: TColor);
  28.     procedure SetPanelOverColor(const Value: TColor);
  29.     procedure SetShapeColor(const Value: TColor);
  30.     procedure SetShapeWidth(const Value: Integer);
  31.     procedure SetTextMenuFont(const Value: TFont);
  32.     procedure Paint; override;
  33.     procedure CreateWnd; override;
  34.   public
  35.     constructor Create(aOwner : TComponent); override;
  36.     destructor Destroy; override;
  37.   published
  38.     property ShapeWidth : Integer read FShapeWidth write SetShapeWidth default 8;
  39.     property ShapeColor : TColor read FShapeColor write SetShapeColor default clLime;
  40.     //property PanelColor : TColor read FPanelColor write SetPanelColor;
  41.     //property PanelOverColor : TColor read FPanelOverColor write SetPanelOverColor;
  42.     property TextMenuFont : TFont read FTextMenuFont write SetTextMenuFont;
  43.     property Imagem : TPicture read FImagem write SetImagem;
  44.     property TextMenu : string read FTextMenu write SetTextMenu;
  45. end;
  46.  
  47. procedure register;
  48.  
  49. implementation
  50.  
  51. procedure register;
  52. begin
  53.   registercomponents('My Componentes', [TMyItemMenu]);
  54. end;
  55.  
  56. constructor TMyItemMenu.Create(aOwner : TComponent);
  57. begin
  58.   inherited Create(aOwner);
  59.   Panel_Fundo := TPanel.Create(self);
  60.   Panel_Fundo.Parent:= self;
  61.  
  62.   Shape_Lateral := TShape.Create(Panel_Fundo);
  63.   Shape_Lateral.Parent:= Panel_Fundo.Parent;
  64.  
  65.   FImagem := TPicture.Create;
  66.   Image_Menu_item := TImage.Create(Panel_Fundo);
  67.   Image_Menu_item.parent:= Panel_Fundo.Parent;
  68.   Image_Menu_item.Picture:=FImagem;
  69.   Image_Menu_item.Stretch:=true;
  70.  
  71.   FTextMenuFont := TFont.Create;
  72.   Label_Menu_Item := TLabel.Create(Panel_Fundo);
  73.   Label_Menu_Item.parent:= Panel_Fundo.Parent;
  74.  
  75.   {
  76.   SpeedButton_Menu_Item := TSpeedButton.Create(Panel_Fundo);
  77.   SpeedButton_Menu_Item.parent:= Panel_Fundo.Parent;
  78.   }
  79.   configuracao;
  80. end;
  81.  
  82. procedure TMyItemMenu.CreateWnd;
  83. begin
  84.   inherited;
  85.     Image_Menu_item.Picture:=FImagem;
  86.     Label_Menu_Item.Font:=FTextMenuFont;
  87. end;
  88.  
  89. destructor TMyItemMenu.Destroy;
  90. begin
  91.   inherited;
  92. end;
  93.  
  94. procedure TMyItemMenu.Paint;
  95. begin
  96.  
  97.   with Canvas do
  98.   begin
  99.    ///usar aqui para desenhar algo novo no componente
  100.   end;
  101.  
  102. end;
  103.  
  104. procedure TMyItemMenu.SetImagem(const Value: TPicture);
  105. begin
  106.   //FImagem := Value;
  107.   FImagem.Assign(Value);
  108.   Image_Menu_item.Picture:=FImagem;
  109. end;
  110.  
  111. procedure TMyItemMenu.SetPanelColor(const Value: TColor);
  112. begin
  113.   FPanelColor := Value;
  114. end;
  115.  
  116. procedure TMyItemMenu.SetPanelOverColor(const Value: TColor);
  117. begin
  118.   FPanelOverColor := Value;
  119. end;
  120.  
  121. procedure TMyItemMenu.SetShapeColor(const Value: TColor);
  122. begin
  123.   FShapeColor := Value;
  124.   Shape_Lateral.Brush.Color:=FShapeColor;
  125. end;
  126.  
  127. procedure TMyItemMenu.SetShapeWidth(const Value: Integer);
  128. begin
  129.   FShapeWidth := Value;
  130.   Shape_Lateral.Width:=FShapeWidth;
  131. end;
  132.  
  133. procedure TMyItemMenu.SetTextMenu(const Value: string);
  134. begin
  135.   FTextMenu := Value;
  136.   Label_Menu_Item.Caption:=FTextMenu;
  137. end;
  138.  
  139. procedure TMyItemMenu.SetTextMenuFont(const Value: TFont);
  140. begin
  141.   FTextMenuFont := Value;
  142.   FTextMenuFont.Assign(Value);
  143.   Label_Menu_Item.Font:=FTextMenuFont;
  144. end;
  145.  
  146. procedure TMyItemMenu.configuracao;
  147. begin
  148.   Panel_Fundo.width:=200;
  149.   Panel_Fundo.Align:=alClient;
  150.   Panel_Fundo.ParentColor:=true;
  151.   Panel_Fundo.BevelOuter:=bvNone;
  152.  
  153.   Shape_Lateral.width:=5;
  154.   Shape_Lateral.Align:=alLeft;
  155.   Shape_Lateral.Brush.Color:=clLime;
  156.   Shape_Lateral.Pen.Style:=psClear;
  157.  
  158.   Image_Menu_item.width:=38;
  159.   Image_Menu_item.Align:=alLeft;
  160.   Image_Menu_item.Stretch:=true;
  161.  
  162.   Label_Menu_Item.width:=100;
  163.   Label_Menu_Item.Align:=alLeft;
  164.   Label_Menu_Item.Caption:='Teste de Texto';
  165.   Label_Menu_Item.Left:=4;
  166.   Label_Menu_Item.Font.Size:=11;
  167.   Label_Menu_Item.Font.Name:='Segoe UI';
  168.   Label_Menu_Item.Font.Color:=clBlue;
  169.  
  170.   {
  171.   SpeedButton_Menu_Item.width:=25;
  172.   SpeedButton_Menu_Item.Align:=alRight;
  173.   }
  174. end;
  175.  
  176. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top