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
How to display an icon on the right side of a label/button [message #3891] Thu, 06 July 2006 20:58 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

By default the image - btn.SetImage(CtrlImg::new_doc()); -
is displayed at left of a label/button. Is there a way to display it to the right side?

Luigi
Re: How to display an icon on the right side of a label/button [message #3892 is a reply to message #3891] Thu, 06 July 2006 22:44 Go to previous messageGo to next message
fudadmin is currently offline  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...)
Re: How to display an icon on the right side of a label/button [message #3893 is a reply to message #3892] Thu, 06 July 2006 22:51 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
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.


[Updated on: Thu, 06 July 2006 22:54]

Report message to a moderator

Re: How to display an icon on the right side of a label/button [message #3894 is a reply to message #3892] Thu, 06 July 2006 23:42 Go to previous messageGo to next message
fudadmin is currently offline  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...
Re: How to display an icon on the right side of a label/button [message #3895 is a reply to message #3893] Fri, 07 July 2006 00:26 Go to previous messageGo to next message
forlano is currently offline  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... Embarassed ... 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

[Updated on: Fri, 07 July 2006 00:27]

Report message to a moderator

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 next 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?
Re: How to display an icon on the right side of a label/button [message #3897 is a reply to message #3895] Fri, 07 July 2006 01:32 Go to previous messageGo to next message
fudadmin is currently offline  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 Smile
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
Re: How to display an icon on the right side of a label/button [message #3898 is a reply to message #3897] Fri, 07 July 2006 01:51 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
...then extend it to the fallingdutch example... Smile
Re: How to display an icon on the right side of a label/button [message #3901 is a reply to message #3898] Fri, 07 July 2006 14:23 Go to previous messageGo to next message
forlano is currently offline  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... Smile


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 Very Happy .
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)

Luigi
Re: How to display an icon on the right side of a label/button [message #3907 is a reply to message #3901] Sat, 08 July 2006 14:28 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Quote:

Any idea to overcome this last obstacle? (I'm using 606-dev3)


606-dev4?
Re: How to display an icon on the right side of a label/button [message #3908 is a reply to message #3907] Sat, 08 July 2006 15:11 Go to previous messageGo to next message
forlano is currently offline  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.
Re: How to display an icon on the right side of a label/button [message #3909 is a reply to message #3908] Sat, 08 July 2006 15:35 Go to previous message
fudadmin is currently offline  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.
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: Thu Mar 28 18:24:15 CET 2024

Total time taken to generate the page: 0.01898 seconds