* Moved the window item sort logic as static method into the TWindowMenuItem
class. * Changed ExpandoMenuBar to use that logic as well, so that your entries will always keep the same sort order. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33704 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -739,10 +739,9 @@ TExpandoMenuBar::DrawBackground(BRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Something to help determine if we are showing too many apps
|
/*! Something to help determine if we are showing too many apps
|
||||||
* need to add in scrolling functionality.
|
need to add in scrolling functionality.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
TExpandoMenuBar::CheckForSizeOverrun()
|
TExpandoMenuBar::CheckForSizeOverrun()
|
||||||
{
|
{
|
||||||
@@ -833,7 +832,9 @@ TExpandoMenuBar::monitor_team_windows(void* arg)
|
|||||||
((1 << current_workspace())
|
((1 << current_workspace())
|
||||||
& wInfo->workspaces) != 0, false);
|
& wInfo->workspaces) != 0, false);
|
||||||
item->ExpandedItem(true);
|
item->ExpandedItem(true);
|
||||||
teamMenu->AddItem(item, i + 1);
|
teamMenu->AddItem(item,
|
||||||
|
TWindowMenuItem::InsertIndexFor(
|
||||||
|
teamMenu, i + 1, item));
|
||||||
resize = true;
|
resize = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ TWindowMenu::AttachedToWindow()
|
|||||||
if (dragging)
|
if (dragging)
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
|
|
||||||
AddItem(item, addIndex);
|
AddItem(item,
|
||||||
|
TWindowMenuItem::InsertIndexFor(this, 0, item));
|
||||||
} else {
|
} else {
|
||||||
TTeamMenuItem* parentItem
|
TTeamMenuItem* parentItem
|
||||||
= static_cast<TTeamMenuItem*>(Superitem());
|
= static_cast<TTeamMenuItem*>(Superitem());
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f);
|
|||||||
|
|
||||||
TWindowMenuItem::TWindowMenuItem(const char* title, int32 id, bool mini,
|
TWindowMenuItem::TWindowMenuItem(const char* title, int32 id, bool mini,
|
||||||
bool currentWorkspace, bool dragging)
|
bool currentWorkspace, bool dragging)
|
||||||
: BMenuItem(title, NULL),
|
:
|
||||||
|
BMenuItem(title, NULL),
|
||||||
fID(id),
|
fID(id),
|
||||||
fMini(mini),
|
fMini(mini),
|
||||||
fCurrentWorkSpace(currentWorkspace),
|
fCurrentWorkSpace(currentWorkspace),
|
||||||
@@ -85,6 +86,7 @@ TWindowMenuItem::Initialize(const char* title)
|
|||||||
|
|
||||||
BFont font(be_plain_font);
|
BFont font(be_plain_font);
|
||||||
fTitleWidth = ceilf(font.StringWidth(title));
|
fTitleWidth = ceilf(font.StringWidth(title));
|
||||||
|
fFullTitle = title;
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
font.GetHeight(&fontHeight);
|
font.GetHeight(&fontHeight);
|
||||||
fTitleAscent = ceilf(fontHeight.ascent);
|
fTitleAscent = ceilf(fontHeight.ascent);
|
||||||
@@ -134,6 +136,27 @@ TWindowMenuItem::SetLabel(const char* string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
TWindowMenuItem::FullTitle() const
|
||||||
|
{
|
||||||
|
return fFullTitle.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/ int32
|
||||||
|
TWindowMenuItem::InsertIndexFor(BMenu* menu, int32 startIndex,
|
||||||
|
TWindowMenuItem* newItem)
|
||||||
|
{
|
||||||
|
for (int32 index = startIndex;; index++) {
|
||||||
|
TWindowMenuItem* item
|
||||||
|
= dynamic_cast<TWindowMenuItem*>(menu->ItemAt(index));
|
||||||
|
if (item == NULL
|
||||||
|
|| strcasecmp(item->FullTitle(), newItem->FullTitle()) > 0)
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
TWindowMenuItem::ID()
|
TWindowMenuItem::ID()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,14 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
|
|||||||
names are registered trademarks or trademarks of their respective holders.
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// individual windows of an application
|
|
||||||
// item for WindowMenu, sub of TeamMenuItem
|
|
||||||
// all DB positions
|
|
||||||
|
|
||||||
#ifndef WINDOWMENUITEM_H
|
#ifndef WINDOWMENUITEM_H
|
||||||
#define WINDOWMENUITEM_H
|
#define WINDOWMENUITEM_H
|
||||||
|
|
||||||
|
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <WindowInfo.h>
|
#include <WindowInfo.h>
|
||||||
@@ -47,43 +43,51 @@ All rights reserved.
|
|||||||
class BBitmap;
|
class BBitmap;
|
||||||
|
|
||||||
|
|
||||||
|
/*! Individual windows of an application item for WindowMenu,
|
||||||
|
sub of TeamMenuItem all DB positions
|
||||||
|
*/
|
||||||
class TWindowMenuItem : public BMenuItem {
|
class TWindowMenuItem : public BMenuItem {
|
||||||
public:
|
public:
|
||||||
TWindowMenuItem(const char* title, int32 id, bool mini,
|
TWindowMenuItem(const char* title, int32 id,
|
||||||
bool currentWorkSpace, bool dragging = false);
|
bool mini, bool currentWorkSpace,
|
||||||
|
bool dragging = false);
|
||||||
|
|
||||||
void ExpandedItem(bool state);
|
void ExpandedItem(bool state);
|
||||||
void SetTo(const char* title, int32 id, bool mini,
|
void SetTo(const char* title, int32 id, bool mini,
|
||||||
bool currentWorkSpace, bool dragging = false);
|
bool currentWorkSpace,
|
||||||
int32 ID();
|
bool dragging = false);
|
||||||
void SetRequireUpdate();
|
int32 ID();
|
||||||
bool RequiresUpdate();
|
void SetRequireUpdate();
|
||||||
bool ChangedState();
|
bool RequiresUpdate();
|
||||||
|
bool ChangedState();
|
||||||
|
|
||||||
virtual void SetLabel(const char* string);
|
virtual void SetLabel(const char* string);
|
||||||
|
const char* FullTitle() const;
|
||||||
|
|
||||||
protected:
|
static int32 InsertIndexFor(BMenu* menu, int32 startIndex,
|
||||||
void Initialize(const char* title);
|
TWindowMenuItem* item);
|
||||||
virtual void GetContentSize(float* width, float* height);
|
|
||||||
virtual void DrawContent();
|
|
||||||
virtual status_t Invoke(BMessage* message = NULL);
|
|
||||||
virtual void Draw();
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
int32 fID;
|
void Initialize(const char* title);
|
||||||
bool fMini;
|
virtual void GetContentSize(float* width, float* height);
|
||||||
bool fCurrentWorkSpace;
|
virtual void DrawContent();
|
||||||
const BBitmap* fBitmap;
|
virtual status_t Invoke(BMessage* message = NULL);
|
||||||
float fTitleWidth;
|
virtual void Draw();
|
||||||
float fTitleAscent;
|
|
||||||
float fTitleDescent;
|
private:
|
||||||
bool fDragging;
|
int32 fID;
|
||||||
bool fExpanded;
|
bool fMini;
|
||||||
bool fRequireUpdate;
|
bool fCurrentWorkSpace;
|
||||||
bool fModified;
|
const BBitmap* fBitmap;
|
||||||
BString fFullTitle;
|
float fTitleWidth;
|
||||||
|
float fTitleAscent;
|
||||||
|
float fTitleDescent;
|
||||||
|
bool fDragging;
|
||||||
|
bool fExpanded;
|
||||||
|
bool fRequireUpdate;
|
||||||
|
bool fModified;
|
||||||
|
BString fFullTitle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* WINDOWMENUITEM_H */
|
#endif /* WINDOWMENUITEM_H */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user