The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Margins for Labels Added to a Graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cdrozdowski111

USA
247 Posts

Posted - 04/08/2014 :  09:40:15 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 9.1 SR2 64-bit/32-bit, Win7 Pro 64-bit, running in VMware Fusion 5.0.4

When I use LabTalk to add a text label to a graph and set the background to black line (see code below), how can I control the size of the margin between the text and black border? It is much too big for my purposes.

If I can't do it in LabTalk, can it be done in Origin C? I don't have time to dig into the source right now.

GObject goMyText = "MY_TEXT";
label -n goMyText temp;

goMyText.text$ = sMyText$; // sMyText$ defined elsewhere
goMyText.attach = 1; // Page
goMyText.left = 0; // Need to change
goMyText.top = 0;// Need to change
goMyText.background = 1; // Black line
goMyText.fSize = 8; // Font size
goMyText.draw(); // Refresh object

Castiel

343 Posts

Posted - 04/08/2014 :  11:16:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
int setLabelMargin(string s, double left = 3., double top = 3., double right = 3., double bottom = 3.)
{
	GraphLayer gl = Project.ActiveLayer();
	if( !gl )
		return -1;
	
	GraphObject go = gl.GraphObjects(s);
	if( !go )
		return -2;
	
	Tree t;
	t = go.GetFormat(FPB_DIMENSION, FOB_ALL, TRUE, TRUE);
	t.Root.Background.Dimension.Left.dVal = left;
	t.Root.Background.Dimension.right.dVal = right;
	t.Root.Background.Dimension.top.dVal = top;
	t.Root.Background.Dimension.bottom.dVal = bottom;
	
	go.UpdateThemeIDs(t.Root);
	go.ApplyFormat(t, TRUE, TRUE);
	
	gl.GetPage().Refresh();
	
	return 0;
}


As for the label you created, goMyText, is named "\"MY_TEXT\"", that is:
int nRet;
nRet = setLabelMargin(""MY_TEXT"", 5.0, 5.0, 5.0, 5.0);


妾+   午旦  妹罕妾  妾伊    用仇  妾/     岫ㄞ
 妾京用 仍巨  件 侈   件戶' 甘岫平   /欠  白岫妹
   併             艮          岫  奈 白   岫
                              岫
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 04/08/2014 :  11:44:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Rock on! Thanks.

I'll correct the quotes around GObject goMyText = "MY_TEXT"; I'm used to programming in languages that require quotes around all string literal assignments.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000