Home » Community » Newbie corner » Clipped text in theIDE
Re: Clipped text in theIDE [message #25432 is a reply to message #25429] |
Tue, 23 February 2010 10:57 |
|
mirek
Messages: 13976 Registered: November 2005
|
Ultimate Member |
|
|
OK, these numbers seem OK. Let us try this:
void MultiButton::Paint(Draw& w)
{
Size sz = GetSize();
int border, lx, rx;
bool frm = Metrics(border, lx, rx);
int mst = ChState(MAIN);
if(frm)
ChPaint(w, sz, style->edge[style->activeedge ? mst : 0]);
bool left = false;
bool right = false;
for(int i = 0; i < button.GetCount(); i++) {
SubButton& b = button[i];
int st = ChState(i);
int x = 0, cx = 0;
GetPos(b, lx, rx, x, cx);
bool dopaint = true;
Value v = b.left ? left ? style->lmiddle[st] : style->left[st]
: right ? style->rmiddle[st] : style->right[st];
if(ComplexFrame())
ChPaint(w, x, border, cx, sz.cy - 2 * border, style->simple[st]);
else
if(frm) {
if(IsTrivial() && style->usetrivial)
dopaint = false;
ChPaint(w, x, border, cx, sz.cy - 2 * border,
dopaint ? v : style->trivial[st]);
}
else {
w.Clip(x, 0, cx, sz.cy);
ChPaint(w, sz, style->look[Frame() ? mst : st]);
if(IsNull(v) || !Frame()) {
if((!IsTrivial() || style->trivialsep) && IsEnabled()) {
if(b.left) {
if(left)
ChPaint(w, x, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1);
ChPaint(w, x + cx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2);
}
else {
ChPaint(w, x, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1);
if(right)
ChPaint(w, x + cx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2);
}
}
}
else
ChPaint(w, x, 0, cx, sz.cy, v);
w.End();
}
if(dopaint) {
Size tsz = GetTextSize(b.label, StdFont());
Image m = tsz.cx > 0 ? b.img : (Image)Nvl(b.img, CtrlsImg::DA());
Size isz = m.GetSize();
Point p = (st == CTRL_PRESSED) * style->pressoffset;
p.x += x + (cx - isz.cx - tsz.cx - (tsz.cx > 0 && isz.cx > 0 ? LB_IMAGE : 0)) / 2;
p.y += (sz.cy - isz.cy) / 2;
if(b.left) {
if(!left) p.x += style->loff;
}
else
if(!right) p.x += style->roff;
if(b.monoimg || IsNull(b.img))
w.DrawImage(p.x, p.y, m, frm ? style->fmonocolor[st] : style->monocolor[st]);
else
w.DrawImage(p.x, p.y, m);
DDUMP(tsz);
DDUMP(isz);
DDUMP(sz);
DDUMP((sz.cy - tsz.cy) / 2);
if(tsz.cx > 0) {
if(isz.cx > 0)
p.x += isz.cx + LB_IMAGE;
w.DrawText(p.x, (sz.cy - tsz.cy) / 2, b.label);
}
}
(b.left ? left : right) = true;
}
Rect r, cr;
Color text = SColorLabel();
Color paper = Null;
if(ComplexFrame()) {
cr = GetSize();
cr.left = lx;
cr.right = rx;
r = cr;
paper = HasFocus() ? SColorHighlight() : SColorPaper();
if(HasFocus())
text = SColorHighlightText();
w.DrawRect(r, paper);
}
else
if(frm) {
Rect m = style->margin;
r = Rect(max(lx, m.left), m.top, min(rx, sz.cx - m.right), sz.cy - m.bottom);
Color paper;
if(mst == CTRL_HOT && !IsTrivial())
paper = Blend(SColorHighlight, SColorPaper, 235);
else
if(mst == CTRL_PRESSED && !IsTrivial())
paper = Blend(SColorHighlight, SColorFace, 235);
else
if(HasFocus()) {
paper = SColorHighlight();
text = SColorHighlightText();
}
else
paper = SColorPaper();
w.DrawRect(r, paper);
cr = r;
}
else {
w.Clip(lx, 0, rx - lx, sz.cy);
ChPaint(w, sz, style->look[mst]);
Rect m = style->margin;
r = Rect(max(lx, m.left), m.top, min(rx, sz.cx - m.right), sz.cy - m.bottom);
if(!IsTrivial() || style->trivialsep) {
if(left) {
r.left++;
if(IsEnabled())
ChPaint(w, lx, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep1);
}
if(right) {
if(IsEnabled())
ChPaint(w, rx - 1, style->sepm, 1, sz.cy - 2 * style->sepm, style->sep2);
r.right--;
}
}
w.End();
cr = r;
}
cr.left++;
Rect clr = cr;
if(!IsNull(valuecy)) {
cr.top += (cr.GetHeight() - valuecy + 1) / 2;
cr.bottom = cr.top + valuecy;
}
Value v = convert->Format(value);
bool f = HasFocus() && !push && frm;
if(cr.left < cr.right && display) {
w.Clip(clr);
display->Paint(w, cr, v,
IsShowEnabled() ? text : SColorDisabled,
paper, f ? Display::CURSOR : Display::FOCUS|Display::CURSOR);
w.End();
}
if(!frm && HasFocus())
DrawFocus(w, r);
}
(It is in CtrlLib/MultiButton.cpp).
Mirek
|
|
|
|
|
Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: fudadmin on Mon, 15 February 2010 08:05
|
|
|
Re: Clipped text in theIDE
By: fudadmin on Mon, 15 February 2010 08:08
|
|
|
Re: Clipped text in theIDE
By: fudadmin on Mon, 15 February 2010 08:11
|
|
|
Re: Clipped text in theIDE
By: mirek on Mon, 15 February 2010 11:59
|
|
|
Re: Clipped text in theIDE
By: fudadmin on Mon, 15 February 2010 13:44
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: fudadmin on Mon, 15 February 2010 22:50
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Mon, 22 February 2010 09:57
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Tue, 23 February 2010 10:57
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Tue, 23 February 2010 15:46
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Wed, 24 February 2010 08:33
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Wed, 24 February 2010 11:40
|
|
|
Re: Clipped text in theIDE
By: mirek on Wed, 24 February 2010 11:51
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Wed, 24 February 2010 20:58
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Wed, 24 February 2010 23:09
|
|
|
Re: Clipped text in theIDE
|
|
|
Re: Clipped text in theIDE
By: mirek on Thu, 25 February 2010 08:08
|
|
|
Re: Clipped text in theIDE
|
Goto Forum:
Current Time: Fri May 10 21:42:52 CEST 2024
Total time taken to generate the page: 0.03202 seconds
|