Final set of style cleanup patches by John Scipione as part of #7052.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40849 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Fredrik Holmqvist 2011-03-06 16:57:59 +00:00
parent 044f12ae62
commit 1687edd0fd
12 changed files with 237 additions and 210 deletions

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -99,11 +100,11 @@ public:
TSwitchManager* manager);
virtual ~TSwitcherWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
virtual void Show();
virtual void Hide();
virtual void WindowActivated(bool state);
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
virtual void Show();
virtual void Hide();
virtual void WindowActivated(bool state);
void DoKey(uint32 key, uint32 modifiers);
TIconView* IconView();
@ -133,12 +134,14 @@ public:
void UpdateGroup(int32 groupIndex, int32 windowIndex);
virtual void AttachedToWindow();
virtual void Draw(BRect update);
virtual void Pulse();
virtual void GetPreferredSize(float* w, float* h);
virtual void Draw(BRect update);
virtual void Pulse();
virtual void GetPreferredSize(float* w, float* h);
void ScrollTo(float x, float y)
{ ScrollTo(BPoint(x,y)); }
virtual void ScrollTo(BPoint where);
{
ScrollTo(BPoint(x, y));
}
virtual void ScrollTo(BPoint where);
void ShowIndex(int32 windex);
BRect FrameOf(int32 index) const;
@ -160,13 +163,15 @@ public:
void Hiding();
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void Pulse();
virtual void MouseDown(BPoint point);
virtual void Draw(BRect updateRect);
virtual void Pulse();
virtual void MouseDown(BPoint point);
virtual void Draw(BRect updateRect);
void ScrollTo(float x, float y)
{ ScrollTo(BPoint(x,y)); }
virtual void ScrollTo(BPoint where);
{
ScrollTo(BPoint(x, y));
}
virtual void ScrollTo(BPoint where);
void Update(int32 previous, int32 current,
int32 previousSlot, int32 currentSlot,
bool forward);
@ -197,9 +202,9 @@ public:
virtual void Draw(BRect update);
virtual void AllAttached();
virtual void DrawIconScrollers(bool force);
virtual void DrawWindowScrollers(bool force);
virtual void MouseDown(BPoint where);
virtual void DrawIconScrollers(bool force);
virtual void DrawWindowScrollers(bool force);
virtual void MouseDown(BPoint where);
private:
TSwitchManager* fManager;
@ -250,16 +255,12 @@ LowBitIndex(uint32 value)
inline bool
IsVisibleInCurrentWorkspace(const window_info* windowInfo)
{
/*
The window list is always ordered from the top
front visible window (the first on the list), going down through all
the other visible windows, then all the hidden or non workspace
visible window at the end.
layer > 2 : normal visible window.
layer == 2 : reserved for the desktop window (visible also).
layer < 2 : hidden (0) and non workspace visible window (1)
*/
// The window list is always ordered from the top front visible window
// (the first on the list), going down through all the other visible
// windows, then all hidden or non-workspace visible windows at the end.
// layer > 2 : normal visible window
// layer == 2 : reserved for the desktop window (visible also)
// layer < 2 : hidden (0) and non workspace visible window (1)
return windowInfo->layer > 2;
}
@ -278,13 +279,11 @@ bool
IsWindowOK(const window_info* windowInfo)
{
// is_mini (true means that the window is minimized).
// if not, then
// show_hide >= 1 means that the window is hidden.
//
// if not, then show_hide >= 1 means that the window is hidden.
// If the window is both minimized and hidden, then you get :
// TWindow->is_mini = false;
// TWindow->was_mini = true;
// TWindow->show_hide >= 1;
// TWindow->is_mini = false;
// TWindow->was_mini = true;
// TWindow->show_hide >= 1;
if (windowInfo->feel != _STD_W_TYPE_)
return false;
@ -330,14 +329,16 @@ SmartStrcmp(const char* s1, const char* s2)
s2++;
continue;
}
if (*s1 != *s2)
return 1; // they differ
if (*s1 != *s2) {
// they differ
return 1;
}
s1++;
s2++;
}
// if one of the strings ended before the other
// ??? could process trailing spaces & underscores!
// TODO: could process trailing spaces and underscores
if (*s1)
return 1;
if (*s2)
@ -446,7 +447,7 @@ TSwitchManager::TSwitchManager(BPoint point)
TBarApp::Subscribe(BMessenger(this), &tmpList);
for (int32 i = 0; ; i++) {
BarTeamInfo *barTeamInfo = (BarTeamInfo *)tmpList.ItemAt(i);
BarTeamInfo* barTeamInfo = (BarTeamInfo*)tmpList.ItemAt(i);
if (!barTeamInfo)
break;
@ -483,6 +484,7 @@ TSwitchManager::MessageReceived(BMessage* message)
int i = 0;
TTeamGroup* tinfo;
message->FindInt32("team", &teamID);
while ((tinfo = (TTeamGroup*)fGroupList.ItemAt(i)) != NULL) {
if (tinfo->TeamList()->HasItem((void*)teamID)) {
fGroupList.RemoveItem(i);
@ -517,15 +519,19 @@ TSwitchManager::MessageReceived(BMessage* message)
delete teams;
break;
}
delete smallIcon;
if (message->FindString("sig", &signature) != B_OK) {
delete teams;
break;
}
if (message->FindInt32("flags", (int32*)&flags) != B_OK) {
delete teams;
break;
}
if (message->FindString("name", &name) != B_OK) {
delete teams;
break;
@ -546,8 +552,7 @@ TSwitchManager::MessageReceived(BMessage* message)
const char* signature = message->FindString("sig");
team_id team = message->FindInt32("team");
int32 numItems = fGroupList.CountItems();
for (int32 i = 0; i < numItems; i++) {
for (int32 i = 0; i < fGroupList.CountItems(); i++) {
TTeamGroup* tinfo = (TTeamGroup*)fGroupList.ItemAt(i);
if (strcasecmp(tinfo->Signature(), signature) == 0) {
if (!(tinfo->TeamList()->HasItem((void*)team)))
@ -562,8 +567,7 @@ TSwitchManager::MessageReceived(BMessage* message)
{
team_id team = message->FindInt32("team");
int32 numItems = fGroupList.CountItems();
for (int32 i = 0; i < numItems; i++) {
for (int32 i = 0; i < fGroupList.CountItems(); i++) {
TTeamGroup* tinfo = (TTeamGroup*)fGroupList.ItemAt(i);
if (tinfo->TeamList()->HasItem((void*)team)) {
tinfo->TeamList()->RemoveItem((void*)team);
@ -584,7 +588,6 @@ TSwitchManager::MessageReceived(BMessage* message)
// starts differentiating initial key_downs from KeyDowns generated
// by auto-repeat. Until then the fSkipUntil stuff helps, but it
// isn't perfect.
if (time < fSkipUntil)
break;
@ -620,7 +623,7 @@ TSwitchManager::_SortApps()
team_id* teams;
int32 count;
if (BPrivate::get_application_order(current_workspace(), &teams, &count)
!= B_OK)
!= B_OK)
return;
BList groups;
@ -656,8 +659,7 @@ TSwitchManager::MainEntry(BMessage* message)
{
bigtime_t now = system_time();
bigtime_t timeout = now + 180000;
// The delay above was arrived at by trial and error and
// has a good "feel"
// The above delay has a good "feel" found by trial and error
app_info appInfo;
be_roster->GetActiveAppInfo(&appInfo);
@ -885,6 +887,7 @@ TSwitchManager::_FindNextValidApp(bool forward)
if (fCurrentIndex < 0)
fCurrentIndex = max - 1;
}
if (fCurrentIndex == startIndex) {
// we've gone completely through the list without finding
// a good app. Oh well.
@ -898,6 +901,7 @@ TSwitchManager::_FindNextValidApp(bool forward)
return false;
}
void
TSwitchManager::SwitchToApp(int32 previousIndex, int32 newIndex, bool forward)
{
@ -930,6 +934,7 @@ TSwitchManager::ActivateApp(bool forceShow, bool allowWorkspaceSwitch)
int32 currentWorkspace = current_workspace();
TTeamGroup* teamGroup = (TTeamGroup*)fGroupList.ItemAt(fCurrentIndex);
// Let's handle the easy case first: There's only 1 team in the group
if (teamGroup->TeamList()->CountItems() == 1) {
bool result;
@ -988,7 +993,8 @@ TSwitchManager::ActivateApp(bool forceShow, bool allowWorkspaceSwitch)
if (tokens == NULL) {
ASSERT(windowInfo);
free(windowInfo);
return true; // weird error, so don't try to recover
return true;
// weird error, so don't try to recover
}
BList windowsToActivate;
@ -1040,6 +1046,7 @@ TSwitchManager::QuitApp()
TTeamGroup* teamGroup;
int32 count = 0;
for (int32 i = fCurrentIndex + 1; i < fGroupList.CountItems(); i++) {
teamGroup = (TTeamGroup*)fGroupList.ItemAt(i);
@ -1296,7 +1303,7 @@ TBox::MouseDown(BPoint where)
if (fLeftScroller) {
BRect lhit(0, frame.top, frame.left, frame.bottom);
if (lhit.Contains(where)) {
// Want to scroll by NUMSLOTS-1 slots
// Want to scroll by NUMSLOTS - 1 slots
int32 previousIndex = fManager->CurrentIndex();
int32 previousSlot = fManager->CurrentSlot();
int32 newSlot = previousSlot - (kNumSlots - 1);
@ -1311,16 +1318,16 @@ TBox::MouseDown(BPoint where)
if (fRightScroller) {
BRect rhit(frame.right, frame.top, bounds.right, frame.bottom);
if (rhit.Contains(where)) {
// Want to scroll by NUMSLOTS-1 slots
// Want to scroll by NUMSLOTS - 1 slots
int32 previousIndex = fManager->CurrentIndex();
int32 previousSlot = fManager->CurrentSlot();
int32 newSlot = previousSlot + (kNumSlots-1);
int32 newSlot = previousSlot + (kNumSlots - 1);
int32 newIndex = fIconView->IndexAt(newSlot);
if (newIndex < 0) {
// don't have a page full to scroll
int32 valid = fManager->CountVisibleGroups();
newIndex = fIconView->IndexAt(valid-1);
newIndex = fIconView->IndexAt(valid - 1);
}
fManager->SwitchToApp(previousIndex, newIndex, true);
}
@ -1329,9 +1336,9 @@ TBox::MouseDown(BPoint where)
frame = fWindow->WindowView()->Frame();
if (fUpScroller) {
BRect hit1(frame.left - 10, frame.top, frame.left,
(frame.top+frame.bottom)/2);
(frame.top + frame.bottom) / 2);
BRect hit2(frame.right, frame.top, frame.right + 10,
(frame.top+frame.bottom)/2);
(frame.top + frame.bottom) / 2);
if (hit1.Contains(where) || hit2.Contains(where)) {
// Want to scroll up 1 window
fManager->CycleWindow(false, false);
@ -1339,10 +1346,10 @@ TBox::MouseDown(BPoint where)
}
if (fDownScroller) {
BRect hit1(frame.left - 10, (frame.top+frame.bottom) / 2, frame.left,
frame.bottom);
BRect hit2(frame.right, (frame.top+frame.bottom) / 2, frame.right + 10,
frame.bottom);
BRect hit1(frame.left - 10, (frame.top + frame.bottom) / 2,
frame.left, frame.bottom);
BRect hit2(frame.right, (frame.top + frame.bottom) / 2,
frame.right + 10, frame.bottom);
if (hit1.Contains(where) || hit2.Contains(where)) {
// Want to scroll down 1 window
fManager->CycleWindow(true, false);
@ -1374,40 +1381,42 @@ TBox::Draw(BRect update)
// Fill the area with dark gray
SetHighColor(darkGray);
box.InsetBy(1,1);
box.InsetBy(1, 1);
FillRect(box);
box.InsetBy(-1,-1);
box.InsetBy(-1, -1);
BeginLineArray(50);
// The main frame around the icon view
AddLine(box.LeftTop(), BPoint(center-kWedge, box.top), veryDarkGray);
AddLine(BPoint(center+kWedge, box.top), box.RightTop(), veryDarkGray);
AddLine(box.LeftTop(), BPoint(center - kWedge, box.top), veryDarkGray);
AddLine(BPoint(center + kWedge, box.top), box.RightTop(), veryDarkGray);
AddLine(box.LeftBottom(), BPoint(center-kWedge, box.bottom), veryDarkGray);
AddLine(BPoint(center+kWedge, box.bottom), box.RightBottom(), veryDarkGray);
AddLine(box.LeftBottom(), BPoint(center - kWedge, box.bottom),
veryDarkGray);
AddLine(BPoint(center + kWedge, box.bottom), box.RightBottom(),
veryDarkGray);
AddLine(box.LeftBottom() + BPoint(1, 1),
BPoint(center-kWedge, box.bottom + 1), white);
AddLine(BPoint(center+kWedge, box.bottom) + BPoint(0, 1),
BPoint(center - kWedge, box.bottom + 1), white);
AddLine(BPoint(center + kWedge, box.bottom) + BPoint(0, 1),
box.RightBottom() + BPoint(1, 1), white);
AddLine(box.LeftTop(), box.LeftBottom(), veryDarkGray);
AddLine(box.RightTop(), box.RightBottom(), veryDarkGray);
AddLine(box.RightTop() + BPoint(1, 1),
box.RightBottom() + BPoint(1, 1), white);
AddLine(box.RightTop() + BPoint(1, 1), box.RightBottom() + BPoint(1, 1),
white);
// downward pointing area at top of frame
BPoint point(center - kWedge, box.top);
AddLine(point, point + BPoint(kWedge, kWedge), veryDarkGray);
AddLine(point + BPoint(kWedge, kWedge),
BPoint(center+kWedge, point.y), veryDarkGray);
AddLine(point + BPoint(kWedge, kWedge), BPoint(center + kWedge, point.y),
veryDarkGray);
AddLine(point + BPoint(1, 0),
point + BPoint(1, 0) + BPoint(kWedge - 1, kWedge - 1), white);
AddLine(point + BPoint(1, 0), point + BPoint(1, 0)
+ BPoint(kWedge - 1, kWedge - 1), white);
AddLine(point + BPoint(2, -1) + BPoint(kWedge - 1, kWedge - 1),
BPoint(center+kWedge-1, point.y), darkGray);
BPoint(center + kWedge - 1, point.y), darkGray);
BPoint topPoint = point;
@ -1416,7 +1425,7 @@ TBox::Draw(BRect update)
point.x = center - kWedge;
AddLine(point, point + BPoint(kWedge, -kWedge), veryDarkGray);
AddLine(point + BPoint(kWedge, -kWedge),
BPoint(center+kWedge, point.y), veryDarkGray);
BPoint(center + kWedge, point.y), veryDarkGray);
AddLine(point + BPoint(1, 0),
point + BPoint(1, 0) + BPoint(kWedge - 1, -(kWedge - 1)), white);
@ -1436,7 +1445,7 @@ TBox::Draw(BRect update)
// fill the upward pointing arrow area
SetHighColor(standardGray);
FillTriangle(bottomPoint + BPoint(2,0),
FillTriangle(bottomPoint + BPoint(2, 0),
bottomPoint + BPoint(2, 0) + BPoint(kWedge - 2, -(kWedge - 2)),
BPoint(center + kWedge - 2, bottomPoint.y));
@ -1467,7 +1476,7 @@ TBox::DrawIconScrollers(bool force)
}
int32 maxIndex = fManager->GroupList()->CountItems() - 1;
// last_frame is in fIconView coordinate space
// last_frame is in fIconView coordinate space
BRect lastFrame = fIconView->FrameOf(maxIndex);
if (lastFrame.right > rect.right) {
@ -1893,7 +1902,7 @@ TIconView::CacheIcons(TTeamGroup* teamGroup)
void
TIconView::AnimateIcon(BBitmap* startIcon, BBitmap* endIcon)
{
BRect centerRect(kCenterSlot*kSlotSize, 0,
BRect centerRect(kCenterSlot * kSlotSize, 0,
(kCenterSlot + 1) * kSlotSize - 1, kSlotSize - 1);
BRect startIconBounds = startIcon->Bounds();
BRect bounds = Bounds();
@ -1917,7 +1926,7 @@ TIconView::AnimateIcon(BBitmap* startIcon, BBitmap* endIcon)
fOffBitmap->Lock();
for (int i = 0; i < 2; i++) {
startIconBounds.InsetBy(amount,amount);
startIconBounds.InsetBy(amount, amount);
snooze(20000);
fOffView->SetDrawingMode(B_OP_COPY);
fOffView->FillRect(fOffView->Bounds());
@ -1927,7 +1936,7 @@ TIconView::AnimateIcon(BBitmap* startIcon, BBitmap* endIcon)
DrawBitmap(fOffBitmap, destRect);
}
for (int i = 0; i < 2; i++) {
startIconBounds.InsetBy(amount,amount);
startIconBounds.InsetBy(amount, amount);
snooze(20000);
fOffView->SetDrawingMode(B_OP_COPY);
fOffView->FillRect(fOffView->Bounds());
@ -2054,6 +2063,7 @@ int32
TIconView::SlotOf(int32 index) const
{
BRect rect = FrameOf(index);
return (int32)(rect.left / kSlotSize) - kCenterSlot;
}
@ -2107,7 +2117,7 @@ TIconView::DrawTeams(BRect update)
SetDrawingMode(B_OP_COPY);
}
rect.OffsetBy(kSlotSize,0);
rect.OffsetBy(kSlotSize, 0);
}
}
@ -2201,7 +2211,6 @@ TWindowView::ScrollTo(BPoint where)
}
BRect
TWindowView::FrameOf(int32 index) const
{
@ -2275,6 +2284,7 @@ TWindowView::Draw(BRect update)
int32 groupIndex = fManager->CurrentIndex();
TTeamGroup* teamGroup
= (TTeamGroup*)fManager->GroupList()->ItemAt(groupIndex);
if (teamGroup == NULL)
return;

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
#ifndef SWITCHER_H
@ -53,7 +54,7 @@ public:
TSwitchManager(BPoint where);
virtual ~TSwitchManager();
virtual void MessageReceived(BMessage* message);
virtual void MessageReceived(BMessage* message);
void Stop(bool doAction, uint32 modifiers);
void Unblock();
@ -85,7 +86,7 @@ private:
bool allowWorkspaceSwitch);
void ActivateWindow(int32 windowID = -1);
void _SortApps();
bool _FindNextValidApp(bool forward);
TSwitcherWindow* fWindow;

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -121,7 +122,7 @@ TTeamMenu::AttachedToWindow()
if (dragging && barview->LockLooper()) {
SetTrackingHook(barview->MenuTrackingHook,
barview->GetTrackingHookData());
barview->DragStart();
barview->DragStart();
barview->UnlockLooper();
}

View File

@ -26,15 +26,16 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
// listing of running applications
// menu of BarMenuTitle
// in mini mode only
// listing of running applications
// menu of BarMenuTitle
// in mini mode only
#ifndef TEAMMENU_H
#define TEAMMENU_H
@ -44,7 +45,7 @@ All rights reserved.
#include "TeamMenuItem.h"
class TTeamMenu : public BMenu {
public:
public:
TTeamMenu();
void AttachedToWindow();

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -71,10 +72,11 @@ TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,
}
TTeamMenuItem::TTeamMenuItem(float width,float height,bool vertical)
TTeamMenuItem::TTeamMenuItem(float width, float height, bool vertical)
: BMenuItem("", NULL)
{
InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, vertical);
InitData(NULL, NULL, strdup(""), strdup(""), width, height, false,
vertical);
}
@ -136,10 +138,11 @@ TTeamMenuItem::Invoke(BMessage* message)
barview->DragStop();
// bring to front or minimize shortcuts
uint32 mods = modifiers();
if (mods & B_CONTROL_KEY)
uint32 mods = modifiers();
if (mods & B_CONTROL_KEY) {
TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY)
? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
}
return BMenuItem::Invoke(message);
}
@ -213,7 +216,7 @@ TTeamMenuItem::GetContentSize(float* width, float* height)
*width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad
+ 20;
if (fOverrideHeight != -1.0f)
if (fOverrideHeight != -1.0f)
*height = fOverrideHeight;
else {
*height = iconBounds.Height();
@ -233,8 +236,8 @@ TTeamMenuItem::Draw()
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());
@ -314,13 +317,14 @@ TTeamMenuItem::Draw()
// these continue the dark grey border on the left or top edge
menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT));
if (fVertical)
if (fVertical) {
// dark line at top
menu->StrokeLine(frame.LeftTop(), frame.RightTop());
else
} else {
// dark line on the left
menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
} else
}
} else
menu->SetLowColor(menuColor);
menu->MovePenTo(ContentLocation());
@ -337,15 +341,15 @@ TTeamMenuItem::DrawContent()
if (fIcon->ColorSpace() == B_RGBA32) {
menu->SetDrawingMode(B_OP_ALPHA);
menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
} else {
} else
menu->SetDrawingMode(B_OP_OVER);
}
BRect frame(Frame());
BRect frame(Frame());
BRect iconBounds(fIcon->Bounds());
BRect dstRect(iconBounds);
float extra = fVertical ? 0.0f : 1.0f;
BPoint contLoc = ContentLocation();
dstRect.OffsetTo(BPoint(contLoc.x + kHPad, contLoc.y +
((frame.Height() - iconBounds.Height()) / 2) + extra));
menu->DrawBitmapAsync(fIcon, dstRect);
@ -357,17 +361,17 @@ TTeamMenuItem::DrawContent()
menu->MovePenTo(drawLoc);
}
// set the pen to black so that either method will draw in the same color
// low color is set in inherited::DrawContent, override makes sure its
// what we want
// set the pen to black so that either method will draw in the same color
// low color is set in inherited::DrawContent, override makes sure its
// what we want
if (fDrawLabel) {
menu->SetDrawingMode(B_OP_OVER);
menu->SetHighColor(0, 0, 0);
// override the drawing of the content when the item is disabled
// the wrong lowcolor is used when the item is disabled since the
// text color does not change
DrawContentLabel();
// override the drawing of the content when the item is disabled
// the wrong lowcolor is used when the item is disabled since the
// text color does not change
DrawContentLabel();
}
// Draw the expandable icon.
@ -387,42 +391,42 @@ TTeamMenuItem::DrawContent()
} else {
rgb_color outlineColor = {80, 80, 80, 255};
rgb_color middleColor = {200, 200, 200, 255};
menu->SetDrawingMode(B_OP_OVER);
if (!fExpanded) {
menu->BeginLineArray(6);
menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
BPoint(rect.left + 7, rect.top + 5), outlineColor);
menu->AddLine(BPoint(rect.left + 7, rect.top + 5),
menu->AddLine(BPoint(rect.left + 7, rect.top + 5),
BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
menu->AddLine(BPoint(rect.left + 4, rect.top + 3),
menu->AddLine(BPoint(rect.left + 4, rect.top + 3),
BPoint(rect.left + 4, rect.bottom - 3), middleColor);
menu->AddLine(BPoint(rect.left + 5, rect.top + 4),
menu->AddLine(BPoint(rect.left + 5, rect.top + 4),
BPoint(rect.left + 5, rect.bottom - 4), middleColor);
menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
BPoint(rect.left + 6, rect.top + 5), middleColor);
menu->EndLineArray();
} else {
// expanded state
menu->BeginLineArray(6);
menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
BPoint(rect.right - 3, rect.top + 3), outlineColor);
menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
BPoint(rect.left + 5, rect.top + 7), outlineColor);
menu->AddLine(BPoint(rect.left + 5, rect.top + 7),
menu->AddLine(BPoint(rect.left + 5, rect.top + 7),
BPoint(rect.right - 3, rect.top + 3), outlineColor);
menu->AddLine(BPoint(rect.left + 3, rect.top + 4),
menu->AddLine(BPoint(rect.left + 3, rect.top + 4),
BPoint(rect.right - 5, rect.top + 4), middleColor);
menu->AddLine(BPoint(rect.left + 4, rect.top + 5),
menu->AddLine(BPoint(rect.left + 4, rect.top + 5),
BPoint(rect.right - 6, rect.top + 5), middleColor);
menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
BPoint(rect.left + 5, rect.top + 6), middleColor);
menu->EndLineArray();
}
@ -437,23 +441,24 @@ TTeamMenuItem::DrawContentLabel()
BMenu* menu = Menu();
menu->MovePenBy(0, fLabelAscent);
float cachedWidth = menu->StringWidth(Label());
float cachedWidth = menu->StringWidth(Label());
if (Submenu() && fVertical)
cachedWidth += 18;
const char* label = Label();
char* truncLabel = NULL;
float max = 0;
if (static_cast<TBarApp*>(be_app)->Settings()->superExpando && fVertical)
max = menu->MaxContentWidth() - kSwitchWidth;
else
max = menu->MaxContentWidth();
if (max > 0) {
BPoint penloc = menu->PenLocation();
BPoint penloc = menu->PenLocation();
BRect frame = Frame();
float offset = penloc.x - frame.left;
if (cachedWidth + offset > max) {
if (cachedWidth + offset > max) {
truncLabel = (char*)malloc(strlen(label) + 4);
if (!truncLabel)
return;
@ -491,7 +496,7 @@ void
TTeamMenuItem::ToggleExpandState(bool resizeWindow)
{
fExpanded = !fExpanded;
if (fExpanded) {
// Populate Menu() with the stuff from SubMenu().
TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu()));
@ -503,7 +508,7 @@ TTeamMenuItem::ToggleExpandState(bool resizeWindow)
if (locked)
sub->UnlockLooper();
if (sub->CountItems() > 1){
if (sub->CountItems() > 1) {
TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu());
int myindex = parent->IndexOf(this) + 1;
@ -551,8 +556,10 @@ TTeamMenuItem::ToggleExpandState(bool resizeWindow)
TWindowMenuItem*
TTeamMenuItem::ExpandedWindowItem(int32 id)
{
if (!fExpanded) // Paranoia
if (!fExpanded) {
// Paranoia
return NULL;
}
TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu());
int childIndex = parent->IndexOf(this) + 1;

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
#ifndef TEAMMENUITEM_H
@ -53,7 +54,7 @@ class TTeamMenuItem : public BMenuItem {
float width = -1.0f, float height = -1.0f,
bool drawLabel = true, bool vertical = true);
TTeamMenuItem(float width = -1.0f, float height = -1.0f,
bool vertical=true);
bool vertical = true);
virtual ~TTeamMenuItem();
status_t Invoke(BMessage* msg = NULL);
@ -82,7 +83,7 @@ class TTeamMenuItem : public BMenuItem {
friend class TExpandoMenuBar;
void InitData(BList* team, BBitmap* icon, char* name, char* sig,
float width = -1.0f, float height = -1.0f,
bool drawLabel = true,bool vertical=true);
bool drawLabel = true, bool vertical = true);
bool _IsSelected() const;

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -154,9 +155,9 @@ TTimeView::GetPreferredSize(float* width, float* height)
GetCurrentTime();
// TODO: SetOrientation never gets called, fix that
// When in vertical mode, we want to limit the width so that it can't
// overlap the bevels in the parent view.
// TODO: SetOrientation never gets called, fix that when in vertical mode,
// we want to limit the width so that it can't overlap the bevels in the
// parent view.
*width = fOrientation ?
min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr))
: kHMargin + StringWidth(fTimeStr);
@ -217,6 +218,7 @@ TTimeView::MessageReceived(BMessage* message)
default:
BView::MessageReceived(message);
break;
}
}
@ -262,8 +264,8 @@ TTimeView::GetCurrentDate()
fLocale.FormatDate(tmp, 64, fTime, B_FULL_DATE_FORMAT);
// remove leading 0 from date when month is less than 10 (MM/DD/YY)
// or remove leading 0 from date when day is less than 10 (DD/MM/YY)
// remove leading 0 from date when month is less than 10 (MM/DD/YY)
// or remove leading 0 from date when day is less than 10 (DD/MM/YY)
const char* str = tmp;
if (str[0] == '0')
str++;
@ -325,7 +327,7 @@ TTimeView::Pulse()
// For dates, Update() could be called two times in a row,
// but that should only happen very rarely
if ((fLastTimeStr[1] != fTimeStr[1]
&& (fLastTimeStr[1] == ':' || fTimeStr[1] == ':'))
&& (fLastTimeStr[1] == ':' || fTimeStr[1] == ':'))
|| !fLastTimeStr[0])
Update();
@ -360,7 +362,6 @@ TTimeView::Update()
GetCurrentTime();
GetCurrentDate();
SetToolTip(fDateStr);
ResizeToPreferred();

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
#ifndef TIME_VIEW_H
@ -73,7 +74,7 @@ class TTimeView : public BView {
void MouseDown(BPoint where);
void Pulse();
bool ShowingSeconds() { return fShowSeconds; }
bool ShowingSeconds() { return fShowSeconds; }
void ShowSeconds(bool);
void ShowCalendar(BPoint where);
@ -109,7 +110,7 @@ class TTimeView : public BView {
float fMaxWidth;
float fHeight;
bool fOrientation; // vertical = true
bool fOrientation; // vertical = true
BPoint fTimeLocation;
BPoint fDateLocation;

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -88,16 +89,14 @@ void
TWindowMenu::AttachedToWindow()
{
SetFont(be_plain_font);
RemoveItems(0, CountItems(), true);
int32 miniCount = 0;
bool dragging = false;
TBarView* barview =(static_cast<TBarApp*>(be_app))->BarView();
if (barview && barview->LockLooper()) {
// 'dragging' mode set in BarView::CacheDragData
// invoke in MouseEnter in ExpandoMenuBar
// 'dragging' mode set in BarView::CacheDragData
// invoke in MouseEnter in ExpandoMenuBar
dragging = barview->Dragging();
if (dragging) {
// We don't want to show the menu when dragging, but it's not
@ -105,7 +104,7 @@ TWindowMenu::AttachedToWindow()
// Don't call BMenu::Hide(), it causes the menu to pop up every now
// and then.
Window()->Hide();
// if in expando (horizontal or vertical)
// if in expando (horizontal or vertical)
if (barview->Expando()) {
SetTrackingHook(barview->MenuTrackingHook,
barview->GetTrackingHookData());
@ -177,8 +176,8 @@ TWindowMenu::AttachedToWindow()
int32 itemCount = CountItems() + parentMenuItems;
if (itemCount < 1) {
TWindowMenuItem* noWindowsItem =
new TWindowMenuItem(B_TRANSLATE("No windows"), -1, false, false);
TWindowMenuItem* noWindowsItem
= new TWindowMenuItem(B_TRANSLATE("No windows"), -1, false, false);
noWindowsItem->SetEnabled(false);
@ -186,23 +185,23 @@ TWindowMenu::AttachedToWindow()
// if an application has no windows, this feature makes it easy to quit
// it. (but we only add this option if the application is not Tracker.)
if (fApplicationSignature.ICompare(kTrackerSignature) != 0) {
if (fApplicationSignature.ICompare(kTrackerSignature) != 0) {
AddSeparatorItem();
AddItem(new TShowHideMenuItem(B_TRANSLATE("Quit application"),
fTeam, B_QUIT_REQUESTED));
}
}
} else {
// if we are in drag mode, then don't add the window controls
// to the menu
// if we are in drag mode, then don't add the window controls
// to the menu
if (!dragging) {
TShowHideMenuItem* hide =
new TShowHideMenuItem(B_TRANSLATE("Hide all"), fTeam,
TShowHideMenuItem* hide
= new TShowHideMenuItem(B_TRANSLATE("Hide all"), fTeam,
B_MINIMIZE_WINDOW);
TShowHideMenuItem* show =
new TShowHideMenuItem(B_TRANSLATE("Show all"), fTeam,
TShowHideMenuItem* show
= new TShowHideMenuItem(B_TRANSLATE("Show all"), fTeam,
B_BRING_TO_FRONT);
TShowHideMenuItem* close =
new TShowHideMenuItem(B_TRANSLATE("Close all"), fTeam,
TShowHideMenuItem* close
= new TShowHideMenuItem(B_TRANSLATE("Close all"), fTeam,
B_QUIT_REQUESTED);
if (miniCount == itemCount)
@ -212,6 +211,7 @@ TWindowMenu::AttachedToWindow()
if (!parentMenuItems)
AddSeparatorItem();
AddItem(hide);
AddItem(show);
AddItem(close);
@ -225,12 +225,12 @@ TWindowMenu::AttachedToWindow()
void
TWindowMenu::DetachedFromWindow()
{
// in expando mode the teammenu will not call DragStop,
// thus, it needs to be called from here
// in expando mode the teammenu will not call DragStop, thus, it needs to
// be called from here
TBarView* barview = (dynamic_cast<TBarApp*>(be_app))->BarView();
if (barview && barview->Expando() && barview->Dragging()
&& barview->LockLooper()) {
// We changed the show level in AttachedToWindow(). Undo it.
// We changed the show level in AttachedToWindow(). Undo it.
Window()->Show();
barview->DragStop();
barview->UnlockLooper();

View File

@ -26,15 +26,16 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
// list of windows for a specific application
// always submenu for a TeamMenuItem
// all DB positions
// list of windows for a specific application
// always submenu for a TeamMenuItem
// all DB positions
#ifndef WINDOWMENU_H
#define WINDOWMENU_H

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
@ -48,10 +49,10 @@ All rights reserved.
#include "WindowMenu.h"
const float kHPad = 10.0f;
const float kVPad = 2.0f;
const float kLabelOffset = 8.0f;
const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f);
const float kHPad = 10.0f;
const float kVPad = 2.0f;
const float kLabelOffset = 8.0f;
const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f);
TWindowMenuItem::TWindowMenuItem(const char* title, int32 id, bool mini,
@ -75,11 +76,11 @@ void
TWindowMenuItem::Initialize(const char* title)
{
if (fMini) {
fBitmap = fCurrentWorkSpace
fBitmap = fCurrentWorkSpace
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon)
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon);
} else {
fBitmap = fCurrentWorkSpace
fBitmap = fCurrentWorkSpace
? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon)
: AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon);
}
@ -204,7 +205,7 @@ TWindowMenuItem::Draw()
menu->PushState();
// if not selected or being tracked on, fill with gray
// 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()) {
@ -241,8 +242,8 @@ TWindowMenuItem::DrawContent()
BRect frame(Frame());
BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad);
// if (fExpanded)
// contLoc.x += kHPad;
//if (fExpanded)
// contLoc.x += kHPad;
if (fID >= 0) {
menu->SetDrawingMode(B_OP_OVER);

View File

@ -26,9 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
trademarks of Be Incorporated in the United States and other countries. Other
brand product names are registered trademarks or trademarks of their respective
holders.
All rights reserved.
*/
#ifndef WINDOWMENUITEM_H
@ -69,7 +70,7 @@ public:
protected:
void Initialize(const char* title);
virtual void GetContentSize(float* width, float* height);
virtual void GetContentSize(float* width, float* height);
virtual void DrawContent();
virtual status_t Invoke(BMessage* message = NULL);
virtual void Draw();
@ -91,3 +92,4 @@ private:
#endif /* WINDOWMENUITEM_H */