mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.GridCtrlTest: initial version
git-svn-id: svn://ultimatepp.org/upp/trunk@2659 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
65b3e28689
commit
272f2222c8
13 changed files with 827 additions and 0 deletions
91
reference/GridCtrlTest/GridCtrlTest.cpp
Normal file
91
reference/GridCtrlTest/GridCtrlTest.cpp
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
#include "GridCtrlTest.h"
|
||||
|
||||
void MakeGrid(One<Ctrl>& ctrl)
|
||||
{
|
||||
GridCtrl &c = ctrl.Create<GridCtrl>();
|
||||
c.AddColumn("Column 1");
|
||||
c.AddColumn("Column 2");
|
||||
c.AddColumn("Column 3");
|
||||
c.MovingCols();
|
||||
c.MovingRows();
|
||||
c.Add("Hello", 1, 2);
|
||||
c.Add("Daniel", 12, 10);
|
||||
c.Add("Ala", 17, 23);
|
||||
c.Add("Baby", 22, 8);
|
||||
}
|
||||
|
||||
App::App()
|
||||
{
|
||||
CtrlLayout(*this, "Grid Test Panel");
|
||||
|
||||
testMain.Init();
|
||||
testExcelGrid.Init();
|
||||
testPropertyGrid.Init();
|
||||
testFocusLost.Init();
|
||||
testArrayCtrl.Init();
|
||||
|
||||
panel.Init(testMain.grid);
|
||||
|
||||
tab.Add(testMain.SizePos(), "Main");
|
||||
tab.Add(testExcelGrid.SizePos(), "Excel grid");
|
||||
tab.Add(testPropertyGrid.SizePos(), "Property grid");
|
||||
tab.Add(testArrayCtrl.SizePos(), "ArrayCtrl");
|
||||
tab.Add(testFocusLost.SizePos(), "Focus lost");
|
||||
|
||||
tab <<= THISBACK(TabChange);
|
||||
|
||||
resort <<= THISBACK(Resort);
|
||||
toxml <<= THISBACK(ToXml);
|
||||
fromxml <<= THISBACK(FromXml);
|
||||
|
||||
Sizeable().Zoomable();//.BackPaint(!false);
|
||||
}
|
||||
|
||||
void App::TabChange()
|
||||
{
|
||||
int t = tab.Get();
|
||||
if(t == 0)
|
||||
panel.Init(testMain.grid);
|
||||
else if(t == 1)
|
||||
panel.Init(testExcelGrid.grid);
|
||||
else if(t == 2)
|
||||
panel.Init(testPropertyGrid.grid);
|
||||
else if(t == 4)
|
||||
panel.Init(testFocusLost.grid0);
|
||||
|
||||
dlog->Clear();
|
||||
}
|
||||
|
||||
void App::Serialize(Stream &s)
|
||||
{
|
||||
SerializePlacement(s);
|
||||
s % panel.level;
|
||||
}
|
||||
|
||||
void App::Resort()
|
||||
{
|
||||
panel.grid->ReSort();
|
||||
}
|
||||
|
||||
void App::ToXml()
|
||||
{
|
||||
String s = StoreAsXML(*panel.grid, "grid-values");
|
||||
FileOut f(ConfigFile("grid.xml"));
|
||||
f << s;
|
||||
f.Close();
|
||||
}
|
||||
|
||||
void App::FromXml()
|
||||
{
|
||||
String s = LoadFile(ConfigFile("grid.xml"));
|
||||
LoadFromXML(*panel.grid, s);
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
App app;
|
||||
LoadFromFile(app);
|
||||
SetLanguage(LNGC_('E','N','E','N', CHARSET_UTF8));
|
||||
app.Run();
|
||||
StoreToFile(app);
|
||||
}
|
||||
90
reference/GridCtrlTest/GridCtrlTest.h
Normal file
90
reference/GridCtrlTest/GridCtrlTest.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#ifndef _GridTest_GridCtrlTest_h_
|
||||
#define _GridTest_GridCtrlTest_h_
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <GridCtrl/GridCtrl.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#include "Panel.h"
|
||||
|
||||
#define LAYOUTFILE <GridCtrlTest/GridCtrlTest.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
struct Test : public Ctrl
|
||||
{
|
||||
virtual void Init() = 0;
|
||||
};
|
||||
|
||||
struct BasicTest : Test
|
||||
{
|
||||
GridCtrl grid;
|
||||
BasicTest()
|
||||
{
|
||||
Add(grid.SizePos());
|
||||
}
|
||||
};
|
||||
|
||||
struct TestMain : BasicTest
|
||||
{
|
||||
EditInt edit0;
|
||||
EditInt edit1;
|
||||
EditString edit2;
|
||||
DropTime dt;
|
||||
EditInt ei;
|
||||
EditString ee0, ee1;
|
||||
|
||||
DropList list, colors, names, numbers;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct TestExcelGrid : BasicTest
|
||||
{
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct TestPropertyGrid : BasicTest
|
||||
{
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct TestFocusLost : Test
|
||||
{
|
||||
Splitter spl;
|
||||
GridCtrl grid0;
|
||||
GridCtrl grid1;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct TestArrayCtrl : Test
|
||||
{
|
||||
EditInt e0, e1;
|
||||
ArrayCtrl arr;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
struct App : public WithGridPanel<TopWindow>
|
||||
{
|
||||
typedef App CLASSNAME;
|
||||
|
||||
Splitter spl;
|
||||
|
||||
TestMain testMain;
|
||||
TestExcelGrid testExcelGrid;
|
||||
TestPropertyGrid testPropertyGrid;
|
||||
TestFocusLost testFocusLost;
|
||||
TestArrayCtrl testArrayCtrl;
|
||||
|
||||
void TabChange();
|
||||
|
||||
void Serialize(Stream &s);
|
||||
void Resort();
|
||||
void ToXml();
|
||||
void FromXml();
|
||||
App();
|
||||
};
|
||||
|
||||
#endif
|
||||
27
reference/GridCtrlTest/GridCtrlTest.lay
Normal file
27
reference/GridCtrlTest/GridCtrlTest.lay
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
LAYOUT(GridPanel, 896, 540)
|
||||
ITEM(TabCtrl, tab, HSizePosZ(4, 412).VSizePosZ(4, 28))
|
||||
ITEM(Button, resort, SetLabel(t_("Resort")).LeftPosZ(4, 104).BottomPosZ(4, 20))
|
||||
ITEM(Button, toxml, SetLabel(t_("To XML")).LeftPosZ(112, 56).BottomPosZ(4, 20))
|
||||
ITEM(Button, fromxml, SetLabel(t_("From XML")).LeftPosZ(172, 56).BottomPosZ(4, 20))
|
||||
ITEM(Panel, panel, RightPosZ(4, 404).VSizePosZ(4, 0))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(Test, 564, 356)
|
||||
ITEM(GridCtrl, dv___0, Indicator(true).MovingCols(true).MovingRows(true).LiveCursor(true).LeftPosZ(112, 312).TopPosZ(48, 202))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(DynamicLayout, 380, 216)
|
||||
ITEM(Button, create, SetLabel(t_("Create Grid")).LeftPosZ(4, 72).TopPosZ(4, 24))
|
||||
ITEM(Button, remove, SetLabel(t_("Remove Grid")).LeftPosZ(80, 72).TopPosZ(4, 24))
|
||||
ITEM(Splitter, spl, HSizePosZ(4, 4).VSizePosZ(32, 4))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(DisplayLayout, 400, 200)
|
||||
ITEM(LabelBox, dv___0, HSizePosZ(4, 8).VSizePosZ(12, 16))
|
||||
ITEM(Button, dv___1, SetLabel(t_("Button")).RightPosZ(32, 76).TopPosZ(72, 32))
|
||||
ITEM(DocEdit, dv___2, LeftPosZ(20, 168).TopPosZ(48, 104))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(GridTestMain, 628, 520)
|
||||
END_LAYOUT
|
||||
|
||||
34
reference/GridCtrlTest/GridCtrlTest.upp
Normal file
34
reference/GridCtrlTest/GridCtrlTest.upp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
description "Application for testing GridCtrl control\377";
|
||||
|
||||
charset "windows-1250";
|
||||
|
||||
uses
|
||||
CtrlLib,
|
||||
GridCtrl;
|
||||
|
||||
library
|
||||
;
|
||||
|
||||
options
|
||||
;
|
||||
|
||||
file
|
||||
GridCtrlTest.h,
|
||||
GridCtrlTest.cpp charset "UTF-8",
|
||||
GridCtrlTest.lay,
|
||||
TestMain.cpp,
|
||||
TestExcelGrid.cpp,
|
||||
TestPropertyGrid.cpp,
|
||||
TestArrayCtrl.cpp,
|
||||
TestFocusLost.cpp,
|
||||
Panel.h,
|
||||
Panel.cpp,
|
||||
Panel.lay;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
custom() "",
|
||||
"",
|
||||
"";
|
||||
|
||||
262
reference/GridCtrlTest/Panel.cpp
Normal file
262
reference/GridCtrlTest/Panel.cpp
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
#include "Panel.h"
|
||||
|
||||
Panel::Panel()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
CtrlLayout(editopt);
|
||||
CtrlLayout(lookopt);
|
||||
CtrlLayout(colsopt);
|
||||
CtrlLayout(numsopt);
|
||||
|
||||
opts.Add(lookopt, "Look");
|
||||
opts.Add(editopt, "Edit");
|
||||
opts.Add(colsopt, "Colors");
|
||||
opts.Add(numsopt, "Numbers");
|
||||
|
||||
lookopt.indicator <<= THISBACK1(LookOptions, 0);
|
||||
lookopt.hgrid <<= THISBACK1(LookOptions, 1);
|
||||
lookopt.vgrid <<= THISBACK1(LookOptions, 2);
|
||||
lookopt.resizing_cols <<= THISBACK1(LookOptions, 3);
|
||||
lookopt.resizing_rows <<= THISBACK1(LookOptions, 4);
|
||||
lookopt.live_cursor <<= THISBACK1(LookOptions, 5);
|
||||
lookopt.resize_paint_mode <<= THISBACK1(LookOptions, 6);
|
||||
lookopt.resize_col_mode <<= THISBACK1(LookOptions, 7);
|
||||
lookopt.resize_row_mode <<= THISBACK1(LookOptions, 8);
|
||||
lookopt.moving_cols <<= THISBACK1(LookOptions, 9);
|
||||
lookopt.moving_rows <<= THISBACK1(LookOptions, 10);
|
||||
lookopt.full_col_resizing <<= THISBACK1(LookOptions, 11);
|
||||
lookopt.full_row_resizing <<= THISBACK1(LookOptions, 12);
|
||||
lookopt.repaint <<= THISBACK1(LookOptions, 13);
|
||||
lookopt.disable <<= THISBACK1(LookOptions, 14);
|
||||
lookopt.chameleon <<= THISBACK1(LookOptions, 15);
|
||||
lookopt.draw_focus <<= THISBACK1(LookOptions, 16);
|
||||
|
||||
editopt.multiline <<= THISBACK1(EditOptions, 0);
|
||||
editopt.select_row <<= THISBACK1(EditOptions, 1);
|
||||
editopt.sorting <<= THISBACK1(EditOptions, 2);
|
||||
editopt.multisort <<= THISBACK1(EditOptions, 3);
|
||||
editopt.tab_changes_row <<= THISBACK1(EditOptions, 4);
|
||||
editopt.tab_adds_row <<= THISBACK1(EditOptions, 5);
|
||||
editopt.edit_mode <<= THISBACK1(EditOptions, 6);
|
||||
editopt.one_click_edit <<= THISBACK1(EditOptions, 7);
|
||||
editopt.enter_like_tab <<= THISBACK1(EditOptions, 8);
|
||||
|
||||
colsopt.theme.Add(-1, "Flat");
|
||||
colsopt.theme.Add(0, "Cairo");
|
||||
colsopt.theme.Add(1, "Gray");
|
||||
colsopt.theme.Add(2, "Plastik");
|
||||
colsopt.theme.Add(3, "Lipstik");
|
||||
colsopt.theme.Add(4, "Alloy");
|
||||
colsopt.theme.Add(5, "Unknown 01");
|
||||
colsopt.theme.Add(6, "Default");
|
||||
|
||||
lookopt.resize_paint_mode.Add(0, "Line");
|
||||
lookopt.resize_paint_mode.Add(1, "Line + Fixed");
|
||||
lookopt.resize_paint_mode.Add(2, "Fixed + NonFixed");
|
||||
|
||||
lookopt.resize_col_mode.Add(0, "Absolute");
|
||||
lookopt.resize_col_mode.Add(1, "Proportional");
|
||||
|
||||
lookopt.resize_row_mode.Add(0, "Absolute");
|
||||
lookopt.resize_row_mode.Add(1, "Proportional");
|
||||
|
||||
colsopt.theme <<= THISBACK1(ColorsOptions, 0);
|
||||
colsopt.odd_color <<= THISBACK1(ColorsOptions, 1);
|
||||
colsopt.even_color <<= THISBACK1(ColorsOptions, 2);
|
||||
colsopt.odd_even_mode <<= THISBACK1(ColorsOptions, 3);
|
||||
colsopt.grid_color <<= THISBACK1(ColorsOptions, 4);
|
||||
colsopt.focus_color <<= THISBACK1(ColorsOptions, 5);
|
||||
colsopt.live_color <<= THISBACK1(ColorsOptions, 6);
|
||||
|
||||
colsopt.odd_color.NoRampWheel();
|
||||
colsopt.even_color.NoRampWheel();
|
||||
colsopt.grid_color.NoRampWheel().NotNull();
|
||||
colsopt.focus_color.NoRampWheel();
|
||||
colsopt.live_color.NoRampWheel();
|
||||
|
||||
numsopt.total_cols <<= THISBACK1(Actions, 0);
|
||||
numsopt.total_rows <<= THISBACK1(Actions, 1);
|
||||
numsopt.fixed_cols <<= THISBACK1(Actions, 2);
|
||||
numsopt.fixed_rows <<= THISBACK1(Actions, 3);
|
||||
|
||||
numsopt.total_cols.Disable();
|
||||
|
||||
clear_grid <<= THISBACK1(Actions, 4);
|
||||
reset_grid <<= THISBACK1(Actions, 5);
|
||||
|
||||
#ifndef flagDEBUG
|
||||
debug.Hide();
|
||||
level.Hide();
|
||||
#else
|
||||
clear <<= THISBACK1(Actions, 400);
|
||||
debug <<= THISBACK1(Actions, 401);
|
||||
level <<= THISBACK1(Actions, 402);
|
||||
#endif
|
||||
|
||||
level.Add(0, "All")
|
||||
.Add(1, "1")
|
||||
.Add(2, "2");
|
||||
|
||||
level <<= 0;
|
||||
|
||||
dlog = &log0;
|
||||
//dlev = &level;
|
||||
}
|
||||
|
||||
void Panel::Init(GridCtrl& g)
|
||||
{
|
||||
grid = &g;
|
||||
|
||||
numsopt.total_cols <<= grid->total_cols;
|
||||
numsopt.total_rows <<= grid->total_rows;
|
||||
numsopt.fixed_cols <<= grid->fixed_cols;
|
||||
numsopt.fixed_rows <<= grid->fixed_rows;
|
||||
|
||||
lookopt.indicator <<= grid->indicator;
|
||||
lookopt.hgrid <<= grid->horz_grid;
|
||||
lookopt.vgrid <<= grid->vert_grid;
|
||||
lookopt.resizing_cols <<= grid->resizing_cols;
|
||||
lookopt.resizing_rows <<= grid->resizing_rows;
|
||||
lookopt.moving_cols <<= grid->moving_cols;
|
||||
lookopt.moving_rows <<= grid->moving_rows;
|
||||
lookopt.full_col_resizing <<= grid->full_col_resizing;
|
||||
lookopt.full_row_resizing <<= grid->full_row_resizing;
|
||||
lookopt.chameleon <<= grid->chameleon;
|
||||
lookopt.draw_focus <<= grid->draw_focus;
|
||||
|
||||
editopt.multiline <<= grid->multi_select;
|
||||
editopt.select_row <<= grid->select_row;
|
||||
editopt.sorting <<= grid->sorting;
|
||||
editopt.multisort <<= grid->sorting_multicol;
|
||||
editopt.tab_changes_row <<= grid->tab_changes_row;
|
||||
editopt.tab_adds_row <<= grid->tab_adds_row;
|
||||
editopt.edit_mode = grid->edit_mode;
|
||||
editopt.one_click_edit <<= grid->one_click_edit;
|
||||
|
||||
lookopt.resize_paint_mode <<= grid->resize_paint_mode;
|
||||
lookopt.resize_col_mode <<= grid->resize_col_mode;
|
||||
lookopt.resize_row_mode <<= grid->resize_row_mode;
|
||||
|
||||
colsopt.theme <<= grid->display->theme;
|
||||
|
||||
colsopt.odd_even_mode <<= grid->coloring_mode;
|
||||
colsopt.odd_color <<= grid->bg_odd;
|
||||
colsopt.even_color <<= grid->bg_even;
|
||||
colsopt.grid_color <<= grid->fg_grid;
|
||||
colsopt.focus_color <<= grid->bg_focus;
|
||||
colsopt.live_color <<= grid->bg_live;
|
||||
}
|
||||
|
||||
void Panel::LookOptions(int n)
|
||||
{
|
||||
switch(n)
|
||||
{
|
||||
case 0: grid->Indicator(lookopt.indicator); break;
|
||||
case 1: grid->HorzGrid(lookopt.hgrid); break;
|
||||
case 2: grid->VertGrid(lookopt.vgrid); break;
|
||||
case 3: grid->ResizingCols(lookopt.resizing_cols); break;
|
||||
case 4: grid->ResizingRows(lookopt.resizing_rows); break;
|
||||
case 5: grid->LiveCursor(lookopt.live_cursor); break;
|
||||
case 6: grid->ResizePaintMode(lookopt.resize_paint_mode.GetIndex()); break;
|
||||
case 7: grid->ResizeColMode(lookopt.resize_col_mode.GetIndex()); break;
|
||||
case 8: grid->ResizeRowMode(lookopt.resize_row_mode.GetIndex()); break;
|
||||
case 9: grid->MovingCols(lookopt.moving_cols); break;
|
||||
case 10: grid->MovingRows(lookopt.moving_rows); break;
|
||||
case 11: grid->FullColResizing(lookopt.full_col_resizing); break;
|
||||
case 12: grid->FullRowResizing(lookopt.full_row_resizing); break;
|
||||
case 13:
|
||||
#ifdef flagDEBUG
|
||||
Ctrl::ShowRepaint((int) lookopt.repaint ? 20 : 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 14: grid->Enable(!lookopt.disable); break;
|
||||
case 15: grid->Chameleon(lookopt.chameleon); break;
|
||||
case 16: grid->DrawFocus(lookopt.draw_focus); break;
|
||||
}
|
||||
grid->Repaint();
|
||||
}
|
||||
|
||||
void Panel::ColorsOptions(int n)
|
||||
{
|
||||
switch(n)
|
||||
{
|
||||
case 0: grid->GetDisplay().SetTheme(~colsopt.theme); break;
|
||||
case 1: grid->OddColor(SColorText, ~colsopt.odd_color); break;
|
||||
case 2: grid->EvenColor(SColorText, ~colsopt.even_color); break;
|
||||
case 3: grid->ColoringMode(colsopt.odd_even_mode); break;
|
||||
case 4: grid->GridColor(~colsopt.grid_color); break;
|
||||
case 5: grid->FocusColor(SColorText, ~colsopt.focus_color); break;
|
||||
case 6: grid->LiveColor(SColorText, ~colsopt.live_color); break;
|
||||
}
|
||||
grid->Repaint();
|
||||
}
|
||||
|
||||
void Panel::EditOptions(int n)
|
||||
{
|
||||
switch(n)
|
||||
{
|
||||
case 0: grid->MultiSelect(editopt.multiline); break;
|
||||
case 1: grid->SelectRow(editopt.select_row); break;
|
||||
case 2: grid->Sorting(editopt.sorting); break;
|
||||
case 3: grid->MultiSorting(editopt.multisort); break;
|
||||
case 4: grid->TabChangesRow(editopt.tab_changes_row); break;
|
||||
case 5: grid->TabAddsRow(editopt.tab_adds_row); break;
|
||||
case 6: grid->EditMode(editopt.edit_mode); break;
|
||||
case 7: grid->OneClickEdit(editopt.one_click_edit); break;
|
||||
case 8: grid->EnterLikeTab(editopt.enter_like_tab); break;
|
||||
}
|
||||
grid->Repaint();
|
||||
}
|
||||
|
||||
void Panel::Actions(int n)
|
||||
{
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
/*
|
||||
int cnt = grid->GetColumnCount();
|
||||
if(cnt < numsopt.total_cols)
|
||||
grid->AddColumn(numsopt.total_cols - cnt);
|
||||
else
|
||||
grid->RemoveColumn(cnt - numsopt.total_cols);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
int cnt = grid->GetTotalCount();
|
||||
if(cnt < numsopt.total_rows)
|
||||
grid->Append(numsopt.total_rows - cnt + 1);
|
||||
else
|
||||
grid->RemoveLast(cnt - numsopt.total_rows);
|
||||
break;
|
||||
}
|
||||
case 2: grid->SetFixedCols(numsopt.fixed_cols); break;
|
||||
case 3: grid->SetFixedRows(numsopt.fixed_rows); break;
|
||||
|
||||
case 4:
|
||||
grid->Clear();
|
||||
grid->RefreshTop();
|
||||
break;
|
||||
case 5:
|
||||
grid->Reset();
|
||||
break;
|
||||
case 400:
|
||||
log0.Clear();
|
||||
break;
|
||||
case 401:
|
||||
grid->Debug(0);
|
||||
break;
|
||||
case 402:
|
||||
dlev = ~level;
|
||||
break;
|
||||
case 403:
|
||||
grid->ReSort();
|
||||
break;
|
||||
case 666:
|
||||
Close();
|
||||
}
|
||||
grid->Repaint();
|
||||
}
|
||||
32
reference/GridCtrlTest/Panel.h
Normal file
32
reference/GridCtrlTest/Panel.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef _GridTest_Panel_h_
|
||||
#define _GridTest_Panel_h_
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <GridCtrl/GridCtrl.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE <GridCtrlTest/Panel.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
struct Panel : WithPanelLayout<ParentCtrl>
|
||||
{
|
||||
GridCtrl* grid;
|
||||
|
||||
WithEditOptionsLayout<ParentCtrl> editopt;
|
||||
WithLookOptionsLayout<ParentCtrl> lookopt;
|
||||
WithColorsOptionsLayout<ParentCtrl> colsopt;
|
||||
WithNumberLayout<ParentCtrl> numsopt;
|
||||
|
||||
void LookOptions(int n);
|
||||
void ColorsOptions(int n);
|
||||
void EditOptions(int n);
|
||||
void Actions(int n);
|
||||
|
||||
void Init(GridCtrl& g);
|
||||
|
||||
Panel();
|
||||
typedef Panel CLASSNAME;
|
||||
};
|
||||
|
||||
#endif
|
||||
72
reference/GridCtrlTest/Panel.lay
Normal file
72
reference/GridCtrlTest/Panel.lay
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
LAYOUT(EditOptionsLayout, 180, 264)
|
||||
ITEM(Option, multiline, SetLabel(t_("Multiline select (MLB + CTRL)")).LeftPosZ(4, 160).TopPosZ(4, 15))
|
||||
ITEM(Option, select_row, SetLabel(t_("Select row")).LeftPosZ(4, 160).TopPosZ(20, 15))
|
||||
ITEM(Option, sorting, SetLabel(t_("Auto sort")).LeftPosZ(4, 160).VCenterPosZ(15, 32))
|
||||
ITEM(Option, multisort, SetLabel(t_("Multicolumn sort")).LeftPosZ(4, 160).VCenterPosZ(15, 48))
|
||||
ITEM(Option, tab_adds_row, SetLabel(t_("Tab adds row")).LeftPosZ(4, 160).TopPosZ(52, 15))
|
||||
ITEM(Option, one_click_edit, SetLabel(t_("One click edit")).LeftPosZ(4, 160).TopPosZ(112, 15))
|
||||
ITEM(Option, enter_like_tab, SetLabel(t_("Enter like tab")).LeftPosZ(4, 160).TopPosZ(128, 15))
|
||||
ITEM(Option, tab_changes_row, SetLabel(t_("Tab changes row")).LeftPosZ(4, 160).TopPosZ(36, 15))
|
||||
ITEM(Switch, edit_mode, SetLabel(t_("Edit row\nEdit cell")).LeftPosZ(4, 160).TopPosZ(72, 32))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(LookOptionsLayout, 180, 468)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Resize paint mode")).LeftPosZ(4, 160).TopPosZ(252, 16))
|
||||
ITEM(DropList, resize_paint_mode, LeftPosZ(4, 160).TopPosZ(268, 19))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Resize col mode")).LeftPosZ(4, 88).TopPosZ(292, 16))
|
||||
ITEM(DropList, resize_col_mode, LeftPosZ(4, 88).TopPosZ(312, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Resize row mode")).LeftPosZ(4, 88).TopPosZ(336, 16))
|
||||
ITEM(DropList, resize_row_mode, LeftPosZ(4, 88).TopPosZ(352, 19))
|
||||
ITEM(Option, indicator, SetLabel(t_("Indicator")).LeftPosZ(4, 160).TopPosZ(4, 15))
|
||||
ITEM(Option, hgrid, SetLabel(t_("Horizontal grid")).LeftPosZ(4, 160).TopPosZ(20, 15))
|
||||
ITEM(Option, vgrid, SetLabel(t_("Vertical grid")).LeftPosZ(4, 160).TopPosZ(36, 15))
|
||||
ITEM(Option, live_cursor, SetLabel(t_("Live cursor")).LeftPosZ(4, 160).TopPosZ(52, 15))
|
||||
ITEM(Option, repaint, SetLabel(t_("Show repaints")).LeftPosZ(4, 160).TopPosZ(68, 15))
|
||||
ITEM(Option, disable, SetLabel(t_("Disable")).LeftPosZ(4, 160).TopPosZ(84, 15))
|
||||
ITEM(Option, chameleon, SetLabel(t_("Chameleon")).LeftPosZ(4, 160).TopPosZ(100, 15))
|
||||
ITEM(Option, draw_focus, SetLabel(t_("Draw focus")).LeftPosZ(4, 160).TopPosZ(116, 15))
|
||||
ITEM(Option, resizing_cols, SetLabel(t_("Resizing columns")).LeftPosZ(4, 160).TopPosZ(140, 15))
|
||||
ITEM(Option, resizing_rows, SetLabel(t_("Resizing rows")).LeftPosZ(4, 160).TopPosZ(156, 15))
|
||||
ITEM(Option, moving_cols, SetLabel(t_("Moving columns")).LeftPosZ(4, 160).TopPosZ(172, 15))
|
||||
ITEM(Option, moving_rows, SetLabel(t_("Moving rows")).LeftPosZ(4, 160).TopPosZ(188, 15))
|
||||
ITEM(Option, full_col_resizing, SetLabel(t_("Full column resizing")).LeftPosZ(4, 160).TopPosZ(212, 15))
|
||||
ITEM(Option, full_row_resizing, SetLabel(t_("Full row resizing")).LeftPosZ(4, 160).TopPosZ(228, 15))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(NumberLayout, 180, 272)
|
||||
ITEM(EditIntSpin, total_cols, LeftPosZ(4, 44).TopPosZ(4, 20))
|
||||
ITEM(Label, dv___1, SetLabel(t_("Number of columns")).LeftPosZ(52, 124).TopPosZ(4, 19))
|
||||
ITEM(EditIntSpin, total_rows, LeftPosZ(4, 44).TopPosZ(28, 20))
|
||||
ITEM(Label, dv___3, SetLabel(t_("Number of rows")).LeftPosZ(52, 124).TopPosZ(28, 19))
|
||||
ITEM(EditIntSpin, fixed_cols, LeftPosZ(4, 44).TopPosZ(52, 20))
|
||||
ITEM(Label, dv___5, SetLabel(t_("Number of fixed columns")).LeftPosZ(52, 124).TopPosZ(52, 19))
|
||||
ITEM(EditIntSpin, fixed_rows, LeftPosZ(4, 44).TopPosZ(76, 20))
|
||||
ITEM(Label, dv___7, SetLabel(t_("Number of fixed rows")).LeftPosZ(52, 124).TopPosZ(76, 19))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(ColorsOptionsLayout, 180, 200)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Fixed theme")).LeftPosZ(4, 80).TopPosZ(4, 16))
|
||||
ITEM(Label, dv___1, SetLabel(t_("Odd color")).LeftPosZ(4, 80).TopPosZ(31, 20))
|
||||
ITEM(DropList, theme, LeftPosZ(88, 88).TopPosZ(3, 19))
|
||||
ITEM(ColorPusher, odd_color, LeftPosZ(88, 76).TopPosZ(31, 20))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Even color")).LeftPosZ(4, 80).TopPosZ(55, 20))
|
||||
ITEM(ColorPusher, even_color, LeftPosZ(88, 76).TopPosZ(55, 20))
|
||||
ITEM(Label, dv___6, SetLabel(t_("Grid color")).LeftPosZ(4, 80).TopPosZ(104, 20))
|
||||
ITEM(ColorPusher, grid_color, LeftPosZ(88, 76).TopPosZ(104, 20))
|
||||
ITEM(Label, dv___8, SetLabel(t_("Focus color")).LeftPosZ(4, 80).TopPosZ(128, 20))
|
||||
ITEM(ColorPusher, focus_color, LeftPosZ(88, 76).TopPosZ(128, 20))
|
||||
ITEM(Label, dv___10, SetLabel(t_("Live cursor color")).LeftPosZ(4, 80).TopPosZ(152, 20))
|
||||
ITEM(ColorPusher, live_color, LeftPosZ(88, 76).TopPosZ(152, 20))
|
||||
ITEM(Switch, odd_even_mode, SetLabel(t_("Off\nColumn\nRow")).LeftPosZ(4, 160).TopPosZ(80, 15))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(PanelLayout, 408, 572)
|
||||
ITEM(Button, clear_grid, SetLabel(t_("Clear grid")).RightPosZ(308, 96).BottomPosZ(4, 20))
|
||||
ITEM(Button, reset_grid, SetLabel(t_("Reset grid")).RightPosZ(208, 92).BottomPosZ(4, 20))
|
||||
ITEM(LineEdit, log0, SetFont(MonospaceZ(12)).RightPosZ(4, 200).VSizePosZ(4, 28))
|
||||
ITEM(Button, clear, SetLabel(t_("Clear")).RightPosZ(4, 64).BottomPosZ(4, 20))
|
||||
ITEM(Button, debug, SetLabel(t_("Debug")).RightPosZ(140, 64).BottomPosZ(4, 20))
|
||||
ITEM(TabCtrl, opts, RightPosZ(208, 196).VSizePosZ(4, 28))
|
||||
ITEM(DropList, level, RightPosZ(72, 64).BottomPosZ(5, 19))
|
||||
END_LAYOUT
|
||||
|
||||
57
reference/GridCtrlTest/TestArrayCtrl.cpp
Normal file
57
reference/GridCtrlTest/TestArrayCtrl.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "GridCtrlTest.h"
|
||||
|
||||
void MakeDropList(One<Ctrl>& ctrl)
|
||||
{
|
||||
ctrl.Create<DropList>()
|
||||
.Add(Null, "")
|
||||
.Add(0, "None")
|
||||
.Add(1, "Minimal")
|
||||
.Add(2, "Full");
|
||||
}
|
||||
|
||||
void MakeButton(One<Ctrl>& ctrl)
|
||||
{
|
||||
ctrl.Create<Button>();
|
||||
ctrl->WantFocus();
|
||||
}
|
||||
|
||||
void MakeCheck(One<Ctrl>& ctrl)
|
||||
{
|
||||
ctrl.Create<Option>();
|
||||
ctrl->WantFocus();
|
||||
}
|
||||
|
||||
void MakeEdit(One<Ctrl>& ctrl)
|
||||
{
|
||||
ctrl.Create<EditInt>();
|
||||
ctrl->WantFocus();
|
||||
}
|
||||
|
||||
void TestArrayCtrl::Init()
|
||||
{
|
||||
arr.HeaderTab(0).SetRatio(10);
|
||||
arr.HeaderObject().Absolute();
|
||||
arr.MultiSelect();
|
||||
arr.Inserting();
|
||||
arr.SetLineCy(20);
|
||||
|
||||
const int total_cols = 15;
|
||||
const int total_rows = 10;
|
||||
|
||||
for(int i = 0; i < total_cols; i++)
|
||||
{
|
||||
String name = Format("Column %d", i + 1);
|
||||
int size = rand() % 40 + 50;
|
||||
arr.AddColumn((const char *)name, size);
|
||||
}
|
||||
|
||||
arr.SetCount(50);
|
||||
|
||||
arr.ColumnAt(1).Ctrls(MakeDropList);
|
||||
arr.ColumnAt(2).Ctrls(MakeButton);
|
||||
arr.ColumnAt(3).Ctrls(MakeEdit);
|
||||
arr.ColumnAt(1).Edit(e0);
|
||||
arr.ColumnAt(2).Edit(e1);
|
||||
|
||||
Add(arr.SizePos());
|
||||
}
|
||||
18
reference/GridCtrlTest/TestExcelGrid.cpp
Normal file
18
reference/GridCtrlTest/TestExcelGrid.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include "GridCtrlTest.h"
|
||||
|
||||
void TestExcelGrid::Init()
|
||||
{
|
||||
const int total_cols = 50;
|
||||
|
||||
for(int i = 0; i < total_cols; i++)
|
||||
{
|
||||
String name = Format("Column %d", i + 1);
|
||||
grid.AddColumn((const char *)name).Width(80);
|
||||
}
|
||||
|
||||
grid.SelectRow(false);
|
||||
grid.SetRowCount(200);
|
||||
grid.ResizeColMode(1);
|
||||
grid.Absolute();
|
||||
grid.Clipboard();
|
||||
}
|
||||
13
reference/GridCtrlTest/TestFocusLost.cpp
Normal file
13
reference/GridCtrlTest/TestFocusLost.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include "GridCtrlTest.h"
|
||||
|
||||
void TestFocusLost::Init()
|
||||
{
|
||||
Add(spl.SizePos());
|
||||
spl.Horz(grid0, grid1);
|
||||
|
||||
grid0.AddColumn("Key");
|
||||
grid0.AddColumn("Value");
|
||||
|
||||
grid1.AddColumn("Key");
|
||||
grid1.AddColumn("Value");
|
||||
}
|
||||
100
reference/GridCtrlTest/TestMain.cpp
Normal file
100
reference/GridCtrlTest/TestMain.cpp
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#include "GridCtrlTest.h"
|
||||
|
||||
void TestMain::Init()
|
||||
{
|
||||
const int names_cnt = 6;
|
||||
const int colors_cnt = 4;
|
||||
const int numbers_cnt = 10;
|
||||
|
||||
const char * s_names[] = { "Jack", "This is a very long multiline text\n\n\n1234\n5678\nThis text is absolutely about nothing interesting. This text is absolutely about nothing interesting. This text is absolutely about nothing interesting. This text is absolutely about nothing interesting. This text is absolutely about nothing interesting. This text is absolutely about nothing interesting. This text is absolutely about nothing interesting.", "Smith", "Billy", "Eve", "Pamela" };
|
||||
const char * s_colors[] = { "Red", "Blue", "White", "Black" };
|
||||
|
||||
grid.Inserting(false);
|
||||
grid.Appending(!false);
|
||||
grid.Moving();
|
||||
grid.Removing();
|
||||
grid.Navigating();
|
||||
grid.Searching();
|
||||
grid.Editing();
|
||||
grid.Hiding();
|
||||
grid.Duplicating();
|
||||
grid.AfterBeforeInserting();
|
||||
grid.Accepting().Canceling();
|
||||
grid.Clipboard();
|
||||
grid.SummaryRow();
|
||||
|
||||
const int total_cols = 15;
|
||||
const int total_rows = 10;
|
||||
|
||||
for(int i = 0; i < total_cols; i++)
|
||||
{
|
||||
String name = Format("Column %d", i + 1);
|
||||
int size = rand() % 40 + 50;
|
||||
grid.AddColumn((const char *)name).Width(size);
|
||||
}
|
||||
|
||||
for(int i = 0; i < names_cnt; i++)
|
||||
names.Add(i, s_names[i]);
|
||||
for(int i = 0; i < colors_cnt; i++)
|
||||
colors.Add(i, s_colors[i]);
|
||||
for(int i = 0; i < numbers_cnt; i++)
|
||||
numbers.Add(i, Format("Number %d", i));
|
||||
|
||||
grid.GetColumn(1).Edit(names).SetConvert(names).Default(0).SetImage(CtrlImg::go_forward());
|
||||
grid.GetColumn(2).Edit(numbers).SetConvert(numbers).Default(1);
|
||||
grid.GetColumn(3).Edit(colors).SetConvert(colors).Default(2);
|
||||
grid.GetColumn(4).Edit(edit0).DoCount();
|
||||
grid.GetColumn(5).Edit(edit1).DoSum("Sum: %` $");
|
||||
grid.GetColumn(6).Edit(dt).DoMin();
|
||||
|
||||
grid.GetColumn(9).Option();
|
||||
grid.GetColumn(10).Option();
|
||||
grid.GetColumn(11).Option();
|
||||
|
||||
grid.GetColumn(total_cols - 1).Min(40).Max(40);
|
||||
grid.GetColumn(total_cols - 2).Fixed(50);
|
||||
grid.GetColumn(total_cols - 3).Fixed(40);
|
||||
|
||||
grid.SetDefaultRowHeight(26);
|
||||
grid.AddRow(total_rows);
|
||||
grid.FixedPaste();
|
||||
|
||||
Date curdate = GetSysDate();
|
||||
|
||||
for(int i = 0; i < total_rows; i++)
|
||||
{
|
||||
for(int j = 0; j < total_cols; j++)
|
||||
{
|
||||
switch(j)
|
||||
{
|
||||
case 0: grid.Set(i, j, Value(i + 1)); break;
|
||||
case 1: grid.Set(i, j, rand() % (names_cnt - 1)); break;
|
||||
case 2: grid.Set(i, j, rand() % (numbers_cnt - 1)); break;
|
||||
case 3: grid.Set(i, j, rand() % (colors_cnt - 1)); break;
|
||||
case 6: grid.Set(i, j, Date(curdate.year, curdate.month, rand() % 27 + 1)); break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 7: grid.Set(i, j, rand() % 1); break;
|
||||
default:
|
||||
grid.Set(i, j, Value(rand() % 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grid.EvenColor();
|
||||
grid.ColoringMode(2);
|
||||
grid.Indicator();
|
||||
grid.EditCell();
|
||||
grid.MultiSelect();
|
||||
grid.SelectRow();
|
||||
grid.Sorting();
|
||||
grid.MovingCols(1).MovingRows(1);
|
||||
grid.SetToolBar();
|
||||
grid.Dragging();
|
||||
grid.SetCursor(0);
|
||||
grid.RemoveHides();
|
||||
grid.DrawFocus();
|
||||
grid.AddColumn().WrapText();
|
||||
grid.SetCtrl(0, 0, ei);
|
||||
}
|
||||
26
reference/GridCtrlTest/TestPropertyGrid.cpp
Normal file
26
reference/GridCtrlTest/TestPropertyGrid.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "GridCtrlTest.h"
|
||||
|
||||
void TestPropertyGrid::Init()
|
||||
{
|
||||
|
||||
grid.AddColumn("Property");
|
||||
grid.AddColumn("Value");
|
||||
|
||||
grid.Add("Name", "Window");
|
||||
grid.SetCtrl(1, new EditString());
|
||||
grid.Add("Title", "User account");
|
||||
grid.SetCtrl(1, new EditString());
|
||||
grid.Add("Width", 500);
|
||||
grid.SetCtrl(1, new EditInt());
|
||||
grid.Add("Height", 600);
|
||||
grid.SetCtrl(1, new EditInt());
|
||||
grid.Add("Editable", "false");
|
||||
grid.Add("Background", Red());
|
||||
grid.SetCtrl(1, new ColorPusher());
|
||||
grid.Add("Hint", "This window is big");
|
||||
grid.SetCtrl(1, new EditString());
|
||||
|
||||
grid.DrawFocus();
|
||||
|
||||
|
||||
}
|
||||
5
reference/GridCtrlTest/init
Normal file
5
reference/GridCtrlTest/init
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef _GridCtrlTest_icpp_init_stub
|
||||
#define _GridCtrlTest_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#include "GridCtrl/init"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue