mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
optimizing Ctrl::Top, LabelBase
This commit is contained in:
parent
1b9382800a
commit
2ebd16b1a1
8 changed files with 60 additions and 65 deletions
|
|
@ -95,9 +95,9 @@ file
|
|||
Algo.h,
|
||||
CoAlgo.h,
|
||||
Sorted.h,
|
||||
Sort.h,
|
||||
CoSort.h,
|
||||
Obsolete.h,
|
||||
Sort.h,
|
||||
Vcont.h,
|
||||
BiCont.h,
|
||||
Other.h,
|
||||
|
|
|
|||
|
|
@ -2,27 +2,6 @@
|
|||
|
||||
namespace Upp {
|
||||
|
||||
/* Faster, but consuming more memory....
|
||||
PteBase::Prec *PteBase::PtrAdd()
|
||||
{
|
||||
AtomicInc(prec->n);
|
||||
return prec;
|
||||
}
|
||||
|
||||
void PteBase::PtrRelease(Prec *prec)
|
||||
{
|
||||
if(prec && AtomicDec(prec->n) == 0)
|
||||
delete prec;
|
||||
}
|
||||
|
||||
PteBase::PteBase()
|
||||
{
|
||||
prec = new Prec;
|
||||
prec->n = 1;
|
||||
prec->ptr = this;
|
||||
}
|
||||
*/
|
||||
|
||||
static StaticMutex sPteLock;
|
||||
|
||||
PteBase::Prec *PteBase::PtrAdd()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ protected:
|
|||
|
||||
Prec *PtrAdd();
|
||||
static void PtrRelease(Prec *prec);
|
||||
static Prec *PtrAdd(const Uuid& uuid);
|
||||
|
||||
PteBase();
|
||||
~PteBase();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ namespace Upp {
|
|||
|
||||
void Ctrl::DeleteTop()
|
||||
{
|
||||
if(top && utop)
|
||||
if(top && utop) {
|
||||
delete utop;
|
||||
utop = nullptr;
|
||||
top = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Ctrl::SetParent(Ctrl *parent)
|
||||
|
|
|
|||
|
|
@ -505,6 +505,8 @@ private:
|
|||
|
||||
|
||||
Frame frame;
|
||||
LogPos pos;//8
|
||||
Rect16 rect; //8
|
||||
|
||||
union {
|
||||
Ctrl *uparent;
|
||||
|
|
@ -514,8 +516,6 @@ private:
|
|||
Ctrl *prev_sibling = nullptr;
|
||||
Ctrl *next_sibling = nullptr;
|
||||
Ctrl *children = nullptr;
|
||||
LogPos pos;//8
|
||||
Rect16 rect; //8
|
||||
const char *info_ptr = nullptr;
|
||||
int16 caretx, carety, caretcx, caretcy;//8
|
||||
|
||||
|
|
|
|||
|
|
@ -503,11 +503,10 @@ void Ctrl::WndFree()
|
|||
{
|
||||
GuiLock __;
|
||||
Top *top = GetTop();
|
||||
if(!top) return;
|
||||
RevokeDragDrop(GetHWND());
|
||||
if(!top) return;
|
||||
ReleaseUDropTarget(top->dndtgt);
|
||||
isopen = false;
|
||||
if(!top) return;
|
||||
HWND owner = GetWindow(top->hwnd, GW_OWNER);// CXL 31.10.2003 z DoRemove
|
||||
bool focus = ::GetFocus() == top->hwnd;
|
||||
LLOG("Ctrl::WndDestroy owner " << (void *)owner
|
||||
|
|
|
|||
|
|
@ -115,19 +115,6 @@ int ChooseAccessKey(const char *text, dword used)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DrawLabel::DrawLabel()
|
||||
{
|
||||
push = focus = disabled = false;
|
||||
lspc = rspc = 0;
|
||||
limg_never_hide = false;
|
||||
rimg_never_hide = false;
|
||||
ink = disabledink = Null;
|
||||
align = valign = ALIGN_CENTER;
|
||||
accesskey = 0;
|
||||
font = StdFont();
|
||||
nowrap = false;
|
||||
}
|
||||
|
||||
Size DrawLabel::GetSize(int txtcx) const
|
||||
{
|
||||
return GetSize(txtcx, limg.GetSize(), lspc, rimg.GetSize(), rspc);
|
||||
|
|
@ -288,7 +275,17 @@ Size DrawLabel::Paint(Draw& w, int x, int y, int cx, int cy, bool vak) const
|
|||
|
||||
void LabelBase::LabelUpdate() {}
|
||||
|
||||
DrawLabel LabelBase::Make() const
|
||||
{
|
||||
DrawLabel lx;
|
||||
(DrawLabelBasic&)lx = lbl;
|
||||
if(ext)
|
||||
(DrawLabelExt&)lx = *ext;
|
||||
return lx;
|
||||
}
|
||||
|
||||
LabelBase& LabelBase::SetLeftImage(const Image& img, int spc, bool never_hide) {
|
||||
DrawLabelExt& lbl = Ext();
|
||||
lbl.limg = img;
|
||||
lbl.lspc = spc;
|
||||
lbl.limg_never_hide = never_hide;
|
||||
|
|
@ -297,6 +294,7 @@ LabelBase& LabelBase::SetLeftImage(const Image& img, int spc, bool never_hide) {
|
|||
}
|
||||
|
||||
LabelBase& LabelBase::SetRightImage(const Image& img, int spc, bool never_hide) {
|
||||
DrawLabelExt& lbl = Ext();
|
||||
lbl.rimg = img;
|
||||
lbl.rspc = spc;
|
||||
lbl.rimg_never_hide = never_hide;
|
||||
|
|
@ -305,7 +303,7 @@ LabelBase& LabelBase::SetRightImage(const Image& img, int spc, bool never_hide)
|
|||
}
|
||||
|
||||
LabelBase& LabelBase::SetPaintRect(const PaintRect& paintrect) {
|
||||
lbl.paintrect = paintrect;
|
||||
Ext().paintrect = paintrect;
|
||||
LabelUpdate();
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -361,7 +359,7 @@ LabelBase& LabelBase::SetVAlign(int valign) {
|
|||
|
||||
Size LabelBase::PaintLabel(Ctrl *ctrl, Draw& w, const Rect& r, bool disabled, bool push, bool focus, bool vak)
|
||||
{
|
||||
DrawLabel lbl1 = lbl;
|
||||
DrawLabel lbl1 = Make();
|
||||
lbl1.disabled = disabled;
|
||||
lbl1.push = push;
|
||||
lbl1.focus = focus;
|
||||
|
|
@ -386,7 +384,7 @@ Size LabelBase::PaintLabel(Draw& w, int x, int y, int cx, int cy, bool disabled,
|
|||
|
||||
Size LabelBase::GetLabelSize() const
|
||||
{
|
||||
return lbl.GetSize();
|
||||
return Make().GetSize();
|
||||
}
|
||||
|
||||
void LinkToolTipIn__();
|
||||
|
|
|
|||
|
|
@ -28,29 +28,41 @@ void DrawVertDrop(Draw& w, int x, int y, int cy);
|
|||
Point GetDragScroll(Ctrl *ctrl, Point p, Size max);
|
||||
Point GetDragScroll(Ctrl *ctrl, Point p, int max = 16);
|
||||
|
||||
struct DrawLabel {
|
||||
PaintRect paintrect;
|
||||
struct DrawLabelBasic {
|
||||
String text;
|
||||
Image limg;
|
||||
Image rimg;
|
||||
Font font;
|
||||
Color lcolor;
|
||||
Color ink, disabledink;
|
||||
Color rcolor;
|
||||
|
||||
int rspc;
|
||||
int lspc;
|
||||
Color ink;
|
||||
Color disabledink;
|
||||
|
||||
int accesskey;
|
||||
|
||||
int align:4, valign:4;
|
||||
|
||||
int align:4;
|
||||
int valign:4;
|
||||
|
||||
bool nowrap:1;
|
||||
bool push:1;
|
||||
bool focus:1;
|
||||
bool disabled:1;
|
||||
bool limg_never_hide:1;
|
||||
bool rimg_never_hide:1;
|
||||
|
||||
DrawLabelBasic() { align = valign = ALIGN_CENTER; nowrap = false; accesskey = 0; font = StdFont(); }
|
||||
};
|
||||
|
||||
struct DrawLabelExt {
|
||||
PaintRect paintrect;
|
||||
|
||||
Image limg;
|
||||
Image rimg;
|
||||
|
||||
Color lcolor;
|
||||
int lspc = 0;
|
||||
Color rcolor;
|
||||
int rspc = 0;
|
||||
|
||||
bool limg_never_hide = false;
|
||||
bool rimg_never_hide = false;
|
||||
};
|
||||
|
||||
struct DrawLabel : DrawLabelBasic, DrawLabelExt {
|
||||
bool push = false;
|
||||
bool focus = false;
|
||||
bool disabled = false;
|
||||
|
||||
Size GetSize(int txtcx, Size sz1, int lspc, Size sz2, int rspc) const;
|
||||
Size GetSize(int txtcx = INT_MAX) const;
|
||||
|
|
@ -58,8 +70,6 @@ struct DrawLabel {
|
|||
Size Paint(Ctrl *ctrl, Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey = true) const;
|
||||
Size Paint(Draw& w, const Rect& r, bool visibleaccesskey = true) const;
|
||||
Size Paint(Draw& w, int x, int y, int cx, int cy, bool visibleaccesskey = true) const;
|
||||
|
||||
DrawLabel();
|
||||
};
|
||||
|
||||
Image DisabledImage(const Image& img, bool disabled = true);
|
||||
|
|
@ -69,7 +79,11 @@ class LabelBase {
|
|||
protected:
|
||||
virtual void LabelUpdate();
|
||||
|
||||
DrawLabel lbl;
|
||||
DrawLabelBasic lbl;
|
||||
One<DrawLabelExt> ext;
|
||||
|
||||
DrawLabelExt& Ext() { if(!ext) ext.Create() ; return *ext; }
|
||||
DrawLabel Make() const;
|
||||
|
||||
public:
|
||||
LabelBase& SetLeftImage(const Image& bmp1, int spc = 0, bool never_hide = false);
|
||||
|
|
@ -93,7 +107,7 @@ public:
|
|||
|
||||
int GetAlign() const { return lbl.align; }
|
||||
int GetVAlign() const { return lbl.valign; }
|
||||
PaintRect GetPaintRect() const { return lbl.paintrect; }
|
||||
PaintRect GetPaintRect() const { return ext ? ext->paintrect : PaintRect(); }
|
||||
String GetText() const { return lbl.text; }
|
||||
Font GetFont() const { return lbl.font; }
|
||||
Color GetInk() const { return lbl.ink; }
|
||||
|
|
@ -107,6 +121,9 @@ public:
|
|||
Size PaintLabel(Draw& w, int x, int y, int cx, int cy,
|
||||
bool disabled = false, bool push = false, bool focus = false, bool vak = true);
|
||||
Size GetLabelSize() const;
|
||||
|
||||
LabelBase(const LabelBase& src) { lbl = src.lbl; if(src.ext) ext = clone(src.ext); }
|
||||
LabelBase() {}
|
||||
|
||||
virtual ~LabelBase();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue