ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnVect Draw and scale a rectangle with text
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Kostas

Germany
21 Posts

Posted - May 09 2018 :  09:26:53  Show Profile  Reply
Hello everyone,

I draw a rectangle object and a text object. The text is in the middle of the rectangle. Both objects are grouped.

If I change the height of the rectangle the text will be larger than this frame. How can prevent this so that the text always stays within this frame?









    with ImageEnVect1 do
    begin
      //Rectangle 	
      ObjNo := AddNewObject;
      ObjKind[ ObjNo ] := iekBOX;
      ObjBrushStyle[ ObjNo ] := bsSolid;
      ObjBrushColor[ ObjNo ] := clGreen;
      ObjLeft[ ObjNo ] := X;
      ObjTop [ ObjNo ] := Y;


      //TextLabel
      TextObj := AddNewObject;
      ObjKind[ TextObj ] := iekTEXT;
      ObjText[ TextObj ] := 'HW 103';
      ObjTextAutoSize[ TextObj ] := false;
      ObjTextAlign[ TextObj ] := iejCenter;

      StretchTextRect( TextObj );
      txtFont := FontDialog1.Font;
      txtFont.Height := 0;
      SetObjFont(TextObj,txtFont);

	  //TextLabel at box center
      ObjLeft[ TextObj ] := Round(ObjLeft[ ObjNo ] + (ObjWidth[ ObjNo ] / 2) - (ObjWidth[ TextObj ] / 2));
      ObjTop[ TextObj ] := Round(ObjTop[ ObjNo ] + (ObjHeight[ ObjNo ] / 2) - (ObjHeight[ TextObj ] / 2));

      //GroupObjects
      UnSelAllObjects;
      AddSelObject( ObjNo );
      AddSelObject( TextObj );
      GroupObjects();


      MouseInteractVt := [miObjectSelect];
    end;




Regards,
Kostas

w2m

USA
1990 Posts

Posted - May 09 2018 :  09:37:29  Show Profile  Reply
TImageEnVect.ObjTextAutoSize

Declaration

property ObjTextAutoSize[hobj: integer]: boolean;

Description

Use ObjTextAutoSize to make the iekText object adjust its size automatically so the bounding box accommodates the width of the text.

When ObjTextAutoSize is false, the text object has a fixed width.
When ObjTextAutoSize is true, the size of the object is re-adjusted whenever the user edits the text.

IEV_PREVIOUS_INSERTED_OBJECT can be specified for hobj to refer to the object that was last inserted.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

Kostas

Germany
21 Posts

Posted - May 09 2018 :  10:47:48  Show Profile  Reply
Unfortunately that does not lead to the desired result.
The objects are grouped and should be enlarged in the same proportion.





Go to Top of Page

xequte

39142 Posts

Posted - May 09 2018 :  15:45:01  Show Profile  Reply
Hi

You would need to change the text size in the OnObjectMoveResize event:

https://www.imageen.com/help/TImageEnVect.OnObjectMoveResize.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Kostas

Germany
21 Posts

Posted - May 11 2018 :  08:35:01  Show Profile  Reply
Hi Nigel,

StretchTextRect adjusts the rectangle to the text.
I need it the other way around. I have a rectangle in which the text should be adjusted.

I have only found a way to change the ObjFontHeight starts by FontHeight=1 and StretchTextRect
until the text reaches the rectangle dimensions.
Or is there another method?

regards,
Kostas

Go to Top of Page

xequte

39142 Posts

Posted - May 13 2018 :  22:42:59  Show Profile  Reply
Hi Kostas

There is not a better way with TImageEnVect objects, but with text layers you can set TextOverflow := ieoShrink; (in the upcoming 8.0.0).



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: