AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi ExpressSpreadSheet mit Hintergrundgrafik in Zellen ...
Thema durchsuchen
Ansicht
Themen-Optionen

ExpressSpreadSheet mit Hintergrundgrafik in Zellen ...

Ein Thema von mschaefer · begonnen am 17. Mai 2006
Antwort Antwort
Benutzerbild von mschaefer
mschaefer

Registriert seit: 4. Feb 2003
Ort: Hannover
2.029 Beiträge
 
Delphi XE3 Enterprise
 
#1

ExpressSpreadSheet mit Hintergrundgrafik in Zellen ...

  Alt 17. Mai 2006, 15:02
Moin, moin,

ich möchte bei einem DevExpressGrid eine Hintergrundgrafik in Zellen mit negativen Wert einügen. Das Problem habe ich insofern schon mit Lösung vermischt, als dass es mir möglich ist Grafiken in Zellen auf folgende Art einzubinden

Delphi-Quellcode:

TMyPainter = class(TcxSheetPainter)
  private
    procedure GradientRect(const ARect: TRect; IsHorizontal, IsSelected: Boolean);
end;


procedure TMyPainter.GradientRect(const ARect: TRect;
  IsHorizontal, IsSelected: Boolean);

  //Returns the Red, Green and Blue components of the color
  procedure ColorToRGBValues(AColor: TColor; var AR, AG, AB: Byte);
  begin
    AColor := ColorToRGB(AColor);
    AR := GetRValue(AColor);
    AG := GetGValue(AColor);
    AB := GetBValue(AColor);
  end;

var
  I, dR, dG, dB: Integer;

  R, G, B, R1, G1, B1: Byte;
  //rectangle filled previously
  PrevLine: TRect;
  //rectangle to fill currently
  LineRect: TRect;
  ABrush: HBrush;

const
  Colors: array[Boolean, 0..1] of TColor =
    ((clWhite, clBtnShadow), (clHighLight, clWhite));

begin
  //get the Red, Green and Blue components of the starting color
  //for the gradient
  ColorToRgbValues(Colors[IsSelected, 0], R1, G1, B1);
  //get the Red, Green and Blue components of the ending color

  //for the gradient
  ColorToRgbValues(Colors[IsSelected, 1], R, G, B);
  dR := R - R1;
  dG := G - G1;
  dB := B - B1;
  LineRect := ARect;
  PrevLine := ARect;
  for I := 0 to 255 do
  begin
    with ARect do
    begin
      if IsHorizontal then
      //determine rectangle boundaries for horizontal filling
      begin
        LineRect.Top := Top + MulDiv(I, Bottom - Top, $100);

        LineRect.Bottom := Top + MulDiv(I + 1, Bottom - Top, $100);
      end
      else
      //determine rectangle boundaries for vertical filling
      begin
        LineRect.Left := Left + MulDiv(I, Right - Left, $100);
        LineRect.Right := Left + MulDiv(I + 1, Right - Left, $100);
      end;
     //step over if the same rectangle was filled before
      if EqualRect(PrevLine, LineRect) then
         Continue;

      //define colors to fill
      R := R1 + MulDiv(I, dR, $FF);
      G := G1 + MulDiv(I, dG, $FF);
      B := B1 + MulDiv(I, dB, $FF);
      //create a brush to fill
      ABrush := CreateSolidBrush(RGB(R, G, B));
      try
        FillRect(Canvas.Canvas.Handle, LineRect, ABrush);
      finally
        DeleteObject(ABrush);
      end;
    end;
  end;
end;
Im Grid selbst muß dann der PainterType auf ptCustom gestellt werden
cxSpreadSheetBook1.PainterType := ptCustom; ImCustomPaint-Ereignis wird dann mit PainterClass := TMyPainter RMypainter eingebunden.

Mit ist aber nicht klar, wie ich da eine Abfrage auf Negativwerte in der aktuell zu
zeichnenden Zelle hinbekomme. Letzlich sollen die Negativwerte Hervorgehoben werden.

Viele Grüße // Martin
Martin Schaefer
  Mit Zitat antworten Zitat
Antwort Antwort


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 22:23 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz