AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Eigene Komponente, Paint in FireMonkey überschreiben
Thema durchsuchen
Ansicht
Themen-Optionen

Eigene Komponente, Paint in FireMonkey überschreiben

Ein Thema von fuxi · begonnen am 13. Nov 2011 · letzter Beitrag vom 19. Nov 2011
 
wurzelzwerg

Registriert seit: 19. Jun 2011
Ort: Ilmenau
111 Beiträge
 
Delphi XE5 Enterprise
 
#4

AW: Eigene Komponente, Paint in FireMonkey überschreiben

  Alt 19. Nov 2011, 13:33
Schon ziemlich alt, vielleicht interessierts noch:
Delphi-Quellcode:
unit Pfeil;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  FMX.Types, FMX.Controls;

type
  TRichtung = (Links, Rechts, Unten, Oben);

type
  TPfeil = class(TControl)
  private
    { Private-Deklarationen }
    FRichtung: TRichtung;
    FVisible: Boolean;
    FColor: TAlphaColor;
    procedure SetRichtung(value: TRichtung);
    procedure SetColor(value: TAlphaColor);
  public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
  protected
    { Protected-Deklarationen }
    procedure Paint; override;
  published
    { Published-Deklarationen }
    property Richtung: TRichtung read FRichtung write SetRichtung;
    property Color: TAlphaColor read FColor write SetColor;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('AfwBackup', [TPfeil]);
end;

procedure TPfeil.SetColor(value: TAlphaColor);
begin
  if value <> FColor then
  begin
    FColor:= value;
    InvalidateRect(Self.BoundsRect);
  end;
end;

procedure TPfeil.SetRichtung(value: TRichtung);
begin
  if value <> FRichtung then
  begin
    FRichtung:= value;
    InvalidateRect(Self.BoundsRect);
  end;
end;

constructor TPfeil.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Self.Height:= 25;
  Self.Width:= 25;
  Self.FVisible:= true;
  Self.FColor:= claBlack;
  Self.FRichtung:= Links;
end;

procedure TPfeil.Paint;
var
  pol: TPolygon;
begin
  if Visible then
    with Self.Canvas do
    begin
      Stroke.Color:= FColor;
      Fill.Color:= FColor;
      Stroke.Kind:= TBrushKind.bkSolid;
      Fill.Kind:= TBrushKind.bkSolid;
      { Pfeil zeichnen }
      SetLength(pol, 3);
      case FRichtung of
        Links:
          begin
            pol[0]:= PointF(Self.Width, 0);
            pol[1]:= PointF(0, Self.Height / 2);
            pol[2]:= PointF(Self.Width, Self.Height);
          end;
        Rechts:
          begin
            pol[0]:= PointF(0, 0);
            pol[1]:= PointF(Self.Width / 2, Self.Height);
            pol[2]:= PointF(0, Self.Height);
          end;
        Unten:
          begin
            pol[0]:= PointF(0, 0);
            pol[1]:= PointF(Self.Width / 2, Self.Height);
            pol[2]:= PointF(Self.Width, 0);
          end;
        Oben:
          begin
            pol[0]:= PointF(0, Self.Height);
            pol[1]:= PointF(Self.Width / 2, 0);
            pol[2]:= PointF(Self.Width, Self.Height);
          end;
      end;

      DrawPolygon(pol, 1);
      SetLength(pol, 0);
    end;
end;

end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz