|
Did you mean to link to a page about "banking industry jargon?" If so, then the link works.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
OOOOPS
and double OOOOOOOOOPS .
Fixed the link, thanks.
|
|
|
|
|
This isn't bugzilla!
|
|
|
|
|
Designs are usually language neutral.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
We use the standard CMFCRibbonBar class to implement a ribbon consisting of a drop down 'File' menu followed by some tabs to select the ribbon panels. Our 'File' menu has a vertical list of menu items, on hte left side of the drop down menu, and on the right side, a recent file list:
Recent Documents
1 FileA
2 FileB
3 FileC
We want to extend this as we have recent documents and recent folders:
Recent Documents
1 FileA
2 FileB
3 FileC
Recent Folders
1 FolderA
2 FolderAB
3 FolderAC
Is anyone aware of any previous implementations of this that I can use? Or any hints as to the easiest/best way to do this?
Obviously we can add menu items to the File menu for 'Recent Documents' and 'Recent Folders', and this would work, but it is not the preferred choice.
Thanks.
|
|
|
|
|
As far as I can see the ribbon code does not allow what we want without making significant changes to the code. So I'll use a standard sub-menu.
Does anyone know how to dynamically add a sub-menu item with no icons, and the text left aligned? I always get a space for the icon i.e. the text is moved right by a significant distance, even though I pass -1 for the icon indices.
|
|
|
|
|
Just in case anyone else wants to do this, I can't for the life of me work out how to left align the menu item, so I created a custom button and overrode the OnDraw method.
|
|
|
|
|
I would like to get better grasp on how C++ class is instantiated / initialized.
Here is a part of what I assume relevant code I like to have help with.
The USBHost class has a method "Task" which is basically a state machine and I am currently trying to figure out how is this state machine "advanced".
Before I can get to that I need better understanding how is the class initialized.
I have put my basic questions as comments to this code snippet.
If someone can also apply descriptive terminology and / or explain the syntax it would be nice, but nothing elaborate.
Appreciate your time.
Thanks
Vaclav
static uint32_t usb_error = 0; // is (global) static initialized to 0 as default anyway?
static uint32_t usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; // this state is not defined as 0 - this is OK
/**
* \brief USBHost class constructor.
*/
USBHost::USBHost() : bmHubPre(0) // may be a default USB hub 0 , not sure
{
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; // why "initialized " again here?
init();
}
/**
* \brief Initialize USBHost class.
*/
void USBHost::init()
{
devConfigIndex = 0; // USB (device ?) default index
bmHubPre = 0; // is this necessary? see constructor parameter
}
|
|
|
|
|
static uint32_t usb_error = 0;
Don't care about what the compiler does. Variables that may be read before they are written should be always initialized.
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
The variable will probably changed by the class. When creating another instance, the value is not the initial one.
bmHubPre = 0;
The variable is set in the constructor but the init function may be called multiple times.
Overall this is a bad example. When using global static variables with a class, you must ensure that only one instance of the class exists. To detect multiple instances some kind of check should be implemented. For your class this can be done by moving the re-initialization of usb_task_state to the destructor and checking the value in the constructor:
ASSERT(usb_task_state == USB_DETACHED_SUBSTATE_INITIALIZE);
Generally there is no need to use a class when that uses global static variables. When global variables are really necessary, they should be at least members of the class:
class USBHost
{
protected:
static uint32_t usb_error;
static uint32_t usb_task_state;
}
uint32_t USBHost::usb_error = 0;
uint32_t USBHost::usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
|
|
|
|
|
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
usb_task state declares a new variable of type usb_task that is a member of the class.
|
|
|
|
|
But there is an underscore between usb_task and state.
|
|
|
|
|
I apologize; I missed the underscore. Never mind.
|
|
|
|
|
It doesn't look a good example.
Quote: static uint32_t usb_error = 0; // is (global) static initialized to 0 as default anyway? Yes, however it doesn't harm.
The other pieces of code are ugly and your observations right.
|
|
|
|
|
Like others mentioned this isn't the cleanest example, but I'll also take a stab at explaining some of these things...
static uint32_t usb_error = 0; static uint32_t usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
Initializing a global (or a static) outside of the user function or class is always good practice. The compiler may or may not initialize for you, but why risk it.
USBHost::USBHost() : bmHubPre(0) {
usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
init();
}
This is initializing a global that is in an undefined state back to the default. Remember that if there was an instance of USBHost that existed, he might have left the state of the variable in some unknown state. Like someone else mentioned however, this initialization does imply you should only ever have one instance of this class... otherwise you'll have a conflict with the state of this variable. With that said though, it is resetting itself, so you should be able to delete the object when not in use and make a new one when you do need it.
void USBHost::init()
{
devConfigIndex = 0;
bmHubPre = 0;
}
init() methods are usually made when there may be a need to initialize variables outside of the constructor, or alternatively, when there are multiple constructors that all need to initialize the same variables. For example, there may be some code that gets called when the USB device gets to a certain state that requires re-initialization.... rather than destruct the object and start all over, the init() may be called to re-initialize.
|
|
|
|
|
Thanks guys, I really appreciate your help.
This class is to make USB host (Arduino) communicate with USB devices and so far I'll be happy if I can work with one device / one instance of the class. Eventually I'll need a USB hub (as USB device) to work with multiple devices so I'll make sure multiple instances of this class can exist.
I sure wish there was an easier way to "see" the objects hierarchy in Arduino code.
But I feel I am really pushing my luck with this toy hardware.
Thanks
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: I sure wish there was an easier way to "see" the objects hierarchy in Arduino code.
I'm not sure where you got the code from, but there's auto-documentation engines such as Doxygen[^] that should make object hierarchies easier to see. A lot of open source projects use this type of "auto-documentation".
|
|
|
|
|
Thanks, this especially may be what I am looking for.
"Doxygen can also visualize the relations between the various elements by means of include dependency graphs, inheritance diagrams, and collaboration diagrams, which are all generated automatically."
|
|
|
|
|
|
Albert,
this doxygen is a FANTASTIC tool!
Thanks a milion!
Vaclav
|
|
|
|
|
Quote: The compiler may or may not initialize for you, but why risk it.
That is not exactly true. The C++ standard specify that such variables 'shall be zero-initialized', hence no risk, unless the compiler is not compliant.
|
|
|
|
|
CPallini wrote: The C++ standard specify that such variables 'shall be zero-initialized'
Was this in every C++ standard since the original? ...I don't really know...but if it wasn't, it's not worth any savings in writing. Plus it makes it easier to read.
|
|
|
|
|
Albert Holguin wrote: Was this in every C++ standard since the original? ...I don't really know... I think so (it comes from C ).
Albert Holguin wrote: it's not worth any savings in writing. Plus it makes it easier to read. I completely agree on that.
|
|
|
|
|
I was just having a discussion on initializing variables with a coworker. We're working with python a lot and the absence of declarations is driving me mad. Python is simple and fast to write but you can definitely make some very ugly code with it (large classes with multiple inheritance within the same python file, ugh).
|
|
|
|
|