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 74 75 76 77
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall jStringGrid::DrawCell(int ACol, int ARow, const TRect &ARect,
TGridDrawState AState)
{
//Juste un exemple, on donne quand même à l'utilisateur de quoi gérer lui-même !
if(jStringGrid::OnDrawCell == NULL)
{
if(AState.Contains(gdFixed))
{
jStringGrid::Canvas->Brush->Style = bsSolid;
jStringGrid::Canvas->Brush->Color = clSilver;
jStringGrid::Canvas->RoundRect(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom,8,8);
}
else
{
jStringGrid::Canvas->Brush->Style = bsClear;
jStringGrid::Canvas->Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
}
}
else
{
//L'image en arrière plan est de facto dessinée par Paint
jStringGrid::OnDrawCell(this, ACol, ARow, ARect, AState);
}
}
//---------------------------------------------------------------------------
void __fastcall jStringGrid::Paint()
{
TGridDrawState GrState;
jStringGrid::Canvas->Draw(0,0,Form1->Image1->Picture->Bitmap); // << ma trifide... invisible
jStringGrid::Canvas->Pen->Style = psSolid;
jStringGrid::Canvas->Pen->Color = clBlack;
jStringGrid::Canvas->Pen->Mode = pmNot;
int xs;
int ys;
// C'est un essai donc pour les boucles ... ... ... je teste sur 5 * 5
for(int y = 0; y < RowCount; y++)
{
for(int x = 0; x < ColCount; x++)
{
//juste pour tester donc à améliorer
if((y == 0) || (x == 0))GrState = GrState << gdFixed;
else GrState = GrState >> gdFixed;
xs = x * DefaultColWidth; // << à améliorer
ys = y * DefaultRowHeight; // << idem
jStringGrid::DrawCell(x,y, Rect(xs,
ys,
xs + DefaultColWidth,
ys + DefaultRowHeight),
GrState);
}
}
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
( (jStringGrid*) StringGrid1 )->jStringGrid::Paint();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
( (jStringGrid*) StringGrid1 )->jStringGrid::DrawCell(2, 2, ( (jStringGrid*) StringGrid1 )->CellRect(2,2), TGridDrawState());
}
//--------------------------------------------------------------------------- |
Partager