*GridCtrlTest: Few small fixes..

git-svn-id: svn://ultimatepp.org/upp/trunk@2673 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
unodgs 2010-09-08 20:04:35 +00:00
parent cfecef441e
commit 381f556d71
8 changed files with 57 additions and 63 deletions

View file

@ -18,14 +18,6 @@ App::App()
{ {
CtrlLayout(*this, "Grid Test Panel"); 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(testMain.SizePos(), "Main");
tab.Add(testExcelGrid.SizePos(), "Excel grid"); tab.Add(testExcelGrid.SizePos(), "Excel grid");
tab.Add(testPropertyGrid.SizePos(), "Property grid"); tab.Add(testPropertyGrid.SizePos(), "Property grid");
@ -33,7 +25,6 @@ App::App()
tab.Add(testFocusLost.SizePos(), "Focus lost"); tab.Add(testFocusLost.SizePos(), "Focus lost");
tab <<= THISBACK(TabChange); tab <<= THISBACK(TabChange);
resort <<= THISBACK(Resort); resort <<= THISBACK(Resort);
toxml <<= THISBACK(ToXml); toxml <<= THISBACK(ToXml);
fromxml <<= THISBACK(FromXml); fromxml <<= THISBACK(FromXml);
@ -41,6 +32,17 @@ App::App()
Sizeable().Zoomable();//.BackPaint(!false); Sizeable().Zoomable();//.BackPaint(!false);
} }
void App::Init()
{
testMain.Init();
testExcelGrid.Init();
testPropertyGrid.Init();
testFocusLost.Init();
testArrayCtrl.Init();
panel.Init(testMain.grid);
}
void App::TabChange() void App::TabChange()
{ {
int t = tab.Get(); int t = tab.Get();
@ -60,6 +62,8 @@ void App::Serialize(Stream &s)
{ {
SerializePlacement(s); SerializePlacement(s);
s % panel.level; s % panel.level;
if(s.IsLoading())
dlev = ~panel.level;
} }
void App::Resort() void App::Resort()
@ -83,9 +87,10 @@ void App::FromXml()
GUI_APP_MAIN GUI_APP_MAIN
{ {
SetLanguage(LNGC_('E','N','E','N', CHARSET_UTF8));
App app; App app;
LoadFromFile(app); LoadFromFile(app);
SetLanguage(LNGC_('E','N','E','N', CHARSET_UTF8)); app.Init();
app.Run(); app.Run();
StoreToFile(app); StoreToFile(app);
} }

View file

@ -79,7 +79,7 @@ struct App : public WithGridPanel<TopWindow>
TestArrayCtrl testArrayCtrl; TestArrayCtrl testArrayCtrl;
void TabChange(); void TabChange();
void Init();
void Serialize(Stream &s); void Serialize(Stream &s);
void Resort(); void Resort();
void ToXml(); void ToXml();

View file

@ -95,12 +95,12 @@ Panel::Panel()
level.Add(0, "All") level.Add(0, "All")
.Add(1, "1") .Add(1, "1")
.Add(2, "2"); .Add(2, "2")
.Add(3, "3");
level <<= 0; level <<= 0;
dlog = &log0; dlog = &log0;
//dlev = &level;
} }
void Panel::Init(GridCtrl& g) void Panel::Init(GridCtrl& g)
@ -117,10 +117,12 @@ void Panel::Init(GridCtrl& g)
lookopt.vgrid <<= grid->vert_grid; lookopt.vgrid <<= grid->vert_grid;
lookopt.resizing_cols <<= grid->resizing_cols; lookopt.resizing_cols <<= grid->resizing_cols;
lookopt.resizing_rows <<= grid->resizing_rows; lookopt.resizing_rows <<= grid->resizing_rows;
lookopt.live_cursor <<= grid->live_cursor;
lookopt.moving_cols <<= grid->moving_cols; lookopt.moving_cols <<= grid->moving_cols;
lookopt.moving_rows <<= grid->moving_rows; lookopt.moving_rows <<= grid->moving_rows;
lookopt.full_col_resizing <<= grid->full_col_resizing; lookopt.full_col_resizing <<= grid->full_col_resizing;
lookopt.full_row_resizing <<= grid->full_row_resizing; lookopt.full_row_resizing <<= grid->full_row_resizing;
lookopt.disable <<= !grid->IsEnabled();
lookopt.chameleon <<= grid->chameleon; lookopt.chameleon <<= grid->chameleon;
lookopt.draw_focus <<= grid->draw_focus; lookopt.draw_focus <<= grid->draw_focus;
@ -226,9 +228,9 @@ void Panel::Actions(int n)
} }
case 1: case 1:
{ {
int cnt = grid->GetTotalCount(); int cnt = grid->total_rows;
if(cnt < numsopt.total_rows) if(cnt < numsopt.total_rows)
grid->Append(numsopt.total_rows - cnt + 1); grid->Append(numsopt.total_rows - cnt);
else else
grid->RemoveLast(cnt - numsopt.total_rows); grid->RemoveLast(cnt - numsopt.total_rows);
break; break;

View file

@ -34,13 +34,13 @@ LAYOUT(LookOptionsLayout, 180, 468)
END_LAYOUT END_LAYOUT
LAYOUT(NumberLayout, 180, 272) LAYOUT(NumberLayout, 180, 272)
ITEM(EditIntSpin, total_cols, LeftPosZ(4, 44).TopPosZ(4, 20)) ITEM(EditIntSpin, total_cols, Min(1).NotNull(true).LeftPosZ(4, 44).TopPosZ(4, 20))
ITEM(Label, dv___1, SetLabel(t_("Number of columns")).LeftPosZ(52, 124).TopPosZ(4, 19)) 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(EditIntSpin, total_rows, Min(1).NotNull(true).LeftPosZ(4, 44).TopPosZ(28, 20))
ITEM(Label, dv___3, SetLabel(t_("Number of rows")).LeftPosZ(52, 124).TopPosZ(28, 19)) 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(EditIntSpin, fixed_cols, Min(0).NotNull(true).LeftPosZ(4, 44).TopPosZ(52, 20))
ITEM(Label, dv___5, SetLabel(t_("Number of fixed columns")).LeftPosZ(52, 124).TopPosZ(52, 19)) 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(EditIntSpin, fixed_rows, Min(0).NotNull(true).LeftPosZ(4, 44).TopPosZ(76, 20))
ITEM(Label, dv___7, SetLabel(t_("Number of fixed rows")).LeftPosZ(52, 124).TopPosZ(76, 19)) ITEM(Label, dv___7, SetLabel(t_("Number of fixed rows")).LeftPosZ(52, 124).TopPosZ(76, 19))
END_LAYOUT END_LAYOUT

View file

@ -12,7 +12,7 @@ void TestExcelGrid::Init()
grid.SelectRow(false); grid.SelectRow(false);
grid.SetRowCount(200); grid.SetRowCount(200);
grid.ResizeColMode(1); grid.ResizePaintMode(1);
grid.Absolute(); grid.Absolute();
grid.Clipboard(); grid.Clipboard();
} }

