CH_STYLE(ProgressIndicator, Style, StyleDefault) { classic = GUI_GlobalStyle() == GUISTYLE_CLASSIC; hlook = CtrlsImg::PI(); hchunk = CtrlsImg::PIC(); vlook = CtrlsImg::VPI(); vchunk = CtrlsImg::VPIC(); bound = false; }
void TopSubMenuItem::Pull() { Rect r = GetScreenRect(); if(parentmenu && parentmenu->IsChild() && !parentmenu->submenu) parentmenu->SetupRestoreFocus(); Point p = r.BottomLeft(); if(GUI_GlobalStyle() >= GUISTYLE_XP) p += style->pullshift; SubMenuBase::Pull(this, p, Size(r.Width(), -r.Height())); if(parentmenu) parentmenu->SyncState(); }
void DrawMenuText(Draw& w, int x, int y, const String& s, Font f, bool enabled, bool hl, int mnemonic, Color color, Color hlcolor, bool menumark) { if(enabled) DrawMnemonicText(w, x, y, s, f, hl ? hlcolor : color, mnemonic, menumark); else { if(GUI_GlobalStyle() >= GUISTYLE_XP) DrawMnemonicText(w, x, y, s, f, SColorDisabled, 0, menumark); else { DrawMnemonicText(w, x + 1, y + 1, s, f, SColorPaper, 0, menumark); DrawMnemonicText(w, x, y, s, f, SColorDisabled, 0, menumark); } } }
void ColorButton::Paint(Draw& w) { Size sz = GetSize(); Size isz = image.GetSize(); Point center = (sz - isz) / 2; if(GUI_GlobalStyle() >= GUISTYLE_XP) ChPaint(w, sz, style->look[!IsEnabled() ? CTRL_DISABLED : push ? CTRL_PRESSED : HasMouse() ? CTRL_HOT : CTRL_NORMAL]); else { w.DrawRect(sz, SColorFace); if(push) DrawFrame(w, sz, SColorShadow, SColorLight); else if(HasMouse()) DrawFrame(w, sz, SColorLight, SColorShadow); } if(IsNull(color)) w.DrawImage(center.x + push, center.y + push, nullimage); else w.DrawImage(center.x + push, center.y + push, image, color); w.DrawImage(center.x + push, center.y + push, staticimage); }
void MenuItemBase::PaintTopItem(Draw& w, int state) { Size sz = GetSize(); if(GUI_GlobalStyle() >= GUISTYLE_XP) { bool opaque = InOpaqueBar(); bool opaque2 = opaque || state; Color bg = SColorFace(); if(opaque2) ChPaint(w, 0, 0, sz.cx, sz.cy, style->topitem[state]); else if(opaque) w.DrawRect(0, 0, sz.cx, sz.cy, bg); String text = GetText(); Size isz = GetTextSize(text, StdFont()); Color txt = opaque ? style->topitemtext[0] : GetLabelTextColor(this); Color hltxt = opaque2 ? style->topitemtext[state] : GetLabelTextColor(this); if(!opaque && state != 2) { // Fix issues when text color is not compatible with transparent background (e.g. Ubuntu Ambience)] Color c = state == 1 ? SColorHighlight() : bg; int g = Grayscale(c); bool dark = IsDark(c); if(abs(g - Grayscale(txt)) < 70) txt = dark ? White() : Black(); if(abs(g - Grayscale(hltxt)) < 70) hltxt = dark ? White() : Black(); } DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), state, txt, hltxt); } else { w.DrawRect(sz, SColorFace); static const ColorF b0[] = { (ColorF)1, SColorLight, SColorLight, SColorShadow, SColorShadow, }; static const ColorF b1[] = { (ColorF)1, SColorShadow, SColorShadow, SColorLight, SColorLight, }; String text = GetText(); Size isz = GetTextSize(text, StdFont()); DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), false, SColorMenuText, SColorHighlightText); if(state) DrawBorder(w, 0, 0, sz.cx, sz.cy, state == 2 ? b1 : b0); } }
Image DisabledImage(const Image& img, bool dis) { return dis ? MakeImage(img, GUI_GlobalStyle() == GUISTYLE_CLASSIC ? Etched : DisImage) : img; }
CtrlFrame& FieldFrame() { return GUI_GlobalStyle() >= GUISTYLE_XP ? XPFieldFrame() : InsetFrame(); }
void LabelBox::Paint(Draw& w) { Size sz = GetSize(); if(!IsTransparent()) w.DrawRect(sz, SColorFace); Size lsz = GetLabelSize(); int d = lsz.cy >> 1; bool hline = sz.cy < 2 * Draw::GetStdFontCy(); bool vline = sz.cx < 2 * Draw::GetStdFontCy(); int ty = hline ? (sz.cy - lsz.cy) / 2 : 0; Size ts = PaintLabel(w, d + 2, ty, sz.cx, lsz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys()); w.Begin(); w.ExcludeClip(d, ty, ts.cx + 4, ts.cy); if(GUI_GlobalStyle() >= GUISTYLE_XP || !IsNull(color)) { if(hline) { d = sz.cy / 2; w.DrawRect(0, d - 1, sz.cx, 1, SColorLight); w.DrawRect(0, d, sz.cx, 1, SColorShadow); w.DrawRect(0, d + 1, sz.cx, 1, SColorLight); } else if(vline) { d = sz.cx / 2; w.DrawRect(d - 1, 0, 1, sz.cy, SColorLight); w.DrawRect(d, 0, 1, sz.cy, SColorShadow); w.DrawRect(d + 1, 0, 1, sz.cy, SColorLight); } else { Color c = Nvl(color, LabelBoxColor); w.DrawRect(0, d + 2, 1, sz.cy - d - 4, c); w.DrawRect(sz.cx - 1, d + 2, 1, sz.cy - d - 4, c); w.DrawRect(2, sz.cy - 1, sz.cx - 4, 1, c); w.DrawRect(2, d, sz.cx - 4, 1, c); w.DrawRect(1, d + 1, 2, 1, c); w.DrawRect(1, d + 2, 1, 1, c); w.DrawRect(sz.cx - 3, d + 1, 2, 1, c); w.DrawRect(sz.cx - 2, d + 2, 1, 1, c); w.DrawRect(1, sz.cy - 2, 2, 1, c); w.DrawRect(1, sz.cy - 3, 1, 1, c); w.DrawRect(sz.cx - 3, sz.cy - 2, 2, 1, c); w.DrawRect(sz.cx - 2, sz.cy - 3, 1, 1, c); } } else { if(hline) { d = sz.cy / 2; w.DrawRect(0, d, sz.cx, 1, SColorShadow); w.DrawRect(0, d + 1, sz.cx, 1, SColorLight); } else if(vline) { d = sz.cx / 2; w.DrawRect(d, 0, 1, sz.cy, SColorShadow); w.DrawRect(d - 1, 1, 0, sz.cy, SColorLight); } else { w.DrawRect(1, d, sz.cx - 2, 1, SColorShadow); w.DrawRect(1, d + 1, sz.cx - 2, 1, SColorLight); w.DrawRect(0, d, 1, sz.cy - d - 1, SColorShadow); w.DrawRect(1, d + 1, 1, sz.cy - d - 2, SColorLight); w.DrawRect(sz.cx - 2, d, 1, sz.cy - d, SColorShadow); w.DrawRect(sz.cx - 1, d, 1, sz.cy - d, SColorLight); w.DrawRect(1, sz.cy - 2, sz.cx - 2, 1, SColorShadow); w.DrawRect(1, sz.cy - 1, sz.cx - 2, 1, SColorLight); } } w.End(); }
void MenuItem::Paint(Draw& w) { int q = text.Find('\t'); String txt, keydesc; if(accel) keydesc = GetKeyDesc(accel); if(q >= 0) { keydesc = text.Mid(q + 1); txt = text.Mid(0, q); } else txt = text; state = GetVisualState(); bool hl = state != NORMAL; Size sz = GetSize(); if(hl) { if(GUI_GlobalStyle() >= GUISTYLE_XP) ChPaint(w, 0, 0, sz.cx, sz.cy, style->item); else w.DrawRect(sz, SColorHighlight); } UPP::Image li = licon; if(li.IsEmpty()) { switch(type) { case CHECK0: li = CtrlImg::MenuCheck0(); break; case CHECK1: li = CtrlImg::MenuCheck1(); break; case RADIO0: li = CtrlImg::MenuRadio0(); break; case RADIO1: li = CtrlImg::MenuRadio1(); break; } } Size isz = li.GetSize(); // Size isz = min(maxiconsize, imsz); // if(isz != imsz) // li = CachedRescale(li, isz); int iy = (sz.cy - isz.cy) / 2; bool chk = false; int x = Zx(2); if(!licon.IsEmpty() && type) { chk = type == CHECK1 || type == RADIO1; if(GUI_GlobalStyle() >= GUISTYLE_XP) { if(chk && !hl) DrawXPButton(w, RectC(0, iy - Zy(2), isz.cx + Zx(4), isz.cy + Zy(4)), BUTTON_EDGE|BUTTON_CHECKED); } else { w.DrawRect(x - Zx(1), iy - Zy(1), isz.cx + Zx(2), isz.cy + Zy(2), chk ? Blend(SColorFace, SColorLight) : SColorFace); DrawBorder(w, x - Zx(2), iy - Zy(2), isz.cx + Zx(4), isz.cy + Zy(4), chk ? ThinInsetBorder : ThinOutsetBorder); } } if(isenabled) DrawHighlightImage(w, x, iy, li, hl || chk, true); else w.DrawImage(x, iy, DisabledImage(li)); x = max(isz.cx, leftgap) + textgap; isz = GetTextSize(text, StdFont()); DrawMenuText(w, x, (sz.cy - isz.cy) / 2, txt, font, isenabled, hl, style->menutext, style->itemtext); isz = ricon.GetSize(); if(isenabled) w.DrawImage(sz.cx - isz.cx, (sz.cy - isz.cy) / 2, ricon, hl ? style->itemtext : style->menutext); else w.DrawImage(sz.cx - isz.cx, (sz.cy - isz.cy) / 2, DisabledImage(ricon)); x = sz.cx - max(isz.cx, Zx(16)) - Zx(1); if(!IsEmpty(keydesc)) { isz = GetTextSize(keydesc, StdFont()); UPP::DrawMenuText(w, x - isz.cx - Zx(2), (sz.cy - isz.cy) / 2, keydesc, font, isenabled, hl, 0, SColorMenuMark(), style->itemtext, false); } }
void MenuBar::PopUp(Ctrl *owner, Point p, Size rsz) { bool szcx = true; bool szcy = true; bool szx = false; bool szy = false; if(parentmenu) { if(parentmenu->IsChild()) szcx = false; else szcy = false; WhenHelp = parentmenu->WhenHelp; } Rect r = GetWorkArea(p); restorefocus = GetFocusCtrl(); LLOG("PopUp " << UPP::Name(this) << " set restorefocus:" << UPP::Name(restorefocus)); DistributeAccessKeys(); frame.Set(style->popupframe); if(GUI_GlobalStyle() >= GUISTYLE_XP) SetFrame(frame); else SetFrame(OutsetFrame()); pane.SubMenu(); Size sz = pane.Repos(false, r.Height()); pane.RightPos(0, sz.cx).BottomPos(0, sz.cy); Size sz0 = sz; sz = AddFrameSize(sz); if(p.y + sz.cy > r.bottom) { if(p.y - r.top > r.bottom - p.y) { int y0; if (parentmenu && parentmenu->GetActiveSubmenu() && parentmenu->submenuitem) y0 = parentmenu->submenuitem->GetScreenRect().BottomRight().y + 2 + rsz.cy; else y0 = p.y + rsz.cy; szy = szcy; sz = pane.Repos(false, y0 - max(y0 - sz.cy, r.top) - (sz.cy - sz0.cy)); pane.RightPos(0, sz.cx).TopPos(0, sz.cy); sz = AddFrameSize(sz); p.y = y0 - sz.cy; } else { sz = pane.Repos(false, r.bottom - p.y - (sz.cy - sz0.cy)); pane.RightPos(0, sz.cx).BottomPos(0, sz.cy); sz = AddFrameSize(sz); } } if(p.x + sz.cx > r.right) { p.x = max(p.x + rsz.cx - sz.cx, r.left); szx = szcx; pane.LeftPos(0, sz.cx); } bool eff = parentmenu == NULL || parentmenu->doeffect; if(eff && GUI_PopUpEffect() == GUIEFFECT_SLIDE) SetRect(szx ? p.x + sz.cx : p.x, szy ? p.y + sz.cy : p.y, parentmenu ? sz.cx : 1, 1); else SetRect(p.x, p.y, sz.cx, sz.cy); #ifdef PLATFORM_WIN32 DWORD dummy; CloseHandle(CreateThread(NULL, 0, PlaySoundThread, NULL, 0, &dummy)); #endif doeffect = true; Ctrl::PopUp(owner, true, true, GUI_DropShadows(), !owner); GuiPlatformAfterMenuPopUp(); if(eff) Animate(*this, p.x, p.y, sz.cx, sz.cy); }
CtrlFrame& MenuFrame() { return GUI_GlobalStyle() >= GUISTYLE_XP ? (CtrlFrame&)XPMenuFrame() : (CtrlFrame&)OutsetFrame(); }