|
|
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
|
|
|
|
|
|
Re: OptionImage ctrl: how to make it better... [message #2451 is a reply to message #2446] |
Thu, 13 April 2006 08:45 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
fudadmin wrote on Wed, 12 April 2006 23:11 | If you download it, it runs "out of the box"...
|
Aris,
I tried your code. It works very nice (what do you mean with
"out of the box"?). I've even learned how to put in the designer a new class object (just rename the classobject after CTRL+T). Before to do my 'todo' task I tried to put the wonderful OptionImage in the arrayctrl. I've added the .iml file and the .h file then
1th temptive.
arr.AddColumn("Avail", "Avail?", 4).Ctrls<OptionImage>();
nothing appear.
2th temptive.
arr.AddColumn("Avail", "Avail?", 4).Ctrls(Avail3);
where, on the model of past example,
void Avail3(One<Ctrl>& ctrl)
{
// ctrl.Create<Option>().ThreeState();
ctrl.Create<OptionImage>();
ctrl.ThreeState(true).SetImage( imgYes(), imgNo(), imgMaybe());
}
but the compiler cryed:
C:\MyApps\vegaMenuStatus\tab1.cpp: In function `void Avail3(One<Ctrl>&)':
C:\MyApps\vegaMenuStatus\tab1.cpp:18: error: 'class One<Ctrl>' has no member named 'ThreeState'
Any idea? I attach the zipped project if could be useful. This part of the code is in the file tab1.cpp. Unzip in vegaMenuStatus with no subfolder.
Thank you,
Luigi
Edit by fudamin:
P.S old zip deleted to save space on the server. New zip below.
[Updated on: Fri, 14 April 2006 07:48] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: OptionImage ctrl: how to make it better... [message #2480 is a reply to message #2478] |
Fri, 14 April 2006 00:33 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
forlano wrote on Thu, 13 April 2006 22:59 | I know perfectly what "spaghetti" and "spaghetti code" means.
Nevertheless I do not understand what Aris mean in point 2) and file *.upp and #include.
|
your *.upp
uses
CtrlLib;
file
C:\MyApps\vegaMenuStatus\app.h,
C:\MyApps\vegaMenuStatus\tab4.cpp,
C:\MyApps\vegaMenuStatus\tab3.cpp,
C:\MyApps\vegaMenuStatus\tab2.cpp,
C:\MyApps\vegaMenuStatus\ForlanoOption.iml,
C:\MyApps\vegaMenuStatus\ForlanoOption.h,
C:\MyApps\vegaMenuStatus\tab1.cpp,
C:\MyApps\vegaMenuStatus\newtournament.lay,
C:\MyApps\vegaMenuStatus\tabs.h,
C:\MyApps\vegaMenuStatus\editmask.lay,
main.cpp;
mainconfig
"" = "GUI";
these are absolute references, aren't they? And if I use Linux? And IMHO, you are killing the whole idea of packages, forcing me to spend my precious time to rename them, then find all spaghetti includes...
It's M$ and Co approach - to waste others time... What Mirek and Co will say?!
Edit:
P.S. Have you recieved any of Ultimate's upp files like this?!
Open them as text and find out...
[Updated on: Fri, 14 April 2006 00:43] Report message to a moderator
|
|
|
Re: OptionImage ctrl: how to make it better... [message #2483 is a reply to message #2480] |
Fri, 14 April 2006 07:09 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
fudadmin wrote on Fri, 14 April 2006 00:33 |
forlano wrote on Thu, 13 April 2006 22:59 | I know perfectly what "spaghetti" and "spaghetti code" means.
Nevertheless I do not understand what Aris mean in point 2) and file *.upp and #include.
|
your *.upp
uses
CtrlLib;
file
C:\MyApps\vegaMenuStatus\app.h,
C:\MyApps\vegaMenuStatus\tab4.cpp,
C:\MyApps\vegaMenuStatus\tab3.cpp,
C:\MyApps\vegaMenuStatus\tab2.cpp,
C:\MyApps\vegaMenuStatus\ForlanoOption.iml,
C:\MyApps\vegaMenuStatus\ForlanoOption.h,
C:\MyApps\vegaMenuStatus\tab1.cpp,
C:\MyApps\vegaMenuStatus\newtournament.lay,
C:\MyApps\vegaMenuStatus\tabs.h,
C:\MyApps\vegaMenuStatus\editmask.lay,
main.cpp;
mainconfig
"" = "GUI";
these are absolute references, aren't they? And if I use Linux? And IMHO, you are killing the whole idea of packages, forcing me to spend my precious time to rename them, then find all spaghetti includes...
It's M$ and Co approach - to waste others time... What Mirek and Co will say?!
Edit:
P.S. Have you recieved any of Ultimate's upp files like this?!
Open them as text and find out...
|
The OptionImage works inside the arrayctrl.
Your *.upp file look like this:
uses
CtrlLib;
file
"ForlanoOption.h"
, main.cpp
, "ForlanoOption.lay"
, "ForlanoOption.iml"
;
mainconfig
"" = "GUI";
That is more clean than mine. However I do not know why my upp file has those absolute paths. When I need a new file I click on "insert any file(s)" and write its name. I'am not aware of this absolute reference... and still I countinue to not understand in what the problem consist (I do not see problem when all work as I want ).
Luigi
|
|
|
|
|
|
Goto Forum:
Current Time: Sat May 04 17:30:13 CEST 2024
Total time taken to generate the page: 0.02566 seconds
|
|
|