Autor Beitrag
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Mo 06.03.06 11:36 
An alle Komponenten-Entwickler,

ich bin gerade dabei eine Kalender Komponente zu entwickeln Vorfahr TCustomGrid.

Eigentlich klappt alles ganz gut, allerdings bin ich gerade am überlegen
ob es sinnvoller wäre die Komponente von TStringGrid oder so abzuleiten.

Ich zeichne derzeit ein Shape für die Termine auf das Gitter, dabei müßte
ich auf alle Änderungen des Gitters Höhe, Breite usw. selbst reagieren.

So nun zu meiner 1.Frage, wäre es einfacher das Shape als Objekt mit der jeweiligen
Zelle zu verbinden.

2. Wann soll ich die Shapes am besten neuzeichnen, da diese beim Scrollen des
Kalenders nicht automatisch neugezeichnet werden.

Habe zum besseren Verständnis eine kleine Demo angehängt.

Vielen Dank für alle Antworten


Moderiert von user profile iconTino: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mo 06.03.2006 um 10:52
Einloggen, um Attachments anzusehen!
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mo 06.03.06 14:29 
1. Ich glaube nicht. So kannst du ggF. das Ereignis veröffentlichen udn andere können z.B. Bilder o.ä. selbst rein zeichnen. Man macht das eigentlich auch immer so, das in einer .Draw Methode die Daten gerändert werden. Da das Visuelle so festzuzurren, das es ein Shape sein soll ist IMHO nicht so toll

2.Du benutzt doch OnDrawCell?(sry. hab deinen Code gerade net zur Hand)
Das einfachste wäre natürlich ein Timer aber das ist n bissel wischiwaschi...
Herbs
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 37

Win XP home edition
Delphi 2005 Prof
BeitragVerfasst: Mo 06.03.06 14:39 
Titel: Doublebufferd
Hilft dir vieleicht dieses:?
ausblenden Delphi-Quelltext
1:
customgrid1.doublebufferd:=true;					

Ich weiß aber nicht Tcustomgrid das kennt. und ob ich das richtig geschrieben habe
uwewo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Mo 06.03.06 15:45 
Hallo Herbs,

DoubleBuffered verwende ich schon, und Du hast es richtig geschrieben.

Hallo Digi_c,

also wenn ich Dich richtig verstehe ein Objekt mit der Zelle verknüpfen.

Im OnDrawCell Ereignis habe ich versucht eine Aktualisierung durchzuführen,
dabei flackert aber das Shape, da zuerst das Grid und dann das Shape
immer wieder gezeichnet wird.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 06.03.06 20:52 
Eventuell in eine Variable vom Typ TBitmap zeichnen und per BitBlt in OnDraw zeichnen.
Dadurch kannst du das Flimmern meistens verhindern.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
uwewo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Di 07.03.06 09:19 
Hallo Fabian,

das mit TBitmap wird auch nicht funktionieren.

Im OnDrawCell wird das Gitter gezeichnet, wenn ich zusätzlich
das Shape darin zeichnen lasse überschreiben sie sich beide
immer wieder und das führt logischerweise immer zu einem flackern.
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Di 07.03.06 12:04 
Könntest du mal deinen OnCellDraw Code posten?
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mi 08.03.06 21:19 
uwe hat ihn mir mal geschickt. So richtig verstehe ich nciht, was du mit den Shapes meisnt. Du malst doch deine Fläche im OnCellDraw. Bloß ebend erst nach dem Text, machst doch einfach davor.

Oder verstehe ich dich falsch?
uwewo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Do 09.03.06 08:12 
Ok zum besseren Verständnis, im OnDrawCell werden die einzelnen Zellen in Ihrer jeweiligen Farbe gefüllt.
Danach zeichne ich ein Rechteck über die ausgewählten Zellen das den Termin
darstellt.

