Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » How to display an icon on the right side of a label/button
Re: How to display an icon on the right side of a label/button [message #3896 is a reply to message #3895] Fri, 07 July 2006 00:56 Go to previous messageGo to previous message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
forlano wrote on Fri, 07 July 2006 00:26

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 Rolling Eyes

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
void SetAlignment(int _align) {align=_align;Refresh();};


the possible Values for align are:
ALIGN_RIGHT, ALIGN_CENTER, ALIGN_LEFT


Hope that helps,
Bas
PS: why isnt that implemented in the original Button class?
PPS: what about valign? could that be usefull, too?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to #define/#include correctly the .iml file
Next Topic: How to Draw a couple of lines over an ArrayCtrl
Goto Forum:
  


Current Time: Wed May 22 04:09:20 CEST 2024

Total time taken to generate the page: 0.01542 seconds