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
 Forum for Origin C
 Code Builder change row style and insert theta
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

michaelbraun

USA
21 Posts

Posted - 07/07/2015 :  6:09:12 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 sr2
Operating System: Windows 7 and 10

I am trying to use the code builder to set the long name row style to rich text programmatically upon importing data, is there a way to do this? Furthermore, I am trying to name a column as 2θ using the unicode character 03B8, however I cannot get the column name to be 2θ using code builder in either the long name or units row.

jasonzhao

China
262 Posts

Posted - 07/08/2015 :  05:06:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Please refer to the function below, which set the format of the long name into Rich Text and set long name=2theta for col(B):


#include <..\OriginLab\theme_utils.h>
void	test_set_greek_in_longname()
{
	Worksheet wks = Project.ActiveLayer();
	if ( wks )
	{
		Tree trFmt;
		trFmt = wks.GetFormat(FPB_ALL, FOB_ALL & ~(FOB_LINK_STYLE|FOB_RANGE_STYLE), TRUE, TRUE);
		TreeNode trTextFmt = theme_tree_get_node_by_name_strval(trFmt, STR_NAMESTYLE_LONG_NAME);
		if ( trTextFmt )
		{
			trTextFmt.Style.Control.strVal = "Origin Text Edit";
			if ( 0 == wks.UpdateThemeIDs(trFmt.Root) )
			{
				wks.ApplyFormat(STYLE_REPAINT | STYLE_RELATIVE | STYLE_UNDO | STYLE_COMPLETE, trFmt);
				//after set as Rich Text, set long name to column
				string strLongName = "2\g(q)";
				Column colB(wks, 1);
				if ( colB )
				{
					colB.SetLongName(strLongName);
					out_str("Please check Long Name of column B");
				}
			}
		}
	}
}


Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 07/08/2015 06:02:00 AM
Go to Top of Page

michaelbraun

USA
21 Posts

Posted - 07/08/2015 :  09:44:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, the code worked great for setting rich text style, however I need the unicode theta not the greek style theta. When exporting from origin as a pdf (and then using as a figure in LaTeX) the greek style theta does not render as a theta, however the unicode theta renders correctly. Furthermore, the greek style theta does not match the font of the 2 well, while the unicode theta takes the same font style as the 2 (ie arial). Any thoughts?
Go to Top of Page

Sophy

China
Posts

Posted - 07/08/2015 :  10:33:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Michael:
You can try to use escaped unicode, see the following line

string strLongName = "2\\x(03B8)"; //\x(03B8) represent the unicode value of theta

quote:
Originally posted by michaelbraun

Hi, the code worked great for setting rich text style, however I need the unicode theta not the greek style theta. When exporting from origin as a pdf (and then using as a figure in LaTeX) the greek style theta does not render as a theta, however the unicode theta renders correctly. Furthermore, the greek style theta does not match the font of the 2 well, while the unicode theta takes the same font style as the 2 (ie arial). Any thoughts?

Go to Top of Page

michaelbraun

USA
21 Posts

Posted - 07/09/2015 :  09:33:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Worked perfect, thank you! I had the unicode, but I didn't realize you needed the second slash in the string "2\\x(03B8)".
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