Hi friends. I come back with a little fix in order to statusbar topic. See message from Maurizio.
Code: Select all
2011-09-12 18:30 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
* samples/statusbar/demo_5.prg
* named statusbar object with difference name to show usage and reference
and to test changes within hmg.ch
! include/hmg.ch
! fixed both HMG3 and HMG4 statusbar command translation
I want use this topic to repeat something.
There are many differences between HMG3 and HMG4, but the two most important are:
- the array (_HMG_SYSDATA) VS the OOP style
- the reference VS the name of the object.
With HMG3 we use:
DEFINE STATUSBAR [ OF | PARENT <ParentWindowName> ] ....
As you can see there isn't the <name> parameter; HMG3, by default, assigns, to this control, the name "StatusBar".
For this reason, we can handle some "statusitem" with: FormName.StatusBar.Item
With HMG4 always we give a name to the object: with an internal system or with a parameter.
This is the code:
WITH OBJECT ..... StatusBar():New( cParam....
If we omit the cParam, this object
will be named by HMG4 like _HMG_OBJECT_n (wher n >= 0 ) and within a program we can use FormName:_HMG_OBJECT_n:.... but we can't know <n>.
The best way is to assign the name/reference to the object within end program; so, the previous code will be:
WITH OBJECT ..... StatusBar():New( "ThisIsTheNameOfStatusBar"....
Now we have a fixed "reference" and we can use FormName:ThisIsTheNameOfStatusBar:....
But this is like OOP style; if we want use XBase style, we must translate
DEFINE STATUSBAR [ OF | PARENT <ParentWindowName> ] into OOP style.
But with HMG3 we don't have the <name>.
For this reason I have changed the Xbase coomand into
DEFINE STATUSBAR [ NAME <oObj> ] [ <dummy1: OF, PARENT> <oParent> ]
and the related translation with
WITH OBJECT StatusBar():New( iif(hb_IsNil( <oObj> ), "StatusBar", <"oObj">), [, <oParent> ] );;
This work with XBase style program. If we use OOP style, we can code
WITH OBJECT StatusBar():New( "ThisIsTheNameOfStatusBar"......
But at then end of the hmg.ch we find these rows:
#xtranslate <window>.StatusBar.Item(<nIndex>) => <window>:StatusBar:Item(<nIndex>)
#xtranslate <window>:StatusBar:Item(<nIndex>) => <window>:StatusBar:Item(<nIndex>)
#xtranslate <window>.StatusBar.Item(<nIndex>) := <cText> => <window>:StatusBar:Item(<nIndex>,<cText>)
#xtranslate <window>:StatusBar:Item(<nIndex>) := <cText> => <window>:StatusBar:Item(<nIndex>,<cText>)
// added to manage icon
#xtranslate <window>.StatusBar.ItemIcon(<nIndex>) => <window>:StatusBar:ItemIcon(<nIndex>)
#xtranslate <window>:StatusBar:ItemIcon(<nIndex>) => <window>:StatusBar:ItemIcon(<nIndex>)
#xtranslate <window>.StatusBar.ItemIcon(<nIndex>) := <xValue> => <window>:StatusBar:ItemIcon(<nIndex>,<xValue>)
#xtranslate <window>:StatusBar:ItemIcon(<nIndex>) := <xValue> => <window>:StatusBar:ItemIcon(<nIndex>,<xValue>)
as you can see, they use StatusBar "reference"! In other words, is encoded only the HMG3 style.
To have both HMG4 and HMG3 we must add/change into:
#xtranslate <window>.<objname>.Item(<nIndex>) => <window>:<objname>:Item(<nIndex>)
#xtranslate <window>:<objname>:Item(<nIndex>) => <window>:<objname>:Item(<nIndex>)
#xtranslate <window>.<objname>.Item(<nIndex>) := <cText> => <window>:<objname>:Item(<nIndex>,<cText>)
#xtranslate <window>:<objname>:Item(<nIndex>) := <cText> => <window>:<objname>:Item(<nIndex>,<cText>)
// added to manage icon
#xtranslate <window>.<objname>.ItemIcon(<nIndex>) => <window>:<objname>:ItemIcon(<nIndex>)
#xtranslate <window>:<objname>:ItemIcon(<nIndex>) => <window>:<objname>:ItemIcon(<nIndex>)
#xtranslate <window>.<objname>.ItemIcon(<nIndex>) := <xValue> => <window>:<objname>:ItemIcon(<nIndex>,<xValue>)
#xtranslate <window>:<objname>:ItemIcon(<nIndex>) := <xValue> => <window>:<objname>:ItemIcon(<nIndex>,<xValue>)
What I want to highlight is that: there are big difference between HMG4 and HMG3 philosopy.
A mix between XBase style and OOP style can be very dangerous.
A strict compatibility with HMG3 can preclude futures development of HMG4.
Sometimes we will have to get a compromise.
Cheers