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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "StrUtils.hpp"
#include "LabelVertical.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TLabelVertical *)
{
new TLabelVertical(NULL);
}
//---------------------------------------------------------------------------
__fastcall TLabelVertical::TLabelVertical(TComponent* Owner)
: TCustomLabel(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TLabelVertical::SetVertical(bool AVertical)
// SetVertical modifie la variable FVertical qui est la valeur
// renvoyee par la propriete
{
if (AVertical != FVertical)
{
FVertical = AVertical;
Invalidate();
AdjustBounds();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TLabelVertical::GetLabelText()
// on recupere le Caption du TLabel
// redefinition de la fonction GetLabelText
{
if (FVertical)
{
// on lit la longueur du Caption
Size = GetTextLen();
// on recupere le Caption
char *capt = new char(Size+1);
GetTextBuf(capt,Size+1);
// on reecrit la chaine du Caption
tempd = "";
for (i=0;i<Size;i++)
{
tempd += capt[i];
tempd += '\n';
}
// on ecrit le Caption
//SetTextBuf(tempd);
delete capt;
return tempd;
}
else
{
// on lit la longueur du Caption
Size = GetTextLen();
// on recupere le Caption
char *capt = new char(Size+1);
GetTextBuf(capt,Size+1);
// on reecrit la chaine du Caption
tempd = "";
for (i=0;i<Size;i++)
{
switch (capt[i])
{
case '\\' :
break;
case 'n' :
break;
default :
tempd += capt[i];
}
}
delete capt;
return tempd;
}
}
//---------------------------------------------------------------------------
// enregistrement du composant et affichage de son icone dans la^palette.
// ici il est mis dans l'onglet "MesComposants"
namespace Labelvertical
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TLabelVertical)};
RegisterComponents("MesComposants", classes, 0);
}
}
//--------------------------------------------------------------------------- |
Partager