void TWindowMenuItem::Initialize(const char* title) { if (fMini) { fBitmap = fCurrentWorkSpace ? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon) : AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon); } else { fBitmap = fCurrentWorkSpace ? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon) : AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon); } BFont font(be_plain_font); fTitleWidth = ceilf(font.StringWidth(title)); fFullTitle = title; font_height fontHeight; font.GetHeight(&fontHeight); fTitleAscent = ceilf(fontHeight.ascent); fTitleDescent = ceilf(fontHeight.descent + fontHeight.leading); }
void TWindowMenuItem::_Init(const char* name) { if (fMini) { fBitmap = fCurrentWorkSpace ? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon) : AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon); } else { fBitmap = fCurrentWorkSpace ? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon) : AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon); } BFont font(be_plain_font); fLabelWidth = ceilf(font.StringWidth(name)); font_height fontHeight; font.GetHeight(&fontHeight); fLabelAscent = ceilf(fontHeight.ascent); fLabelDescent = ceilf(fontHeight.descent + fontHeight.leading); SetLabel(name); }
void TBarMenuBar::AddTeamMenu() { if (CountItems() > 1) return; BRect frame(Frame()); delete fAppListMenuItem; fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f, AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new TTeamMenu()); AddItem(fAppListMenuItem); SmartResize(frame.Width() - 1.0f, frame.Height()); }
TBarMenuBar::TBarMenuBar(TBarView* bar, BRect frame, const char* name) : BMenuBar(frame, name, B_FOLLOW_NONE, B_ITEMS_IN_ROW, false), fBarView(bar), fAppListMenuItem(NULL) { SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); TDeskbarMenu* beMenu = new TDeskbarMenu(bar); TBarWindow::SetDeskbarMenu(beMenu); fDeskbarMenuItem = new TBarMenuTitle(frame.Width(), frame.Height(), AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap), beMenu); AddItem(fDeskbarMenuItem); }
bool TBarMenuBar::AddTeamMenu() { if (CountItems() > 1) return false; BRect frame(Frame()); delete fAppListMenuItem; fAppListMenuItem = new TBarMenuTitle(0.0f, 0.0f, AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_TeamIcon), new TTeamMenu()); bool added = AddItem(fAppListMenuItem); if (added) SmartResize(frame.Width() - 1.0f, frame.Height()); else SmartResize(frame.Width(), frame.Height()); return added; }
TExpandoMenuBar::TExpandoMenuBar(TBarView* barView, bool vertical) : BMenuBar(BRect(0, 0, 0, 0), "ExpandoMenuBar", B_FOLLOW_NONE, vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW), fBarView(barView), fVertical(vertical), fOverflow(false), fFirstBuild(true), fDeskbarMenuWidth(kMinMenuItemWidth), fPreviousDragTargetItem(NULL), fLastMousedOverItem(NULL), fLastClickedItem(NULL) { SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f); SetFont(be_plain_font); SetMaxItemWidth(); // top or bottom mode, add deskbar menu and sep for menubar tracking // consistency const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap); if (logoBitmap != NULL) fDeskbarMenuWidth = logoBitmap->Bounds().Width() + 16; }
void TExpandoMenuBar::AttachedToWindow() { BMessenger self(this); BList teamList; TBarApp::Subscribe(self, &teamList); float width = fVertical ? Frame().Width() : kMinimumWindowWidth; float height = -1.0f; // top or bottom mode, add be menu and sep for menubar tracking consistency if (!fVertical) { TBeMenu *beMenu = new TBeMenu(fBarView); TBarWindow::SetBeMenu(beMenu); fBeMenuItem = new TBarMenuTitle(kBeMenuWidth, Frame().Height(), AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu, true); AddItem(fBeMenuItem); fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical); AddItem(fSeparatorItem); fSeparatorItem->SetEnabled(false); fFirstApp = 2; } else { fBeMenuItem = NULL; fSeparatorItem = NULL; } desk_settings *settings = ((TBarApp *)be_app)->Settings(); if (settings->sortRunningApps) teamList.SortItems(CompareByName); int32 count = teamList.CountItems(); for (int32 i = 0; i < count; i++) { BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i); if ((barInfo->flags & B_BACKGROUND_APP) == 0 && strcasecmp(barInfo->sig, TASK_BAR_MIME_SIG) != 0) { if ((settings->trackerAlwaysFirst) && (strcmp(barInfo->sig, kTrackerSignature)) == 0) { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical), fFirstApp); } else { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical)); } barInfo->teams = NULL; barInfo->icon = NULL; barInfo->name = NULL; barInfo->sig = NULL; } delete barInfo; } BMenuBar::AttachedToWindow(); if (fVertical) { sDoMonitor = true; sMonThread = spawn_thread(monitor_team_windows, "Expando Window Watcher", B_LOW_PRIORITY, this); resume_thread(sMonThread); } }
void TExpandoMenuBar::AttachedToWindow() { BMessenger self(this); BList teamList; TBarApp::Subscribe(self, &teamList); float width = fVertical ? Frame().Width() : sMinimumWindowWidth; float height = -1.0f; // top or bottom mode, add deskbar menu and sep for menubar tracking // consistency if (!fVertical) { TDeskbarMenu* beMenu = new TDeskbarMenu(fBarView); TBarWindow::SetDeskbarMenu(beMenu); const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap); if (logoBitmap != NULL) fDeskbarMenuWidth = logoBitmap->Bounds().Width() + 16; fDeskbarMenuItem = new TBarMenuTitle(fDeskbarMenuWidth, Frame().Height(), logoBitmap, beMenu, true); AddItem(fDeskbarMenuItem); fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical); AddItem(fSeparatorItem); fSeparatorItem->SetEnabled(false); fFirstApp = 2; } else { fDeskbarMenuItem = NULL; fSeparatorItem = NULL; } desk_settings* settings = ((TBarApp*)be_app)->Settings(); if (settings->sortRunningApps) teamList.SortItems(CompareByName); int32 count = teamList.CountItems(); for (int32 i = 0; i < count; i++) { BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i); if ((barInfo->flags & B_BACKGROUND_APP) == 0 && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) { if (settings->trackerAlwaysFirst && !strcmp(barInfo->sig, kTrackerSignature)) { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical), fFirstApp); } else { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical)); } barInfo->teams = NULL; barInfo->icon = NULL; barInfo->name = NULL; barInfo->sig = NULL; } delete barInfo; } BMenuBar::AttachedToWindow(); if (CountItems() == 0) { // If we're empty, BMenuBar::AttachedToWindow() resizes us to some // weird value - we just override it again ResizeTo(width, 0); } if (fVertical) { sDoMonitor = true; sMonThread = spawn_thread(monitor_team_windows, "Expando Window Watcher", B_LOW_PRIORITY, this); resume_thread(sMonThread); } }