View file

@ -93,7 +93,6 @@ void TestMain::Init()
grid.SetToolBar(); grid.SetToolBar();
grid.Dragging(); grid.Dragging();
grid.SetCursor(0); grid.SetCursor(0);
grid.RemoveHides();
grid.DrawFocus(); grid.DrawFocus();
grid.AddColumn().WrapText(); grid.AddColumn().WrapText();
grid.SetCtrl(0, 0, ei); grid.SetCtrl(0, 0, ei);

View file

@ -1088,11 +1088,11 @@ void GridCtrl::Paint(Draw &w)
bool skip; bool skip;
Rect r; Rect r;
LG("---- Paint(%d)", ++paintcnt); LG(0, "---- Paint(%d)", ++paintcnt);
if(total_cols <= 1 || total_rows == 0) if(total_cols <= 1 || total_rows == 0)
{ {
LG("empty"); LG(0, "---- Paint(%d) Empty.", paintcnt);
w.DrawRect(sz, SColorPaper); w.DrawRect(sz, SColorPaper);
return; return;
} }
@ -1103,8 +1103,8 @@ void GridCtrl::Paint(Draw &w)
if(firstCol < 0) firstCol = GetFirstVisCol(fixed_width); if(firstCol < 0) firstCol = GetFirstVisCol(fixed_width);
if(firstRow < 0) firstRow = GetFirstVisRow(fixed_height); if(firstRow < 0) firstRow = GetFirstVisRow(fixed_height);
LG("firstCol %d", firstCol); LG(0, "firstCol %d", firstCol);
LG("firstRow %d", firstRow); LG(0, "firstRow %d", firstRow);
int en = IsShowEnabled() ? 0 : GD::READONLY; int en = IsShowEnabled() ? 0 : GD::READONLY;
@ -1125,11 +1125,9 @@ void GridCtrl::Paint(Draw &w)
r.Set(fixed_width, 0, sz.cx, summary_row ? sz.cy : fixed_height); r.Set(fixed_width, 0, sz.cx, summary_row ? sz.cy : fixed_height);
LG("painting %d, tc %d", (int)w.IsPainting(r), total_cols);
LG("%d, %d, %d, %d", r.left, r.top, r.right, r.bottom);
if(w.IsPainting(r) && total_cols > 1) if(w.IsPainting(r) && total_cols > 1)
{ {
LG("Top header"); LG(0, "Top header");
w.Clip(r); w.Clip(r);
x = hitems[total_cols - 1].nRight(sbx); x = hitems[total_cols - 1].nRight(sbx);
@ -1244,7 +1242,7 @@ void GridCtrl::Paint(Draw &w)
if(can_paint && w.IsPainting(r)) if(can_paint && w.IsPainting(r))
{ {
LG("Left header"); LG(0, "Left header");
w.Clip(r); w.Clip(r);
y = vitems[total_rows - 1].nBottom(sby); y = vitems[total_rows - 1].nBottom(sby);
@ -1328,7 +1326,7 @@ void GridCtrl::Paint(Draw &w)
if(can_paint && w.IsPainting(r)) if(can_paint && w.IsPainting(r))
{ {
LG("Body"); LG(0, "Body");
w.Clip(r); w.Clip(r);
x = hitems[total_cols - 1].nRight(sbx); x = hitems[total_cols - 1].nRight(sbx);
@ -1557,7 +1555,7 @@ void GridCtrl::Paint(Draw &w)
if(++paint_flag > 100) if(++paint_flag > 100)
paint_flag = 0; paint_flag = 0;
LG("---- Paint(%d).", paintcnt); LG(0, "---- Paint(%d).", paintcnt);
} }
void GridCtrl::DrawHorzDragLine(Draw &w, int pos, int cx, int size, Color c) void GridCtrl::DrawHorzDragLine(Draw &w, int pos, int cx, int size, Color c)
@ -2136,7 +2134,7 @@ void GridCtrl::LeftDown(Point p, dword keyflags)
void GridCtrl::LeftUp(Point p, dword keyflags) void GridCtrl::LeftUp(Point p, dword keyflags)
{ {
LG("LeftUp"); LG(0, "LeftUp");
ReleaseCapture(); ReleaseCapture();
fixed_click = false; fixed_click = false;
@ -2145,7 +2143,7 @@ void GridCtrl::LeftUp(Point p, dword keyflags)
if(moving_header) if(moving_header)
{ {
LG("moving_header"); LG(0, "moving_header");
pophdr.Close(); pophdr.Close();
moving_header = false; moving_header = false;
@ -2265,7 +2263,7 @@ void GridCtrl::LeftUp(Point p, dword keyflags)
void GridCtrl::LeftDouble(Point p, dword keyflags) void GridCtrl::LeftDouble(Point p, dword keyflags)
{ {
LG("LeftDouble"); LG(0, "LeftDouble");
if(full_col_resizing && curSplitCol >= 0) if(full_col_resizing && curSplitCol >= 0)
return; return;
@ -2365,8 +2363,6 @@ void GridCtrl::Layout()
if(!ready) if(!ready)
return; return;
LG("Layout");
UpdateCols(); UpdateCols();
UpdateRows(); UpdateRows();
UpdateSizes(); UpdateSizes();
@ -2548,7 +2544,7 @@ void GridCtrl::Scroll()
if(!doscroll) if(!doscroll)
return; return;
LG("Scroll (%d, %d)", delta.cx, delta.cy); LG(0, "Scroll (%d, %d)", delta.cx, delta.cy);
SyncCtrls(); SyncCtrls();
UpdateCtrls(UC_CHECK_VIS | UC_SHOW | UC_SCROLL); UpdateCtrls(UC_CHECK_VIS | UC_SHOW | UC_SCROLL);
@ -2581,7 +2577,7 @@ void GridCtrl::SetFixedRows(int n)
{ {
if(n >= 0 && n <= total_rows) if(n >= 0 && n <= total_rows)
{ {
LG("SetFixedRows"); LG(0, "SetFixedRows");
fixed_rows = n; fixed_rows = n;
firstRow = -1; firstRow = -1;
UpdateSizes(); UpdateSizes();
@ -2597,7 +2593,7 @@ void GridCtrl::SetFixedCols(int n)
{ {
if(n >= 0 && n < total_cols) if(n >= 0 && n < total_cols)
{ {
LG("SetFixedCols"); LG(0, "SetFixedCols");
fixed_cols = n + 1; /* +1 - indicator! */ fixed_cols = n + 1; /* +1 - indicator! */
firstCol = -1; firstCol = -1;
UpdateSizes(); UpdateSizes();
@ -3152,7 +3148,7 @@ void GridCtrl::MouseAccel(const Point &p, bool horz, bool vert, dword keyflags)
if(speedx || speedy) if(speedx || speedy)
{ {
LG("speedx %d, speedy %d", speedx, speedy); LG(0, "speedx %d, speedy %d", speedx, speedy);
MouseMove(p, keyflags); MouseMove(p, keyflags);
} }
@ -3521,7 +3517,7 @@ GridCtrl::CurState GridCtrl::SetCursor0(Point p, int opt, int dirx, int diry)
if(isnewrow) if(isnewrow)
SetCtrlsData(); SetCtrlsData();
LG("cur(%d, %d)", curpos.x, curpos.y); LG(0, "cur(%d, %d)", curpos.x, curpos.y);
return cs; return cs;
} }
@ -3566,7 +3562,6 @@ int GridCtrl::GetFirst0(Vector<ItemRect> &its, int total, int sb, int p)
{ {
if(!its[i].hidden) if(!its[i].hidden)
{ {
LG("!");
return i; return i;
} }
else else
@ -3613,7 +3608,7 @@ GridCtrl& GridCtrl::SetColWidth(int n, int width, bool recalc /* = true */)
GridCtrl& GridCtrl::SetRowHeight(int n, int height, bool recalc) GridCtrl& GridCtrl::SetRowHeight(int n, int height, bool recalc)
{ {
LG("SetRowHeight %d %d", n, height); LG(0, "SetRowHeight %d %d", n, height);
if(resize_row_mode > 0 && n >= fixed_rows) if(resize_row_mode > 0 && n >= fixed_rows)
return *this; return *this;
@ -3832,7 +3827,6 @@ bool GridCtrl::UpdateCols(bool force)
if((osz.cx != sz.cx && resize_col_mode > 0) || force || recalc_cols) if((osz.cx != sz.cx && resize_col_mode > 0) || force || recalc_cols)
{ {
LG(" RecalcCols");
RecalcCols(-1); RecalcCols(-1);
recalc_cols = false; recalc_cols = false;
change = true; change = true;
@ -3849,7 +3843,6 @@ bool GridCtrl::UpdateRows(bool force)
if((osz.cy != sz.cy && resize_row_mode > 0) || force || recalc_rows) if((osz.cy != sz.cy && resize_row_mode > 0) || force || recalc_rows)
{ {
LG(" RecalcRows");
RecalcRows(-1); RecalcRows(-1);
recalc_rows = false; recalc_rows = false;
change = true; change = true;
@ -4653,7 +4646,6 @@ void GridCtrl::UpdateCtrls(int opt /*= UC_CHECK_VIS | UC_SHOW | UC_CURSOR */)
if(dofocus && ctrl->IsShown()) if(dofocus && ctrl->IsShown())
{ {
LG(2, "Focus on %d", i);
ctrl->SetFocus(); ctrl->SetFocus();
focused_ctrl = ctrl; focused_ctrl = ctrl;
focused_ctrl_id = id; focused_ctrl_id = id;
@ -5344,7 +5336,7 @@ bool GridCtrl::CanMoveCol(int n, int m)
void GridCtrl::MoveCol(int n, int m) void GridCtrl::MoveCol(int n, int m)
{ {
LG("%d->%d", n, m); LG(0, "%d->%d", n, m);
if(!CanMoveCol(n, m)) if(!CanMoveCol(n, m))
{ {
@ -5352,8 +5344,6 @@ void GridCtrl::MoveCol(int n, int m)
return; return;
} }
LG("Moved");
ItemRect ir = hitems[n]; ItemRect ir = hitems[n];
if(m > total_cols) if(m > total_cols)
hitems.Add(ir); hitems.Add(ir);
@ -5370,7 +5360,7 @@ void GridCtrl::MoveCol(int n, int m)
bool GridCtrl::MoveRow(int n, int m, bool repaint) bool GridCtrl::MoveRow(int n, int m, bool repaint)
{ {
LG("%d->%d", n, m); LG(0, "%d->%d", n, m);
if(m == n || m == n - 1 || if(m == n || m == n - 1 ||
n < 0 || n > total_rows - 1 || n < 0 || n > total_rows - 1 ||
@ -5388,8 +5378,6 @@ bool GridCtrl::MoveRow(int n, int m, bool repaint)
return false; return false;
} }
LG("Moved");
ItemRect ir = vitems[n]; ItemRect ir = vitems[n];
if(m > total_rows) if(m > total_rows)
vitems.Add(ir); vitems.Add(ir);
@ -6292,7 +6280,7 @@ GridCtrl& GridCtrl::SetColsMax(int size)
void GridCtrl::GotFocus() void GridCtrl::GotFocus()
{ {
LG("GotFocus"); LG(0, "GotFocus");
RestoreFocus(); RestoreFocus();
if(valid_cursor) if(valid_cursor)
RefreshRow(curpos.y, 0, 0); RefreshRow(curpos.y, 0, 0);
@ -6300,11 +6288,11 @@ void GridCtrl::GotFocus()
void GridCtrl::LostFocus() void GridCtrl::LostFocus()
{ {
LG("LostFocus"); LG(0, "LostFocus");
if(valid_cursor) if(valid_cursor)
{ {
// if(focus_lost_accepting && !HasFocusDeep()) if(focus_lost_accepting && !HasFocusDeep())
// EndEdit(); EndEdit();
RefreshRow(curpos.y, 0, 0); RefreshRow(curpos.y, 0, 0);
} }
popup.Close(); popup.Close();
@ -6312,7 +6300,7 @@ void GridCtrl::LostFocus()
void GridCtrl::ChildGotFocus() void GridCtrl::ChildGotFocus()
{ {
LG("ChildGotFocus"); LG(0, "ChildGotFocus");
if(valid_cursor) if(valid_cursor)
RefreshRow(curpos.y, 0, 0); RefreshRow(curpos.y, 0, 0);
Ctrl::ChildGotFocus(); Ctrl::ChildGotFocus();
@ -6320,7 +6308,7 @@ void GridCtrl::ChildGotFocus()
void GridCtrl::ChildLostFocus() void GridCtrl::ChildLostFocus()
{ {
LG("ChildLostFocus"); LG(0, "ChildLostFocus");
if(valid_cursor) if(valid_cursor)
RefreshRow(curpos.y, 0, 0); RefreshRow(curpos.y, 0, 0);
Ctrl::ChildLostFocus(); Ctrl::ChildLostFocus();
@ -7103,7 +7091,7 @@ bool GridCtrl::IsSelected()
void GridCtrl::ClearSelection() void GridCtrl::ClearSelection()
{ {
LG("Cleared %d", selected_rows); LG(0, "Cleared %d", selected_rows);
shiftmode = false; shiftmode = false;
shiftpos = curpos; shiftpos = curpos;
if(selected_rows > 0) if(selected_rows > 0)
@ -7227,7 +7215,7 @@ void GridCtrl::DoRemove()
if(keep_last_row && (maxRowSelected - minRowSelected + 1) == GetCount()) if(keep_last_row && (maxRowSelected - minRowSelected + 1) == GetCount())
maxRowSelected--; maxRowSelected--;
LG("Min:%d, Max:%d", minRowSelected, maxRowSelected); LG(0, "Min:%d, Max:%d", minRowSelected, maxRowSelected);
for(int i = minRowSelected; i <= maxRowSelected; i++) for(int i = minRowSelected; i <= maxRowSelected; i++)
{ {
@ -7517,7 +7505,7 @@ int GridCtrl::ShowMatchedRows(const WString &f)
{ {
if(change || search_highlight) if(change || search_highlight)
{ {
LG("Repaint %d", search_hide); LG(0, "Repaint %d", search_hide);
Repaint(false, search_hide, 0); Repaint(false, search_hide, 0);
} }
} }
@ -7537,7 +7525,7 @@ int GridCtrl::ShowMatchedRows(const WString &f)
WhenSearchCursor(); WhenSearchCursor();
} }
LG("Matched rows %d", rows); LG(0, "Matched rows %d", rows);
return rows; return rows;
} }

View file

@ -29,7 +29,7 @@ void LogCon(int level, const char *fmt, ...)
void LogGui(const char *fmt, ...) void LogGui(const char *fmt, ...)
{ {
if(!dlog || dlev > 0) if(!dlog)
return; return;
pos = dlog->GetLength(); pos = dlog->GetLength();