Search found 111 matches

by beneficii
Fri Jun 20, 2014 1:34 pm
Forum: C++ Development
Topic: For controls, dialogs, etc., always use new?
Replies: 2
Views: 733

Re: For controls, dialogs, etc., always use new?

With very few exceptions all windows/controls must be created on the heap. But most of them will be deleted automatically: - wxWindows that are children of other windows (all "normal" controls, like wxButton etc). - wxSizers that are either inside other sizers or are assigned to a window (this usua...
by beneficii
Fri Jun 20, 2014 7:17 am
Forum: C++ Development
Topic: For controls, dialogs, etc., always use new?
Replies: 2
Views: 733

For controls, dialogs, etc., always use new?

Which model should I use, creating a new pointer or simply building the object? For example, for wxFileDialog, should I use: wxFileDialog* file_dlg = new wxFileDialog(this, "Open File", ... (etc.) ); //no accompanying delete statement or this: wxFileDialog file_dlg(this, "Open File", ... (etc.)); Wh...
by beneficii
Thu Jun 19, 2014 8:35 am
Forum: Open Discussion
Topic: C++11: Factory allocators?
Replies: 0
Views: 1638

C++11: Factory allocators?

Let's say that I have a base class, with many classes derived through inheritance, and I want to store all instances of the base/derived classes in a container storing, say, smart pointers of the type std::unique_ptr<base> , which stores a pointer to the base class. It seems that with the addition o...
by beneficii
Wed Jun 18, 2014 8:10 pm
Forum: Open Discussion
Topic: Location in memory of class object and member objects (C++)
Replies: 2
Views: 1364

Location in memory of class object and member objects (C++)

In C++, when you create a class object which has member objects, are there any guarantees that the first member object starts at the same location in memory as the class object itself and that the member objects will be consecutive (i.e. a member object that is not the first is guaranteed to follow ...
by beneficii
Wed Jun 18, 2014 2:28 pm
Forum: General Development
Topic: Porting wxWidgets apps developed with Visual C++ to other OS
Replies: 3
Views: 1735

Re: Porting wxWidgets apps developed with Visual C++ to othe

Thank you very much for that reply. That would help a lot. By the way, can you post a list of VC++ specific commands(or give a link to a page containing that). You would just open up the wx_vc10.sln in the build\msw folder of your wxWidgets directory, say yes to upgrade it, and then build wxWidgets...
by beneficii
Wed Jun 18, 2014 5:28 am
Forum: C++ Development
Topic: wxFileName relative and absolute path
Replies: 3
Views: 1506

Re: wxFileName relative and absolute path

I could also write a handler function that does this for me automatically:

Code: Select all

wxFileName concat_dir(wxFileName original, const wxString& rel_path) {
	original.Assign(original.GetPathWithSep() + rel_path);
	original.Normalize();
	return original;
}
by beneficii
Tue Jun 17, 2014 9:46 pm
Forum: C++ Development
Topic: wxFileName relative and absolute path
Replies: 3
Views: 1506

Re: wxFileName relative and absolute path

I think wxFileName alone can't do it. Try something like this: wxString base_dir( "C:\\blah\\" ); wxString rel_file( "..\\blah2\\blah2.bin" ); wxString pathname = base_dir + rel_file; wxFileName fn( pathname ); fn.Normalize(); wxLogMessage( fn.GetFullPath() ); OK. That makes sense. So I could do, s...
by beneficii
Tue Jun 17, 2014 6:37 pm
Forum: C++ Development
Topic: wxFileName relative and absolute path
Replies: 3
Views: 1506

wxFileName relative and absolute path

I'm trying to make it so that I can move wxFileName into a particular directory, and then just set filenames relative to that directory. For example, I have wxFileName get a filename "C:\blah\blah.prj." I then would like to be able to set the relative filename (gotten from blah.prj) as "..\blah2\bla...
by beneficii
Tue Jun 17, 2014 5:03 pm
Forum: Announcements and Discoveries
Topic: New C++ container class template: range_map
Replies: 0
Views: 837

New C++ container class template: range_map

I have now created a new type of container for C++, which actually works a lot like an XML document if you think about it, that is like map, but stores ranges instead of points (and there can be subsets and supersets, but no partial overlap between ranges): http://beneficii.net/range_map/ Also, if a...
by beneficii
Tue Jun 17, 2014 4:25 pm
Forum: General Development
Topic: Porting wxWidgets apps developed with Visual C++ to other OS
Replies: 3
Views: 1735

Re: Porting wxWidgets apps developed with Visual C++ to othe

In answer to your questions: 1.) Yes, if you make sure to not put in your code VC++-specific features such as #pragma or any OS-specific features, but instead let wxWidgets completely wrap around the API. 2.) Yes, you will need to re-compile wxWidgets. I'm assuming you're using Visual Studio 2013. O...
by beneficii
Mon Jun 16, 2014 8:57 am
Forum: C++ Development
Topic: Trying to write XML Document keeping track
Replies: 4
Views: 846

Re: Trying to write XML Document keeping track

SOLVED IT! static const wxString wxsCode = _T("code"); static const wxString wxsData = _("data"); void master::save_document() { wxXmlDocument doc; wxXmlNode* root = new wxXmlNode(wxXML_ELEMENT_NODE, _T("project")); root->AddAttribute(_T("bin_file"), fnBIN.GetFullPath()); doc.SetRoot(root); wxXmlNod...
by beneficii
Mon Jun 16, 2014 8:44 am
Forum: C++ Development
Topic: Trying to write XML Document keeping track
Replies: 4
Views: 846

Re: Trying to write XML Document keeping track

I could get it to work also using an intermediary between the root and the children: wxXmlDocument thedoc; wxXmlNode* theroot = new wxXmlNode(); theroot->SetName("project"); theroot->SetType(wxXML_ELEMENT_NODE); wxXmlAttribute* info = new wxXmlAttribute(); info->SetName("file"); info->SetValue("thes...
by beneficii
Mon Jun 16, 2014 8:25 am
Forum: C++ Development
Topic: Trying to write XML Document keeping track
Replies: 4
Views: 846

Re: Trying to write XML Document keeping track

I've created a provisional one that works. Don't mind the tag names: wxXmlDocument thedoc; wxXmlNode* theroot = new wxXmlNode(); theroot->SetName("project"); theroot->SetType(wxXML_ELEMENT_NODE); wxXmlAttribute* info = new wxXmlAttribute(); info->SetName("file"); info->SetValue("thestuff.txt"); ther...
by beneficii
Mon Jun 16, 2014 6:53 am
Forum: C++ Development
Topic: Trying to write XML Document keeping track
Replies: 4
Views: 846

Re: Trying to write XML Document keeping track

Rearranging the code, waiting to add the child nodes at the last minute and the root at the last minute seemed to help: void master::save_document() { wxXmlDocument doc; wxXmlNode* root = new wxXmlNode(wxXML_ELEMENT_NODE, _T("project")); root->AddAttribute(_T("bin-file"), fnBIN.GetFullPath()); wxXml...
by beneficii
Mon Jun 16, 2014 6:36 am
Forum: C++ Development
Topic: Trying to write XML Document keeping track
Replies: 4
Views: 846

Trying to write XML Document keeping track

...of data/code nodes and base origin nodes. Here is the code: void master::save_document() { wxXmlDocument doc; wxXmlNode* root = new wxXmlNode(wxXML_ELEMENT_NODE, _T("project")); root->AddAttribute(_T("bin-file"), fnBIN.GetFullPath()); doc.SetRoot(root); wxXmlNode* bases = new wxXmlNode(doc.GetRoo...