Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridCtrl: custom ButtonOption inside a cell
GridCtrl: custom ButtonOption inside a cell [message #43271] |
Sat, 21 June 2014 08:46  |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
GridCtrl let me add easily an Option
grid.AddColumn(STATUS, "Status", 4).Option().Default(true);
Now I would like to add instead a ButtonOption with my own images.
I thought to modify the library (other idea are welcome)
static void MakeOption(One<Ctrl>& ctrl)
{
//ctrl.Create<Option>().ShowLabel(false); //original code
ctrl.Create<ButtonOption>(); //new
ctrl->SetData(0);
ctrl->WantFocus();
}
It works but I do not see where to use
.SetImage()
(ctrl do not like SetImage() ).
Any solution?
Thanks,
Luigi
[Updated on: Sat, 21 June 2014 10:32] Report message to a moderator
|
|
|
Re: GridCtrl: custom ButtonOption inside a cell [message #43277 is a reply to message #43271] |
Sat, 21 June 2014 22:28   |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello, Luigi.
forlano wrote on Sat, 21 June 2014 08:46It works but I do not see where to use
.SetImage()
The One::Create() method returns reference to created object of specified type. For example, in your case:
void MakeButtonOption(One<Ctrl>& ctrl)
{
ButtonOption& option = ctrl.Create<ButtonOption>();
option.SetImage(Null, CtrlImg::check());
option.WantFocus();
}
I created following example to demonstrate this:

Toggle source code#include <GridCtrl/GridCtrl.h>
using namespace Upp;
void MakeButtonOption(One<Ctrl>& ctrl)
{
ButtonOption& option = ctrl.Create<ButtonOption>();
option.SetImage(Null, CtrlImg::check());
option.WantFocus();
}
class App : public TopWindow {
private:
GridCtrl grid;
public:
typedef App CLASSNAME;
App();
void FillData(int count = 0x100);
};
App::App()
{
Title("GridCtrl with Option and ButtonOption");
Sizeable().Zoomable();
const Size sz(400, 240);
SetMinSize(sz); SetRect(sz);
grid.Chameleon();
grid.AddColumn("Option").Option().Default(true);
grid.AddColumn("ButtonOption").Ctrls(MakeButtonOption).Default(true);
Add(grid.VSizePosZ(2, 2).HSizePosZ(2, 2));
}
void App::FillData(int count)
{
if (grid.GetCount())
grid.Clear();
grid.Ready(false);
for (int i = 0; i < count; ++i) {
const bool v = i % 2 == 0;
grid.Add(v, v);
}
grid.Ready(true);
}
GUI_APP_MAIN
{
App app;
app.FillData();
app.Run();
}
[Updated on: Sat, 21 June 2014 22:42] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 17:48:56 CEST 2025
Total time taken to generate the page: 0.00775 seconds
|