Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) FitsizeToText (Read 9136 times)
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
FitsizeToText
Apr 18th, 2011 at 2:45pm
Print Post  
I´m developing a system using Visual C++ and FlowChart. I´m having a problem in using the method fitsizetotext. I will explain the problem bellow:

- Such element of my diagram, has a principal box and inside i put a box to display the text. The size of text is 124 characters and i want the box has a ideal size to display all the text. But, i don´t had success with the method fitsizetotext.

What can i do to get the box with a good size to display all the text?

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: FitsizeToText
Reply #1 - Apr 18th, 2011 at 4:37pm
Print Post  
If you mean you need to limit the size of the resized node to the width of its parent node, first set the child node's width to that of the parent, and then call ResizeToFitText(FitSize.KeepWidth).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #2 - Apr 20th, 2011 at 3:33pm
Print Post  
Thanks for your reply but I think that i didn´t express correctly.

I have a princpal box and inside this, i put 2 boxes in each half. In the first half, a put a text that has 124 characters but the size of a principal box doesn´t contain all the text and i want the box has a size that show all the text automatically. Each box in my diagram should have this comportament then, all the boxes will have your size according with the text in side.

P.S: How can i put a image in this post?  Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: FitsizeToText
Reply #3 - Apr 20th, 2011 at 4:56pm
Print Post  
You will have to upload the image to your server or some site like flickr, and only add the link here.
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #4 - Apr 20th, 2011 at 4:59pm
Print Post  
Thanks! I´m in my job and all sites of the same type of flickr are blocked.

Some suggestion for my problem with flowchart?

Thanks for yout attention.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: FitsizeToText
Reply #5 - Apr 20th, 2011 at 5:14pm
Print Post  
If you need the two boxes to occupy exactly half of the parent box, can't you use the same solution as above? Only set the child's width to parent.Bounds.Width / 2 instead of the full width, then call child.ResizeToFitText(FitSize.KeepWidth), and perhaps assign the new child's Height to the parent and to the sibling node in the second half. You might also consider implementing that via a TableNode with two cells instead of creating groups of nodes.
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #6 - Apr 20th, 2011 at 6:26pm
Print Post  
I´m using the class BOX and BOXITEM to generate the diagram and these classes don´t have the method indicated.

I saw in the help and the method ResizeToFitText is to class Table.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: FitsizeToText
Reply #7 - Apr 20th, 2011 at 7:36pm
Print Post  
So you are not using the .NET WinForms control but the ActiveX one. The Box.FitSizeToText method there does not have a FitSize parameter, but always keeps widths unchanged for some text styles. From the help file - If TextStyle is set to one of the multi-line styles – tsLeftML, tsRightML or tsCenterML, FitSizeToText changes only the height of a box, leaving its width intact.
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #8 - Apr 20th, 2011 at 8:34pm
Print Post  
The style of the box that i using is tsFitPolyCenter

I put the code of my program bellow to show how i creating the boxes.

//principal box
// Criação do box.
BoxItem box = CreateBox(nX, nY, nWidth, nHeight);
GroupItem g = CreateGroup(box);
box.SetShape(m_shapeRetangular);
box.SetCustomDraw(cdAdditional);
box.SetConstraints(ncMoveDirection, 1);
box.SetLocked(false);
box.SetMnpHandlesMask(0x1FF);
AddTextos(box, strTexto, _T(""));

//internal boxes

