mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
CtrlLib: ArrayCtrl absolute mode visual issue fixed
This commit is contained in:
parent
30801cf271
commit
a5563f9322
7 changed files with 126 additions and 6 deletions
|
|
@ -191,6 +191,26 @@ struct NullFrameClass : public CtrlFrame {
|
|||
|
||||
CtrlFrame& NullFrame();
|
||||
|
||||
class MarginFrame : public CtrlFrame {
|
||||
public:
|
||||
virtual void FrameLayout(Rect& r);
|
||||
virtual void FramePaint(Draw& w, const Rect& r);
|
||||
virtual void FrameAddSize(Size& sz);
|
||||
virtual void FrameAdd(Ctrl& parent);
|
||||
virtual void FrameRemove();
|
||||
|
||||
private:
|
||||
Ctrl *owner;
|
||||
Color color;
|
||||
Rect margins;
|
||||
|
||||
public:
|
||||
void SetMargins(const Rect& r);
|
||||
void SetColor(Color c);
|
||||
|
||||
MarginFrame();
|
||||
};
|
||||
|
||||
class BorderFrame : public CtrlFrame {
|
||||
public:
|
||||
virtual void FrameLayout(Rect& r);
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ void Ctrl::SyncLayout(int force)
|
|||
Rect oview = GetView();
|
||||
Rect view = GetRect().Size();
|
||||
overpaint = OverPaint();
|
||||
bool dolog = parent && !parent->GetParent() && parent->IsOpen();
|
||||
for(int i = 0; i < frame.GetCount(); i++) {
|
||||
Frame& f = frame[i];
|
||||
f.frame->FrameLayout(view);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,62 @@ void NullFrameClass::FrameAddSize(Size& sz) {}
|
|||
|
||||
CtrlFrame& NullFrame() { return Single<NullFrameClass>(); }
|
||||
|
||||
void MarginFrame::FrameAdd(Ctrl& parent)
|
||||
{
|
||||
owner = &parent;
|
||||
}
|
||||
|
||||
void MarginFrame::FrameRemove()
|
||||
{
|
||||
owner = NULL;
|
||||
}
|
||||
|
||||
void MarginFrame::FrameLayout(Rect& r)
|
||||
{
|
||||
r.left += margins.left;
|
||||
r.right -= margins.right;
|
||||
r.top += margins.top;
|
||||
r.bottom -= margins.bottom;
|
||||
}
|
||||
|
||||
void MarginFrame::FramePaint(Draw& w, const Rect& r)
|
||||
{
|
||||
if(IsNull(color))
|
||||
return;
|
||||
w.DrawRect(r.left, r.top, r.Width(), margins.top, color);
|
||||
w.DrawRect(r.left, r.bottom - margins.bottom, r.Width(), margins.bottom, color);
|
||||
int h = r.GetHeight() - margins.top - margins.bottom;
|
||||
w.DrawRect(r.left, r.top + margins.top, margins.left, h, color);
|
||||
w.DrawRect(r.right - margins.right, r.top + margins.top, margins.right, h, color);
|
||||
}
|
||||
|
||||
void MarginFrame::SetMargins(const Rect& r)
|
||||
{
|
||||
margins = r;
|
||||
if(owner)
|
||||
owner->RefreshLayout();
|
||||
}
|
||||
|
||||
void MarginFrame::SetColor(Color c)
|
||||
{
|
||||
color = c;
|
||||
if(owner)
|
||||
owner->RefreshLayout();
|
||||
}
|
||||
|
||||
void MarginFrame::FrameAddSize(Size& sz)
|
||||
{
|
||||
sz.cx += margins.left + margins.right;
|
||||
sz.cy += margins.bottom + margins.top;
|
||||
}
|
||||
|
||||
MarginFrame::MarginFrame()
|
||||
{
|
||||
margins = Rect(0, 0, 0, 0);
|
||||
color = SColorFace();
|
||||
owner = nullptr;
|
||||
}
|
||||
|
||||
void BorderFrame::FrameLayout(Rect& r)
|
||||
{
|
||||
Size sz = r.GetSize();
|
||||
|
|
|
|||
|
|
@ -1068,11 +1068,8 @@ void ArrayCtrl::HeaderScroll()
|
|||
|
||||
void ArrayCtrl::HeaderScrollVisibility()
|
||||
{
|
||||
scrollbox.Height(ScrollBarSize());
|
||||
if(header.IsScroll())
|
||||
sb.SetFrame(scrollbox);
|
||||
else
|
||||
sb.SetFrame(NullFrame());
|
||||
scrollbox.SetMargins(Rect(0, 0, 0, header.IsScroll() ? ScrollBarSize() : 0));
|
||||
scrollbox.SetColor(IsTransparent() ? Null : SColorFace());
|
||||
}
|
||||
|
||||
void ArrayCtrl::RefreshRow(int i)
|
||||
|
|
@ -3114,6 +3111,7 @@ ArrayCtrl::ArrayCtrl() {
|
|||
Reset();
|
||||
AddFrame(sb);
|
||||
AddFrame(header);
|
||||
sb.AddFrame(scrollbox);
|
||||
header.WhenLayout = THISBACK(HeaderLayout);
|
||||
header.WhenScroll = THISBACK(HeaderScroll);
|
||||
sb.WhenScroll = THISBACK(Scroll);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,6 @@ private:
|
|||
Vector<Ln> ln;
|
||||
Vector< Vector<CellInfo> > cellinfo;
|
||||
Vector<bool> modify;
|
||||
FrameBottom<ParentCtrl> scrollbox;
|
||||
Vector<int> column_width, column_pos;
|
||||
DisplayPopup info;
|
||||
const Order *columnsortsecondary;
|
||||
|
|
@ -208,6 +207,7 @@ private:
|
|||
int ctrl_low, ctrl_high;
|
||||
int sorting_from;
|
||||
Index<String> id_ndx;
|
||||
MarginFrame scrollbox;
|
||||
|
||||
int keypos;
|
||||
int cursor;
|
||||
|
|
|
|||
9
upptst/ArrayCtrlAbsolute/ArrayCtrlAbsolute.upp
Normal file
9
upptst/ArrayCtrlAbsolute/ArrayCtrlAbsolute.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
36
upptst/ArrayCtrlAbsolute/main.cpp
Normal file
36
upptst/ArrayCtrlAbsolute/main.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct MyApp : TopWindow {
|
||||
ArrayCtrl a;
|
||||
MarginFrame f;
|
||||
|
||||
virtual void Paint(Draw& w) {
|
||||
w.DrawRect(GetSize(), LtBlue());
|
||||
}
|
||||
|
||||
MyApp() {
|
||||
for(int i = 0; i < 50; i++)
|
||||
a.AddColumn("A", 100);
|
||||
a.HeaderObject().Absolute();
|
||||
|
||||
for(int i = 0; i < 40; i++) {
|
||||
a.Add("This is very very long line...");
|
||||
a.Add("This is long line, but the next column is not empty", 12);
|
||||
a.Add("Short line");
|
||||
}
|
||||
Sizeable();
|
||||
Add(a.SizePos());
|
||||
|
||||
// a.Transparent();
|
||||
a.SetFrame(f);
|
||||
f.SetColor(LtGreen());
|
||||
f.SetMargins(Rect(20, 50, 20, 10));
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
MyApp().Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue