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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnVect Draw and scale a rectangle with text

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Kostas Posted - May 09 2018 : 09:26:53
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

5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 13 2018 : 22:42:59
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
Kostas Posted - May 11 2018 : 08:35:01
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

xequte Posted - May 09 2018 : 15:45:01
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
Kostas Posted - May 09 2018 : 10:47:48
Unfortunately that does not lead to the desired result.
The objects are grouped and should be enlarged in the same proportion.





w2m Posted - May 09 2018 : 09:37:29
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