Home » U++ Library support » U++ Widgets - General questions or Mixed problems » List of custom controls, how?
Re: List of custom controls, how? [message #37718 is a reply to message #37717] |
Mon, 05 November 2012 13:46   |
|
crydev wrote on Mon, 05 November 2012 12:35 | - I know I have to make a new class deriving from (Ctrl)?
- I have to override the Paint(Draw& g) method
- I have to draw a rectangle inside the paint method in which the contents of my custom control will be drawn.
I really don't know how this would work. I have tried to find out the things I need to know but it is hard to find. Can somebody supply me with an example of how it works or how they would do this? I really appriciate your help!
|
Hi crydev,
It is sure possible to draw the contents of you Ctrl yourself, but in most cases it is not needed. You can also create new Ctrls by combining already existng ones, e.g. in your case you'd take an Image and two Ctrls for text display (Label, RichTextCtrl, etc...). Something like this should be sufficient (plus you have to add your logic to fill the data of course):struct MyCtrl : public ParentCtrl { // it is easier to inherit from ParentCtrl,
private: // because it paint it's background
ImageCtrl img;
Label title;
Label info;
public:
MyCtrl() {
Add(img.LeftPosZ(5,30).TopPosZ(5,30));
Add(title.LeftPosZ(40,90).TopPosZ(5,30));
Add(info.HSizePosZ(5,5).VSizePosZ(40,5));
SetValues();
}
void SetValues(){
img.SetImage(CtrlImg::save()); // some random image
title.SetText("Save private Ryan"); // some title
info.SetText("This is some info."); // some info text
}
};
This way you can simple group many widgets and then use them in your app just as any other U++ Ctrl. The Labels used are just an example, you will probably want to use something more fancy, like RichTextCtrl.
Best regards,
Honza
PS: If you want to try the other way, with overriding paint etc., you should have a look at Gui tutorial, chapter 21.
[Updated on: Mon, 05 November 2012 13:48] Report message to a moderator
|
|
|
 |
|
List of custom controls, how?
By: crydev on Mon, 05 November 2012 12:35
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: mirek on Mon, 05 November 2012 19:50
|
 |
|
Re: List of custom controls, how?
By: crydev on Mon, 05 November 2012 21:48
|
 |
|
Re: List of custom controls, how?
By: crydev on Wed, 07 November 2012 10:02
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: crydev on Thu, 08 November 2012 09:29
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: crydev on Tue, 27 November 2012 17:33
|
 |
|
Re: List of custom controls, how?
|
 |
|
Re: List of custom controls, how?
By: crydev on Wed, 28 November 2012 08:20
|
Goto Forum:
Current Time: Sat Jun 07 01:28:48 CEST 2025
Total time taken to generate the page: 0.04256 seconds
|