* 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
This commit is contained in:
@@ -9,8 +9,8 @@ Addon <input>keyboard :
|
|||||||
KeyboardInputDevice.cpp
|
KeyboardInputDevice.cpp
|
||||||
Keymap.cpp
|
Keymap.cpp
|
||||||
|
|
||||||
TMWindow.cpp
|
TeamMonitorWindow.cpp
|
||||||
TMListItem.cpp
|
TeamListItem.cpp
|
||||||
|
|
||||||
: input_server be ;
|
: input_server be ;
|
||||||
|
|
||||||
|
|||||||
@@ -657,7 +657,7 @@ KeyboardInputDevice::_DeviceWatcher(void* arg)
|
|||||||
|
|
||||||
// show the team monitor
|
// show the team monitor
|
||||||
if (owner->fTeamMonitorWindow == NULL)
|
if (owner->fTeamMonitorWindow == NULL)
|
||||||
owner->fTeamMonitorWindow = new(std::nothrow) TMWindow();
|
owner->fTeamMonitorWindow = new(std::nothrow) TeamMonitorWindow();
|
||||||
|
|
||||||
if (owner->fTeamMonitorWindow != NULL)
|
if (owner->fTeamMonitorWindow != NULL)
|
||||||
owner->fTeamMonitorWindow->Enable();
|
owner->fTeamMonitorWindow->Enable();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
|
|
||||||
#include "Keymap.h"
|
#include "Keymap.h"
|
||||||
#include "TMWindow.h"
|
#include "TeamMonitorWindow.h"
|
||||||
#include "kb_mouse_settings.h"
|
#include "kb_mouse_settings.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ private:
|
|||||||
|
|
||||||
BObjectList<keyboard_device> fDevices;
|
BObjectList<keyboard_device> fDevices;
|
||||||
Keymap fKeymap;
|
Keymap fKeymap;
|
||||||
TMWindow* fTeamMonitorWindow;
|
TeamMonitorWindow* fTeamMonitorWindow;
|
||||||
BLocker fKeymapLock;
|
BLocker fKeymapLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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 <Bitmap.h>
|
|
||||||
#include <ListItem.h>
|
|
||||||
#include <Path.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2004-2008, Haiku.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Jérôme Duval
|
|
||||||
* Axel Doerfler, [email protected]
|
|
||||||
*/
|
|
||||||
#ifndef TMWINDOW_H
|
|
||||||
#define TMWINDOW_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <Box.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#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
|
|
||||||
+30
-45
@@ -1,39 +1,27 @@
|
|||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
/*
|
||||||
//
|
* Copyright 2004-2008, Haiku.
|
||||||
// Copyright (c) 2004-2005, Haiku
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// This software is part of the Haiku distribution and is covered
|
* Authors:
|
||||||
// by the Haiku license.
|
* Jérôme Duval
|
||||||
//
|
*/
|
||||||
//
|
|
||||||
// File: TMListItem.cpp
|
#include "TeamListItem.h"
|
||||||
// Author: Jérôme Duval
|
|
||||||
// Description: Keyboard input server addon
|
#include <string.h>
|
||||||
// Created : October 24, 2004
|
|
||||||
//
|
|
||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
|
||||||
|
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include "TMListItem.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
static const int32 kItemMargin = 2;
|
static const int32 kItemMargin = 2;
|
||||||
|
|
||||||
|
|
||||||
TMListItem::TMListItem(team_info &tinfo)
|
TeamListItem::TeamListItem(team_info &tinfo)
|
||||||
: BListItem(),
|
:
|
||||||
fInfo(tinfo),
|
fInfo(tinfo),
|
||||||
#ifdef __HAIKU__
|
|
||||||
fIcon(BRect(0, 0, 15, 15), B_RGBA32),
|
fIcon(BRect(0, 0, 15, 15), B_RGBA32),
|
||||||
fLargeIcon(BRect(0, 0, 31, 31), 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;
|
int32 cookie = 0;
|
||||||
image_info info;
|
image_info info;
|
||||||
@@ -47,13 +35,13 @@ TMListItem::TMListItem(team_info &tinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TMListItem::~TMListItem()
|
TeamListItem::~TeamListItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
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 kHighlight = { 140,140,140,0 };
|
||||||
rgb_color kBlack = { 0,0,0,0 };
|
rgb_color kBlack = { 0,0,0,0 };
|
||||||
@@ -63,11 +51,11 @@ TMListItem::DrawItem(BView *owner, BRect frame, bool complete)
|
|||||||
|
|
||||||
if (IsSelected() || complete) {
|
if (IsSelected() || complete) {
|
||||||
rgb_color color;
|
rgb_color color;
|
||||||
if (IsSelected()) {
|
if (IsSelected())
|
||||||
color = kHighlight;
|
color = kHighlight;
|
||||||
} else {
|
else
|
||||||
color = owner->ViewColor();
|
color = owner->ViewColor();
|
||||||
}
|
|
||||||
owner->SetHighColor(color);
|
owner->SetHighColor(color);
|
||||||
owner->SetLowColor(color);
|
owner->SetLowColor(color);
|
||||||
owner->FillRect(r);
|
owner->FillRect(r);
|
||||||
@@ -78,13 +66,10 @@ TMListItem::DrawItem(BView *owner, BRect frame, bool complete)
|
|||||||
|
|
||||||
frame.left += 4;
|
frame.left += 4;
|
||||||
BRect iconFrame(frame);
|
BRect iconFrame(frame);
|
||||||
iconFrame.Set(iconFrame.left, iconFrame.top+1, iconFrame.left+15, iconFrame.top+16);
|
iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15,
|
||||||
#ifdef __HAIKU__
|
iconFrame.top + 16);
|
||||||
owner->SetDrawingMode(B_OP_ALPHA);
|
owner->SetDrawingMode(B_OP_ALPHA);
|
||||||
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
#else
|
|
||||||
owner->SetDrawingMode(B_OP_OVER);
|
|
||||||
#endif
|
|
||||||
owner->DrawBitmap(&fIcon, iconFrame);
|
owner->DrawBitmap(&fIcon, iconFrame);
|
||||||
owner->SetDrawingMode(B_OP_COPY);
|
owner->SetDrawingMode(B_OP_COPY);
|
||||||
|
|
||||||
@@ -95,22 +80,22 @@ TMListItem::DrawItem(BView *owner, BRect frame, bool complete)
|
|||||||
font_height finfo;
|
font_height finfo;
|
||||||
font.GetHeight(&finfo);
|
font.GetHeight(&finfo);
|
||||||
owner->SetFont(&font);
|
owner->SetFont(&font);
|
||||||
owner->MovePenTo(frame.left+8, frame.top + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2) +
|
owner->MovePenTo(frame.left + 8, frame.top + ((frame.Height()
|
||||||
(finfo.ascent + finfo.descent) - 1);
|
- (finfo.ascent + finfo.descent + finfo.leading)) / 2)
|
||||||
|
+ (finfo.ascent + finfo.descent) - 1);
|
||||||
owner->DrawString(fPath.Leaf());
|
owner->DrawString(fPath.Leaf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*static*/
|
/*static*/ int32
|
||||||
int32
|
TeamListItem::MinimalHeight()
|
||||||
TMListItem::MinimalHeight()
|
|
||||||
{
|
{
|
||||||
return 16 + kItemMargin;
|
return 16 + kItemMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
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
|
// we need to override the update method so we can make sure
|
||||||
// the list item size doesn't change
|
// the list item size doesn't change
|
||||||
@@ -120,17 +105,17 @@ TMListItem::Update(BView *owner, const BFont *font)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const team_info *
|
const team_info*
|
||||||
TMListItem::GetInfo()
|
TeamListItem::GetInfo()
|
||||||
{
|
{
|
||||||
return &fInfo;
|
return &fInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TMListItem::IsSystemServer()
|
TeamListItem::IsSystemServer()
|
||||||
{
|
{
|
||||||
char *system = "/boot/beos/system/";
|
char* system = "/boot/beos/system/";
|
||||||
if (strncmp(system, fInfo.args, strlen(system)) == 0)
|
if (strncmp(system, fInfo.args, strlen(system)) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -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 <Bitmap.h>
|
||||||
|
#include <ListItem.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
+50
-28
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
//! Keyboard input server addon
|
//! Keyboard input server addon
|
||||||
|
|
||||||
#include "TMWindow.h"
|
#include "TeamMonitorWindow.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -29,7 +29,29 @@
|
|||||||
#include <tracker_private.h>
|
#include <tracker_private.h>
|
||||||
|
|
||||||
#include "KeyboardInputDevice.h"
|
#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';
|
static const uint32 kMsgUpdate = 'TMup';
|
||||||
@@ -42,7 +64,7 @@ const uint32 TM_SELECTED_TEAM = 'TMst';
|
|||||||
static const uint32 kMsgRebootTick = 'TMrt';
|
static const uint32 kMsgRebootTick = 'TMrt';
|
||||||
|
|
||||||
|
|
||||||
TMWindow::TMWindow()
|
TeamMonitorWindow::TeamMonitorWindow()
|
||||||
: BWindow(BRect(0, 0, 350, 300), "Team Monitor",
|
: BWindow(BRect(0, 0, 350, 300), "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,
|
||||||
@@ -75,7 +97,7 @@ TMWindow::TMWindow()
|
|||||||
|
|
||||||
groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
|
groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
|
||||||
|
|
||||||
fDescriptionView = new TMDescView;
|
fDescriptionView = new TeamDescriptionView;
|
||||||
layout->AddView(fDescriptionView);
|
layout->AddView(fDescriptionView);
|
||||||
|
|
||||||
groupView = new BGroupView(B_HORIZONTAL);
|
groupView = new BGroupView(B_HORIZONTAL);
|
||||||
@@ -121,13 +143,13 @@ TMWindow::TMWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TMWindow::~TMWindow()
|
TeamMonitorWindow::~TeamMonitorWindow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMWindow::MessageReceived(BMessage *msg)
|
TeamMonitorWindow::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case SYSTEM_SHUTTING_DOWN:
|
case SYSTEM_SHUTTING_DOWN:
|
||||||
@@ -151,7 +173,7 @@ TMWindow::MessageReceived(BMessage *msg)
|
|||||||
break;
|
break;
|
||||||
case TM_KILL_APPLICATION:
|
case TM_KILL_APPLICATION:
|
||||||
{
|
{
|
||||||
TMListItem* item = (TMListItem*)fListView->ItemAt(
|
TeamListItem* item = (TeamListItem*)fListView->ItemAt(
|
||||||
fListView->CurrentSelection());
|
fListView->CurrentSelection());
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
kill_team(item->GetInfo()->team);
|
kill_team(item->GetInfo()->team);
|
||||||
@@ -170,7 +192,7 @@ TMWindow::MessageReceived(BMessage *msg)
|
|||||||
case TM_SELECTED_TEAM:
|
case TM_SELECTED_TEAM:
|
||||||
{
|
{
|
||||||
fKillButton->SetEnabled(fListView->CurrentSelection() >= 0);
|
fKillButton->SetEnabled(fListView->CurrentSelection() >= 0);
|
||||||
TMListItem* item = (TMListItem*)fListView->ItemAt(
|
TeamListItem* item = (TeamListItem*)fListView->ItemAt(
|
||||||
fListView->CurrentSelection());
|
fListView->CurrentSelection());
|
||||||
fDescriptionView->SetItem(item);
|
fDescriptionView->SetItem(item);
|
||||||
break;
|
break;
|
||||||
@@ -187,7 +209,7 @@ TMWindow::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TMWindow::QuitRequested()
|
TeamMonitorWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
Disable();
|
Disable();
|
||||||
return fQuitting;
|
return fQuitting;
|
||||||
@@ -195,13 +217,13 @@ TMWindow::QuitRequested()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMWindow::UpdateList()
|
TeamMonitorWindow::UpdateList()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
||||||
TMListItem *item = (TMListItem*)fListView->ItemAt(i);
|
TeamListItem *item = (TeamListItem*)fListView->ItemAt(i);
|
||||||
item->fFound = false;
|
item->SetFound(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
@@ -212,26 +234,26 @@ TMWindow::UpdateList()
|
|||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
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) {
|
if (item->GetInfo()->team == info.team) {
|
||||||
item->fFound = true;
|
item->SetFound(true);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
TMListItem *item = new TMListItem(info);
|
TeamListItem* item = new TeamListItem(info);
|
||||||
|
|
||||||
fListView->AddItem(item,
|
fListView->AddItem(item,
|
||||||
item->IsSystemServer() ? fListView->CountItems() : 0);
|
item->IsSystemServer() ? fListView->CountItems() : 0);
|
||||||
item->fFound = true;
|
item->SetFound(true);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32 i = fListView->CountItems() - 1; i >= 0; i--) {
|
for (int32 i = fListView->CountItems() - 1; i >= 0; i--) {
|
||||||
TMListItem *item = (TMListItem*)fListView->ItemAt(i);
|
TeamListItem *item = (TeamListItem*)fListView->ItemAt(i);
|
||||||
if (!item->fFound) {
|
if (!item->Found()) {
|
||||||
if (item == fDescriptionView->Item()) {
|
if (item == fDescriptionView->Item()) {
|
||||||
fDescriptionView->SetItem(NULL);
|
fDescriptionView->SetItem(NULL);
|
||||||
fKillButton->SetEnabled(false);
|
fKillButton->SetEnabled(false);
|
||||||
@@ -257,7 +279,7 @@ TMWindow::UpdateList()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMWindow::Enable()
|
TeamMonitorWindow::Enable()
|
||||||
{
|
{
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
if (IsHidden()) {
|
if (IsHidden()) {
|
||||||
@@ -273,7 +295,7 @@ TMWindow::Enable()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMWindow::Disable()
|
TeamMonitorWindow::Disable()
|
||||||
{
|
{
|
||||||
fListView->DeselectAll();
|
fListView->DeselectAll();
|
||||||
delete fUpdateRunner;
|
delete fUpdateRunner;
|
||||||
@@ -285,8 +307,8 @@ TMWindow::Disable()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
TMDescView::TMDescView()
|
TeamDescriptionView::TeamDescriptionView()
|
||||||
: BBox("descview", B_WILL_DRAW | B_PULSE_NEEDED, B_NO_BORDER),
|
: BBox("description view", B_WILL_DRAW | B_PULSE_NEEDED, B_NO_BORDER),
|
||||||
fItem(NULL),
|
fItem(NULL),
|
||||||
fSeconds(4),
|
fSeconds(4),
|
||||||
fRebootRunner(NULL)
|
fRebootRunner(NULL)
|
||||||
@@ -315,14 +337,14 @@ TMDescView::TMDescView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TMDescView::~TMDescView()
|
TeamDescriptionView::~TeamDescriptionView()
|
||||||
{
|
{
|
||||||
delete fRebootRunner;
|
delete fRebootRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMDescView::MessageReceived(BMessage* message)
|
TeamDescriptionView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case kMsgRebootTick:
|
case kMsgRebootTick:
|
||||||
@@ -340,7 +362,7 @@ TMDescView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMDescView::CtrlAltDelPressed(bool keyDown)
|
TeamDescriptionView::CtrlAltDelPressed(bool keyDown)
|
||||||
{
|
{
|
||||||
if (!(keyDown ^ fRebootRunner != NULL))
|
if (!(keyDown ^ fRebootRunner != NULL))
|
||||||
return;
|
return;
|
||||||
@@ -358,7 +380,7 @@ TMDescView::CtrlAltDelPressed(bool keyDown)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMDescView::Draw(BRect rect)
|
TeamDescriptionView::Draw(BRect rect)
|
||||||
{
|
{
|
||||||
rect = Bounds();
|
rect = Bounds();
|
||||||
|
|
||||||
@@ -413,7 +435,7 @@ TMDescView::Draw(BRect rect)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMDescView::GetPreferredSize(float *_width, float *_height)
|
TeamDescriptionView::GetPreferredSize(float *_width, float *_height)
|
||||||
{
|
{
|
||||||
if (_width != NULL) {
|
if (_width != NULL) {
|
||||||
float width = 0;
|
float width = 0;
|
||||||
@@ -444,7 +466,7 @@ TMDescView::GetPreferredSize(float *_width, float *_height)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMDescView::SetItem(TMListItem *item)
|
TeamDescriptionView::SetItem(TeamListItem *item)
|
||||||
{
|
{
|
||||||
fItem = item;
|
fItem = item;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004-2008, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Jérôme Duval
|
||||||
|
* Axel Doerfler, [email protected]
|
||||||
|
*/
|
||||||
|
#ifndef TEAM_MONITOR_WINDOW_H
|
||||||
|
#define TEAM_MONITOR_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Box.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <ListView.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#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
|
||||||
Reference in New Issue
Block a user