Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » OptionImage ctrl: how to make it better...
OptionImage ctrl: how to make it better... [message #2437] |
Wed, 12 April 2006 17:24  |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
Ok, I'm posting my a bit improved OptionImage control version and we can disscuss it here...
class OptionImage : public Option {
protected:
Image imgYes, imgNo, imgMaybe;
public:
virtual void Paint(Draw& draw);
OptionImage& SetImage(const Image& m1, const Image& m2, const Image& m3)
{ imgYes = m1; imgNo = m2; imgMaybe = m3; Refresh(); return *this; }
OptionImage& SetImage(const Image& m1, const Image& m2)
{ imgYes = m1; imgNo = m2; Refresh(); return *this; }
OptionImage& ThreeState(bool b = true) { threestate = b; notnull = false; return *this; }
typedef OptionImage CLASSNAME;
OptionImage();
~OptionImage(){;}
};
OptionImage::OptionImage()
{
}
void OptionImage::Paint(Draw& w) {
Size sz = GetSize();
if(!IsTransparent())
w.DrawRect(0, 0, sz.cx, sz.cy, SColorFace);
Size isz = imgYes.GetSize(); //although maybe it would be good to calc from the biggest...?
Size tsz = GetSmartTextSize(w, label, font);
int ty = (sz.cy - tsz.cy) / 2; //text up-down
int iy = (tsz.cy - isz.cy) / 2 + ty;
bool ds = !IsShowEnabled();
Image m = (!notnull || threestate) && IsNull(option) ? ds ? imgMaybe
: IsPush() ? imgYes
: imgMaybe :
option == 1 ? ds ? (switchimage ? imgYes : imgYes)
: IsPush() ? (switchimage ? imgYes : imgYes)
: (switchimage ? imgYes : imgYes)
: ds ? (switchimage ? imgNo : imgNo)
: IsPush() ? (switchimage ? imgNo : imgNo)
: (switchimage ? imgNo : imgNo);
w.DrawImage(0, iy, m);
// if(!switchimage) //for borders - need to adjust sizes...
// w.DrawImage(0, iy, ds ? CtrlImg::optionedged : blackedge ? CtrlImg::blackoptionedge : CtrlImg::optionedge);
DrawSmartText(w, isz.cx + 4, ty, tsz.cx, label, font, ds ? SGray : SBlack, VisibleAccessKeys() ? accesskey : 0);
//text length problem - tsz.cx - doesn't work? adjust your size in *.lay... :)
}
Now it works with assigned images from *.iml:
(with autosize from the 1st img - yes...)
opt3.SetLabel("Avail?"); //todo: doesn't show all text if long... - adjust your size in *.lay... :)
opt3.ThreeState(true).SetImage( imgYes(), imgNo(), imgMaybe());
P.S. Unzip into ForlanoOption folder (no folders inside!)
[Updated on: Wed, 12 April 2006 20:11] Report message to a moderator
|
|
|
 |
|
OptionImage ctrl: how to make it better...
By: fudadmin on Wed, 12 April 2006 17:24
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Wed, 12 April 2006 17:51
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Wed, 12 April 2006 23:03
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Wed, 12 April 2006 23:11
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Thu, 13 April 2006 08:45
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Thu, 13 April 2006 16:47
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Thu, 13 April 2006 17:13
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Thu, 13 April 2006 17:43
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: mr_ped on Thu, 13 April 2006 18:16
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: mirek on Thu, 13 April 2006 18:18
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: mr_ped on Thu, 13 April 2006 18:37
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Thu, 13 April 2006 18:24
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Thu, 13 April 2006 19:32
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Thu, 13 April 2006 23:59
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Fri, 14 April 2006 00:18
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Fri, 14 April 2006 00:33
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Fri, 14 April 2006 07:09
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Fri, 14 April 2006 07:26
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Fri, 14 April 2006 07:29
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: forlano on Fri, 14 April 2006 18:46
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Fri, 14 April 2006 20:45
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: fudadmin on Fri, 14 April 2006 07:44
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: mr_ped on Fri, 14 April 2006 09:01
|
 |
|
Re: OptionImage ctrl: how to make it better...
By: mirek on Fri, 14 April 2006 09:26
|
Goto Forum:
Current Time: Sat Apr 26 04:55:02 CEST 2025
Total time taken to generate the page: 0.00714 seconds
|