Da OnDrawCell eigentlich bei jeder Änderung neugezeichnet wird muß ich nach dem Scrollen
der Gridfläche auch die Einträge neuzeichnen.

Im OnDrawCell Ereignis kann ich das nicht tun, weil es sonst immer wieder zu einem
Neuzeichnen des Grids und der Rechtecke kommt.

Dabei ensteht das flackern.

Ok hier der Quellcode. (Header = Kopfzeile, SideBar = 1.Spalte)

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
procedure TDateLine.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);
Var i            : Integer;
    CellText     : String;
    Hour, Time   : Real;
    ActDay:Integer;
begin
  if Header.Gradient then  
    if (ARow = 0then DrawGradient(Canvas, Header.GradientFrom, Header.GradientTo,
                                    ARect.Left, ARect.Right, ARect.Top, ARect.Bottom,0);
   if SideBar.Gradient then
    if (ACol = 0then DrawGradient(Canvas, SideBar.GradientFrom, SideBar.GradientTo,
                                    ARect.Left, ARect.Right, ARect.Top, ARect.Bottom,1);

  SetBkMode(Canvas.Handle, TRANSPARENT);

  //SideBar = ftClock
  if ((ACol = 0)  and (SideBar.Format = ftClock)) then  //SideBar Text
    begin
     Canvas.Font := SideBar.Font; //Schriftart einstellen
       if ((ARow > 0and (ACol = 0)) then //SideBar Text
        begin
          Time     := (ARow - FixedRows) * SideBar.DisplayUnit;//Gesamt Minuten
          Hour := Time / 1440//Dezimale Zeit
          CellText := FormatDateTime(ShortTimeFormat, Hour); //Zeitangaben
          //TextAusgabe
         DrawCellText(Canvas.Handle, Canvas, CellText, ARect,SideBar.FAlignmentHoriz,   SideBar.FAlignmentVert, False);
        end;
    end//SideBar = ftClock ende

   //SideBar = ftCustomItems
   if ((ACol = 0and (ARow > 0and (SideBar.Format = ftCustomItems)) then  //SideBar Text
    begin
      Canvas.Font := SideBar.Font; //Schriftart einstellen
      CellText    := SideBar.FCustomItems.Strings[ARow-1];
      DrawCellText(Canvas.Handle,Canvas,CellText, ARect, SideBar.FAlignmentHoriz, SideBar.FAlignmentvert, False);
    end;    //SideBar = ftCustomItems ende

  //Header Text
  if ((ARow = 0and (ACol > 0)) then 
   begin
     Canvas.Font := Header.Font;
    for i := 1 to FDays do
     begin
      if Header.DateTimeFormat > '' then
         CellText := FormatDateTime(Header.DateTimeFormat,Header.FirstDate + ACol -1)
      else Header.DateTimeFormat := ShortDateFormat;

      DrawCellText(Canvas.Handle, Canvas, CellText, ARect,Header.FAlignmentHoriz, Header.FAlignmentvert,true);
     end;
   end;  //Header Text ende

   //Zellen mit Farbe füllen
   if ((ACol > 0and (ARow > 0)) then //Keine Kopfzeile keine SideBar
   begin
    ActDay := DayOfWeek(Header.FirstDate + ACol-FixedCols);

    Canvas.Brush.Color := InActiveDayColor; //Inaktive Tage zuerst

    case ActDay of //Farbe wir geändert wenn aktiver Tag
      1 : if  Sunday    in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
      2 : if  Monday    in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
      3 : if  Thuesday  in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
      4 : if  Wednesday in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
      5 : if  Thursday  in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
      6 : if  Friday    in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
      7 : if  Saturday  in ActiveDays then Canvas.Brush.Color := ActiveDayColor;
    end;
     //Farbe wir geändert wenn Zelle markiert
     if AState = [gdSelected] then Canvas.Brush.Color := SelectedColor;

     Canvas.FillRect(ARect);
    end;
end;