Hi, buddies, I am writing a C++ library, it is an open source software, contains GUI/Threads/TextToken and so on...
find more information at http://stdex.sourceforge.net
Are you interesting in implemention of GUI controls?
hehe..regards.
Hi, buddies, I am writing a C++ library, it is an open source software, contains GUI/Threads/TextToken and so on...
find more information at http://stdex.sourceforge.net
Are you interesting in implemention of GUI controls?
hehe..regards.
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
Very nice to see something like this.
I would be interested in making changes more to VB-like style (ie form.Caption = "something") instead of a function and such.
Also more of a suggestion - but you can use Option Tree for listboxes and such. Incredibly feature rich.
>>I would be interested in making changes more to VB-like style (ie form.Caption = "something") instead of a function and such.
Eww...stick to accessors.
Yeah, but it makes more sense to keep the interface away from the data especially if you are in early stages of a library.
IIRC when you write a COM object in C++ (and I think the same applies to when you write them in VB) you have to use accessors in the interface you expose that the VB language then hides from the user when it makes those properties accessible.
Let the users access your data and somewhere down the line you might have to do something like check state before allowing access to that data, but as the data is "on show" your stuck
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
Ah yes, I was never suggesting letting users access data directly. No no no.
It's possible to "emulate" properties using some operators and templates. They act just like data members from the outside, but they are actually fully fledged functions.
That's similar to what I'm suggesting (I even developed a template for this kind of purpose).
Sounds good, but complicated and maybe a bit of a bloat. I'll stick with good old inline accessors!
thank you for your suggestion.
I tried to implement a generic property template, and its object is initialized in the init-list of a class, the property objects are always initilized with 'this' pointer, so compiler gives a warning that using 'this' in init-list, I don't like this warning, so I give up this implementation.
>>Option Tree for listboxes and such
All the widgets are own-draw, would you please implement an option tree? :-)
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
You can refer to "this" in the initialization list, but you cannot use it to either directly or indirectly reference members which have not yet been constructed. In other words, you can use "this" to access members of the base (if one exists) but not members of the class itself. At least, not members which are not yet constructed.
The conditions are sufficiently tricky, and compilers are sufficiently buggy, that a wise programmer would not use "this" in the init list. This is why the warning is there.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
In other words, an proprety object should not use 'this' in the initialization list, because the object refered by this is under constrcution and the object is imcomplete. Although the property object just stores the 'this' while initializing, I gave up this implementation in logic/concept correct.
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.
I have met with similar designs, and the warning made me feel as you do. In the long run I think it is harmless in this situation, since the stored "this" will not be used until a call to a member, which can only happen after the object is fully constructed. You just have to be sure that the self-pointer is initialized in ALL constructors, including copy constructors -- which means you'll have to write a copy constructor explicitly.
In the end I also chose to switch to a different design.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
You can pass this in the initializer list without any danger if the only thing you do with it is store it for later use.
But I consider property emulation a waste of code and memory. (Yes, the emulation needs one word per property of overhead.)
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.