fudadmin Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
Ultimate Contributor Administrator
I haven't tried - but what if
btn.SetImage(CtrlImg::new_doc().SizeRight());
? or something similar? (at least, I'd like to have this kind of interface...)
don't know wether the first suggestion works, but i am sure it works with deriving and rewriting Paint()
in Button::Paint a DrawLabel 'dl' is created an painted, just add the following instruction:
dl.align = ALIGN_RIGHT
best would be to add align as a private Member to Button class and add get/set methods and in the Paint method set dl.align as the private align member.
fudadmin Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
Ultimate Contributor Administrator
fudadmin wrote on Thu, 06 July 2006 21:44
I haven't tried - but what if
btn.SetImage(CtrlImg::new_doc().SizeRight());
? or something similar? (at least, I'd like to have this kind of interface...)
No, it looks like this doesn't work.
But LabelBase has got some kind of image positioning interface...
forlano Messages: 1182 Registered: March 2006 Location: Italy
Senior Contributor
fallingdutch wrote on Thu, 06 July 2006 22:51
don't know wether the first suggestion works, but i am sure it works with deriving and rewriting Paint()
in Button::Paint a DrawLabel 'dl' is created an painted, just add the following instruction:
dl.align = ALIGN_RIGHT
best would be to add align as a private Member to Button class and add get/set methods and in the Paint method set dl.align as the private align member.
Thank you.
The Aris' method doesn't work. While your method... ... I do not know what to do. It seems in U++ one should be ready to derive often and at the moment I feel not confortable with this operation regarding Paint, Display, Draw, etc.... Can you be more explicit about the operation I have to do?
Luigi
PS: I agree that a method like .SetImgAlign(LEFT/RIGHT) would be more friendly
It seems in U++ one should be ready to derive often
don't know wether it is ment to be this way, but its the only way I see
forlano wrote on Fri, 07 July 2006 00:26
Can you be more explicit about the operation I have to do?
sure!
#include <CtrlLib/CtrLib.h>
//derived Class:
// adding a new private member: align, containing the alignment value
// the two methods to get and set the value mentioned above (Get/SetAlignment() )
// adding one line to the Paint method (see ImageButton::Paint)
class ImageButton : public Button {
private:
int align;
public:
ImageButton() {align = ALIGN_CENTER; }; //default alignment is center
virtual void Paint(Draw& draw);
void SetAlignment(int _align) {align = _align;}; //method to set the Alignment
int GetAlignment() {return align;}; //method to get the alignment
};
void ImageButton::Paint(Draw& w) {
Size sz = GetSize(); //this is the beginning of the original Paint method
bool ds = !IsShowEnabled();
DrawLabel dl;
dl.align = align; //this is the only line to be added
// PUT HERE THE REST OF BUTTON::PAINT (CtrlLib/Button.cpp)
};
after changing the Alignment you have to call Refresh() so the Ctrl will be repainted. Or change the implementation to
fudadmin Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
Ultimate Contributor Administrator
Very primitive explanation about Paint and deriving.
Luigi, imagine every widget as consisting of 2 parts:
1. ala Database and functions (methods).
2. Paint
Paint creates parts of the widget on the screen. That means, if you make your derived widget (you can do it, can't you?) with Paint method, in your new widget class you can output to the screen anything you want. As an example I'd suggest to have a look once again at my OptionImage example which you already have succesfully used.
Then
1. copy it with a new name, say CellButton
2. change it to be derived from Button ( :public Button)
3. comment/remove all except Paint
4. copy from Button.cpp Paint( all lines and paste over into your Paint
5. Below DrawLabel dl; add a new line
dl.align = ALIGN_RIGHT
forlano Messages: 1182 Registered: March 2006 Location: Italy
Senior Contributor
fudadmin wrote on Fri, 07 July 2006 01:51
...then extend it to the fallingdutch example...
Thanks a lot!
After the explanation and the code ready to use I'm ready to derive a horse and obtain a zebra using the paint method .
Unfortunately some thing was wrong because the compiler doesn't recognise these identifiers
C:\MyApps\RowColorPair\main.cpp(31) : error C3861: 'ButtonFont': identifier not found
C:\MyApps\RowColorPair\main.cpp(40) : error C2065: 'ButtonLook' : undeclared identifier
C:\MyApps\RowColorPair\main.cpp(42) : error C2065: 'EdgeButtonLook' : undeclared identifier
C:\MyApps\RowColorPair\main.cpp(44) : error C2065: 'OkButtonLook' : undeclared identifier
C:\MyApps\RowColorPair\main.cpp(48) : error C3861: 'ButtonTextColor': identifier not found
C:\MyApps\RowColorPair\main.cpp(50) : error C3861: 'ButtonMonoColor': identifier not found
C:\MyApps\RowColorPair\main.cpp(51) : error C3861: 'ButtonPressOffsetFlag': identifier not found
All are connected with Chamaleon. Any idea to overcome this last obstacle? (I'm using 606-dev3)
forlano Messages: 1182 Registered: March 2006 Location: Italy
Senior Contributor
fudadmin wrote on Sat, 08 July 2006 14:28
Quote:
Any idea to overcome this last obstacle? (I'm using 606-dev3)
606-dev4?
Werner signaled problems with this version under XP and nobody replied. http://www.arilect.com/upp/forum/index.php?t=msg&th=1139 &start=0& .
So I wait a bit because I've no time up Monday. For the moment I have added an icon-label to the right or the left of a button to get the effect.
fudadmin Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
Ultimate Contributor Administrator
forlano wrote on Sat, 08 July 2006 14:11
fudadmin wrote on Sat, 08 July 2006 14:28
Quote:
Any idea to overcome this last obstacle? (I'm using 606-dev3)
606-dev4?
Werner signaled problems with this version under XP and nobody replied. http://www.arilect.com/upp/forum/index.php?t=msg&th=1139 &start=0& .
So I wait a bit because I've no time up Monday. For the moment I have added an icon-label to the right or the left of a button to get the effect.
But in 606-dev4 Debug mode you can progress without any problems. At least, I haven't encountered.