Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » Wrap EditString Rect to text
Re: Wrap EditString Rect to text [message #40923 is a reply to message #40919] Tue, 08 October 2013 18:39 Go to previous messageGo to previous message
iST1 is currently offline  iST1
Messages: 107
Registered: August 2013
Experienced Member
Mirek, please check this example
class EditableTree : public TreeCtrl {
public:
	typedef EditableTree CLASSNAME;
	
	EditableTree() : selId_(0) {
		editNode_.SetCtrl(edit_);
		edit_.SetFrame(NullFrame());
		OpenDeep(0, true);
		
		WhenSel = THISBACK(OnSelect);		
	}
	
	void AddNode() {
		CloseEdit();
		
		selId_ = Add(0);
		Open(selId_);
		BeginEdit();
	}
	
	void BeginEdit() {
		editNode_.image = selNode_.image;
		SetNode(selId_, editNode_);
		
		String editval = "NODE" + AsString(selId_);
	   	edit_.SetData(editval);
   		edit_.Show();
    	edit_.AutoSize();
		edit_.SetFocus();//todo: at first not select because IsOpen is false*.
		edit_.SetSelection(editval.GetCount()); 
	}
	
	void CloseEdit() {
		if (selId_ > 0) {
			selNode_.value = ~edit_;
			SetNode(selId_, Node(~edit_));
			edit_.Hide();
		}
	}
	
	void OnSelect()
	{
		CloseEdit();
		selId_ = GetSel()[0];
		selNode_ = GetNode(selId_);
		BeginEdit();
	}
	
private:
	int selId_;
        EditString edit_;
   	Node selNode_;
   	Node editNode_;
};

GUI_APP_MAIN
{	
	TopWindow wnd;
	Button btn;
	wnd.Add(btn.SetLabel("Add").LeftPos(10).TopPos(10));
	
	EditableTree tree;
	wnd.Add(tree.VSizePos(40).HSizePos());

	btn <<= callback(&tree, &EditableTree::AddNode);
    wnd.Run();
}


In edit mode (when select) text shifts in horizontal
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Should EditField::Paint respect IsEditable method???
Next Topic: Please help debug this program (Re: EditDouble with customized Convert)
Goto Forum:
  


Current Time: Sun Apr 28 13:45:04 CEST 2024

Total time taken to generate the page: 0.06321 seconds