destructor TBrowserTitle.Destroy;
begin
inherited;
end;
Procedure TBrowserTitle.setColorTitle(Value:TColor);
Begin
fColorTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.setColorSubTitle(Value:TColor);
Begin
fColorSubTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.setColorRectTitle(Value:TColor);
Begin
fColorRectTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.SetTitle(Value:String);
Begin
fTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.SetSubTitle(Value:String);
Begin
fSubTitle:=Value;
Invalidate;
End;
procedure TBrowserTitle.Resize;
Begin
Width:=163;
If Height<49 Then
Height:=49;
Invalidate;
End;
procedure TBrowserTitle.Paint;
Var
RectTitle:TRect;
WidthString,HeightString,LeftString,TopString:Integer;
Begin
InHerited;
With Canvas Do
Begin
Brush.Style:=BsClear;
With RectTitle Do
Begin
Left:=0;
Right:=Self.Width;
Top:=0;
Bottom:=49;
Brush.Color:=Self.fColorRectTitle;
Pen.Color:=ClBlack;
Pen.Width:=4;
Rectangle(RectTitle);
Font.Name:='Comic Sans MS';
Font.Size:=11;
Font.Color:=Self.fColorSubTitle;
WidthString:=TextWidth(fSubTitle);
HeightString:=TextHeight(fSubTitle);
LeftString:=Self.Width-WidthString-5;
TopString:=Bottom-Pen.Width-HeightString;
TextOut(LeftString,TopString,fSubTitle);
End;
End
End;
{>>TBrowserButton}
constructor TBrowserButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fClicked:=False;
end;
destructor TBrowserButton.Destroy;
begin
inherited;
end;
Procedure TBrowserButton.SetColorLine(Value:TColor);
begin
Self.fColorLine:=Value;
Self.Invalidate;
end;
Procedure TBrowserButton.SetColorTop(Value:TColor);
begin
Self.fColorTop:=Value;
Self.Invalidate;
end;
Procedure TBrowserButton.SetColorBottom(Value:TColor);
begin
Self.fColorBottom:=Value;
Self.Invalidate;
end;
Procedure TBrowserButton.SetCaption(Value:String);
begin
Self.fCaption:=Value;
Self.Invalidate;
end;
procedure TBrowserButton.Paint;
Var
RectTop,RectBottom : TRect;
HeightCaption, WidthCaption:Integer;
Begin
InHerited;
DrawBorder;
With Self.Canvas Do
Begin
Font:=Self.Font;
With RectTop Do
Begin
Top:=6;
Bottom:=Self.Height Div 2 ;
Left:=6;
Right:=Self.Width-6;
Brush.Color:=Self.fColorTop;
Pen.Color:=Self.fColorTop;
Rectangle(RectTop);
End;
With RectBottom Do
Begin
Top:=Self.Height Div 2;
Bottom:=Self.Height-6;
Left:=6;
Right:=Self.Width-6;
Brush.Color:=Self.fColorBottom;
Pen.Color:=Self.fColorBottom;
Rectangle(RectBottom );
End;
Brush.Color:=Self.fColorLine;
Pen.Color:=Self.fColorLine;
Pen.Width:=2;
MoveTo(5,Self.Height Div 2);
LineTo(Self.Width-7,Self.Height Div 2);
HeightCaption:=Self.Canvas.TextHeight(Self.Caption);
WidthCaption:=Self.Canvas.TextWidth(Self.Caption);
Brush.Style:=BsClear;
TextOut((Self.Width - WidthCaption) Div 2,(Self.Height - HeightCaption) Div 2, Self.Caption);
End;
End;
Procedure TBrowserButton.DrawBorder;
Var
LeftColor, RightColor:TColor;
UpperCorner,LowerCorner:Array [0..2] Of TPoint;
Begin
If Not fClicked Then
Begin
LeftColor:=ClWhite;
RightColor:=$00657271;
End
Else
Begin
LeftColor:=$00657271;
RightColor:=ClWhite;
End;
With Self.Canvas Do
Begin
Pen.Width:=2;
UpperCorner[0]:=Point(Pen.Width,Self.Height-Pen.Width);
UpperCorner[1]:=Point(Pen.Width,Pen.Width);
UpperCorner[2]:=Point(Self.Width-Pen.Width,Pen.Width);
LowerCorner[0]:=Point(Pen.Width,Self.Height-Pen.Width);
LowerCorner[1]:=Point(Self.Width-Pen.Width,Self.Height-Pen.Width);
LowerCorner[2]:=Point(Self.Width-Pen.Width,Pen.Width);
Brush.Color:=LeftColor;
Pen.Color:=LeftColor;
Polyline(UpperCorner);
Brush.Color:=RightColor;
Pen.Color:=RightColor;
Polyline(LowerCorner);
End;
End;
procedure TBrowserButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
Begin
InHerited;
If Shift=[SSLeft] Then
Begin
Self.fClicked:= True;
Self.Invalidate;
End;
End;
destructor TGaugeBar.Destroy;
begin
inherited;
end;
Procedure TGaugeBar.SetMin(Value:Integer);
Begin
If (Value<=fMax) And (Value<=fPos) Then
Begin
fMin:=Value;
Self.Invalidate;
End;
End;
Procedure TGaugeBar.SetMax(Value:Integer);
Begin
If (Value>=fMin) And (Value>=fPos) Then
Begin
fMax:=Value;
Self.Invalidate;
End;
End;
Procedure TGaugeBar.SetPos(Value:Integer);
Begin
If (Value>=fMin) And (Value<=fMax) Then
Begin
fPos:=Value;
Self.Invalidate;
End;
End;
Procedure TGaugeBar.SetStickColor(Value:TColor);
Begin
fStickColor:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.SetBackGroundColor(Value:TColor);
Begin
fBackGroundColor:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.SetFullColor(Value:TColor);
Begin
fFullColor:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.SetText(Value:String);
Begin
fText:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.Resize;
begin
inherited;
Height:=25;
end;
Procedure TGaugeBar.Paint;
Var
LeftRect,StickRect,BackGroundRect:TRect;
WidthText:Integer;
Str:String;
begin
inherited;
With Canvas Do
Begin
Font.Size:=8;
Pen.Width:=2;
Str:=fText+IntToStr(fPos);
WidthText:=(Width-TextWidth(Str)) Div 2;
Brush.Style:=BsClear;
TextOut(WidthText,0,Str);
With BackGroundRect Do
Begin
Left:=0;
Right:=Width;
Top:=15;
Bottom:=23;
Brush.Color:=fBackGroundColor;
Rectangle(BackGroundRect);
End;
With LeftRect Do
Begin
Left:=0;
Right:=Round(Width*(fPos-fMin) / (fMax-fMin));
Top:=15;
Bottom:=23;
Brush.Color:=fFullColor;
Rectangle(LeftRect);
End;
Brush.Color:=ClWhite;
Pen.Color:=ClWhite;
Pen.Width:=0;
MoveTo(4,19);
LineTo(Width-4,19);
With StickRect Do
Begin
Left:=Round(Width*((fPos-fMin) / (fMax-fMin))-0.01*Width);
Right:=Round(Width*((fPos-fMin) / (fMax-fMin))+0.01*Width);
If Left<=0 Then
Begin
Left:=0;
Right:=Round(0.02*Width);
End;
If Right>=Width Then
Begin
Left:=Round(Width*0.98);
Right:=Width;
End;
Top:=13;
Bottom:=25;
Brush.Color:=fStickColor;
Pen.Color:=ClBlack;
Pen.Width:=2;
Rectangle(StickRect);
End;
End;
End;
Procedure TGaugeBar.MouseDown(Button: TMouseButton; Shift: TShiftState;X, Y: integer);
Var
BnMax,BnMin : Integer;
begin
inherited;
If (Shift=[SSLeft]) Then
Begin
BnMin:=Round(Width*((fPos-fMin) / (fMax-fMin))-0.01*Width);
BnMax:=Round(Width*((fPos-fMin) / (fMax-fMin))+0.01*Width);
If (Shift=[SSLeft]) And (X>=BnMin) And (X<=BnMax) Then
fPos:=X*(fMax-fMin) Div Width+fMin;
If fPos<fMin Then fPos:=fMin;
If fPos>fMax Then fPos:=fMax;
Self.Invalidate;
End;
End;
procedure TGaugeBar.MouseMove(Shift: TShiftState; X, Y: integer);
begin
inherited;
If (Shift=[SSLeft]) Then
Begin
fPos:=X*(fMax-fMin) Div Width+fMin;
If fPos<fMin Then fPos:=fMin;
If fPos>fMax Then fPos:=fMax;
Self.Invalidate;
End;
End;
Procedure TBrowserEffects.Resize;
Begin
InHerited;
Width:=168;
Height:=329;
End;
Procedure TBrowserEffects.CreateButton(var Button:TBrowserButton;BtLeft,BtTop:Integer; AName, BtCaption:String);
Begin
Button:=TBrowserButton.Create(Self);
With Button Do
Begin
Parent:=Self;
Name:=AName;
SetSubComponent(TRUE);
Width:=28;
Height:=28;
Left:=BtLeft;
Top:=BtTop;
Caption:=BtCaption;
Font.Size:=14;
Font.Style:=[FsBold];
Button.ColorTop:=$00FFE6E1;
Button.ColorBottom:=$00E8E8E8;
Button.ColorLine:=$0041C9D3;
End;
End;
Procedure TBrowserEffects.Create_Constantes_Nodes;
Begin
With fEffectsView Do
Begin
SndFontNode:=Items.Add(NIL,'SOUNDFONTS');
VSTINode:=Items.Add(NIL,'EFFETS VSTI');
VSTENode:=Items.Add(NIL,'EFFETS VSTE');
AutoWahNode:=Items.AddChild(NIL,'AUTOWAH');
PhaserNode:=Items.AddChild(NIL,'PHASER');
ChorusNode:=Items.AddChild(NIL,'CHORUS');
DistortionNode:=Items.AddChild(NIL,'DISTORTION');
CompressorNode:=Items.AddChild(NIL,'COMPRESSOR');
AllPassFilterNode:=Items.AddChild(NIL,'ALL PASS FILTER');
EchoNode:=Items.AddChild(NIL,'ECHO');
DSPNode:=Items.Add(NIL,'EFFETS DSP');
End;
End;
Procedure TBrowserEffects.SetTracksGrid(Value:TTracksGrid);
Begin
fTracksGrid:=Value;
Self.Invalidate;
End;
Procedure TBrowserEffects.Paint;
Begin
InHerited;
With fEffectsView Do
Begin
Font.Color:=$00400080;
Font.Size:=6;
Color:=ClSilver;
End;
End;
end.
Je suis confronté à un problème : J'aimerai pouvoir rajouter un enfant à SndFontNode. Cependant si je fais : :fEffectsView.Items.Add(SndFontNode,'Test'); j'ai une magnifique exception qui apparait et je ne comprend pas pourquoi (Ca marche pas non plus avec AddChild). En fait l'idée est que quand je rajoute un TEffect via AnSoundFontCnt.Add, j'ai un noeud enfant qui est rajouté à SndFontNode et cela apparait dans le TreeView. Si quelqu'un comprend pourquoi ca serait cool .
Je ne suis pas d'accord avec toi : la procédure setColorTitle(Value:TColor) est appelé une fois en Runtime ou en Designtime lors de la "création" du composant. J'ai fais le choix de ne pas alourdir le code pour cette raison, dans un esprit d'optimisation.
Ce que tu dis est valable pour des valeurs Min,Max et Pos pour un TrackBar ou une ScrollBar
Procedure TBrowserTitle.SetSubTitle(Value:String);
Begin
fSubTitle:=Value;
Invalidate;
End;
Aucune raison de vérifier le sous-titre : une fois qu'il y est aucune raison de le changer .
"Si c'est pareil tu peux toutes les modifier et faire 1 seul Invalidate sur le dernier appelé ?? " : Ben non les procédures sont indépendantes Bacterius. SetSubTitle n'appelle pas setColorTitle par exemple donc je ne vois pas comment je pourrais avoir un seul Invalidate sauf créer une procedure spécifique mais qui faudra bien que j'appelle de toute facon. Donc Invalidate ou cette procédure ca ne change rien en terme d'optimisation.
Avant de parler d'optimisation, j'essaye déjà de résoudre mon probleme . Apres on en reparlera .
Vous n’avez pas trouvé la réponse que vous recherchez ?
Bacterius
Messages postés3792Date d'inscriptionsamedi 22 décembre 2007StatutMembreDernière intervention 3 juin 201610 12 oct. 2008 à 00:29
Mais tu dis que tu appelles en runtime ou en design ces fonctions au moins 1 fois chacune.
Donc, si tu les appelles au moins 1 fois chacune, c'est à dire chacune leur tour - on est toujours d'accord - alors tu n'as pas besoin de mettre Invalidate dans la première, ni dans les suivantes, uniquement dans la dernière - toujours d'accord - car la dernière appellera de toute façon Invalidate.
Les couleurs sont justes là pour la décoration : une fois que tu as choisis ta couleur, tu n'y touche plus.
Par contre tu dois pouvoir modifier une couleur indépendamment des autres d'ou le Invalidate a chaque procedure. Ce que tu proposes fais que la changement ne serait valable quand RunTime pas en DesignTime, ce qui n'est pas bon.
De plus comme je viens de l'indiquer, tu dois pouvoir quand meme proposer ces paramétrages.
En résumé : ce que tu proposais allourdissais le code vu la nature meme de l'utilisation de ces fonctions. Une comparaison ne se fait sans contre partie : Dans 99% des cas ta comparaison n'aurait rien changé à l'appel du Invalidate : le seul cas de figure est de choisir deux fois la meme couleur et de facon successives (Du noir),ce qui est peu probable. Par contre dans tout les cas suivant cela induit une comparaison qui en définitif rend ton code lourd. Donc dans un but d'optimisation, j'évite de le faire .
Bacterius
Messages postés3792Date d'inscriptionsamedi 22 décembre 2007StatutMembreDernière intervention 3 juin 201610 12 oct. 2008 à 01:23
Ok ok ok je me rends tu as gagné ^^'
Sinon pour ton problème (venons-en ...) :
je n'arrive pas à trouver l'endroit qui ne va pas ... mais si mes souvenirs sont bons et que tu utilises TCustomTreeView, pour ajouter un noeud il faut d'abord créer une variable TTreeNode, l'initialiser et ensuite la passer en paramètre dans AddChild ou AddNode ...
Je ne sais pas si tu n'as fait, le code est tellement gros et ma molette est tellement mal foutue ...
mes souvenirs sont bons et que tu utilises TCustomTreeView, pour ajouter un noeud il faut d'abord créer une variable TTreeNode, l'initialiser et ensuite la passer en paramètre dans AddChild ou AddNode : c'est ce que j'ai fais Bacterius .