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