// Add text in the internal box
void AddText(BoxItem box, CString texto1, CString texto2)
{
long width = box.GetRight() - box.GetLeft();
long height = box.GetBottom() - box.GetTop();
BoxItem t1, t2, line;

t1 = this->CreateBox(box.GetLeft(), box.GetTop(), width, height/2);
t2 = this->CreateBox(box.GetLeft()+1, box.GetTop()+(height/2)+1, width-1, (height/2)-1);
if (box.GetShape() == m_shapeRetangular)
{
t1.SetShape(GetShapes(_variant_t("Rectangle")));
t2.SetShape(GetShapes(_variant_t("Rectangle")));
}
else if (box.GetShape() == m_shapeOval)
{
t1.SetShape(m_shapeMeiaLuaCima);
t2.SetShape(m_shapeMeiaLuaBaixo);
}

// Texto 1
t1.SetStyle(bsShape);
t1.SetTextStyle(tsFitPolyCenter);
t1.SetTextColor(RGB(0,0,0));
t1.SetText(texto1);
t1.SetTransparent(true);
t1.SetLocked(true);
t1.SetTag(tagDescricaoSucinta);
t1.FitSizeToText();

CY fsize;
fsize.int64 = 80000;

CFontHolder fh1(NULL);
fh1.InitializeFont();
    t1.SetFont((LPDISPATCH)fh1.m_pFont);
t1.GetFont().SetSize(fsize);
    t1.GetFont().SetName(_T("Arial"));

// Texto 2
t2.SetStyle(bsShape);
t2.SetTextStyle(tsFitPolyCenter);
t2.SetText(texto2);
t2.SetTransparent(true);
t2.SetLocked(true);
t2.SetTag(tagEspecificacao);

CFontHolder fh2(NULL);
fh2.InitializeFont();
    t2.SetFont((LPDISPATCH)fh2.m_pFont);
t2.GetFont().SetSize(fsize);
    t2.GetFont().SetName(_T("Arial"));


GroupItem g = box.GetSubordinateGroup();
g.AttachProportional(t1,0,0,100,50);
g.AttachProportional(t2,0,50,100,100);
}
  
Back to top
 
IP Logged
 
Forum Admin
YaBB Administrator
*****
Offline


Rock and Roll

Posts: 688
Joined: Apr 6th, 2003
Re: FitsizeToText
Reply #9 - Apr 21st, 2011 at 5:48am
Print Post  
*** moved ***
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: FitsizeToText
Reply #10 - Apr 21st, 2011 at 8:00am
Print Post  
If your aim is to keep the two text boxes the same size, do something like this:

t1.FitSizeToText();
t2.FitSizeToText();
int w = max(t1.Right - t1.Left, t2.Right - t2.Left);
int h = max(t1.Bottom - t1.Top, t2.Bottom - t2.Top);
t1.SetSize(w, h);
t2.SetSize(w, h);
t2.MoveTo(t1.Left, t1.Bottom);
box.SetSize(w, h * 2);
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #11 - Apr 25th, 2011 at 2:57pm
Print Post  
Thanks for your help. My problem was solved.

I trying to learn how to use this tool and sorry for the inconvenience.

Congratulations for the forum and flowchart.
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #12 - May 20th, 2011 at 5:46pm
Print Post  
Hi!

The solution give for you helps a lot. But now, i have a new problem that i think has a relation with the solution. Some diagrams are above other lines. I have a example to send and you will see the circle above of line group. -> https://picasaweb.google.com/lh/photo/So1a-DaTxZQATYHrhYmnmlpLwJT5Im4NB-TAiEapas
w?feat=directlink

I got a solution that i increased the tree level in TreeLayout and works well. But i would like a sugestion for dynamic solution without increase the tree level.

Thanks!

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: FitsizeToText
Reply #13 - May 23rd, 2011 at 6:24am
Print Post  
Hi,

There is no solution without increasing the level distance. What you can do dynamically is to find the maximum node height after resizing all nodes and set LevelSpacing to that value before calling Arrange.

If you wish to compact the arranged tree further, you could loop over all nodes in increasing Y order order and pull each node's children closer to it. However tat will lead to nodes on the same tree level be placed on different Y positions when there are nodes of varying height in the tree.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rafael.06
YaBB Newbies
*
Offline



Posts: 14
Joined: Apr 18th, 2011
Re: FitsizeToText
Reply #14 - May 24th, 2011 at 9:46pm
Print Post  
Stoyo, thanks for your post
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint