@@ -26,6 +26,7 @@
|
|||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <StringView.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
@@ -109,7 +110,9 @@ FilterKeyDown(BMessage* message, BHandler** target,
|
|||||||
class AllShowingTextView : public BTextView {
|
class AllShowingTextView : public BTextView {
|
||||||
public:
|
public:
|
||||||
AllShowingTextView(const char* name);
|
AllShowingTextView(const char* name);
|
||||||
virtual void FrameResized(float width, float height);
|
virtual bool HasHeightForWidth();
|
||||||
|
virtual void GetHeightForWidth(float width, float* min,
|
||||||
|
float* max, float* preferred);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -131,11 +134,12 @@ private:
|
|||||||
BMessageRunner* fRebootRunner;
|
BMessageRunner* fRebootRunner;
|
||||||
IconView* fIconView;
|
IconView* fIconView;
|
||||||
const char* fInfoString;
|
const char* fInfoString;
|
||||||
const char* fSysComponentString;
|
|
||||||
const char* fQuitOverdueString;
|
|
||||||
BCardLayout* fLayout;
|
BCardLayout* fLayout;
|
||||||
AllShowingTextView* fIconTextView;
|
AllShowingTextView* fInfoTextView;
|
||||||
AllShowingTextView* fInfoTextView;
|
|
||||||
|
BStringView* fTeamName;
|
||||||
|
BStringView* fSysComponent;
|
||||||
|
BStringView* fQuitOverdue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -153,7 +157,7 @@ static const uint32 kMsgRebootTick = 'TMrt';
|
|||||||
|
|
||||||
TeamMonitorWindow::TeamMonitorWindow()
|
TeamMonitorWindow::TeamMonitorWindow()
|
||||||
:
|
:
|
||||||
BWindow(BRect(0, 0, 350, 400), B_TRANSLATE("Team monitor"),
|
BWindow(BRect(0, 0, 350, 100), B_TRANSLATE("Team monitor"),
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
|
B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
|
||||||
B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
|
B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
|
||||||
| B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS,
|
| B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS,
|
||||||
@@ -174,67 +178,44 @@ TeamMonitorWindow::TeamMonitorWindow()
|
|||||||
|
|
||||||
BScrollView* scrollView = new BScrollView("scroll_teams", fListView,
|
BScrollView* scrollView = new BScrollView("scroll_teams", fListView,
|
||||||
0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER);
|
0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER);
|
||||||
layout->AddView(scrollView);
|
scrollView->SetExplicitMinSize(BSize(B_SIZE_UNSET, 150));
|
||||||
|
|
||||||
BGroupView* groupView = new BGroupView(B_HORIZONTAL);
|
|
||||||
layout->AddView(groupView);
|
|
||||||
|
|
||||||
fKillButton = new BButton("kill", B_TRANSLATE("Kill application"),
|
fKillButton = new BButton("kill", B_TRANSLATE("Kill application"),
|
||||||
new BMessage(TM_KILL_APPLICATION));
|
new BMessage(TM_KILL_APPLICATION));
|
||||||
groupView->AddChild(fKillButton);
|
|
||||||
fKillButton->SetEnabled(false);
|
fKillButton->SetEnabled(false);
|
||||||
|
|
||||||
fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"),
|
fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"),
|
||||||
new BMessage(TM_QUIT_APPLICATION));
|
new BMessage(TM_QUIT_APPLICATION));
|
||||||
groupView->AddChild(fQuitButton);
|
|
||||||
fQuitButton->SetEnabled(false);
|
fQuitButton->SetEnabled(false);
|
||||||
|
|
||||||
groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
|
|
||||||
|
|
||||||
fDescriptionView = new TeamDescriptionView;
|
fDescriptionView = new TeamDescriptionView;
|
||||||
layout->AddView(fDescriptionView);
|
|
||||||
|
|
||||||
groupView = new BGroupView(B_HORIZONTAL);
|
|
||||||
layout->AddView(groupView);
|
|
||||||
|
|
||||||
BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"),
|
BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"),
|
||||||
new BMessage(TM_FORCE_REBOOT));
|
new BMessage(TM_FORCE_REBOOT));
|
||||||
groupView->GroupLayout()->AddView(forceReboot);
|
|
||||||
|
|
||||||
BSpaceLayoutItem* glue = BSpaceLayoutItem::CreateGlue();
|
|
||||||
glue->SetExplicitMinSize(BSize(inset, -1));
|
|
||||||
groupView->GroupLayout()->AddItem(glue);
|
|
||||||
|
|
||||||
fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"),
|
fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"),
|
||||||
new BMessage(TM_RESTART_DESKTOP));
|
new BMessage(TM_RESTART_DESKTOP));
|
||||||
SetDefaultButton(fRestartButton);
|
|
||||||
groupView->GroupLayout()->AddView(fRestartButton);
|
|
||||||
|
|
||||||
glue = BSpaceLayoutItem::CreateGlue();
|
|
||||||
glue->SetExplicitMinSize(BSize(inset, -1));
|
|
||||||
groupView->GroupLayout()->AddItem(glue);
|
|
||||||
|
|
||||||
fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
|
fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
|
||||||
new BMessage(TM_CANCEL));
|
new BMessage(TM_CANCEL));
|
||||||
SetDefaultButton(fCancelButton);
|
SetDefaultButton(fCancelButton);
|
||||||
groupView->GroupLayout()->AddView(fCancelButton);
|
|
||||||
|
|
||||||
BSize preferredSize = layout->View()->PreferredSize();
|
BGroupLayoutBuilder(layout)
|
||||||
if (preferredSize.width > Bounds().Width())
|
.Add(scrollView)
|
||||||
ResizeTo(preferredSize.width, Bounds().Height());
|
.AddGroup(B_HORIZONTAL)
|
||||||
if (preferredSize.height > Bounds().Height())
|
.Add(fKillButton)
|
||||||
ResizeTo(Bounds().Width(), preferredSize.height);
|
.Add(fQuitButton)
|
||||||
|
.AddGlue()
|
||||||
|
.End()
|
||||||
|
.Add(fDescriptionView)
|
||||||
|
.AddGroup(B_HORIZONTAL)
|
||||||
|
.Add(forceReboot)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(fRestartButton)
|
||||||
|
.AddGlue(inset)
|
||||||
|
.Add(fCancelButton);
|
||||||
|
|
||||||
BRect screenFrame = BScreen(this).Frame();
|
CenterOnScreen();
|
||||||
BPoint point;
|
|
||||||
point.x = (screenFrame.Width() - Bounds().Width()) / 2;
|
|
||||||
point.y = (screenFrame.Height() - Bounds().Height()) / 2;
|
|
||||||
|
|
||||||
if (screenFrame.Contains(point))
|
|
||||||
MoveTo(point);
|
|
||||||
|
|
||||||
SetSizeLimits(Bounds().Width(), Bounds().Width() * 2,
|
|
||||||
Bounds().Height(), screenFrame.Height());
|
|
||||||
|
|
||||||
fRestartButton->Hide();
|
fRestartButton->Hide();
|
||||||
|
|
||||||
@@ -386,6 +367,11 @@ TeamMonitorWindow::Enable()
|
|||||||
}
|
}
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not sure why this is needed, but without it the layout isn't correct
|
||||||
|
// when the window is first shown and the buttons at the bottom aren't
|
||||||
|
// visible.
|
||||||
|
InvalidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -602,16 +588,22 @@ TeamDescriptionView::TeamDescriptionView()
|
|||||||
"in order to close it.\n\n"
|
"in order to close it.\n\n"
|
||||||
"Hold CONTROL+ALT+DELETE for %ld seconds to reboot.");
|
"Hold CONTROL+ALT+DELETE for %ld seconds to reboot.");
|
||||||
|
|
||||||
fSysComponentString = B_TRANSLATE("(This team is a system component)");
|
fTeamName = new BStringView("team name", "team name");
|
||||||
fQuitOverdueString = B_TRANSLATE("If the application will not quit "
|
fSysComponent = new BStringView("system component", B_TRANSLATE(
|
||||||
"you may have to kill it.");
|
"(This team is a system component)"));
|
||||||
|
fQuitOverdue = new BStringView("quit overdue", B_TRANSLATE(
|
||||||
|
"If the application will not quit you may have to kill it."));
|
||||||
|
fQuitOverdue->SetFont(be_bold_font);
|
||||||
|
|
||||||
fInfoTextView = new AllShowingTextView("info text");
|
fInfoTextView = new AllShowingTextView("info text");
|
||||||
fIconTextView = new AllShowingTextView("icon text");
|
BGroupView* group = new BGroupView(B_VERTICAL);
|
||||||
|
BGroupLayoutBuilder(group)
|
||||||
|
.Add(fInfoTextView)
|
||||||
|
.AddGlue();
|
||||||
|
|
||||||
fIconView = new IconView();
|
fIconView = new IconView();
|
||||||
fIconView->SetExplicitAlignment(
|
fIconView->SetExplicitAlignment(
|
||||||
BAlignment(B_ALIGN_HORIZONTAL_UNSET, B_ALIGN_TOP));
|
BAlignment(B_ALIGN_HORIZONTAL_UNSET, B_ALIGN_VERTICAL_CENTER));
|
||||||
|
|
||||||
BView* teamPropertiesView = new BView("team properties", B_WILL_DRAW);
|
BView* teamPropertiesView = new BView("team properties", B_WILL_DRAW);
|
||||||
teamPropertiesView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
teamPropertiesView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -619,11 +611,16 @@ TeamDescriptionView::TeamDescriptionView()
|
|||||||
teamPropertiesView->SetLayout(layout);
|
teamPropertiesView->SetLayout(layout);
|
||||||
BGroupLayoutBuilder(layout)
|
BGroupLayoutBuilder(layout)
|
||||||
.Add(fIconView)
|
.Add(fIconView)
|
||||||
.Add(fIconTextView);
|
.AddGroup(B_VERTICAL)
|
||||||
|
.Add(fTeamName)
|
||||||
|
.Add(fSysComponent)
|
||||||
|
.Add(fQuitOverdue)
|
||||||
|
.End()
|
||||||
|
.AddGlue();
|
||||||
|
|
||||||
fLayout = new BCardLayout();
|
fLayout = new BCardLayout();
|
||||||
SetLayout(fLayout);
|
SetLayout(fLayout);
|
||||||
fLayout->AddView(fInfoTextView);
|
fLayout->AddView(group);
|
||||||
fLayout->AddView(teamPropertiesView);
|
fLayout->AddView(teamPropertiesView);
|
||||||
|
|
||||||
SetItem(NULL);
|
SetItem(NULL);
|
||||||
@@ -678,39 +675,46 @@ void
|
|||||||
TeamDescriptionView::SetItem(TeamListItem* item)
|
TeamDescriptionView::SetItem(TeamListItem* item)
|
||||||
{
|
{
|
||||||
fItem = item;
|
fItem = item;
|
||||||
int32 styleStart = 0;
|
|
||||||
int32 styleEnd = 0;
|
|
||||||
BTextView* view = NULL;
|
|
||||||
|
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
|
int32 styleStart = 0;
|
||||||
|
int32 styleEnd = 0;
|
||||||
BString text;
|
BString text;
|
||||||
|
|
||||||
text.SetToFormat(fInfoString, fSeconds);
|
text.SetToFormat(fInfoString, fSeconds);
|
||||||
fInfoTextView->SetText(text);
|
fInfoTextView->SetText(text);
|
||||||
if (fRebootRunner != NULL && fSeconds < 4) {
|
if (fRebootRunner != NULL && fSeconds < 4) {
|
||||||
styleStart = text.FindLast('\n');
|
styleStart = text.FindLast('\n');
|
||||||
styleEnd = text.Length();
|
styleEnd = text.Length();
|
||||||
}
|
}
|
||||||
view = fInfoTextView;
|
|
||||||
} else {
|
|
||||||
BString text = item->Path()->Path();
|
|
||||||
if (item->IsSystemServer())
|
|
||||||
text << "\n" << fSysComponentString;
|
|
||||||
if (item->IsRefusingToQuit()) {
|
|
||||||
text << "\n\n" << fQuitOverdueString;
|
|
||||||
styleStart = text.FindLast('\n');
|
|
||||||
styleEnd = text.Length();
|
|
||||||
}
|
|
||||||
view = fIconTextView;
|
|
||||||
fIconTextView->SetText(text);
|
|
||||||
fIconView->SetIcon(item->Path()->Path());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (styleStart != styleEnd && view != NULL) {
|
if (styleStart != styleEnd && fInfoTextView != NULL) {
|
||||||
BFont font;
|
BFont font;
|
||||||
view->GetFont(&font);
|
fInfoTextView->GetFont(&font);
|
||||||
font.SetFace(B_BOLD_FACE);
|
font.SetFace(B_BOLD_FACE);
|
||||||
view->SetStylable(true);
|
fInfoTextView->SetStylable(true);
|
||||||
view->SetFontAndColor(styleStart, styleEnd, &font);
|
fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fTeamName->SetText(item->Path()->Path());
|
||||||
|
|
||||||
|
if (item->IsSystemServer()) {
|
||||||
|
if (fSysComponent->IsHidden(fSysComponent))
|
||||||
|
fSysComponent->Show();
|
||||||
|
} else {
|
||||||
|
if (!fSysComponent->IsHidden(fSysComponent))
|
||||||
|
fSysComponent->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->IsRefusingToQuit()) {
|
||||||
|
if (fQuitOverdue->IsHidden(fQuitOverdue))
|
||||||
|
fQuitOverdue->Show();
|
||||||
|
} else {
|
||||||
|
if (!fQuitOverdue->IsHidden(fQuitOverdue))
|
||||||
|
fQuitOverdue->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
fIconView->SetIcon(item->Path()->Path());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fLayout == NULL)
|
if (fLayout == NULL)
|
||||||
@@ -738,10 +742,19 @@ AllShowingTextView::AllShowingTextView(const char* name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
bool
|
||||||
AllShowingTextView::FrameResized(float width, float height)
|
AllShowingTextView::HasHeightForWidth()
|
||||||
{
|
{
|
||||||
float minHeight = TextHeight(0, CountLines() - 1);
|
return true;
|
||||||
SetExplicitMinSize(BSize(B_SIZE_UNSET, minHeight));
|
}
|
||||||
BTextView::FrameResized(width, minHeight);
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AllShowingTextView::GetHeightForWidth(float width, float* min, float* max,
|
||||||
|
float* preferred)
|
||||||
|
{
|
||||||
|
BTextView::GetHeightForWidth(width, min, max, preferred);
|
||||||
|
float minHeight = TextHeight(0, CountLines() - 1);
|
||||||
|
if (min)
|
||||||
|
*min = minHeight;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user