From 65018030ea571f5a7f62911a2ed53e9ac2fff60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 26 Oct 2004 21:05:06 +0000 Subject: [PATCH] Completed Team Monitor Unimplemented : 4 seconds pressing reboot git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9515 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../devices/keyboard/KeyboardInputDevice.cpp | 1 - .../devices/keyboard/TMListItem.cpp | 4 +- .../devices/keyboard/TMListItem.h | 6 +- .../devices/keyboard/TMWindow.cpp | 89 ++++++++++++++++++- .../input_server/devices/keyboard/TMWindow.h | 11 +++ 5 files changed, 104 insertions(+), 7 deletions(-) diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index 70f8d50c5a..3d2d7962ce 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -675,7 +675,6 @@ KeyboardInputDevice::DeviceWatcher(void *arg) LOG("TeamMonitor called\n"); // show the team monitor - // argh we don't have one ! if (!dev->owner->fTMWindow) dev->owner->fTMWindow = new TMWindow(); diff --git a/src/add-ons/input_server/devices/keyboard/TMListItem.cpp b/src/add-ons/input_server/devices/keyboard/TMListItem.cpp index 07e6800712..2c1c8a0e73 100644 --- a/src/add-ons/input_server/devices/keyboard/TMListItem.cpp +++ b/src/add-ons/input_server/devices/keyboard/TMListItem.cpp @@ -24,7 +24,8 @@ TMListItem::TMListItem(team_info &tinfo) : BListItem(), fInfo(tinfo), - fIcon(BRect(0,0,15,15), B_CMAP8) + fIcon(BRect(0,0,15,15), B_CMAP8), + fLargeIcon(BRect(0,0,31,31), B_CMAP8) { SetHeight(16 + kITEM_MARGIN); @@ -35,6 +36,7 @@ TMListItem::TMListItem(team_info &tinfo) BNode node(info.name); BNodeInfo nodeInfo(&node); nodeInfo.GetTrackerIcon(&fIcon, B_MINI_ICON); + nodeInfo.GetTrackerIcon(&fLargeIcon, B_LARGE_ICON); } } diff --git a/src/add-ons/input_server/devices/keyboard/TMListItem.h b/src/add-ons/input_server/devices/keyboard/TMListItem.h index a98a7be41d..bc8cf91190 100644 --- a/src/add-ons/input_server/devices/keyboard/TMListItem.h +++ b/src/add-ons/input_server/devices/keyboard/TMListItem.h @@ -30,11 +30,13 @@ public: virtual void Update(BView *owner, const BFont *finfo); const team_info *GetInfo(); + const BBitmap *LargeIcon() { return &fLargeIcon; }; + const BPath *Path() { return &fPath; }; + bool IsSystemServer(); bool fFound; private: - bool IsSystemServer(); team_info fInfo; - BBitmap fIcon; + BBitmap fIcon, fLargeIcon; BPath fPath; }; diff --git a/src/add-ons/input_server/devices/keyboard/TMWindow.cpp b/src/add-ons/input_server/devices/keyboard/TMWindow.cpp index d3a8a508da..fef1923728 100644 --- a/src/add-ons/input_server/devices/keyboard/TMWindow.cpp +++ b/src/add-ons/input_server/devices/keyboard/TMWindow.cpp @@ -25,6 +25,10 @@ const uint32 TM_FORCE_REBOOT = 'TMfr'; const uint32 TM_KILL_APPLICATION = 'TMka'; const uint32 TM_SELECTED_TEAM = 'TMst'; +extern "C" void _kshutdown_(long arg); +#define SHUTDOWN_HALT 0 +#define SHUTDOWN_REBOOT 1 + TMWindow::TMWindow() : BWindow(BRect(0,0,350,300), "Team Monitor", B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL, @@ -66,6 +70,12 @@ TMWindow::TMWindow() fBackground->AddChild(fKillApp); fKillApp->SetEnabled(false); + rect.top = rect.bottom + 10; + rect.bottom = rect.top + 65; + rect.right = rect.left + Bounds().right - 10; + fDescView = new TMDescView(rect); + fBackground->AddChild(fDescView); + BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame()); BPoint pt; pt.x = screenFrame.Width()/2 - Bounds().Width()/2; @@ -90,6 +100,9 @@ TMWindow::MessageReceived(BMessage *msg) { switch(msg->what) { + case TM_FORCE_REBOOT: + _kshutdown_(SHUTDOWN_REBOOT); + break; case TM_KILL_APPLICATION: { TMListItem *item = (TMListItem*)fBackground->fListView->ItemAt( fBackground->fListView->CurrentSelection()); @@ -97,8 +110,12 @@ TMWindow::MessageReceived(BMessage *msg) fKillApp->SetEnabled(false); } break; - case TM_SELECTED_TEAM: - fKillApp->SetEnabled(true); + case TM_SELECTED_TEAM: { + fKillApp->SetEnabled(fBackground->fListView->CurrentSelection() >= 0); + TMListItem *item = (TMListItem*)fBackground->fListView->ItemAt( + fBackground->fListView->CurrentSelection()); + fDescView->SetItem(item); + } break; case TM_CANCEL: Disable(); @@ -126,14 +143,17 @@ TMWindow::Enable() { SetPulseRate(1000000); - if (IsHidden()) + if (IsHidden()) { + PostMessage(B_PULSE); Show(); + } } void TMWindow::Disable() { + fBackground->fListView->DeselectAll(); SetPulseRate(0); Hide(); } @@ -201,3 +221,66 @@ TMBox::Pulse() fListView->Invalidate(); } + + +TMDescView::TMDescView(BRect rect) + : BBox(rect, "descview", B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW, B_NO_BORDER), + fItem(NULL) +{ + + +} + + +void +TMDescView::Draw(BRect rect) +{ + if (fItem) { + BRect frame(rect); + frame.OffsetBy(2,3); + frame.Set(frame.left, frame.top, frame.left+31, frame.top+31); + SetDrawingMode(B_OP_OVER); + DrawBitmap(fItem->LargeIcon(), frame); + SetDrawingMode(B_OP_COPY); + + BFont font = be_plain_font; + font_height finfo; + font.GetHeight(&finfo); + SetFont(&font); + MovePenTo(frame.right+9, frame.top - 2 + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 4) + + (finfo.ascent + finfo.descent) - 1); + DrawString(fItem->Path()->Path()); + + if (fItem->IsSystemServer()) { + MovePenTo(frame.right+9, frame.top + 1 + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) *3 / 4) + + (finfo.ascent + finfo.descent) - 1); + DrawString("(This team is a component of the BeOS"); + } + } else { + BFont font = be_plain_font; + font_height finfo; + font.GetHeight(&finfo); + SetFont(&font); + BPoint point(rect.left+4, rect.top - 9 + ((rect.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 4) + + (finfo.ascent + finfo.descent) - 1); + MovePenTo(point); + DrawString("Select an application from the list above and click the \"Kill\" button in"); + + point.y += 13; + MovePenTo(point); + DrawString("order to close it."); + + point.y += 26; + MovePenTo(point); + DrawString("Hold CONTROL+ALT+DELETE for 4 seconds to reboot."); + + } +} + + +void +TMDescView::SetItem(TMListItem *item) +{ + fItem = item; + Invalidate(); +} diff --git a/src/add-ons/input_server/devices/keyboard/TMWindow.h b/src/add-ons/input_server/devices/keyboard/TMWindow.h index 108f92d201..235d646d18 100644 --- a/src/add-ons/input_server/devices/keyboard/TMWindow.h +++ b/src/add-ons/input_server/devices/keyboard/TMWindow.h @@ -22,6 +22,7 @@ #include #include "InputServerTypes.h" +#include "TMListItem.h" class TMBox : public BBox { public: @@ -33,6 +34,15 @@ public: BListView *fListView; }; +class TMDescView : public BBox { +public: + TMDescView(BRect bounds); + void Draw(BRect bounds); + void SetItem(TMListItem *item); +private: + TMListItem *fItem; +}; + class TMWindow : public BWindow { public: @@ -48,6 +58,7 @@ private: BButton *fKillApp; TMBox *fBackground; + TMDescView *fDescView; };