From 997c3d8afb7f0f2cbbb9c7b918304806757d6770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 21 Oct 2008 12:30:25 +0000 Subject: [PATCH] * Renamed TMWindow to TeamMonitorWindow, TMListItem to TeamListItem, TMDescView to TeamDescriptionView. * Renamed files accordingly. * Minor cleanup (made TeamListItem::fFound private, and added accessor methods). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28261 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../input_server/devices/keyboard/Jamfile | 4 +- .../devices/keyboard/KeyboardInputDevice.cpp | 2 +- .../devices/keyboard/KeyboardInputDevice.h | 4 +- .../devices/keyboard/TMListItem.h | 47 ----------- .../input_server/devices/keyboard/TMWindow.h | 68 ---------------- .../{TMListItem.cpp => TeamListItem.cpp} | 75 +++++++----------- .../devices/keyboard/TeamListItem.h | 44 +++++++++++ .../{TMWindow.cpp => TeamMonitorWindow.cpp} | 78 ++++++++++++------- .../devices/keyboard/TeamMonitorWindow.h | 47 +++++++++++ 9 files changed, 176 insertions(+), 193 deletions(-) delete mode 100644 src/add-ons/input_server/devices/keyboard/TMListItem.h delete mode 100644 src/add-ons/input_server/devices/keyboard/TMWindow.h rename src/add-ons/input_server/devices/keyboard/{TMListItem.cpp => TeamListItem.cpp} (58%) create mode 100644 src/add-ons/input_server/devices/keyboard/TeamListItem.h rename src/add-ons/input_server/devices/keyboard/{TMWindow.cpp => TeamMonitorWindow.cpp} (83%) create mode 100644 src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.h diff --git a/src/add-ons/input_server/devices/keyboard/Jamfile b/src/add-ons/input_server/devices/keyboard/Jamfile index a0a051cf8a..2aee21b75a 100644 --- a/src/add-ons/input_server/devices/keyboard/Jamfile +++ b/src/add-ons/input_server/devices/keyboard/Jamfile @@ -9,8 +9,8 @@ Addon keyboard : KeyboardInputDevice.cpp Keymap.cpp - TMWindow.cpp - TMListItem.cpp + TeamMonitorWindow.cpp + TeamListItem.cpp : input_server be ; diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index d22ea4d19f..2982421c46 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -657,7 +657,7 @@ KeyboardInputDevice::_DeviceWatcher(void* arg) // show the team monitor if (owner->fTeamMonitorWindow == NULL) - owner->fTeamMonitorWindow = new(std::nothrow) TMWindow(); + owner->fTeamMonitorWindow = new(std::nothrow) TeamMonitorWindow(); if (owner->fTeamMonitorWindow != NULL) owner->fTeamMonitorWindow->Enable(); diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h index b712d1f714..4a78411304 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h @@ -15,7 +15,7 @@ #include #include "Keymap.h" -#include "TMWindow.h" +#include "TeamMonitorWindow.h" #include "kb_mouse_settings.h" @@ -73,7 +73,7 @@ private: BObjectList fDevices; Keymap fKeymap; - TMWindow* fTeamMonitorWindow; + TeamMonitorWindow* fTeamMonitorWindow; BLocker fKeymapLock; }; diff --git a/src/add-ons/input_server/devices/keyboard/TMListItem.h b/src/add-ons/input_server/devices/keyboard/TMListItem.h deleted file mode 100644 index d650908a2f..0000000000 --- a/src/add-ons/input_server/devices/keyboard/TMListItem.h +++ /dev/null @@ -1,47 +0,0 @@ -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -// -// Copyright (c) 2004, Haiku -// -// This software is part of the Haiku distribution and is covered -// by the Haiku license. -// -// -// File: TMListItem.h -// Author: Jérôme Duval -// Description: Keyboard input server addon -// Created : October 24, 2004 -// -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - -#ifndef TMLISTITEM_H -#define TMLISTITEM_H - -#include -#include -#include - -class TMListItem : public BListItem { - public: - TMListItem(team_info &info); - ~TMListItem(); - - virtual void DrawItem(BView *owner, BRect frame, bool complete = false); - virtual void Update(BView *owner, const BFont *finfo); - - const team_info *GetInfo(); - const BBitmap *LargeIcon() { return &fLargeIcon; }; - const BPath *Path() { return &fPath; }; - bool IsSystemServer(); - - static int32 MinimalHeight(); - - bool fFound; - - private: - team_info fInfo; - BBitmap fIcon, fLargeIcon; - BPath fPath; -}; - - -#endif //TMLISTITEM_H diff --git a/src/add-ons/input_server/devices/keyboard/TMWindow.h b/src/add-ons/input_server/devices/keyboard/TMWindow.h deleted file mode 100644 index 5e15add0ca..0000000000 --- a/src/add-ons/input_server/devices/keyboard/TMWindow.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2008, Haiku. - * Distributed under the terms of the MIT License. - * - * Authors: - * Jérôme Duval - * Axel Doerfler, axeld@pinc-software.de - */ -#ifndef TMWINDOW_H -#define TMWINDOW_H - - -#include -#include -#include -#include - -#include "TMListItem.h" - - -class TMDescView : public BBox { - public: - TMDescView(); - virtual ~TMDescView(); - - virtual void MessageReceived(BMessage* message); - virtual void Draw(BRect bounds); - virtual void GetPreferredSize(float *_width, float *_height); - - void CtrlAltDelPressed(bool keyDown); - - void SetItem(TMListItem *item); - TMListItem *Item() { return fItem; } - - private: - const char* fText[3]; - TMListItem* fItem; - int32 fSeconds; - BMessageRunner* fRebootRunner; -}; - -class TMWindow : public BWindow { - public: - TMWindow(); - virtual ~TMWindow(); - - virtual void MessageReceived(BMessage* message); - virtual bool QuitRequested(); - - void Enable(); - void Disable(); - - private: - void UpdateList(); - - bool fQuitting; - - BMessageRunner* fUpdateRunner; - BView *fView; - BListView *fListView; - BButton *fKillButton; - BButton *fRestartButton; - TMDescView *fDescriptionView; -}; - -static const uint32 kMsgCtrlAltDelPressed = 'TMcp'; - -#endif // TMWINDOW_H diff --git a/src/add-ons/input_server/devices/keyboard/TMListItem.cpp b/src/add-ons/input_server/devices/keyboard/TeamListItem.cpp similarity index 58% rename from src/add-ons/input_server/devices/keyboard/TMListItem.cpp rename to src/add-ons/input_server/devices/keyboard/TeamListItem.cpp index ec76a185ea..15831914f2 100644 --- a/src/add-ons/input_server/devices/keyboard/TMListItem.cpp +++ b/src/add-ons/input_server/devices/keyboard/TeamListItem.cpp @@ -1,39 +1,27 @@ -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -// -// Copyright (c) 2004-2005, Haiku -// -// This software is part of the Haiku distribution and is covered -// by the Haiku license. -// -// -// File: TMListItem.cpp -// Author: Jérôme Duval -// Description: Keyboard input server addon -// Created : October 24, 2004 -// -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +/* + * Copyright 2004-2008, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jérôme Duval + */ + +#include "TeamListItem.h" + +#include #include #include -#include "TMListItem.h" - -#include - static const int32 kItemMargin = 2; -TMListItem::TMListItem(team_info &tinfo) - : BListItem(), +TeamListItem::TeamListItem(team_info &tinfo) + : fInfo(tinfo), -#ifdef __HAIKU__ fIcon(BRect(0, 0, 15, 15), B_RGBA32), fLargeIcon(BRect(0, 0, 31, 31), B_RGBA32) -#else - fIcon(BRect(0, 0, 15, 15), B_CMAP8), - fLargeIcon(BRect(0, 0, 31, 31), B_CMAP8) -#endif { int32 cookie = 0; image_info info; @@ -47,13 +35,13 @@ TMListItem::TMListItem(team_info &tinfo) } -TMListItem::~TMListItem() +TeamListItem::~TeamListItem() { } void -TMListItem::DrawItem(BView *owner, BRect frame, bool complete) +TeamListItem::DrawItem(BView *owner, BRect frame, bool complete) { rgb_color kHighlight = { 140,140,140,0 }; rgb_color kBlack = { 0,0,0,0 }; @@ -63,11 +51,11 @@ TMListItem::DrawItem(BView *owner, BRect frame, bool complete) if (IsSelected() || complete) { rgb_color color; - if (IsSelected()) { + if (IsSelected()) color = kHighlight; - } else { + else color = owner->ViewColor(); - } + owner->SetHighColor(color); owner->SetLowColor(color); owner->FillRect(r); @@ -78,13 +66,10 @@ TMListItem::DrawItem(BView *owner, BRect frame, bool complete) frame.left += 4; BRect iconFrame(frame); - iconFrame.Set(iconFrame.left, iconFrame.top+1, iconFrame.left+15, iconFrame.top+16); -#ifdef __HAIKU__ + iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15, + iconFrame.top + 16); owner->SetDrawingMode(B_OP_ALPHA); owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); -#else - owner->SetDrawingMode(B_OP_OVER); -#endif owner->DrawBitmap(&fIcon, iconFrame); owner->SetDrawingMode(B_OP_COPY); @@ -95,22 +80,22 @@ TMListItem::DrawItem(BView *owner, BRect frame, bool complete) font_height finfo; font.GetHeight(&finfo); owner->SetFont(&font); - owner->MovePenTo(frame.left+8, frame.top + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2) + - (finfo.ascent + finfo.descent) - 1); + owner->MovePenTo(frame.left + 8, frame.top + ((frame.Height() + - (finfo.ascent + finfo.descent + finfo.leading)) / 2) + + (finfo.ascent + finfo.descent) - 1); owner->DrawString(fPath.Leaf()); } -/*static*/ -int32 -TMListItem::MinimalHeight() +/*static*/ int32 +TeamListItem::MinimalHeight() { return 16 + kItemMargin; } void -TMListItem::Update(BView *owner, const BFont *font) +TeamListItem::Update(BView* owner, const BFont* font) { // we need to override the update method so we can make sure // the list item size doesn't change @@ -120,17 +105,17 @@ TMListItem::Update(BView *owner, const BFont *font) } -const team_info * -TMListItem::GetInfo() +const team_info* +TeamListItem::GetInfo() { return &fInfo; } bool -TMListItem::IsSystemServer() +TeamListItem::IsSystemServer() { - char *system = "/boot/beos/system/"; + char* system = "/boot/beos/system/"; if (strncmp(system, fInfo.args, strlen(system)) == 0) return true; diff --git a/src/add-ons/input_server/devices/keyboard/TeamListItem.h b/src/add-ons/input_server/devices/keyboard/TeamListItem.h new file mode 100644 index 0000000000..aab5553249 --- /dev/null +++ b/src/add-ons/input_server/devices/keyboard/TeamListItem.h @@ -0,0 +1,44 @@ +/* + * Copyright 2004-2008, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jérôme Duval + */ +#ifndef TEAM_LIST_ITEM_H +#define TEAM_LIST_ITEM_H + + +#include +#include +#include + + +class TeamListItem : public BListItem { +public: + TeamListItem(team_info& info); + virtual ~TeamListItem(); + + virtual void DrawItem(BView* owner, BRect frame, + bool complete = false); + virtual void Update(BView* owner, const BFont* font); + + const team_info* GetInfo(); + const BBitmap* LargeIcon() { return &fLargeIcon; }; + const BPath* Path() { return &fPath; }; + bool IsSystemServer(); + + bool Found() const { return fFound; } + void SetFound(bool found) { fFound = found; } + + static int32 MinimalHeight(); + +private: + team_info fInfo; + BBitmap fIcon, fLargeIcon; + BPath fPath; + bool fFound; +}; + + +#endif // TEAM_LIST_ITEM_H diff --git a/src/add-ons/input_server/devices/keyboard/TMWindow.cpp b/src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.cpp similarity index 83% rename from src/add-ons/input_server/devices/keyboard/TMWindow.cpp rename to src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.cpp index d02acce51b..48f51f74a1 100644 --- a/src/add-ons/input_server/devices/keyboard/TMWindow.cpp +++ b/src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.cpp @@ -9,7 +9,7 @@ //! Keyboard input server addon -#include "TMWindow.h" +#include "TeamMonitorWindow.h" #include @@ -29,7 +29,29 @@ #include #include "KeyboardInputDevice.h" -#include "TMListItem.h" +#include "TeamListItem.h" + + +class TeamDescriptionView : public BBox { +public: + TeamDescriptionView(); + virtual ~TeamDescriptionView(); + + virtual void MessageReceived(BMessage* message); + virtual void Draw(BRect bounds); + virtual void GetPreferredSize(float* _width, float* _height); + + void CtrlAltDelPressed(bool keyDown); + + void SetItem(TeamListItem* item); + TeamListItem* Item() { return fItem; } + +private: + const char* fText[3]; + TeamListItem* fItem; + int32 fSeconds; + BMessageRunner* fRebootRunner; +}; static const uint32 kMsgUpdate = 'TMup'; @@ -42,7 +64,7 @@ const uint32 TM_SELECTED_TEAM = 'TMst'; static const uint32 kMsgRebootTick = 'TMrt'; -TMWindow::TMWindow() +TeamMonitorWindow::TeamMonitorWindow() : BWindow(BRect(0, 0, 350, 300), "Team Monitor", B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL, B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS, @@ -75,7 +97,7 @@ TMWindow::TMWindow() groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); - fDescriptionView = new TMDescView; + fDescriptionView = new TeamDescriptionView; layout->AddView(fDescriptionView); groupView = new BGroupView(B_HORIZONTAL); @@ -121,13 +143,13 @@ TMWindow::TMWindow() } -TMWindow::~TMWindow() +TeamMonitorWindow::~TeamMonitorWindow() { } void -TMWindow::MessageReceived(BMessage *msg) +TeamMonitorWindow::MessageReceived(BMessage *msg) { switch (msg->what) { case SYSTEM_SHUTTING_DOWN: @@ -151,7 +173,7 @@ TMWindow::MessageReceived(BMessage *msg) break; case TM_KILL_APPLICATION: { - TMListItem* item = (TMListItem*)fListView->ItemAt( + TeamListItem* item = (TeamListItem*)fListView->ItemAt( fListView->CurrentSelection()); if (item != NULL) { kill_team(item->GetInfo()->team); @@ -170,7 +192,7 @@ TMWindow::MessageReceived(BMessage *msg) case TM_SELECTED_TEAM: { fKillButton->SetEnabled(fListView->CurrentSelection() >= 0); - TMListItem* item = (TMListItem*)fListView->ItemAt( + TeamListItem* item = (TeamListItem*)fListView->ItemAt( fListView->CurrentSelection()); fDescriptionView->SetItem(item); break; @@ -187,7 +209,7 @@ TMWindow::MessageReceived(BMessage *msg) bool -TMWindow::QuitRequested() +TeamMonitorWindow::QuitRequested() { Disable(); return fQuitting; @@ -195,13 +217,13 @@ TMWindow::QuitRequested() void -TMWindow::UpdateList() +TeamMonitorWindow::UpdateList() { bool changed = false; for (int32 i = 0; i < fListView->CountItems(); i++) { - TMListItem *item = (TMListItem*)fListView->ItemAt(i); - item->fFound = false; + TeamListItem *item = (TeamListItem*)fListView->ItemAt(i); + item->SetFound(false); } int32 cookie = 0; @@ -212,26 +234,26 @@ TMWindow::UpdateList() bool found = false; for (int32 i = 0; i < fListView->CountItems(); i++) { - TMListItem *item = (TMListItem*)fListView->ItemAt(i); + TeamListItem *item = (TeamListItem*)fListView->ItemAt(i); if (item->GetInfo()->team == info.team) { - item->fFound = true; + item->SetFound(true); found = true; } } if (!found) { - TMListItem *item = new TMListItem(info); + TeamListItem* item = new TeamListItem(info); fListView->AddItem(item, item->IsSystemServer() ? fListView->CountItems() : 0); - item->fFound = true; + item->SetFound(true); changed = true; } } for (int32 i = fListView->CountItems() - 1; i >= 0; i--) { - TMListItem *item = (TMListItem*)fListView->ItemAt(i); - if (!item->fFound) { + TeamListItem *item = (TeamListItem*)fListView->ItemAt(i); + if (!item->Found()) { if (item == fDescriptionView->Item()) { fDescriptionView->SetItem(NULL); fKillButton->SetEnabled(false); @@ -257,7 +279,7 @@ TMWindow::UpdateList() void -TMWindow::Enable() +TeamMonitorWindow::Enable() { if (Lock()) { if (IsHidden()) { @@ -273,7 +295,7 @@ TMWindow::Enable() void -TMWindow::Disable() +TeamMonitorWindow::Disable() { fListView->DeselectAll(); delete fUpdateRunner; @@ -285,8 +307,8 @@ TMWindow::Disable() // #pragma mark - -TMDescView::TMDescView() - : BBox("descview", B_WILL_DRAW | B_PULSE_NEEDED, B_NO_BORDER), +TeamDescriptionView::TeamDescriptionView() + : BBox("description view", B_WILL_DRAW | B_PULSE_NEEDED, B_NO_BORDER), fItem(NULL), fSeconds(4), fRebootRunner(NULL) @@ -315,14 +337,14 @@ TMDescView::TMDescView() } -TMDescView::~TMDescView() +TeamDescriptionView::~TeamDescriptionView() { delete fRebootRunner; } void -TMDescView::MessageReceived(BMessage* message) +TeamDescriptionView::MessageReceived(BMessage* message) { switch (message->what) { case kMsgRebootTick: @@ -340,7 +362,7 @@ TMDescView::MessageReceived(BMessage* message) void -TMDescView::CtrlAltDelPressed(bool keyDown) +TeamDescriptionView::CtrlAltDelPressed(bool keyDown) { if (!(keyDown ^ fRebootRunner != NULL)) return; @@ -358,7 +380,7 @@ TMDescView::CtrlAltDelPressed(bool keyDown) void -TMDescView::Draw(BRect rect) +TeamDescriptionView::Draw(BRect rect) { rect = Bounds(); @@ -413,7 +435,7 @@ TMDescView::Draw(BRect rect) void -TMDescView::GetPreferredSize(float *_width, float *_height) +TeamDescriptionView::GetPreferredSize(float *_width, float *_height) { if (_width != NULL) { float width = 0; @@ -444,7 +466,7 @@ TMDescView::GetPreferredSize(float *_width, float *_height) void -TMDescView::SetItem(TMListItem *item) +TeamDescriptionView::SetItem(TeamListItem *item) { fItem = item; Invalidate(); diff --git a/src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.h b/src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.h new file mode 100644 index 0000000000..f49ecb6e8d --- /dev/null +++ b/src/add-ons/input_server/devices/keyboard/TeamMonitorWindow.h @@ -0,0 +1,47 @@ +/* + * Copyright 2004-2008, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jérôme Duval + * Axel Doerfler, axeld@pinc-software.de + */ +#ifndef TEAM_MONITOR_WINDOW_H +#define TEAM_MONITOR_WINDOW_H + + +#include +#include +#include +#include + +#include "TeamListItem.h" + + +class TeamDescriptionView; + +class TeamMonitorWindow : public BWindow { +public: + TeamMonitorWindow(); + virtual ~TeamMonitorWindow(); + + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); + + void Enable(); + void Disable(); + +private: + void UpdateList(); + + bool fQuitting; + BMessageRunner* fUpdateRunner; + BListView* fListView; + BButton* fKillButton; + BButton* fRestartButton; + TeamDescriptionView* fDescriptionView; +}; + +static const uint32 kMsgCtrlAltDelPressed = 'TMcp'; + +#endif // TEAM_MONITOR_WINDOW_H