本文整理汇总了C++中BMenu::SetLowColor方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::SetLowColor方法的具体用法?C++ BMenu::SetLowColor怎么用?C++ BMenu::SetLowColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenu
的用法示例。
在下文中一共展示了BMenu::SetLowColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Menu
void
TTeamMenuItem::DrawContentLabel()
{
BMenu* menu = Menu();
menu->MovePenBy(0, fLabelAscent);
float cachedWidth = menu->StringWidth(Label());
if (Submenu() && fVertical)
cachedWidth += 18;
const char* label = Label();
char* truncLabel = NULL;
float max = 0;
if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando)
max = menu->MaxContentWidth() - kSwitchWidth;
else
max = menu->MaxContentWidth() - 4.0f;
if (max > 0) {
BPoint penloc = menu->PenLocation();
BRect frame = Frame();
float offset = penloc.x - frame.left;
if (cachedWidth + offset > max) {
truncLabel = (char*)malloc(strlen(label) + 4);
if (!truncLabel)
return;
TruncateLabel(max-offset, truncLabel);
label = truncLabel;
}
}
if (!label)
label = Label();
TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
bool canHandle = !barview->Dragging()
|| barview->AppCanHandleTypes(Signature());
if (_IsSelected() && IsEnabled() && canHandle)
menu->SetLowColor(tint_color(menu->LowColor(),
B_HIGHLIGHT_BACKGROUND_TINT));
else
menu->SetLowColor(menu->LowColor());
menu->DrawString(label);
free(truncLabel);
}
示例2: frame
void
TWindowMenuItem::Draw()
{
if (!fExpanded) {
BMenuItem::Draw();
return;
}
// TODO: Tint this smartly based on the low color, this does
// nothing to black.
rgb_color menuColor = tint_color(Menu()->LowColor(), 1.07);
BRect frame(Frame());
BMenu* menu = Menu();
menu->PushState();
// if not selected or being tracked on, fill with gray
TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
if ((!IsSelected() && !menu->IsRedrawAfterSticky())
|| barview->Dragging() || !IsEnabled()) {
rgb_color shadow = tint_color(menuColor, 1.09);
menu->SetHighColor(shadow);
frame.right = frame.left + kHPad / 2;
menu->FillRect(frame);
menu->SetHighColor(menuColor);
frame.left = frame.right + 1;
frame.right = Frame().right;
menu->FillRect(frame);
}
if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky()) {
// fill
rgb_color backColor = tint_color(menuColor,
B_HIGHLIGHT_BACKGROUND_TINT);
menu->SetLowColor(backColor);
menu->SetHighColor(backColor);
menu->FillRect(frame);
} else {
menu->SetLowColor(menuColor);
menu->SetHighColor(menuColor);
}
DrawContent();
menu->PopState();
}
示例3: copy_attrs
void ArpMenuField::copy_attrs(BMenu* menu)
{
if( !menu ) return;
int32 num = menu->CountItems();
for( int32 i=0; i<num; i++ ) {
BMenu* child = menu->SubmenuAt(i);
if( child ) {
copy_attrs(child);
// the menu doesn't seem to see this.
child->SetFont(&PV_MenuFont);
child->SetHighColor(PV_MenuForeColor);
child->SetLowColor(PV_MenuBackColor);
child->SetViewColor(PV_MenuBackColor);
child->InvalidateLayout();
}
}
}
示例4: frame
void
TTeamMenuItem::Draw()
{
BRect frame(Frame());
BMenu* menu = Menu();
menu->PushState();
rgb_color menuColor = menu->LowColor();
TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView();
bool canHandle = !barView->Dragging()
|| barView->AppCanHandleTypes(Signature());
if (be_control_look != NULL) {
uint32 flags = 0;
if (_IsSelected() && canHandle)
flags |= BControlLook::B_ACTIVATED;
uint32 borders = BControlLook::B_TOP_BORDER;
if (fVertical) {
menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT));
borders |= BControlLook::B_LEFT_BORDER
| BControlLook::B_RIGHT_BORDER;
menu->StrokeLine(frame.LeftBottom(), frame.RightBottom());
frame.bottom--;
be_control_look->DrawMenuBarBackground(menu, frame, frame,
menuColor, flags, borders);
} else {
if (flags & BControlLook::B_ACTIVATED)
menu->SetHighColor(tint_color(menuColor, B_DARKEN_3_TINT));
else
menu->SetHighColor(tint_color(menuColor, 1.22));
borders |= BControlLook::B_BOTTOM_BORDER;
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
frame.left++;
be_control_look->DrawButtonBackground(menu, frame, frame,
menuColor, flags, borders);
}
menu->MovePenTo(ContentLocation());
DrawContent();
menu->PopState();
return;
}
// if not selected or being tracked on, fill with gray
if ((!_IsSelected() && !menu->IsRedrawAfterSticky()) || !canHandle
|| !IsEnabled()) {
frame.InsetBy(1, 1);
menu->SetHighColor(menuColor);
menu->FillRect(frame);
}
// draw the gray, unselected item, border
if (!_IsSelected() || !IsEnabled()) {
rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);
frame = Frame();
menu->SetHighColor(shadow);
if (fVertical)
menu->StrokeLine(frame.LeftBottom(), frame.RightBottom());
else
menu->StrokeLine(frame.LeftBottom() + BPoint(1, 0),
frame.RightBottom());
menu->StrokeLine(frame.RightBottom(), frame.RightTop());
menu->SetHighColor(light);
menu->StrokeLine(frame.RightTop() + BPoint(-1, 0), frame.LeftTop());
if (fVertical)
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()
+ BPoint(0, -1));
else
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
}
// if selected or being tracked on, fill with the hilite gray color
if (IsEnabled() && _IsSelected() && !menu->IsRedrawAfterSticky()
&& canHandle) {
// fill
menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT));
menu->FillRect(frame);
// these continue the dark grey border on the left or top edge
menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT));
if (fVertical) {
// dark line at top
menu->StrokeLine(frame.LeftTop(), frame.RightTop());
} else {
// dark line on the left
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
}
} else
menu->SetLowColor(menuColor);
menu->MovePenTo(ContentLocation());
DrawContent();
//.........这里部分代码省略.........
示例5: rect
void
MemoryBarMenuItem::DrawBar(bool force)
{
// only draw anything if something has changed
if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll
&& fCommittedMemory == fLastCommitted)
return;
bool selected = IsSelected();
BRect frame = Frame();
BMenu* menu = Menu();
// draw the bar itself
BRect rect(frame.right - kMargin - kBarWidth, frame.top + 5,
frame.right - kMargin, frame.top + 13);
if (fWriteMemory < 0)
return;
if (fGrenze1 < 0)
force = true;
if (force) {
if (selected)
menu->SetHighColor(gFrameColorSelected);
else
menu->SetHighColor(gFrameColor);
menu->StrokeRect(rect);
}
rect.InsetBy(1, 1);
BRect r = rect;
double grenze1 = rect.left + (rect.right - rect.left) * float(fWriteMemory)
/ fCommittedMemory;
double grenze2 = rect.left + (rect.right - rect.left) * float(fAllMemory)
/ fCommittedMemory;
if (grenze1 > rect.right)
grenze1 = rect.right;
if (grenze2 > rect.right)
grenze2 = rect.right;
r.right = grenze1;
if (!force)
r.left = fGrenze1;
if (r.left < r.right) {
if (selected)
menu->SetHighColor(gKernelColorSelected);
else
menu->SetHighColor(gKernelColor);
menu->FillRect(r);
}
r.left = grenze1;
r.right = grenze2;
if (!force) {
if (fGrenze2 > r.left && r.left >= fGrenze1)
r.left = fGrenze2;
if (fGrenze1 < r.right && r.right <= fGrenze2)
r.right = fGrenze1;
}
if (r.left < r.right) {
if (selected)
menu->SetHighColor(gUserColorSelected);
else
menu->SetHighColor(gUserColor);
menu->FillRect(r);
}
r.left = grenze2;
r.right = rect.right;
if (!force)
r.right = fGrenze2;
if (r.left < r.right) {
if (selected)
menu->SetHighColor(gWhiteSelected);
else
menu->SetHighColor(kWhite);
menu->FillRect(r);
}
menu->SetHighColor(kBlack);
fGrenze1 = grenze1;
fGrenze2 = grenze2;
fLastCommitted = fCommittedMemory;
// Draw the values if necessary; if only fCommitedMemory changes, only
// the bar might have to be updated
if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll)
return;
if (selected)
menu->SetLowColor(gMenuBackColorSelected);
else
menu->SetLowColor(gMenuBackColor);
//.........这里部分代码省略.........
示例6: cadre
void
KernelMemoryBarMenuItem::DrawBar(bool force)
{
bool selected = IsSelected();
BRect frame = Frame();
BMenu* menu = Menu();
// draw the bar itself
BRect cadre (frame.right - kMargin - kBarWidth, frame.top + 5,
frame.right - kMargin, frame.top + 13);
if (fLastSum < 0)
force = true;
if (force) {
if (selected)
menu->SetHighColor(gFrameColorSelected);
else
menu->SetHighColor(gFrameColor);
menu->StrokeRect (cadre);
}
cadre.InsetBy(1, 1);
BRect r = cadre;
float grenze1 = cadre.left + (cadre.right - cadre.left)
* fCachedMemory / fPhysicalMemory;
float grenze2 = cadre.left + (cadre.right - cadre.left)
* fCommittedMemory / fPhysicalMemory;
if (grenze1 > cadre.right)
grenze1 = cadre.right;
if (grenze2 > cadre.right)
grenze2 = cadre.right;
r.right = grenze1;
if (!force)
r.left = fGrenze1;
if (r.left < r.right) {
if (selected)
menu->SetHighColor(gKernelColorSelected);
else
menu->SetHighColor(gKernelColor);
// menu->SetHighColor(gKernelColor);
menu->FillRect (r);
}
r.left = grenze1;
r.right = grenze2;
if (!force) {
if (fGrenze2 > r.left && r.left >= fGrenze1)
r.left = fGrenze2;
if (fGrenze1 < r.right && r.right <= fGrenze2)
r.right = fGrenze1;
}
if (r.left < r.right) {
if (selected)
menu->SetHighColor(tint_color (kLavender, B_HIGHLIGHT_BACKGROUND_TINT));
else
menu->SetHighColor(kLavender);
// menu->SetHighColor(gUserColor);
menu->FillRect (r);
}
r.left = grenze2;
r.right = cadre.right;
if (!force)
r.right = fGrenze2;
if (r.left < r.right) {
if (selected)
menu->SetHighColor(gWhiteSelected);
else
menu->SetHighColor(kWhite);
menu->FillRect(r);
}
menu->SetHighColor(kBlack);
fGrenze1 = grenze1;
fGrenze2 = grenze2;
// draw the value
double sum = fCachedMemory * FLT_MAX + fCommittedMemory;
if (force || sum != fLastSum) {
if (selected) {
menu->SetLowColor(gMenuBackColorSelected);
menu->SetHighColor(gMenuBackColorSelected);
} else {
menu->SetLowColor(gMenuBackColor);
menu->SetHighColor(gMenuBackColor);
}
BRect trect(cadre.left - kMargin - gMemoryTextWidth, frame.top,
cadre.left - kMargin, frame.bottom);
menu->FillRect(trect);
menu->SetHighColor(kBlack);
char infos[128];
string_for_size(fCachedMemory * 1024.0, infos, sizeof(infos));
BPoint loc(cadre.left, cadre.bottom + 1);
loc.x -= kMargin + gMemoryTextWidth / 2 + menu->StringWidth(infos);
menu->DrawString(infos, loc);
string_for_size(fCommittedMemory * 1024.0, infos, sizeof(infos));
loc.x = cadre.left - kMargin - menu->StringWidth(infos);
menu->DrawString(infos, loc);
fLastSum = sum;
}
}