* 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:
Axel Dörfler 2008-10-21 12:30:25 +00:00
parent 4d34c4eba6
commit 997c3d8afb
9 changed files with 176 additions and 193 deletions

View File

@ -9,8 +9,8 @@ Addon <input>keyboard :
KeyboardInputDevice.cpp
Keymap.cpp
TMWindow.cpp
TMListItem.cpp
TeamMonitorWindow.cpp
TeamListItem.cpp
: input_server be ;

View File

@ -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();

View File

@ -15,7 +15,7 @@
#include <ObjectList.h>
#include "Keymap.h"
#include "TMWindow.h"
#include "TeamMonitorWindow.h"
#include "kb_mouse_settings.h"
@ -73,7 +73,7 @@ private:
BObjectList<keyboard_device> fDevices;
Keymap fKeymap;
TMWindow* fTeamMonitorWindow;
TeamMonitorWindow* fTeamMonitorWindow;
BLocker fKeymapLock;
};

View File

@ -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

View File

@ -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 <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

View File

@ -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 <string.h>
#include <NodeInfo.h>
#include <View.h>
#include "TMListItem.h"
#include <string.h>
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;

View File

@ -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

View File

@ -9,7 +9,7 @@
//! Keyboard input server addon
#include "TMWindow.h"
#include "TeamMonitorWindow.h"
#include <stdio.h>
@ -29,7 +29,29 @@
#include <tracker_private.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';
@ -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();

View File

@ -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 <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