Aligning label Captions

General discussion on Visual GLCD Software.
Post Reply
Author
Message
chuckster35
Posts: 145
Joined: 23 Dec 2005 19:36
Location: Pa
Contact:

Aligning label Captions

#1 Post by chuckster35 » 16 Nov 2011 20:00

Trouble Aligning txt on label captions. the font is Tahoma27x33_Regular and the max length property is set to 17 on each label.

If there is a space in the string, it shows up at the beginning of the box.
"Text Box " shows up as " TextBox " on the initial screen start up. I must replace the space with "_" like "Text_Box ".

Also, when Label Captions are replaced they shift random amounts.

Example: Here's a list of Labels

"Text_Box1 "
"Text_Box2 "
"Text_Box3 "
"Text_Box4 "
"Text_Box5 "
"Text_Box6 "

And I set all the label_captions to this:

"Text2_Box1 "
"Text2_Box2 "
"Text2_Box3 "
"Text2_Box4 "
"Text2_Box5 "
"Text2_Box6 "

It comes out like this:

"Text2_Box1 "
" Text2_Box2 "
" Text2_Box3 "
"Text2_Box4 "
" Text2_Box5 "
"Text2_Box6 "

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Aligning label Captions

#2 Post by janko.kaljevic » 23 Nov 2011 17:29

Hello,

Thanks for reporting this, I have forwarded it to our developers, and we will fix it soon.

At the moment I can offer you a work around to fix this, so you can continue with your project.

Generate code, and press start compiler. After compiler has been loaded open *_driver.c source and find DrawLabel() function.
Replace that function with following one:

Code: Select all

void DrawLabel(TLabel *ALabel) {
int x_pos, y_pos;
x_pos = 0;
y_pos = 0;
if (ALabel->Visible == 1) {
TFT_Set_Font(ALabel->FontName, ALabel->Font_Color, FO_HORIZONTAL);
TFT_Write_Text_Return_Pos(ALabel->Caption, ALabel->Left, ALabel->Top);
x_pos = ALabel->Left;
y_pos = ALabel->Top;
if ((x_pos >= 0) && (y_pos >= 0)) {
TFT_Write_Text(ALabel->Caption, x_pos, y_pos);
}
else {
TFT_Write_Text(ALabel->Caption, ALabel->Left, ALabel->Top);
}
}
}

This will fix your issue.

Best regards.

chuckster35
Posts: 145
Joined: 23 Dec 2005 19:36
Location: Pa
Contact:

Re: Aligning label Captions

#3 Post by chuckster35 » 27 Nov 2011 07:04

Thank you very much. I am programming in Basic Pro. Will the command lines be the same?

Is there a new release coming soon? I still have no basic examples.



Thanks,

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Aligning label Captions

#4 Post by janko.kaljevic » 28 Nov 2011 16:32

Hello,

This would be the code for DrawLabel in mikroeBasic

Code: Select all

sub procedure DrawLabel(dim ALabel as ^TLabel)
dim x_pos, y_pos as integer
  x_pos = 0
  y_pos = 0
  if (ALabel^.Visible = 1) then
    TFT_Set_Font(ALabel^.FontName, ALabel^.Font_Color, FO_HORIZONTAL)
    TFT_Write_Text_Return_Pos(ALabel^.Caption, ALabel^.Left_, ALabel^.Top)
    x_pos = ALabel^.Left_
    y_pos = ALabel^.Top
    if ((x_pos >= 0) and (y_pos >= 0)) then
      TFT_Write_Text(ALabel^.Caption, x_pos, y_pos)
    else
      TFT_Write_Text(ALabel^.Caption, ALabel^.Left_, ALabel^.Top)
    end if
  end if
end sub
Best regards.

chuckster35
Posts: 145
Joined: 23 Dec 2005 19:36
Location: Pa
Contact:

Re: Aligning label Captions

#5 Post by chuckster35 » 28 Nov 2011 19:10

Janko,

That worked perfectly.

Thanks,

Post Reply

Return to “Visual GLCD General”