Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl: Edit doesn't like Option
Re: ArrayCtrl: Edit doesn't like Option [message #34970 is a reply to message #29522] |
Thu, 22 December 2011 02:43  |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello.
While reading uppdev sources, I found ArrayOption example.
I think, it could be used here, like follows:
Toggle Spoiler
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class App : public TopWindow {
private:
int toggle_count;
LabelBase *toggle_label;
public:
typedef App CLASSNAME;
App();
// Ctrls
ArrayCtrl list;
ArrayOption option;
EditString text;
// Bars
void ArrayBar(Bar& bar);
// Methods
void FillWithData();
void ToggleCount(bool value);
void ToggleOption();
void ToggleHeaderOption();
// Events
void OnHeaderClick();
void OnOptionClick();
};
App::App() : toggle_count(0)
{
Title("ArrayOption example");
CenterScreen().Sizeable().MinimizeBox().MaximizeBox();
const Size sz(320, 240);
SetMinSize(sz); SetRect(sz);
list.AutoHideSb();
// Initialize ArrayOption column and assign label address
toggle_label = &option.AddColumn(list).HeaderTab().Fixed(30).SetAlign(ALIGN_CENTER);
// Initialize ArrayCtrl column
list.AddColumn("Content", 120).Edit(text);
// Assign callbacks
list.HeaderTab(0).WhenAction = THISBACK(OnHeaderClick);
list.WhenBar = THISBACK(ArrayBar);
option.WhenAction = THISBACK(OnOptionClick);
Add(list.VSizePosZ(4, 4).HSizePosZ(4, 4));
}
// Bars
void App::ArrayBar(Bar& bar)
{
if (list.HasFocus() && list.IsCursor())
bar.AddKey(K_SPACE, THISBACK(ToggleOption));
list.StdBar(bar);
}
// Methods
void App::FillWithData()
{
GuiLock __;
list.Clear();
for (int i = 1; i <= 10; ++i)
list.Add(i % 2 == 0, FormatIntRoman(i, true));
toggle_count = 5;
ToggleHeaderOption();
}
void App::ToggleCount(bool value)
{
if (value)
++toggle_count;
else
--toggle_count;
}
void App::ToggleOption()
{
GuiLock __;
list.Set(0, !list.Get(0));
ToggleCount(list.Get(0));
ToggleHeaderOption();
}
void App::ToggleHeaderOption()
{
static bool changed = true;
if (toggle_count == list.GetCount()) {
toggle_label->SetImage(CtrlsImg::Get(CtrlsImg::I_O1), 2);
changed = true;
}
else if (changed) {
toggle_label->SetImage(CtrlsImg::Get(CtrlsImg::I_O0), 2);
changed = false;
}
}
// Events
void App::OnHeaderClick()
{
GuiLock __;
bool value = true;
const int count = list.GetCount();
if (toggle_count == count) {
value = false;
toggle_count = 0;
}
else
toggle_count = count;
for (int i = 0; i < count; ++i)
if (list.Get(i, 0) != value)
list.Set(i, 0, value);
ToggleHeaderOption();
}
void App::OnOptionClick()
{
ToggleCount(list.Get(0));
ToggleHeaderOption();
PromptOK(String().Cat() << "{{1:2:3@L [* Index:: Option:: Content]::! "
<< list.GetCursor() << ":: " << FormatBool(list.Get(0)) << ":: " << list.Get(1) << " }}");
}
GUI_APP_MAIN
{
Ctrl::GlobalBackPaint();
App app;
app.FillWithData();
app.Run();
}

[Updated on: Fri, 23 December 2011 21:08] Report message to a moderator
|
|
|
 |
|
ArrayCtrl: Edit doesn't like Option
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Tue, 07 December 2010 09:37
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: unodgs on Tue, 07 December 2010 11:08
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Tue, 07 December 2010 11:22
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: unodgs on Tue, 07 December 2010 12:37
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Tue, 07 December 2010 12:39
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: unodgs on Tue, 07 December 2010 13:14
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Tue, 07 December 2010 14:03
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Wed, 08 December 2010 09:51
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Thu, 09 December 2010 09:31
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: mirek on Sun, 26 December 2010 01:12
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
By: kohait00 on Sun, 26 December 2010 09:46
|
 |
|
Re: ArrayCtrl: Edit doesn't like Option
|
Goto Forum:
Current Time: Mon Jul 14 06:22:47 CEST 2025
Total time taken to generate the page: 0.03840 seconds
|