Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.03.07;
Скачать: [xml.tar.bz2];

Вниз

Ищу компонент.   Найти похожие ветки 

 
Dan_Viking   (2002-02-21 14:51) [0]

Подскажите пожалуйста, где можно скачать компонент похожий на TLabel, но позволяющий писать число в n степени и с коэффициентом внизу (похожий на редактор формул в Word. Заранее благодарен.


 
MBo   (2002-02-21 15:22) [1]

недописанное упражнение, но работает

type
TCLabel=class(TGraphicControl)
private
FCaption:string;
FColor:TColor;
FFont,FSmallFont,TempFont:TFont;
VShift:integer;
FTransparent:Boolean;
public
constructor create(AOwner:TComponent);override;
destructor Destroy;override;
procedure Paint;override;
published
property Caption:String read FCaption write FCaption;
property Color:Tcolor read FColor write FColor;
property Font:TFont read FFont write FFont;
property SmallFont:TFont read FSmallFont write FSmallFont;
property Transparent:Boolean read FTransparent write FTransparent;
end;

constructor TCLabel.create(AOwner: TComponent);
begin
inherited;
FColor:=clBtnFace;
FFont:=TFont.create;
FSmallFont:=TFont.create;
TempFont:=TFont.create;
setbounds(10,10,150,30);
end;

destructor TCLabel.Destroy;
begin
FFont.Free;
FSmallFont.Free;
TempFont.Free;
inherited;
end;

procedure TCLabel.Paint;
var
xpos,ypos,curypos:integer;
tagend:integer;
tags,temps:string;

procedure setfnt;
var c,c2:char;
l:integer;
begin
l:=length(tags);
if l>0 then begin
c:=tags[1];
case c of
"/":begin
if l>1 then begin
c2:=tags[2];
case c2 of
"b":TempFont.Style:=TempFont.Style - [fsBold];
"g":TempFont.name:=FFont.name;
"i":TempFont.Style:=TempFont.Style - [fsItalic];
"s":TempFont.size:=FFont.size;
"v":begin TempFont.assign(FFont); VShift:=0; end;
"n":begin TempFont.assign(FFont); VShift:=0; end;
end;
end;
end;
"b":TempFont.Style:=TempFont.Style + [fsBold];
"g":TempFont.name:="Symbol";
"v":begin TempFont.assign(FSmallFont); VShift:=-5; end;
"n":begin TempFont.assign(FSmallFont); VShift:=5; end;
"i":TempFont.Style:=TempFont.Style + [fsItalic];
"s": if l>1 then TempFont.Size:=StrToIntDef(Copy(tags,2,l-1),FFont.Size);
end;
end;
end;

function findtag:integer;
var i,j:integer;
begin
result:=0;
i:=pos("<",temps);
j:=pos(">",temps);
if (i>0) and (j>i) then begin
result:=i;tagend:=j;tags:=copy(temps,i+1,j-i-1);
end;
end;

begin
inherited;
if not FTransparent then begin
canvas.Brush.Color := FColor;
Canvas.Brush.Style := bsSolid;
Canvas.FillRect(ClientRect);
end;
Canvas.Brush.Style:=bsClear;
tempfont.assign(ffont);
temps:=fcaption;
xpos:=0;ypos:=height div 2;
while length(temps)>0 do begin
if findtag<>1 then begin
Canvas.Font.assign(TempFont);
curypos:=ypos-TempFont.size*3 div 4+Vshift;
canvas.TextOut(xpos,curypos,temps[1]);
xpos:=xpos+canvas.TextWidth(temps[1]);
delete(temps,1,1);
end else begin
setfnt;
delete(temps,1,tagend);
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
cl:=tclabel.create(self);
cl.Parent:=self;
cl.Transparent:=True;
cl.caption:=
"<g> <s18>S</g></s><v> i</v><n>j</n>H<n>2</n>SO<n>4";
cl.Font.name:="Arial";
cl.Font.size:=12;
cl.SmallFont.name:="Arial";
cl.SmallFont.size:=8;
cl.SmallFont.Color:=clGreen;
end;



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.03.07;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.004 c
3-19049
yaJohn
2002-02-07 17:05
2002.03.07
DBGrid


6-19294
Maximka
2001-12-19 07:37
2002.03.07
Как узнать какие компы есть в сети


4-19384
XM-AD
2002-01-03 12:19
2002.03.07
Как вытащить текст из эдита чужого окна???


3-19097
vopros
2002-02-08 16:35
2002.03.07
События:


3-19090
DimaIv
2002-02-08 16:52
2002.03.07
Возможно ли при помощи процедуры AppendRecord ничего





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский