* Moved "install to Deskbar" alert into the application.
* If you install ProcessController to the Deskbar after startup, its window is not opened anymore. * When you install ProcessController, the Deskbar is only restarted if needed; this can probably be removed completely under Haiku. * Renamed some menu items. * Removed "Use Pulse's settings" menu item. * Fixed remaining issues from bug #633 as far as ProcessController was concerned. * Removed unused source files. * Big cleanup, even though there could be done much much more. * Compacted the source files a bit, merged PCView.cpp and PCView2.cpp to ProcessController.cpp to match the name of the class. * Renamed PCUtils.{cpp|h} to Utilities.{cpp|h} git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17647 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
AutoIcon.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,30 +15,30 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "AutoIcon.h"
|
||||
#include "PCUtils.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Entry.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Roster.h>
|
||||
|
||||
AutoIcon::~AutoIcon ()
|
||||
|
||||
AutoIcon::~AutoIcon()
|
||||
{
|
||||
if (fBitmap)
|
||||
delete fBitmap;
|
||||
delete fBitmap;
|
||||
}
|
||||
|
||||
BBitmap* AutoIcon::bitmap ()
|
||||
|
||||
BBitmap*
|
||||
AutoIcon::bitmap()
|
||||
{
|
||||
if (fBitmap == 0)
|
||||
{
|
||||
if (fBitmap == NULL) {
|
||||
fBitmap = new BBitmap (BRect (0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
if (fSignature)
|
||||
{
|
||||
if (fSignature) {
|
||||
entry_ref ref;
|
||||
be_roster->FindApp (fSignature, &ref);
|
||||
if (BNodeInfo::GetTrackerIcon(&ref, fBitmap, B_MINI_ICON) != B_OK)
|
||||
@@ -54,4 +50,3 @@ BBitmap* AutoIcon::bitmap ()
|
||||
return fBitmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
AutoIcon.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,30 +15,31 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _AUTO_ICON_H_
|
||||
#define _AUTO_ICON_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BBitmap;
|
||||
|
||||
class AutoIcon {
|
||||
|
||||
public:
|
||||
AutoIcon (const char* signature): fSignature (signature), fbits (0), fBitmap (0) {}
|
||||
AutoIcon (const uchar* bits): fSignature (0), fbits (bits), fBitmap (0) {}
|
||||
~AutoIcon ();
|
||||
|
||||
operator BBitmap* () { return bitmap (); }
|
||||
BBitmap* bitmap ();
|
||||
|
||||
private:
|
||||
const char* fSignature;
|
||||
const uchar* fbits;
|
||||
BBitmap * fBitmap;
|
||||
class AutoIcon {
|
||||
public:
|
||||
AutoIcon(const char* signature)
|
||||
: fSignature (signature), fbits (0), fBitmap (0) {}
|
||||
AutoIcon(const uchar* bits)
|
||||
: fSignature (0), fbits (bits), fBitmap (0) {}
|
||||
~AutoIcon();
|
||||
|
||||
operator BBitmap*() { return bitmap(); }
|
||||
BBitmap* bitmap();
|
||||
|
||||
private:
|
||||
const char* fSignature;
|
||||
const uchar* fbits;
|
||||
BBitmap * fBitmap;
|
||||
};
|
||||
|
||||
#endif // _AUTO_ICON_H_
|
||||
|
||||
@@ -9,22 +9,17 @@ Application ProcessController :
|
||||
MemoryBarMenu.cpp
|
||||
MemoryBarMenuItem.cpp
|
||||
NoiseBarMenuItem.cpp
|
||||
PCUtils.cpp
|
||||
PCView.cpp
|
||||
PCView2.cpp
|
||||
ProcessController.cpp
|
||||
PCWindow.cpp
|
||||
PCWorld.cpp
|
||||
Preferences.cpp
|
||||
PrintMessage.cpp
|
||||
PriorityMenu.cpp
|
||||
QuitMenu.cpp
|
||||
ReadableLong.cpp
|
||||
TeamBarMenu.cpp
|
||||
TeamBarMenuItem.cpp
|
||||
ThreadBarMenu.cpp
|
||||
ThreadBarMenuItem.cpp
|
||||
URLView.cpp
|
||||
WindowsTools.cpp
|
||||
Utilities.cpp
|
||||
: be
|
||||
: ProcessController.rdef
|
||||
;
|
||||
|
||||
@@ -19,22 +19,23 @@
|
||||
|
||||
|
||||
#include "KernelMemoryBarMenuItem.h"
|
||||
#include "MemoryBarMenu.h"
|
||||
|
||||
#include "Colors.h"
|
||||
#include "PCView.h"
|
||||
#include "MemoryBarMenu.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
KernelMemoryBarMenuItem::KernelMemoryBarMenuItem(system_info* sinfo)
|
||||
KernelMemoryBarMenuItem::KernelMemoryBarMenuItem(system_info& systemInfo)
|
||||
: BMenuItem("System Resources & Caches...", NULL)
|
||||
{
|
||||
fTotalWriteMemory = -1;
|
||||
fLastSum = -1;
|
||||
fGrenze1 = -1;
|
||||
fGrenze2 = -1;
|
||||
fPhsysicalMemory = float(int(sinfo->max_pages * B_PAGE_SIZE / 1024));
|
||||
fCommitedMemory = float(int(sinfo->used_pages * B_PAGE_SIZE / 1024));
|
||||
fPhsysicalMemory = float(int(systemInfo.max_pages * B_PAGE_SIZE / 1024));
|
||||
fCommitedMemory = float(int(systemInfo.used_pages * B_PAGE_SIZE / 1024));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
class KernelMemoryBarMenuItem : public BMenuItem {
|
||||
public:
|
||||
KernelMemoryBarMenuItem(system_info* systemInfo);
|
||||
KernelMemoryBarMenuItem(system_info& systemInfo);
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* _width, float* _height);
|
||||
void DrawBar(bool force);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "MemoryBarMenu.h"
|
||||
#include "MemoryBarMenuItem.h"
|
||||
#include "KernelMemoryBarMenuItem.h"
|
||||
#include "PCView.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Roster.h>
|
||||
@@ -35,18 +35,19 @@
|
||||
float gMemoryTextWidth;
|
||||
|
||||
|
||||
MemoryBarMenu::MemoryBarMenu(const char* name, infosPack *infos, system_info* sinfo)
|
||||
MemoryBarMenu::MemoryBarMenu(const char* name, info_pack* infos,
|
||||
system_info& systemInfo)
|
||||
: BMenu(name),
|
||||
fFirstShow(true)
|
||||
{
|
||||
fTeamCount = sinfo->used_teams + EXTRA;
|
||||
fTeamCount = systemInfo.used_teams + EXTRA;
|
||||
SetFlags(Flags() | B_PULSE_NEEDED);
|
||||
|
||||
fTeamList = (team_id*)malloc(sizeof (team_id) * fTeamCount);
|
||||
|
||||
int k;
|
||||
for (k = 0; k < sinfo->used_teams; k++) {
|
||||
fTeamList[k] = infos[k].tminfo.team;
|
||||
for (k = 0; k < systemInfo.used_teams; k++) {
|
||||
fTeamList[k] = infos[k].team_info.team;
|
||||
}
|
||||
|
||||
while (k < fTeamCount) {
|
||||
@@ -58,7 +59,7 @@ MemoryBarMenu::MemoryBarMenu(const char* name, infosPack *infos, system_info* si
|
||||
fRecycleCount = EXTRA;
|
||||
fRecycleList = (MRecycleItem*)malloc(sizeof(MRecycleItem) * fRecycleCount);
|
||||
SetFont(be_plain_font);
|
||||
AddItem(new KernelMemoryBarMenuItem(sinfo));
|
||||
AddItem(new KernelMemoryBarMenuItem(systemInfo));
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +96,8 @@ MemoryBarMenu::Pulse()
|
||||
int k;
|
||||
MemoryBarMenuItem *item;
|
||||
int total = 0;
|
||||
for (k = 1; (item = (MemoryBarMenuItem*) ItemAt (k)) != NULL; k++) {
|
||||
int m = item->UpdateSituation (commitedMemory);
|
||||
for (k = 1; (item = (MemoryBarMenuItem*)ItemAt(k)) != NULL; k++) {
|
||||
int m = item->UpdateSituation(commitedMemory);
|
||||
if (m < 0) {
|
||||
if (lastRecycle == fRecycleCount) {
|
||||
fRecycleCount += EXTRA;
|
||||
@@ -117,20 +118,20 @@ MemoryBarMenu::Pulse()
|
||||
|
||||
// Look new teams that have appeared. Create an item for them, or recycle from the list.
|
||||
int32 cookie = 0;
|
||||
infosPack infos;
|
||||
info_pack infos;
|
||||
item = NULL;
|
||||
while (get_next_team_info(&cookie, &infos.tminfo) == B_OK) {
|
||||
while (get_next_team_info(&cookie, &infos.team_info) == B_OK) {
|
||||
int j = 0;
|
||||
while (j < fTeamCount && infos.tminfo.team != fTeamList[j]) {
|
||||
while (j < fTeamCount && infos.team_info.team != fTeamList[j]) {
|
||||
j++;
|
||||
}
|
||||
|
||||
if (infos.tminfo.team != fTeamList[j]) {
|
||||
if (infos.team_info.team != fTeamList[j]) {
|
||||
// new team
|
||||
team_info info;
|
||||
team_info info;
|
||||
j = 0;
|
||||
while (j < fTeamCount && fTeamList[j] != -1) {
|
||||
if (get_team_info (fTeamList[j], &info) != B_OK)
|
||||
if (get_team_info(fTeamList[j], &info) != B_OK)
|
||||
fTeamList[j] = -1;
|
||||
else
|
||||
j++;
|
||||
@@ -138,23 +139,23 @@ MemoryBarMenu::Pulse()
|
||||
|
||||
if (j == fTeamCount) {
|
||||
fTeamCount += 10;
|
||||
fTeamList = (team_id*)realloc(fTeamList, sizeof (team_id) * fTeamCount);
|
||||
fTeamList = (team_id*)realloc(fTeamList, sizeof(team_id) * fTeamCount);
|
||||
}
|
||||
|
||||
fTeamList[j] = infos.tminfo.team;
|
||||
fTeamList[j] = infos.team_info.team;
|
||||
if (!get_team_name_and_icon(infos, true)) {
|
||||
// the team is already gone!
|
||||
delete infos.tmicon;
|
||||
delete infos.team_icon;
|
||||
fTeamList[j] = -1;
|
||||
} else {
|
||||
if (!item && firstRecycle < lastRecycle) {
|
||||
if (!item && firstRecycle < lastRecycle)
|
||||
item = fRecycleList[firstRecycle++].item;
|
||||
}
|
||||
|
||||
if (item)
|
||||
item->Reset(infos.tmname, infos.tminfo.team, infos.tmicon, true);
|
||||
item->Reset(infos.team_name, infos.team_info.team, infos.team_icon, true);
|
||||
else {
|
||||
AddItem(item = new MemoryBarMenuItem (infos.tmname,
|
||||
infos.tminfo.team, infos.tmicon, true, NULL));
|
||||
AddItem(item = new MemoryBarMenuItem(infos.team_name,
|
||||
infos.team_info.team, infos.team_icon, true, NULL));
|
||||
}
|
||||
|
||||
int m = item->UpdateSituation(commitedMemory);
|
||||
@@ -178,10 +179,10 @@ MemoryBarMenu::Pulse()
|
||||
lastRecycle - firstRecycle, true);
|
||||
}
|
||||
|
||||
fLastTotalTime = system_time ();
|
||||
fLastTotalTime = system_time();
|
||||
KernelMemoryBarMenuItem *kernelItem;
|
||||
if ((kernelItem = (KernelMemoryBarMenuItem*)ItemAt(0)) != NULL)
|
||||
kernelItem->UpdateSituation (commitedMemory, total);
|
||||
kernelItem->UpdateSituation(commitedMemory, total);
|
||||
|
||||
Window()->EndViewTransaction();
|
||||
Window()->Flush();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define _MEMORY_BAR_MENU_H_
|
||||
|
||||
|
||||
#include "PCUtils.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Menu.h>
|
||||
|
||||
@@ -34,8 +34,8 @@ typedef struct {
|
||||
|
||||
class MemoryBarMenu : public BMenu {
|
||||
public:
|
||||
MemoryBarMenu(const char* name, infosPack *infos,
|
||||
system_info* sinfo);
|
||||
MemoryBarMenu(const char* name, info_pack* infos,
|
||||
system_info& systemInfo);
|
||||
virtual ~MemoryBarMenu();
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "PCView.h"
|
||||
#include "MemoryBarMenuItem.h"
|
||||
#include "MemoryBarMenu.h"
|
||||
|
||||
#include "Colors.h"
|
||||
#include "MemoryBarMenu.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
|
||||
@@ -93,12 +94,18 @@ MemoryBarMenuItem::DrawIcon()
|
||||
void
|
||||
MemoryBarMenuItem::DrawBar(bool force)
|
||||
{
|
||||
// only draw anything if something has changed
|
||||
if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll
|
||||
&& fCommitedMemory == fLastCommited)
|
||||
return;
|
||||
|
||||
bool selected = IsSelected();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu();
|
||||
|
||||
// draw the bar itself
|
||||
BRect cadre(frame.right - kMargin - kBarWidth, frame.top + 5,
|
||||
|
||||
BRect rect(frame.right - kMargin - kBarWidth, frame.top + 5,
|
||||
frame.right - kMargin, frame.top + 13);
|
||||
if (fWriteMemory < 0)
|
||||
return;
|
||||
@@ -111,17 +118,17 @@ MemoryBarMenuItem::DrawBar(bool force)
|
||||
menu->SetHighColor(gFrameColorSelected);
|
||||
else
|
||||
menu->SetHighColor(gFrameColor);
|
||||
menu->StrokeRect(cadre);
|
||||
menu->StrokeRect(rect);
|
||||
}
|
||||
|
||||
cadre.InsetBy(1, 1);
|
||||
BRect r = cadre;
|
||||
float grenze1 = cadre.left + (cadre.right - cadre.left) * float (fWriteMemory) / fCommitedMemory;
|
||||
float grenze2 = cadre.left + (cadre.right - cadre.left) * float (fAllMemory) / fCommitedMemory;
|
||||
if (grenze1 > cadre.right)
|
||||
grenze1 = cadre.right;
|
||||
if (grenze2 > cadre.right)
|
||||
grenze2 = cadre.right;
|
||||
rect.InsetBy(1, 1);
|
||||
BRect r = rect;
|
||||
float grenze1 = rect.left + (rect.right - rect.left) * float(fWriteMemory) / fCommitedMemory;
|
||||
float grenze2 = rect.left + (rect.right - rect.left) * float(fAllMemory) / fCommitedMemory;
|
||||
if (grenze1 > rect.right)
|
||||
grenze1 = rect.right;
|
||||
if (grenze2 > rect.right)
|
||||
grenze2 = rect.right;
|
||||
r.right = grenze1;
|
||||
if (!force)
|
||||
r.left = fGrenze1;
|
||||
@@ -152,7 +159,7 @@ MemoryBarMenuItem::DrawBar(bool force)
|
||||
}
|
||||
|
||||
r.left = grenze2;
|
||||
r.right = cadre.right;
|
||||
r.right = rect.right;
|
||||
|
||||
if (!force)
|
||||
r.right = fGrenze2;
|
||||
@@ -169,41 +176,38 @@ MemoryBarMenuItem::DrawBar(bool force)
|
||||
fGrenze1 = grenze1;
|
||||
fGrenze2 = grenze2;
|
||||
|
||||
// draw the value
|
||||
if (force || fCommitedMemory != fLastCommited || fWriteMemory != fLastWrite
|
||||
|| fAllMemory != fLastAll) {
|
||||
if (selected)
|
||||
menu->SetLowColor(gMenuBackColorSelected);
|
||||
else
|
||||
menu->SetLowColor(gMenuBackColor);
|
||||
fLastCommited = fCommitedMemory;
|
||||
|
||||
if (force || fWriteMemory != fLastWrite || fAllMemory != fLastAll) {
|
||||
menu->SetHighColor(menu->LowColor());
|
||||
BRect trect(cadre.left - kMargin - gMemoryTextWidth, frame.top,
|
||||
cadre.left - kMargin, frame.bottom);
|
||||
menu->FillRect(trect);
|
||||
fLastWrite = fWriteMemory;
|
||||
fLastAll = fAllMemory;
|
||||
}
|
||||
fLastCommited = fCommitedMemory;
|
||||
menu->SetHighColor(kBlack);
|
||||
// Draw the values if necessary; if only fCommitedMemory changes, only
|
||||
// the bar might have to be updated
|
||||
|
||||
char infos[128];
|
||||
// if (fWriteMemory >= 1024)
|
||||
// sprintf(infos, "%.1f MB", float (fWriteMemory) / 1024.f);
|
||||
// else
|
||||
sprintf(infos, "%d KB", fWriteMemory);
|
||||
if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll)
|
||||
return;
|
||||
|
||||
BPoint loc(cadre.left - kMargin - gMemoryTextWidth / 2 - menu->StringWidth (infos),
|
||||
cadre.bottom + 1);
|
||||
menu->DrawString(infos, loc);
|
||||
// if (fAllMemory >= 1024)
|
||||
// sprintf (infos, "%.1f MB", float (fAllMemory) / 1024.f);
|
||||
// else
|
||||
sprintf(infos, "%d KB", fAllMemory);
|
||||
loc.x = cadre.left - kMargin - menu->StringWidth(infos);
|
||||
menu->DrawString(infos, loc);
|
||||
}
|
||||
if (selected)
|
||||
menu->SetLowColor(gMenuBackColorSelected);
|
||||
else
|
||||
menu->SetLowColor(gMenuBackColor);
|
||||
|
||||
BRect textRect(rect.left - kMargin - gMemoryTextWidth, frame.top,
|
||||
rect.left - kMargin, frame.bottom);
|
||||
menu->FillRect(textRect, B_SOLID_LOW);
|
||||
|
||||
fLastWrite = fWriteMemory;
|
||||
fLastAll = fAllMemory;
|
||||
|
||||
menu->SetHighColor(kBlack);
|
||||
|
||||
char infos[128];
|
||||
sprintf(infos, "%d KB", fWriteMemory);
|
||||
|
||||
BPoint loc(rect.left - kMargin - gMemoryTextWidth / 2 - menu->StringWidth(infos),
|
||||
rect.bottom + 1);
|
||||
menu->DrawString(infos, loc);
|
||||
|
||||
sprintf(infos, "%d KB", fAllMemory);
|
||||
loc.x = rect.left - kMargin - menu->StringWidth(infos);
|
||||
menu->DrawString(infos, loc);
|
||||
}
|
||||
|
||||
|
||||
@@ -240,11 +244,11 @@ MemoryBarMenuItem::BarUpdate()
|
||||
lram_size += ainfo.ram_size;
|
||||
|
||||
// TODO: this won't work this way anymore under Haiku!
|
||||
int zone = (int (ainfo.address) & 0xf0000000) >> 24;
|
||||
if ((ainfo.protection & B_WRITE_AREA)
|
||||
&& (zone & 0xf0) != 0xA0 // Exclude media buffers
|
||||
&& (fTeamID != gAppServerTeamID || zone != 0x90)) // Exclude app_server side of bitmaps
|
||||
// int zone = (int (ainfo.address) & 0xf0000000) >> 24;
|
||||
if ((ainfo.protection & B_WRITE_AREA) != 0)
|
||||
lwram_size += ainfo.ram_size;
|
||||
// && (zone & 0xf0) != 0xA0 // Exclude media buffers
|
||||
// && (fTeamID != gAppServerTeamID || zone != 0x90)) // Exclude app_server side of bitmaps
|
||||
}
|
||||
if (!exists) {
|
||||
team_info info;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
NoiseBarMenuItem.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,16 +15,17 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "NoiseBarMenuItem.h"
|
||||
#include "Colors.h"
|
||||
#include "PCView.h"
|
||||
|
||||
// --------------------------------------------------------------
|
||||
#include "NoiseBarMenuItem.h"
|
||||
|
||||
#include "Colors.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
|
||||
NoiseBarMenuItem::NoiseBarMenuItem()
|
||||
:BMenuItem("Gone Teams...", NULL)
|
||||
: BMenuItem("Gone Teams...", NULL)
|
||||
{
|
||||
fBusyWaiting = -1;
|
||||
fLost = -1;
|
||||
@@ -36,20 +33,22 @@ NoiseBarMenuItem::NoiseBarMenuItem()
|
||||
fGrenze2 = -1;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void NoiseBarMenuItem::DrawContent()
|
||||
|
||||
void
|
||||
NoiseBarMenuItem::DrawContent()
|
||||
{
|
||||
DrawBar(true);
|
||||
Menu()->MovePenTo(ContentLocation());
|
||||
BMenuItem::DrawContent();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void NoiseBarMenuItem::DrawBar(bool force)
|
||||
|
||||
void
|
||||
NoiseBarMenuItem::DrawBar(bool force)
|
||||
{
|
||||
bool selected = IsSelected ();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu ();
|
||||
bool selected = IsSelected ();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu ();
|
||||
frame.right -= 24;
|
||||
frame.left = frame.right-kBarWidth;
|
||||
frame.top += 5;
|
||||
@@ -66,9 +65,9 @@ void NoiseBarMenuItem::DrawBar(bool force)
|
||||
menu->StrokeRect(frame);
|
||||
}
|
||||
frame.InsetBy(1, 1);
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fBusyWaiting;
|
||||
float grenze2 = frame.left+(frame.right-frame.left)*(fBusyWaiting+fLost);
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fBusyWaiting;
|
||||
float grenze2 = frame.left+(frame.right-frame.left)*(fBusyWaiting+fLost);
|
||||
if (grenze1 > frame.right)
|
||||
grenze1 = frame.right;
|
||||
if (grenze2 > frame.right)
|
||||
@@ -78,7 +77,7 @@ void NoiseBarMenuItem::DrawBar(bool force)
|
||||
r.left = fGrenze1;
|
||||
if (r.left < r.right) {
|
||||
if (selected)
|
||||
menu->SetHighColor (tint_color (kGreen, B_HIGHLIGHT_BACKGROUND_TINT));
|
||||
menu->SetHighColor(tint_color (kGreen, B_HIGHLIGHT_BACKGROUND_TINT));
|
||||
else
|
||||
menu->SetHighColor(kGreen);
|
||||
// menu->SetHighColor(gKernelColor);
|
||||
@@ -113,8 +112,9 @@ void NoiseBarMenuItem::DrawBar(bool force)
|
||||
fGrenze2 = grenze2;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void NoiseBarMenuItem::GetContentSize(float* width, float* height)
|
||||
|
||||
void
|
||||
NoiseBarMenuItem::GetContentSize(float* width, float* height)
|
||||
{
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
if (*height < 16)
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
PCUtils.cpp
|
||||
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "PCUtils.h"
|
||||
#include "PCWorld.h"
|
||||
#include "PCView.h"
|
||||
#include "icons.data"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Deskbar.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Path.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define snooze_time 1000000
|
||||
|
||||
team_id gAppServerTeamID = -1;
|
||||
|
||||
|
||||
bool
|
||||
get_team_name_and_icon(infosPack& infopack, bool icon)
|
||||
{
|
||||
if (gAppServerTeamID == -1 && !strcmp(infopack.tminfo.args, "/boot/beos/system/servers/app_server"))
|
||||
gAppServerTeamID = infopack.tminfo.team;
|
||||
|
||||
bool nameFromArgs = false;
|
||||
bool tryTrackerIcon = true;
|
||||
|
||||
for (int len = strlen(infopack.tminfo.args) - 1; len >= 0 && infopack.tminfo.args[len] == ' '; len--) {
|
||||
infopack.tminfo.args[len] = 0;
|
||||
}
|
||||
|
||||
app_info info;
|
||||
status_t status = be_roster->GetRunningAppInfo(infopack.tminfo.team, &info);
|
||||
if (status == B_OK || infopack.tminfo.team == B_SYSTEM_TEAM) {
|
||||
if (infopack.tminfo.team == B_SYSTEM_TEAM) {
|
||||
BPath kernel;
|
||||
find_directory(B_BEOS_SYSTEM_DIRECTORY, &kernel, true);
|
||||
system_info sinfo;
|
||||
get_system_info(&sinfo);
|
||||
kernel.Append(sinfo.kernel_name);
|
||||
get_ref_for_path(kernel.Path(), &info.ref);
|
||||
nameFromArgs = true;
|
||||
}
|
||||
} else {
|
||||
BEntry entry(infopack.tminfo.args, true);
|
||||
status = entry.GetRef(&info.ref);
|
||||
if (status != B_OK || strncmp(infopack.tminfo.args, "/boot/beos/system/", 18) != 0)
|
||||
nameFromArgs = true;
|
||||
tryTrackerIcon = (status == B_OK);
|
||||
}
|
||||
|
||||
strncpy(infopack.tmname, nameFromArgs ? infopack.tminfo.args : info.ref.name,
|
||||
B_PATH_NAME_LENGTH - 1);
|
||||
|
||||
if (icon) {
|
||||
infopack.tmicon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
if (!tryTrackerIcon || BNodeInfo::GetTrackerIcon(&info.ref, infopack.tmicon, B_MINI_ICON) != B_OK)
|
||||
infopack.tmicon->SetBits(k_app_mini, 256, 0, B_COLOR_8_BIT);
|
||||
} else
|
||||
infopack.tmicon = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
launch(const char* signature, const char* path)
|
||||
{
|
||||
status_t status = be_roster->Launch(signature);
|
||||
if (status != B_OK && path) {
|
||||
entry_ref ref;
|
||||
if (get_ref_for_path(path, &ref) == B_OK)
|
||||
status = be_roster->Launch(&ref);
|
||||
}
|
||||
return status == B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mix_colors(rgb_color &target, rgb_color & first, rgb_color & second, float mix)
|
||||
{
|
||||
target.red = (uint8)(second.red * mix + (1. - mix) * first.red);
|
||||
target.green = (uint8)(second.green * mix + (1. - mix) * first.green);
|
||||
target.blue = (uint8)(second.blue * mix + (1. - mix) * first.blue);
|
||||
target.alpha = (uint8)(second.alpha * mix + (1. - mix) * first.alpha);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
find_self(entry_ref& ref)
|
||||
{
|
||||
int32 cookie = 0;
|
||||
image_info info;
|
||||
while (get_next_image_info (0, &cookie, &info) == B_OK) {
|
||||
if (((uint32) info.text <= (uint32) move_to_deskbar
|
||||
&& (uint32) info.text + (uint32) info.text_size > (uint32) move_to_deskbar)
|
||||
|| ((uint32) info.data <= (uint32) move_to_deskbar
|
||||
&& (uint32) info.data + (uint32) info.data_size > (uint32) move_to_deskbar)) {
|
||||
if (get_ref_for_path (info.name, &ref) == B_OK)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This works, but not always... :(
|
||||
app_info appInfo;
|
||||
be_roster->GetAppInfo(kSignature, &appInfo);
|
||||
ref = appInfo.ref;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
move_to_deskbar(BDeskbar& deskbar)
|
||||
{
|
||||
entry_ref ref;
|
||||
find_self(ref);
|
||||
|
||||
deskbar.AddItem(&ref);
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
/*
|
||||
PCView2.cpp
|
||||
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "PCView.h"
|
||||
|
||||
#include "AutoIcon.h"
|
||||
#include "IconMenuItem.h"
|
||||
#include "MemoryBarMenu.h"
|
||||
#include "MemoryBarMenuItem.h"
|
||||
#include "PCUtils.h"
|
||||
#include "PCWorld.h"
|
||||
#include "Preferences.h"
|
||||
#include "QuitMenu.h"
|
||||
#include "TeamBarMenu.h"
|
||||
#include "TeamBarMenuItem.h"
|
||||
#include "ThreadBarMenu.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Deskbar.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define addtopbottom(x) if (top) popup->AddItem(x); else popup->AddItem(x, 0)
|
||||
|
||||
long thread_popup(void *arg);
|
||||
|
||||
int32 gPopupFlag = 0;
|
||||
thread_id gPopupThreadID = 0;
|
||||
|
||||
typedef struct {
|
||||
BPoint where;
|
||||
BRect clickToOpenRect;
|
||||
bool top;
|
||||
} Tpopup_param;
|
||||
|
||||
|
||||
void
|
||||
ProcessController::MouseDown(BPoint where)
|
||||
{
|
||||
if (atomic_add (&gPopupFlag, 1) > 0) {
|
||||
atomic_add (&gPopupFlag, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
Tpopup_param* param = new Tpopup_param;
|
||||
ConvertToScreen(&where);
|
||||
param->where = where;
|
||||
param->clickToOpenRect = Frame ();
|
||||
ConvertToScreen (¶m->clickToOpenRect);
|
||||
param->top = where.y < BScreen(this->Window()).Frame().bottom-50;
|
||||
|
||||
gPopupThreadID = spawn_thread(thread_popup, "Popup holder thread",
|
||||
B_URGENT_DISPLAY_PRIORITY, param);
|
||||
resume_thread(gPopupThreadID);
|
||||
}
|
||||
|
||||
|
||||
long
|
||||
thread_popup(void *arg)
|
||||
{
|
||||
Tpopup_param* param = (Tpopup_param*) arg;
|
||||
int32 mcookie, hcookie;
|
||||
long m, h;
|
||||
BMenuItem* item;
|
||||
bool top = param->top;
|
||||
|
||||
system_info systemInfo;
|
||||
get_system_info(&systemInfo);
|
||||
infosPack* infos = new infosPack[systemInfo.used_teams];
|
||||
// TODO: this doesn't necessarily get all teams
|
||||
for (m = 0, mcookie = 0; m < systemInfo.used_teams; m++) {
|
||||
infos[m].tmicon = NULL;
|
||||
infos[m].tmname[0] = 0;
|
||||
infos[m].thinfo = NULL;
|
||||
if (get_next_team_info(&mcookie, &infos[m].tminfo) == B_OK) {
|
||||
infos[m].thinfo = new thread_info[infos[m].tminfo.thread_count];
|
||||
for (h = 0, hcookie = 0; h < infos[m].tminfo.thread_count; h++) {
|
||||
if (get_next_thread_info(infos[m].tminfo.team, &hcookie, &infos[m].thinfo[h]) != B_OK)
|
||||
infos[m].thinfo[h].thread = -1;
|
||||
}
|
||||
get_team_name_and_icon(infos[m], true);
|
||||
} else {
|
||||
systemInfo.used_teams = m;
|
||||
infos[m].tminfo.team = -1;
|
||||
}
|
||||
}
|
||||
|
||||
BPopUpMenu* popup = new BPopUpMenu("Global Popup", false, false);
|
||||
popup->SetFont(be_plain_font);
|
||||
|
||||
// Quit section
|
||||
BMenu* QuitPopup = new QuitMenu("Quit an Application", infos, systemInfo.used_teams);
|
||||
QuitPopup->SetFont(be_plain_font);
|
||||
popup->AddItem(QuitPopup);
|
||||
|
||||
// Memory Usage section
|
||||
MemoryBarMenu* MemoryPopup = new MemoryBarMenu("Spy Memory Usage", infos, &systemInfo);
|
||||
int commitedMemory = int(systemInfo.used_pages * B_PAGE_SIZE / 1024);
|
||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||
if (infos[m].tminfo.team >= 0) {
|
||||
MemoryBarMenuItem* memoryItem = new MemoryBarMenuItem(infos[m].tmname, infos[m].tminfo.team, infos[m].tmicon, false, NULL);
|
||||
MemoryPopup->AddItem(memoryItem);
|
||||
memoryItem->UpdateSituation(commitedMemory);
|
||||
}
|
||||
}
|
||||
|
||||
addtopbottom(MemoryPopup);
|
||||
|
||||
// CPU Load section
|
||||
TeamBarMenu* CPUPopup = new TeamBarMenu("Kill, Debug, or Change Priority", infos, systemInfo.used_teams);
|
||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||
if (infos[m].tminfo.team >= 0) {
|
||||
ThreadBarMenu* TeamPopup = new ThreadBarMenu(infos[m].tmname, infos[m].tminfo.team, infos[m].tminfo.thread_count);
|
||||
BMessage* kill_team = new BMessage('KlTm');
|
||||
kill_team->AddInt32("team", infos[m].tminfo.team);
|
||||
TeamBarMenuItem* item = new TeamBarMenuItem(TeamPopup, kill_team, infos[m].tminfo.team, infos[m].tmicon, false);
|
||||
item->SetTarget(gPCView);
|
||||
CPUPopup->AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
addtopbottom(CPUPopup);
|
||||
addtopbottom(new BSeparatorItem());
|
||||
|
||||
// CPU on/off section
|
||||
if (gCPUcount > 1) {
|
||||
for (int i = 0; i < gCPUcount; i++) {
|
||||
char item_name[32];
|
||||
sprintf (item_name, "Processor %d", i + 1);
|
||||
BMessage* m = new BMessage ('CPU ');
|
||||
m->AddInt32 ("cpu", i);
|
||||
item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m);
|
||||
if (_kget_cpu_state_(i))
|
||||
item->SetMarked (true);
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
addtopbottom (new BSeparatorItem ());
|
||||
}
|
||||
|
||||
if (!be_roster->IsRunning(kTrackerSig)) {
|
||||
item = new IconMenuItem(gPCView->fTrackerIcon, "Launch Tracker", new BMessage('Trac'));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
if (!be_roster->IsRunning(kDeskbarSig)) {
|
||||
item = new IconMenuItem(gPCView->fDeskbarIcon, "Launch Deskbar", new BMessage('Dbar'));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
|
||||
item = new IconMenuItem(gPCView->fTerminalIcon, "New Terminal", new BMessage('Term'));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
|
||||
addtopbottom(new BSeparatorItem());
|
||||
|
||||
if (be_roster->IsRunning(kDeskbarSig)) {
|
||||
item = new BMenuItem("Live in the Deskbar", new BMessage ('AlDb'));
|
||||
BDeskbar db;
|
||||
item->SetMarked (gInDeskbar || db.HasItem (kDeskbarItemName));
|
||||
item->SetTarget (gPCView);
|
||||
addtopbottom (item);
|
||||
}
|
||||
|
||||
item = new BMenuItem("Use Pulse's Settings for Colors", new BMessage ('Colo'));
|
||||
item->SetTarget (gPCView);
|
||||
item->SetMarked (gMimicPulse);
|
||||
addtopbottom (item);
|
||||
|
||||
addtopbottom(new BSeparatorItem ());
|
||||
|
||||
item = new IconMenuItem(gPCView->fProcessControllerIcon, "About ProcessController",
|
||||
new BMessage(B_ABOUT_REQUESTED));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
|
||||
param->where.x -= 5;
|
||||
param->where.y -= 8;
|
||||
popup->Go(param->where, true, true, param->clickToOpenRect);
|
||||
|
||||
delete popup;
|
||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||
if (infos[m].tminfo.team >= 0) {
|
||||
delete[] infos[m].thinfo;
|
||||
delete infos[m].tmicon;
|
||||
}
|
||||
}
|
||||
delete[] infos;
|
||||
delete param;
|
||||
atomic_add (&gPopupFlag, -1);
|
||||
gPopupThreadID = 0;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
PCWindow.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,95 +15,65 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "PCWorld.h"
|
||||
#include "PCWindow.h"
|
||||
#include "PCView.h"
|
||||
#include "Preferences.h"
|
||||
#include "PCUtils.h"
|
||||
#include <StringView.h>
|
||||
#include <Dragger.h>
|
||||
#include <Deskbar.h>
|
||||
#include "ProcessController.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Deskbar.h>
|
||||
#include <Dragger.h>
|
||||
#include <Roster.h>
|
||||
#include <StringView.h>
|
||||
|
||||
const char* kPosPrefName = "Position";
|
||||
const char* kVersionName = "Version";
|
||||
const int kCurrentVersion = 310;
|
||||
|
||||
PCWindow::PCWindow():BWindow(BRect(100, 150, 590, 175), "ProcessController", B_TITLED_WINDOW, B_NOT_ZOOMABLE+B_NOT_RESIZABLE, 0)
|
||||
PCWindow::PCWindow()
|
||||
: BWindow(BRect(100, 150, 131, 181), "ProcessController", B_TITLED_WINDOW,
|
||||
B_NOT_H_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
BView *topview;
|
||||
BStringView *manuel;
|
||||
BRect rect;
|
||||
GebsPreferences preferences(kPreferencesFileName);
|
||||
preferences.SaveInt32(kCurrentVersion, kVersionName);
|
||||
preferences.LoadWindowPosition(this, kPosPrefName);
|
||||
|
||||
GebsPreferences tPreferences(kPreferencesFileName);
|
||||
int32 version = 0;
|
||||
tPreferences.ReadInt32 (version, kVersionName);
|
||||
if (version != kCurrentVersion)
|
||||
{
|
||||
BAlert* alert = new BAlert("", "Do you want ProcessController to live in the Deskbar?",
|
||||
"Don't", "Install", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
if (alert->Go())
|
||||
{
|
||||
team_id deskbar = be_roster->TeamFor (kDeskbarSig);
|
||||
if (deskbar >= 0)
|
||||
{
|
||||
BMessenger messenger (NULL, deskbar);
|
||||
messenger.SendMessage (B_QUIT_REQUESTED);
|
||||
int k = 500;
|
||||
do {
|
||||
snooze (10000);
|
||||
} while (be_roster->IsRunning (kDeskbarSig) && k-- > 0);
|
||||
}
|
||||
be_roster->Launch (kDeskbarSig);
|
||||
int k = 500;
|
||||
do {
|
||||
snooze (10000);
|
||||
} while (!be_roster->IsRunning (kDeskbarSig) && k-- > 0);
|
||||
BDeskbar db;
|
||||
if (!db.HasItem (kDeskbarItemName))
|
||||
move_to_deskbar (db);
|
||||
}
|
||||
}
|
||||
tPreferences.SaveInt32 (kCurrentVersion, kVersionName);
|
||||
tPreferences.LoadWindowPosition(this, kPosPrefName);
|
||||
rect = Bounds();
|
||||
AddChild(topview = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW));
|
||||
topview->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
rect.left = 28;
|
||||
rect.top = 9;
|
||||
rect.bottom = rect.top+16;
|
||||
manuel = new BStringView(rect, NULL, "Drag this Replicant out of here, or click on it, and ask it to \"Live in the Deskbar\"");
|
||||
topview->AddChild(manuel);
|
||||
manuel->SetFont(be_bold_font);
|
||||
SetSizeLimits(Bounds().Width(), Bounds().Width(), 31, 32767);
|
||||
BRect rect = Bounds();
|
||||
|
||||
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(topView);
|
||||
|
||||
// set up a rectangle && instantiate a new view
|
||||
// view rect should be same size as window rect but with left top at (0, 0)
|
||||
rect.Set(0, 0, 15, 15);
|
||||
rect.OffsetTo(8, 9);
|
||||
topview->AddChild(new ProcessController(rect));
|
||||
|
||||
rect.OffsetTo((Bounds().Width() - 16) / 2, (Bounds().Height() - 16) / 2);
|
||||
topView->AddChild(new ProcessController(rect));
|
||||
|
||||
// make window visible
|
||||
Show();
|
||||
wasShowing = BDragger::AreDraggersDrawn ();
|
||||
BDragger::ShowAllDraggers ();
|
||||
fDraggersAreDrawn = BDragger::AreDraggersDrawn();
|
||||
BDragger::ShowAllDraggers();
|
||||
}
|
||||
|
||||
PCWindow::~PCWindow ()
|
||||
|
||||
PCWindow::~PCWindow()
|
||||
{
|
||||
if (!wasShowing)
|
||||
BDragger::HideAllDraggers ();
|
||||
if (!fDraggersAreDrawn)
|
||||
BDragger::HideAllDraggers();
|
||||
}
|
||||
|
||||
bool PCWindow::QuitRequested()
|
||||
|
||||
bool
|
||||
PCWindow::QuitRequested()
|
||||
{
|
||||
GebsPreferences tPreferences(kPreferencesFileName);
|
||||
tPreferences.SaveWindowPosition(this, kPosPrefName);
|
||||
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
PCWindow.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,23 +15,23 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _PCWINDOW_H_
|
||||
#define _PCWINDOW_H_
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
class PCWindow : public BWindow {
|
||||
public:
|
||||
PCWindow();
|
||||
~PCWindow();
|
||||
|
||||
public:
|
||||
PCWindow();
|
||||
~PCWindow();
|
||||
virtual bool QuitRequested();
|
||||
virtual bool QuitRequested();
|
||||
|
||||
private:
|
||||
bool wasShowing;
|
||||
private:
|
||||
bool fDraggersAreDrawn;
|
||||
};
|
||||
|
||||
#endif // _PCWINDOW_H_
|
||||
|
||||
@@ -22,21 +22,38 @@
|
||||
|
||||
#include "PCWorld.h"
|
||||
#include "PCWindow.h"
|
||||
#include "PCView.h"
|
||||
#include "PCUtils.h"
|
||||
#include "Preferences.h"
|
||||
#include "ProcessController.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Roster.h>
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Deskbar.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
class PCApplication : public BApplication {
|
||||
public:
|
||||
PCApplication();
|
||||
virtual ~PCApplication();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
virtual void ArgvReceived(int32 argc, char **argv);
|
||||
};
|
||||
|
||||
|
||||
const char* kSignature = "application/x-vnd.Geb-ProcessController";
|
||||
const char* kTrackerSig = "application/x-vnd.Be-TRAK";
|
||||
const char* kDeskbarSig = "application/x-vnd.Be-TSKB";
|
||||
const char* kTerminalSig = "application/x-vnd.Haiku-Terminal";
|
||||
const char* kPreferencesFileName = "ProcessController Prefs";
|
||||
|
||||
const char* kPosPrefName = "Position";
|
||||
const char* kVersionName = "Version";
|
||||
const int kCurrentVersion = 311;
|
||||
|
||||
thread_id id = 0;
|
||||
|
||||
@@ -59,8 +76,51 @@ PCApplication::~PCApplication()
|
||||
void
|
||||
PCApplication::ReadyToRun()
|
||||
{
|
||||
GebsPreferences preferences(kPreferencesFileName);
|
||||
int32 version = 0;
|
||||
preferences.ReadInt32(version, kVersionName);
|
||||
if (version != kCurrentVersion) {
|
||||
BAlert* alert = new BAlert("", "Do you want ProcessController to live in the Deskbar?",
|
||||
"Don't", "Install", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
|
||||
if (alert->Go()) {
|
||||
bool hasOne = false;
|
||||
{
|
||||
BDeskbar deskbar;
|
||||
if (deskbar.HasItem(kDeskbarItemName))
|
||||
hasOne = true;
|
||||
}
|
||||
|
||||
if (hasOne) {
|
||||
// Restart deskbar to make sure the new version is picked up
|
||||
team_id deskbarTeam = be_roster->TeamFor(kDeskbarSig);
|
||||
if (deskbarTeam >= 0) {
|
||||
BMessenger messenger(NULL, deskbarTeam);
|
||||
messenger.SendMessage(B_QUIT_REQUESTED);
|
||||
int k = 500;
|
||||
do {
|
||||
snooze (10000);
|
||||
} while (be_roster->IsRunning(kDeskbarSig) && k-- > 0);
|
||||
}
|
||||
be_roster->Launch(kDeskbarSig);
|
||||
int k = 500;
|
||||
do {
|
||||
snooze (10000);
|
||||
} while (!be_roster->IsRunning(kDeskbarSig) && k-- > 0);
|
||||
}
|
||||
|
||||
BDeskbar deskbar;
|
||||
if (!deskbar.HasItem(kDeskbarItemName))
|
||||
move_to_deskbar(deskbar);
|
||||
|
||||
Quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new PCWindow();
|
||||
|
||||
|
||||
// quit other eventually running instances
|
||||
BList list;
|
||||
be_roster->GetAppList(kSignature, &list);
|
||||
@@ -77,7 +137,7 @@ PCApplication::ReadyToRun()
|
||||
|
||||
|
||||
void
|
||||
PCApplication::ArgvReceived (int32 argc, char **argv)
|
||||
PCApplication::ArgvReceived(int32 argc, char **argv)
|
||||
{
|
||||
if (argc == 2 && strcmp(argv[1], "-desktop-reset") == 0) {
|
||||
team_id tracker = be_roster->TeamFor(kTrackerSig);
|
||||
@@ -97,8 +157,8 @@ PCApplication::ArgvReceived (int32 argc, char **argv)
|
||||
move_to_deskbar(deskbar);
|
||||
} else if (argc > 1) {
|
||||
// print a simple usage string
|
||||
printf( "Usage: %s [-deskbar]\n", argv[0]);
|
||||
printf( "(c) 1997-2001 Georges-Edouard Berenger, [email protected]\n");
|
||||
printf("Usage: %s [-deskbar]\n", argv[0]);
|
||||
printf("(c) 1996-2001 Georges-Edouard Berenger, [email protected]\n");
|
||||
}
|
||||
|
||||
Quit();
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
PCWorld.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,38 +15,34 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _PCWORLD_H_
|
||||
#define _PCWORLD_H_
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
extern const char *kSignature;
|
||||
extern const char *kTrackerSig;
|
||||
extern const char *kDeskbarSig;
|
||||
extern const char *kTerminalSig;
|
||||
#include <OS.h>
|
||||
|
||||
extern const char *kPosPrefName;
|
||||
extern const char *kPreferencesFileName;
|
||||
|
||||
class PCApplication : public BApplication {
|
||||
extern const char* kSignature;
|
||||
extern const char* kTrackerSig;
|
||||
extern const char* kDeskbarSig;
|
||||
extern const char* kTerminalSig;
|
||||
|
||||
public:
|
||||
PCApplication();
|
||||
~PCApplication();
|
||||
virtual void ReadyToRun();
|
||||
virtual void ArgvReceived(int32 argc, char **argv);
|
||||
};
|
||||
extern const char* kPosPrefName;
|
||||
extern const char* kPreferencesFileName;
|
||||
|
||||
extern const uchar k_app_mini[];
|
||||
extern const char* kProgramName;
|
||||
extern const char* kPCSemaphoreName;
|
||||
extern const char* kPosPrefName;
|
||||
extern const char* kVersionName;
|
||||
extern const int kCurrentVersion;
|
||||
|
||||
extern thread_id id;
|
||||
|
||||
extern "C" int _kget_cpu_state_ (int cpu);
|
||||
extern "C" int _kset_cpu_state_ (int cpu, int enabled);
|
||||
extern const uchar k_app_mini[];
|
||||
extern const char* kProgramName;
|
||||
extern const char* kPCSemaphoreName;
|
||||
|
||||
extern thread_id id;
|
||||
|
||||
extern "C" int _kget_cpu_state_(int cpu);
|
||||
extern "C" int _kset_cpu_state_(int cpu, int enabled);
|
||||
|
||||
#endif // _PCWORLD_H_
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
Preferences.cpp
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,187 +15,209 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "Preferences.h"
|
||||
#include "Locker.h"
|
||||
#include "WindowsTools.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Path.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Alert.h>
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Locker.h>
|
||||
#include <Mime.h>
|
||||
#include <Alert.h>
|
||||
#include <Path.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* kDirectory = "Geb";
|
||||
|
||||
GebsPreferences::GebsPreferences(const char* thename, const char* thesignature, bool doSave) : BMessage('Pref'), BLocker("Preferences", true), fSavePreferences(doSave)
|
||||
GebsPreferences::GebsPreferences(const char* name, const char* signature, bool doSave)
|
||||
: BMessage('Pref'), BLocker("Preferences", true),
|
||||
fSavePreferences(doSave)
|
||||
{
|
||||
fNewPreferences = false;
|
||||
fSettingsFile = 0;
|
||||
BPath prefpath;
|
||||
fName=strdup(thename);
|
||||
if (thesignature)
|
||||
fSignature=strdup(thesignature);
|
||||
BPath prefpath;
|
||||
fName = strdup(name);
|
||||
if (signature)
|
||||
fSignature = strdup(signature);
|
||||
else
|
||||
fSignature=NULL;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &prefpath)==B_OK) {
|
||||
BDirectory prefdir(prefpath.Path());
|
||||
BEntry entry;
|
||||
prefdir.FindEntry(kDirectory, &entry, true);
|
||||
prefdir.SetTo(&entry);
|
||||
fSignature = NULL;
|
||||
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &prefpath) == B_OK) {
|
||||
BDirectory prefdir(prefpath.Path());
|
||||
BEntry entry;
|
||||
prefdir.FindEntry(fName, &entry);
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
if (file.InitCheck()==B_OK)
|
||||
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK)
|
||||
Unflatten(&file);
|
||||
else
|
||||
fNewPreferences=true;
|
||||
fNewPreferences = true;
|
||||
}
|
||||
}
|
||||
|
||||
GebsPreferences::GebsPreferences(const entry_ref &ref, const char* thesignature, bool doSave)
|
||||
: BMessage('Pref'), BLocker("Preferences", true), fSavePreferences (doSave)
|
||||
|
||||
GebsPreferences::GebsPreferences(const entry_ref &ref, const char* signature, bool doSave)
|
||||
: BMessage('Pref'), BLocker("Preferences", true),
|
||||
fSavePreferences(doSave)
|
||||
{
|
||||
fSettingsFile = new entry_ref (ref);
|
||||
fSettingsFile = new entry_ref(ref);
|
||||
fNewPreferences = false;
|
||||
BPath prefpath;
|
||||
fName = 0;
|
||||
if (thesignature)
|
||||
fSignature = strdup(thesignature);
|
||||
BPath prefpath;
|
||||
fName = NULL;
|
||||
if (signature)
|
||||
fSignature = strdup(signature);
|
||||
else
|
||||
fSignature = NULL;
|
||||
BFile file (fSettingsFile, B_READ_ONLY);
|
||||
|
||||
BFile file(fSettingsFile, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK)
|
||||
Unflatten(&file);
|
||||
else
|
||||
fNewPreferences = true;
|
||||
}
|
||||
|
||||
|
||||
GebsPreferences::~GebsPreferences()
|
||||
{
|
||||
if (fSavePreferences) {
|
||||
BFile file;
|
||||
status_t set = B_ERROR;
|
||||
BFile file;
|
||||
status_t set = B_ERROR;
|
||||
if (fSettingsFile)
|
||||
file.SetTo (fSettingsFile, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||
else
|
||||
{
|
||||
BPath prefpath;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &prefpath, true)==B_OK) {
|
||||
BDirectory prefdir(prefpath.Path());
|
||||
BDirectory gebprefdir;
|
||||
BEntry entry;
|
||||
if (prefdir.FindEntry(kDirectory, &entry, true)==B_OK)
|
||||
gebprefdir.SetTo(&entry);
|
||||
else
|
||||
prefdir.CreateDirectory (kDirectory, &gebprefdir);
|
||||
if (gebprefdir.InitCheck () == B_OK)
|
||||
set = gebprefdir.CreateFile (fName, &file, false);
|
||||
else {
|
||||
BPath prefpath;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &prefpath, true) == B_OK) {
|
||||
BDirectory prefdir(prefpath.Path());
|
||||
set = prefdir.CreateFile(fName, &file, false);
|
||||
}
|
||||
}
|
||||
if (file.InitCheck () == B_OK)
|
||||
{
|
||||
Flatten (&file);
|
||||
if (fSignature)
|
||||
file.WriteAttr ("BEOS:TYPE", B_MIME_STRING_TYPE, 0, fSignature, strlen(fSignature)+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (file.InitCheck () == B_OK) {
|
||||
Flatten(&file);
|
||||
if (fSignature) {
|
||||
file.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0, fSignature,
|
||||
strlen(fSignature)+1);
|
||||
}
|
||||
} else {
|
||||
// implement saving somewhere else!
|
||||
char error[1024];
|
||||
sprintf (error, "Your setting file could not be saved!\n(%s)", strerror (file.InitCheck ()));
|
||||
char error[1024];
|
||||
sprintf(error, "Your setting file could not be saved!\n(%s)",
|
||||
strerror(file.InitCheck()));
|
||||
BAlert *alert = new BAlert("Error saving file", error,
|
||||
"Damned!", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
"Damned!", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
alert->Go();
|
||||
}
|
||||
}
|
||||
free (fName);
|
||||
if (fSignature)
|
||||
free (fSignature);
|
||||
free(fName);
|
||||
free(fSignature);
|
||||
}
|
||||
|
||||
status_t GebsPreferences::MakeEmpty()
|
||||
|
||||
status_t
|
||||
GebsPreferences::MakeEmpty()
|
||||
{
|
||||
status_t st;
|
||||
Lock();
|
||||
st=BMessage::MakeEmpty();
|
||||
status_t status = BMessage::MakeEmpty();
|
||||
Unlock();
|
||||
return st;
|
||||
return status;
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveWindowPosition(BWindow* window, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::SaveWindowPosition(BWindow* window, const char* name)
|
||||
{
|
||||
BRect rect=window->Frame();
|
||||
Lock();
|
||||
|
||||
BRect rect = window->Frame();
|
||||
if (HasPoint(name))
|
||||
ReplacePoint(name, rect.LeftTop());
|
||||
else
|
||||
AddPoint(name, rect.LeftTop());
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void GebsPreferences::LoadWindowPosition(BWindow* window, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::LoadWindowPosition(BWindow* window, const char* name)
|
||||
{
|
||||
BPoint p;
|
||||
Lock();
|
||||
if (FindPoint(name, &p)==B_OK) {
|
||||
|
||||
BPoint p;
|
||||
if (FindPoint(name, &p) == B_OK) {
|
||||
window->MoveTo(p);
|
||||
visible_window(window);
|
||||
make_window_visible(window);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveWindowFrame(BWindow* window, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::SaveWindowFrame(BWindow* window, const char* name)
|
||||
{
|
||||
BRect rect=window->Frame();
|
||||
Lock();
|
||||
|
||||
BRect rect = window->Frame();
|
||||
if (HasRect(name))
|
||||
ReplaceRect(name, rect);
|
||||
else
|
||||
AddRect(name, rect);
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void GebsPreferences::LoadWindowFrame(BWindow* window, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::LoadWindowFrame(BWindow* window, const char* name)
|
||||
{
|
||||
BRect f;
|
||||
Lock();
|
||||
if (FindRect(name, &f)==B_OK) {
|
||||
window->MoveTo(f.LeftTop());
|
||||
window->ResizeTo(f.Width(), f.Height());
|
||||
visible_window(window);
|
||||
|
||||
BRect frame;
|
||||
if (FindRect(name, &frame) == B_OK) {
|
||||
window->MoveTo(frame.LeftTop());
|
||||
window->ResizeTo(frame.Width(), frame.Height());
|
||||
make_window_visible(window);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveInt32(int32 val, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::SaveInt32(int32 value, const char* name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
if (HasInt32(name))
|
||||
ReplaceInt32(name, val);
|
||||
ReplaceInt32(name, value);
|
||||
else
|
||||
AddInt32(name, val);
|
||||
AddInt32(name, value);
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
bool GebsPreferences::ReadInt32(int32 &val, const char* name)
|
||||
|
||||
bool
|
||||
GebsPreferences::ReadInt32(int32 &val, const char* name)
|
||||
{
|
||||
Lock();
|
||||
int32 readVal;
|
||||
bool found=FindInt32(name, &readVal)==B_OK;
|
||||
int32 readVal;
|
||||
bool found = FindInt32(name, &readVal) == B_OK;
|
||||
if (found)
|
||||
val=readVal;
|
||||
val = readVal;
|
||||
Unlock();
|
||||
return found;
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveFloat(float val, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::SaveFloat(float val, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasFloat(name))
|
||||
@@ -209,18 +227,22 @@ void GebsPreferences::SaveFloat(float val, const char* name)
|
||||
Unlock();
|
||||
}
|
||||
|
||||
bool GebsPreferences::ReadFloat(float &val, const char* name)
|
||||
|
||||
bool
|
||||
GebsPreferences::ReadFloat(float &val, const char* name)
|
||||
{
|
||||
Lock();
|
||||
float readVal;
|
||||
bool found=FindFloat(name, &readVal)==B_OK;
|
||||
float readVal;
|
||||
bool found = FindFloat(name, &readVal)==B_OK;
|
||||
if (found)
|
||||
val=readVal;
|
||||
val = readVal;
|
||||
Unlock();
|
||||
return found;
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveRect(BRect &rect, const char* name)
|
||||
|
||||
void
|
||||
GebsPreferences::SaveRect(BRect &rect, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasRect(name))
|
||||
@@ -230,40 +252,48 @@ void GebsPreferences::SaveRect(BRect &rect, const char* name)
|
||||
Unlock();
|
||||
}
|
||||
|
||||
BRect & GebsPreferences::ReadRect(BRect &rect, const char* name)
|
||||
|
||||
BRect &
|
||||
GebsPreferences::ReadRect(BRect &rect, const char* name)
|
||||
{
|
||||
Lock();
|
||||
BRect loaded;
|
||||
BRect loaded;
|
||||
if (FindRect(name, &loaded)==B_OK)
|
||||
rect=loaded;
|
||||
rect = loaded;
|
||||
Unlock();
|
||||
return rect;
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveString (BString &string, const char* name)
|
||||
{
|
||||
Lock ();
|
||||
if (HasString (name))
|
||||
ReplaceString (name, string);
|
||||
else
|
||||
AddString (name, string);
|
||||
Unlock ();
|
||||
}
|
||||
|
||||
void GebsPreferences::SaveString (const char* string, const char* name)
|
||||
{
|
||||
Lock ();
|
||||
if (HasString (name))
|
||||
ReplaceString (name, string);
|
||||
else
|
||||
AddString (name, string);
|
||||
Unlock ();
|
||||
}
|
||||
|
||||
bool GebsPreferences::ReadString (BString &string, const char* name)
|
||||
void
|
||||
GebsPreferences::SaveString(BString &string, const char* name)
|
||||
{
|
||||
Lock();
|
||||
bool loaded = FindString (name, &string) == B_OK;
|
||||
if (HasString(name))
|
||||
ReplaceString(name, string);
|
||||
else
|
||||
AddString(name, string);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveString(const char* string, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasString(name))
|
||||
ReplaceString(name, string);
|
||||
else
|
||||
AddString(name, string);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
GebsPreferences::ReadString(BString &string, const char* name)
|
||||
{
|
||||
Lock();
|
||||
bool loaded = FindString(name, &string) == B_OK;
|
||||
Unlock();
|
||||
return loaded;
|
||||
}
|
||||
|
||||
@@ -1,698 +0,0 @@
|
||||
/*
|
||||
PrintMessage.cpp
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "PrintMessage.h"
|
||||
#include "ReadableLong.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <AppFileInfo.h>
|
||||
#include <Path.h>
|
||||
#include <SymLink.h>
|
||||
#include <fs_attr.h>
|
||||
#include <Application.h>
|
||||
#include <Resources.h>
|
||||
#include <PropertyInfo.h>
|
||||
#include <Roster.h>
|
||||
|
||||
int32 gHexalinesPref=9;
|
||||
|
||||
void do_print_message(pchar & texte, BMessage* message);
|
||||
void print_type(pchar & texte, ulong type, void* pvoid, ssize_t size);
|
||||
void tab_to(pchar & texte, int n);
|
||||
void print_hex(pchar & texte, void* pvoid, ssize_t size, int extra_space);
|
||||
void ajoute(pchar & texte, const char* mot, long length=0);
|
||||
inline void ajoute(pchar & texte, const char c) { *texte++=c; }
|
||||
|
||||
const char* specifiers[] = {
|
||||
"B_NO_SPECIFIER",
|
||||
"B_DIRECT_SPECIFIER",
|
||||
"B_INDEX_SPECIFIER",
|
||||
"B_REVERSE_INDEX_SPECIFIER",
|
||||
"B_RANGE_SPECIFIER",
|
||||
"B_REVERSE_RANGE_SPECIFIER",
|
||||
"B_NAME_SPECIFIER",
|
||||
"B_ID_SPECIFIER",
|
||||
NULL };
|
||||
|
||||
const int kTabType=22;
|
||||
const int kTabName=25;
|
||||
const int kTabNum=12;
|
||||
|
||||
const char* indent1=" | ";
|
||||
const char* indent2=" > ";
|
||||
const char* indent3=" \" ";
|
||||
const int maxprefix=1000;
|
||||
|
||||
char gPrefix[maxprefix];
|
||||
|
||||
void print_message(pchar & texte, BMessage* message, bool dig)
|
||||
{
|
||||
gPrefix[0]=0;
|
||||
if (dig) {
|
||||
#if B_BEOS_VERSION > B_BEOS_VERSION_5
|
||||
const char* name;
|
||||
#else
|
||||
char * name;
|
||||
#endif
|
||||
ulong type;
|
||||
off_t size;
|
||||
long m;
|
||||
long count, k;
|
||||
entry_ref ref;
|
||||
bool found=false;
|
||||
for (k=0; message->GetInfo(B_REF_TYPE, k, &name, &type, &count)==B_OK; k++)
|
||||
for (m=0; m<count; m++)
|
||||
if (message->FindRef(name, m, &ref)==B_OK) {
|
||||
BEntry entry(&ref, true);
|
||||
if (entry.InitCheck()==B_OK && entry.IsFile()) {
|
||||
found=true;
|
||||
ajoute(texte, "File");
|
||||
BPath path;
|
||||
entry.GetPath(&path);
|
||||
texte+=sprintf(texte, ": %s\n", path.Path());
|
||||
entry.GetSize(&size);
|
||||
if (size==0)
|
||||
ajoute(texte, " Empty file.\n");
|
||||
else {
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
BResources rsrc;
|
||||
if (rsrc.SetTo(&file)==B_OK) {
|
||||
ajoute(texte, " Resource file:\n");
|
||||
// file has resource file
|
||||
int32 index=0;
|
||||
type_code typeFound;
|
||||
int32 idFound;
|
||||
const char* nameFound;
|
||||
size_t lengthFound;
|
||||
while (rsrc.GetResourceInfo(index++, &typeFound, &idFound, &nameFound, &lengthFound)) {
|
||||
void* resource=rsrc.FindResource(typeFound, idFound, &lengthFound);
|
||||
if (resource) {
|
||||
texte+=sprintf(texte, " %d", int(idFound));
|
||||
tab_to(texte, 5);
|
||||
ajoute(texte, long_to_be_string(typeFound));
|
||||
tab_to(texte, 1+kTabType);
|
||||
texte+=sprintf(texte, "\"%s\"", nameFound);
|
||||
tab_to(texte, 1+kTabType+kTabName);
|
||||
strcpy(gPrefix, " ");
|
||||
print_type(texte, typeFound, resource, lengthFound);
|
||||
free(resource);
|
||||
} else
|
||||
texte+=sprintf(texte, "Could not read resource of type %s with id=%d\n", long_to_be_string(typeFound), int(idFound));
|
||||
}
|
||||
} else {
|
||||
char* content=new char[size];
|
||||
if (file.Read(content, size)==size) {
|
||||
BMessage inmessage;
|
||||
strcpy(gPrefix, " > ");
|
||||
if (inmessage.Unflatten(content)==B_OK) {
|
||||
ajoute(texte, " BMessage file:\n");
|
||||
do_print_message(texte, &inmessage);
|
||||
} else {
|
||||
ajoute(texte, " Not a BMessage, not a resource file.\n");
|
||||
print_hex(texte, content, size, 0);
|
||||
//print_type(texte, B_RAW_TYPE, content, size);
|
||||
}
|
||||
} else
|
||||
ajoute(texte, " The file's content could not be read.\n");
|
||||
delete[] content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
ajoute(texte, "(No file referenced in the BMessage)");
|
||||
} else
|
||||
do_print_message(texte, message);
|
||||
*texte=0;
|
||||
}
|
||||
|
||||
void do_print_message(pchar & texte, BMessage* message)
|
||||
{
|
||||
#if B_BEOS_VERSION > B_BEOS_VERSION_5
|
||||
const char* name;
|
||||
#else
|
||||
char * name;
|
||||
#endif
|
||||
ulong type;
|
||||
void* data;
|
||||
ssize_t size;
|
||||
long m;
|
||||
long count, k;
|
||||
int lPrefix=strlen(gPrefix);
|
||||
|
||||
ajoute(texte, gPrefix);
|
||||
ajoute(texte, "What=");
|
||||
ajoute(texte, long_to_be_string(message->what));
|
||||
ajoute(texte, "\n");
|
||||
for (k=0; message->GetInfo(B_ANY_TYPE, k, &name, &type, &count)==B_OK; k++) {
|
||||
for (m=0; m<count; m++) {
|
||||
if (message->FindData(name, type, m, (const void**) &data, &size)==B_OK) {
|
||||
ajoute(texte, gPrefix);
|
||||
ajoute(texte, long_to_be_string(type));
|
||||
tab_to(texte, lPrefix+kTabType);
|
||||
if (count>1)
|
||||
texte+=sprintf(texte, "\"%s\" #%d", name, (int) m+1);
|
||||
else
|
||||
texte+=sprintf(texte, "\"%s\"", name);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName);
|
||||
if (type==B_REF_TYPE) {
|
||||
entry_ref ref;
|
||||
message->FindRef(name, m, &ref);
|
||||
print_type(texte, type, &ref, sizeof(ref));
|
||||
} else if (type==B_MESSENGER_TYPE) {
|
||||
BMessenger messenger;
|
||||
message->FindMessenger(name, m, &messenger);
|
||||
print_type(texte, type, &messenger, sizeof(messenger));
|
||||
} else
|
||||
print_type(texte, type, data, size);
|
||||
} else
|
||||
texte+=sprintf(texte, "%sError retreiving data.\n", gPrefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_type(pchar & texte, ulong type, void* pvoid, ssize_t size)
|
||||
{
|
||||
union Data {
|
||||
char c;
|
||||
double d;
|
||||
float f;
|
||||
int8 i8;
|
||||
uint8 ui8;
|
||||
int16 i16;
|
||||
uint16 ui16;
|
||||
int32 i32;
|
||||
uint32 ui32;
|
||||
int64 i64;
|
||||
uint64 ui64;
|
||||
time_t time;
|
||||
rgb_color rgb;
|
||||
version_info vinfos;
|
||||
};
|
||||
|
||||
Data* data=(Data*) pvoid;
|
||||
char* txtdata=(char*) pvoid;
|
||||
BMessage local;
|
||||
bool cr=true;
|
||||
int lPrefix=strlen(gPrefix);
|
||||
int max=maxprefix-lPrefix-1;
|
||||
|
||||
long_to_be_string(type);
|
||||
switch (type) {
|
||||
case B_BOOL_TYPE:
|
||||
ajoute(texte, '0'+data->c);
|
||||
break;
|
||||
|
||||
case B_CHAR_TYPE:
|
||||
ajoute(texte, data->c);
|
||||
break;
|
||||
|
||||
case B_DOUBLE_TYPE:
|
||||
texte+=sprintf(texte, "%f", data->d);
|
||||
break;
|
||||
|
||||
case B_FLOAT_TYPE:
|
||||
texte+=sprintf(texte, "%f", data->f);
|
||||
break;
|
||||
|
||||
case B_UINT8_TYPE:
|
||||
texte+=sprintf(texte, "%u (0x%.2hX)", data->ui8, data->ui8);
|
||||
break;
|
||||
|
||||
case B_INT8_TYPE:
|
||||
texte+=sprintf(texte, "%d (0x%.2hX)", data->i8, data->ui8);
|
||||
break;
|
||||
|
||||
case B_INT16_TYPE:
|
||||
texte+=sprintf(texte, "%hd (0x%.4hX)", data->i16, data->i16);
|
||||
break;
|
||||
|
||||
case B_UINT16_TYPE:
|
||||
texte+=sprintf(texte, "%hu (0x%.4hX)", data->ui16, data->ui16);
|
||||
break;
|
||||
|
||||
case B_INT32_TYPE:
|
||||
case B_SSIZE_T_TYPE:
|
||||
texte+=sprintf(texte, "%ld (%s", data->i32, long_to_be_string(data->ui32));
|
||||
if (data->i32<=B_ERRORS_END)
|
||||
texte+=sprintf(texte, " %s", strerror(data->i32));
|
||||
ajoute(texte, ')');
|
||||
break;
|
||||
|
||||
case B_UINT32_TYPE:
|
||||
case B_SIZE_T_TYPE:
|
||||
texte+=sprintf(texte, "%lu (%s)", data->ui32, long_to_be_string(data->ui32));
|
||||
break;
|
||||
|
||||
case B_INT64_TYPE:
|
||||
case B_OFF_T_TYPE:
|
||||
texte+=sprintf(texte, "%Ld (0x%.16LX)", data->i64, data->i64);
|
||||
break;
|
||||
|
||||
case B_UINT64_TYPE:
|
||||
texte+=sprintf(texte, "%Lu (0x%.16LX)", data->ui64, data->ui64);
|
||||
break;
|
||||
|
||||
case B_ASCII_TYPE:
|
||||
case B_STRING_TYPE:
|
||||
case B_MIME_TYPE:
|
||||
case B_MIME_STRING_TYPE:
|
||||
case 'MSIG':
|
||||
{
|
||||
long tt=0;
|
||||
while (txtdata[tt]!=0 && txtdata[tt]!='\n')
|
||||
tt++;
|
||||
if (txtdata[tt]!=0) {
|
||||
ajoute(texte, "Multiline texte follows:\n");
|
||||
ajoute(texte, gPrefix);
|
||||
ajoute(texte, indent3);
|
||||
tt=0;
|
||||
while (txtdata[tt]!=0 && tt<size) {
|
||||
ajoute(texte, txtdata[tt]);
|
||||
if (txtdata[tt++]=='\n') {
|
||||
ajoute(texte, gPrefix);
|
||||
ajoute(texte, indent3);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ajoute(texte, '"');
|
||||
tt=0;
|
||||
while (txtdata[tt]!=0 && tt<size)
|
||||
ajoute(texte, txtdata[tt++]);
|
||||
ajoute(texte, '"');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case B_POINTER_TYPE:
|
||||
texte+=sprintf(texte, "%p", pvoid);
|
||||
break;
|
||||
|
||||
case B_POINT_TYPE:
|
||||
{
|
||||
BPoint *point=(BPoint*) pvoid;
|
||||
texte+=sprintf(texte, "x=%.2f", point->x);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+kTabNum);
|
||||
texte+=sprintf(texte, "y=%.2f", point->y);
|
||||
}
|
||||
break;
|
||||
|
||||
case B_RECT_TYPE:
|
||||
{
|
||||
BRect *rect=(BRect*) pvoid;
|
||||
texte+=sprintf(texte, "l=%.2f", rect->left);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+kTabNum);
|
||||
texte+=sprintf(texte, "t=%.2f", rect->top);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+2*kTabNum);
|
||||
texte+=sprintf(texte, "r=%.2f", rect->right);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+3*kTabNum);
|
||||
texte+=sprintf(texte, "b=%.2f", rect->bottom);
|
||||
}
|
||||
break;
|
||||
|
||||
case B_REF_TYPE:
|
||||
{
|
||||
entry_ref *ref=(entry_ref*) pvoid;
|
||||
off_t size;
|
||||
texte+=sprintf(texte, "\n%s ", gPrefix);
|
||||
BEntry entry(ref, false);
|
||||
if (entry.InitCheck()==B_OK) {
|
||||
if (entry.IsFile())
|
||||
ajoute(texte, "File");
|
||||
else if (entry.IsDirectory())
|
||||
ajoute(texte, "Directory");
|
||||
else if (entry.IsSymLink())
|
||||
ajoute(texte, "Link");
|
||||
else ajoute(texte, "The entry points to an unexisting object");
|
||||
BPath path;
|
||||
entry.GetPath(&path);
|
||||
texte+=sprintf(texte, ": %s\n", path.Path());
|
||||
BNode node(&entry);
|
||||
if (entry.IsSymLink()) {
|
||||
texte+=sprintf(texte, "%s ", gPrefix);
|
||||
BEntry target(ref, true);
|
||||
if (target.GetPath(&path)==B_OK)
|
||||
texte+=sprintf(texte, "Valid target: ");
|
||||
else
|
||||
texte+=sprintf(texte, "Invalid target: ");
|
||||
char linkto[B_PATH_NAME_LENGTH+1];
|
||||
BSymLink link(ref);
|
||||
if (link.InitCheck()==B_OK) {
|
||||
linkto[link.ReadLink(linkto, B_PATH_NAME_LENGTH)]=0;
|
||||
texte+=sprintf(texte, "%s\n", linkto);
|
||||
} else
|
||||
ajoute(texte, "Unreadable link.\n");
|
||||
} else if (entry.IsFile()) {
|
||||
node.GetSize(&size);
|
||||
texte+=sprintf(texte, "%s Size: %Ld byte", gPrefix, size);
|
||||
if (size!=1)
|
||||
ajoute(texte, 's');
|
||||
ajoute(texte, ".\n");
|
||||
}
|
||||
char attribute[B_ATTR_NAME_LENGTH];
|
||||
cr=false;
|
||||
strncat(gPrefix, indent2, max);
|
||||
while (node.GetNextAttrName(attribute)==B_OK) {
|
||||
attr_info infos;
|
||||
size_t length;
|
||||
node.GetAttrInfo(attribute, &infos);
|
||||
ajoute(texte, gPrefix);
|
||||
ajoute(texte, long_to_be_string(infos.type));
|
||||
tab_to(texte, strlen(gPrefix)+kTabType);
|
||||
texte+=sprintf(texte, "\"%s\"", attribute);
|
||||
tab_to(texte, strlen(gPrefix)+kTabType+kTabName);
|
||||
char* buffeur=new char[infos.size+1];
|
||||
length=node.ReadAttr(attribute, infos.type, 0, buffeur, infos.size);
|
||||
if (length==infos.size) {
|
||||
buffeur[length]=0;
|
||||
print_type(texte, infos.type, buffeur, infos.size);
|
||||
} else
|
||||
texte+=sprintf(texte, "[attribute not read properly (%s)]\n", strerror(length));
|
||||
delete[] buffeur;
|
||||
}
|
||||
gPrefix[lPrefix]=0;
|
||||
} else
|
||||
ajoute(texte, "Bad ref.");
|
||||
}
|
||||
break;
|
||||
|
||||
case B_MESSAGE_TYPE:
|
||||
if (local.Unflatten(txtdata)==B_OK) {
|
||||
ajoute(texte, '\n');
|
||||
strncat(gPrefix, indent1, max);
|
||||
do_print_message(texte, &local);
|
||||
gPrefix[lPrefix]=0;
|
||||
cr=false;
|
||||
} else
|
||||
ajoute(texte, "[invalid message]");
|
||||
break;
|
||||
|
||||
case B_TIME_TYPE:
|
||||
{
|
||||
char* t=ctime(&data->time);
|
||||
if (t) {
|
||||
ajoute(texte, t);
|
||||
cr=false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case B_RGB_32_BIT_TYPE:
|
||||
case B_RGB_COLOR_TYPE:
|
||||
texte+=sprintf(texte, "r=%u", data->rgb.red);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+kTabNum);
|
||||
texte+=sprintf(texte, "g=%u", data->rgb.green);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+2*kTabNum);
|
||||
texte+=sprintf(texte, "b=%u", data->rgb.blue);
|
||||
tab_to(texte, lPrefix+kTabType+kTabName+3*kTabNum);
|
||||
texte+=sprintf(texte, "a=%u", data->rgb.alpha);
|
||||
break;
|
||||
|
||||
case B_PROPERTY_INFO_TYPE:
|
||||
{
|
||||
BPropertyInfo pinfo;
|
||||
if (pinfo.Unflatten(B_PROPERTY_INFO_TYPE, pvoid, size)==B_OK) {
|
||||
const property_info *infos=pinfo.Properties();
|
||||
if (infos) {
|
||||
int k=0;
|
||||
int count=pinfo.CountProperties();
|
||||
while (count-->0) {
|
||||
texte+=sprintf(texte, "\n%s Name[%d]=%s\n%s ", gPrefix, k+1, infos[k].name, gPrefix);
|
||||
int j=0;
|
||||
do {
|
||||
ajoute(texte, ' ');
|
||||
if (infos[k].commands[j]==0)
|
||||
ajoute(texte, "All possible commands.");
|
||||
else
|
||||
ajoute(texte, long_to_be_string(infos[k].commands[j]));
|
||||
} while (j<9 && infos[k].commands[j]!=0 && infos[k].commands[++j]!=0);
|
||||
texte+=sprintf(texte, "\n%s ", gPrefix);
|
||||
j=0;
|
||||
do {
|
||||
if (infos[k].specifiers[j]==0)
|
||||
ajoute(texte, " All possible specifiers.");
|
||||
else {
|
||||
ajoute(texte, ' ');
|
||||
uint32 s=0;
|
||||
while (specifiers[s]!=NULL && s!=infos[k].specifiers[j])
|
||||
s++;
|
||||
if (specifiers[s])
|
||||
ajoute(texte, specifiers[s]);
|
||||
else
|
||||
texte+=sprintf(texte, "%d", (int) infos[k].specifiers[j]);
|
||||
}
|
||||
} while (j<9 && infos[k].specifiers[j]!=0 && infos[k].specifiers[++j]!=0);
|
||||
if (infos[k].usage) {
|
||||
texte+=sprintf(texte, "\n%s Usage=", gPrefix);
|
||||
if (infos[k].usage)
|
||||
ajoute(texte, infos[k].usage);
|
||||
}
|
||||
if (infos[k].extra_data)
|
||||
texte+=sprintf(texte, "\n%s Extra Data: %lu", gPrefix, infos[k].extra_data);
|
||||
k++;
|
||||
}
|
||||
} else
|
||||
ajoute(texte, "Empty.");
|
||||
} else
|
||||
ajoute(texte, "Invalid.");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'APPV':
|
||||
{
|
||||
struct version_info *vinfos=(struct version_info*) pvoid;
|
||||
const char* variety[]= { "Development", "Alpha", "Beta", "Gamma", "Golden Master", "Final" };
|
||||
for (int32 v=0; (unsigned)size>=sizeof(version_info); size-=sizeof(version_info), v++, vinfos++) {
|
||||
texte+=sprintf(texte, "\n%s%s", gPrefix, indent1);
|
||||
if (v==B_APP_VERSION_KIND)
|
||||
ajoute(texte, "Application");
|
||||
else if (v==B_SYSTEM_VERSION_KIND)
|
||||
ajoute(texte, "System");
|
||||
else
|
||||
ajoute(texte, "Extra");
|
||||
texte+=sprintf(texte, " Version: %lu.%lu.%lu ", vinfos->major, vinfos->middle, vinfos->minor);
|
||||
if (vinfos->variety<6)
|
||||
ajoute(texte, variety[vinfos->variety]);
|
||||
else
|
||||
texte+=sprintf(texte, "Unknown Variety (%lu)", vinfos->variety);
|
||||
texte+=sprintf(texte, " #%lu", vinfos->internal);
|
||||
vinfos->short_info[63]=0;
|
||||
texte+=sprintf(texte, "\n%s%s Short Info: %s", gPrefix, indent1, vinfos->short_info);
|
||||
vinfos->long_info[255]=0;
|
||||
texte+=sprintf(texte, "\n%s%s Long Info: %s", gPrefix, indent1, vinfos->long_info);
|
||||
}
|
||||
if (size>0)
|
||||
texte+=sprintf(texte, "\n%s with %lu extra byte(s)", gPrefix, size);
|
||||
}
|
||||
break;
|
||||
|
||||
case B_MESSENGER_TYPE:
|
||||
{
|
||||
BMessenger *messenger=(BMessenger*) pvoid;
|
||||
if (!messenger->IsValid())
|
||||
ajoute(texte, "Invalid Messenger");
|
||||
else {
|
||||
if (messenger->IsTargetLocal()) {
|
||||
BLooper *looper;
|
||||
BHandler *handler=messenger->Target(&looper);
|
||||
if (!handler) {
|
||||
team_info tminfo;
|
||||
texte+=sprintf(texte, "\n%s%sLooper: ", gPrefix, indent1);
|
||||
if (get_team_info(looper->Team(), &tminfo)==B_OK)
|
||||
texte+=sprintf(texte, "\n%s%s Team #%d", gPrefix, indent1, (int) looper->Team());
|
||||
else
|
||||
texte+=sprintf(texte, "\n%s%s Team #%d (not found)", gPrefix, indent1, (int) looper->Team());
|
||||
thread_info thinfo;
|
||||
if (get_thread_info(looper->Thread(), &thinfo)==B_OK)
|
||||
texte+=sprintf(texte, "\n%s%s Thread #%d %s", gPrefix, indent1, (int) looper->Thread(), thinfo.name);
|
||||
else
|
||||
texte+=sprintf(texte, "\n%s%s Thread #%d (not found)", gPrefix, indent1, (int) looper->Thread());
|
||||
handler=looper;
|
||||
}
|
||||
texte+=sprintf(texte, "\n%s%sHandler: %s", gPrefix, indent1, handler->Name());
|
||||
} else {
|
||||
app_info info;
|
||||
ajoute(texte, "Remote Looper:");
|
||||
if (be_roster->GetRunningAppInfo(messenger->Team(), &info)==B_OK) {
|
||||
BEntry entry(&info.ref);
|
||||
char appname[B_FILE_NAME_LENGTH];
|
||||
entry.GetName(appname);
|
||||
texte+=sprintf(texte, " Team #%d \"%s\" (%s)", (int) messenger->Team(), appname, info.signature);
|
||||
} else
|
||||
texte+=sprintf(texte, " Team #%d (team not found)", (int) messenger->Team());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ICON':
|
||||
case 'MICN':
|
||||
texte+=sprintf(texte, "[%d bytes of icon]", (int) size);
|
||||
break;
|
||||
|
||||
case B_ANY_TYPE:
|
||||
case B_COLOR_8_BIT_TYPE:
|
||||
case B_GRAYSCALE_8_BIT_TYPE:
|
||||
case B_MONOCHROME_1_BIT_TYPE:
|
||||
case B_OBJECT_TYPE:
|
||||
case B_PATTERN_TYPE:
|
||||
case B_RAW_TYPE:
|
||||
default:
|
||||
// if (size==1)
|
||||
// ajoute(texte, "[Unsupported (one byte)]");
|
||||
// else
|
||||
// texte+=sprintf(texte, "[Unsupported (%d bytes)]", size);
|
||||
// Type is not known. Try to interpret it as an archived object...
|
||||
BMessage archive;
|
||||
if (archive.Unflatten(txtdata)==B_OK) {
|
||||
ajoute(texte, "Is an archived object in a BMessage\n");
|
||||
strncat(gPrefix, indent2, max);
|
||||
do_print_message(texte, &archive);
|
||||
gPrefix[lPrefix]=0;
|
||||
cr=false;
|
||||
} else {
|
||||
print_hex(texte, pvoid, size, kTabType+kTabName);
|
||||
// int32 *pint=(int32 *) pvoid;
|
||||
// long done=0;
|
||||
// int tab=lPrefix+kTabType+kTabName;
|
||||
// while (done<size && (done<gHexalinesPref*16 || size-done<=16)) {
|
||||
// texte+=sprintf(texte, "%.4lX - ", done);
|
||||
// int todo=size-done;
|
||||
// if (todo>=16) {
|
||||
// todo=16;
|
||||
// int32 *cp=&pint[done/4];
|
||||
// texte+=sprintf(texte, "%.8lX %.8lX %.8lX %.8lX ", B_HOST_TO_BENDIAN_INT32(*cp), B_HOST_TO_BENDIAN_INT32(cp[1]),
|
||||
// B_HOST_TO_BENDIAN_INT32(cp[2]), B_HOST_TO_BENDIAN_INT32(cp[3]));
|
||||
// } else {
|
||||
// int32 intbuff[4];
|
||||
// memcpy(intbuff, &txtdata[done], size-done);
|
||||
// texte+=sprintf(texte, "%.8lX %.8lX %.8lX %.8lX ", B_HOST_TO_BENDIAN_INT32(*intbuff), B_HOST_TO_BENDIAN_INT32(intbuff[1]),
|
||||
// B_HOST_TO_BENDIAN_INT32(intbuff[2]), B_HOST_TO_BENDIAN_INT32(intbuff[3]));
|
||||
// int efface=(16-(size-done))*2;
|
||||
// char *e=texte;
|
||||
// while (efface>0) {
|
||||
// e--;
|
||||
// if (*e!=' ') {
|
||||
// *e=' ';
|
||||
// efface--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int n=0; n<todo; n++, done) {
|
||||
// char c=txtdata[done++];
|
||||
// if (!isprint(c))
|
||||
// c='.';
|
||||
// ajoute(texte, c);
|
||||
// // if (done % 8 == 0)
|
||||
// // ajoute(texte, ' ');
|
||||
// }
|
||||
// if (done<size) {
|
||||
// texte+=sprintf(texte, "\n%s", gPrefix);
|
||||
// tab_to(texte, tab);
|
||||
// }
|
||||
// }
|
||||
// if (done<size)
|
||||
// texte+=sprintf(texte, " [%d bytes remaining of %d bytes]", (int) (size-done), (int) size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cr)
|
||||
ajoute(texte, '\n');
|
||||
}
|
||||
|
||||
void ajoute(pchar & texte, const char* mot, long length)
|
||||
{
|
||||
long k;
|
||||
if (length==0)
|
||||
while (mot[length])
|
||||
ajoute(texte, mot[length++]);
|
||||
else
|
||||
for (k=0; mot[k]!=0 && k<length; k++)
|
||||
ajoute(texte, mot[k]);
|
||||
}
|
||||
|
||||
void tab_to(pchar & texte, int n)
|
||||
{
|
||||
int p=0;
|
||||
while (texte[-p-1]!='\n')
|
||||
p++;
|
||||
if (p<n) {
|
||||
while (p++<n)
|
||||
ajoute(texte, ' ');
|
||||
} else
|
||||
if (texte[p-1]!=' ')
|
||||
ajoute(texte, ' ');
|
||||
}
|
||||
|
||||
void print_hex(pchar & texte, void* pvoid, ssize_t size, int extra_space)
|
||||
{
|
||||
int32 *pint=(int32 *) pvoid;
|
||||
char* txtdata=(char*) pvoid;
|
||||
long done=0;
|
||||
int tab=strlen(gPrefix)+extra_space;
|
||||
if (extra_space == 0)
|
||||
ajoute (texte, gPrefix);
|
||||
while (done<size && (done<gHexalinesPref*16 || size-done<=16)) {
|
||||
texte+=sprintf(texte, "%04lX - ", done);
|
||||
int todo=size-done;
|
||||
if (todo>=16) {
|
||||
todo=16;
|
||||
int32 *cp=&pint[done/4];
|
||||
texte+=sprintf(texte, "%.8lX %.8lX %.8lX %.8lX ", B_HOST_TO_BENDIAN_INT32(*cp), B_HOST_TO_BENDIAN_INT32(cp[1]),
|
||||
B_HOST_TO_BENDIAN_INT32(cp[2]), B_HOST_TO_BENDIAN_INT32(cp[3]));
|
||||
} else {
|
||||
int32 intbuff[4];
|
||||
memcpy(intbuff, &txtdata[done], size-done);
|
||||
texte+=sprintf(texte, "%.8lX %.8lX %.8lX %.8lX ", B_HOST_TO_BENDIAN_INT32(*intbuff), B_HOST_TO_BENDIAN_INT32(intbuff[1]),
|
||||
B_HOST_TO_BENDIAN_INT32(intbuff[2]), B_HOST_TO_BENDIAN_INT32(intbuff[3]));
|
||||
int efface=(16-(size-done))*2;
|
||||
char *e=texte;
|
||||
while (efface>0) {
|
||||
e--;
|
||||
if (*e!=' ') {
|
||||
*e=' ';
|
||||
efface--;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int n=0; n<todo; n++, done) {
|
||||
char c=txtdata[done++];
|
||||
if (c >= 0 && c < ' ')
|
||||
c='.';
|
||||
ajoute(texte, c);
|
||||
// if (done % 8 == 0)
|
||||
// ajoute(texte, ' ');
|
||||
}
|
||||
if (done<size) {
|
||||
texte+=sprintf(texte, "\n%s", gPrefix);
|
||||
if (extra_space>0)
|
||||
tab_to(texte, tab);
|
||||
}
|
||||
}
|
||||
if (done<size)
|
||||
texte+=sprintf(texte, " [%d bytes remaining of %d bytes]", (int) (size-done), (int) size);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
|
||||
print_message.h
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _PRINT_MESSAGE_H_
|
||||
#define _PRINT_MESSAGE_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class BMessage;
|
||||
typedef char* pchar;
|
||||
|
||||
void print_message(pchar & texte, BMessage* message, bool dig=false);
|
||||
|
||||
extern int32 gHexalinesPref;
|
||||
|
||||
// texte=new char[5000000];
|
||||
// print_message(texte,message);
|
||||
// ...
|
||||
// delete[] texte;
|
||||
|
||||
#endif // _PRINT_MESSAGE_H_
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
PriorityMenu.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,29 +15,38 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "PriorityMenu.h"
|
||||
#include "PCView.h"
|
||||
#include <Window.h>
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <MenuItem.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PriorityMenu::PriorityMenu (thread_id thread, int32 priority) :
|
||||
BMenu (B_EMPTY_STRING), fThreadID (thread), fPriority (priority)
|
||||
|
||||
PriorityMenu::PriorityMenu(thread_id thread, int32 priority)
|
||||
: BMenu(B_EMPTY_STRING),
|
||||
fThreadID(thread),
|
||||
fPriority(priority)
|
||||
{
|
||||
}
|
||||
|
||||
void PriorityMenu::Update (int32 priority)
|
||||
|
||||
void
|
||||
PriorityMenu::Update(int32 priority)
|
||||
{
|
||||
if (priority != fPriority && CountItems () > 0)
|
||||
RemoveItems (0, CountItems (), true);
|
||||
if (CountItems () < 1)
|
||||
BuildMenu ();
|
||||
if (priority != fPriority && CountItems() > 0)
|
||||
RemoveItems(0, CountItems(), true);
|
||||
if (CountItems() < 1)
|
||||
BuildMenu();
|
||||
|
||||
fPriority = priority;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
char name[32];
|
||||
long priority;
|
||||
@@ -62,13 +67,14 @@ static PriorityRec priorities[] = {
|
||||
|
||||
PriorityRec customPriority = { "Custom", 0 };
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void PriorityMenu::BuildMenu ()
|
||||
|
||||
void
|
||||
PriorityMenu::BuildMenu()
|
||||
{
|
||||
BMenuItem* item;
|
||||
BMessage* message;
|
||||
char name[B_OS_NAME_LENGTH + 20];
|
||||
long found = false;
|
||||
char name[B_OS_NAME_LENGTH + 20];
|
||||
long found = false;
|
||||
|
||||
for (long index = 0; ; index++) {
|
||||
PriorityRec *priority = &priorities[index];
|
||||
@@ -82,7 +88,7 @@ void PriorityMenu::BuildMenu ()
|
||||
message = new BMessage('PrTh');
|
||||
message->AddInt32("thread", fThreadID);
|
||||
message->AddInt32("priority", priority->priority);
|
||||
sprintf(name, "%s Priority [%d]", priority->name, (int) priority->priority);
|
||||
sprintf(name, "%s Priority [%d]", priority->name, (int)priority->priority);
|
||||
item = new BMenuItem(name, message);
|
||||
item->SetTarget(gPCView);
|
||||
if (fPriority == priority->priority)
|
||||
|
||||
+312
-111
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
PCView.cpp
|
||||
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
Copyright (c) 2006 Haiku, Inc. All Rights Reserved.
|
||||
@@ -20,14 +18,24 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "PCView.h"
|
||||
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include "AutoIcon.h"
|
||||
#include "Colors.h"
|
||||
#include "IconMenuItem.h"
|
||||
#include "MemoryBarMenu.h"
|
||||
#include "MemoryBarMenuItem.h"
|
||||
#include "PCWorld.h"
|
||||
#include "Preferences.h"
|
||||
#include "PCUtils.h"
|
||||
#include "Colors.h"
|
||||
#include "QuitMenu.h"
|
||||
#include "TeamBarMenu.h"
|
||||
#include "TeamBarMenuItem.h"
|
||||
#include "ThreadBarMenu.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Deskbar.h>
|
||||
#include <Directory.h>
|
||||
#include <Dragger.h>
|
||||
@@ -35,6 +43,7 @@
|
||||
#include <FindDirectory.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <TextView.h>
|
||||
@@ -73,6 +82,19 @@ ThreadBarMenu* gCurrentThreadBarMenu;
|
||||
bool gInDeskbar = false;
|
||||
int32 gMimicPulse = 0;
|
||||
|
||||
#define addtopbottom(x) if (top) popup->AddItem(x); else popup->AddItem(x, 0)
|
||||
|
||||
long thread_popup(void *arg);
|
||||
|
||||
int32 gPopupFlag = 0;
|
||||
thread_id gPopupThreadID = 0;
|
||||
|
||||
typedef struct {
|
||||
BPoint where;
|
||||
BRect clickToOpenRect;
|
||||
bool top;
|
||||
} Tpopup_param;
|
||||
|
||||
#define DEBUG_THREADS 1
|
||||
|
||||
long thread_quit_application(void *arg);
|
||||
@@ -84,6 +106,27 @@ typedef struct {
|
||||
time_t totalTime;
|
||||
} Tdebug_thead_param;
|
||||
|
||||
// Bar layout depending on number of CPUs
|
||||
|
||||
typedef struct {
|
||||
float cpu_width;
|
||||
float cpu_inter;
|
||||
float mem_width;
|
||||
} layoutT;
|
||||
|
||||
layoutT layout[] = {
|
||||
{ 1, 1, 1 },
|
||||
{ 5, 1, 5 }, // 1
|
||||
{ 3, 1, 4 }, // 2
|
||||
{ 1, 1, 1 },
|
||||
{ 2, 0, 3 }, // 4
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 0, 3 } // 8
|
||||
};
|
||||
|
||||
|
||||
extern "C" _EXPORT BView *instantiate_deskbar_item(void);
|
||||
|
||||
extern "C" _EXPORT BView *
|
||||
@@ -94,8 +137,12 @@ instantiate_deskbar_item(void)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
ProcessController::ProcessController(BRect frame, bool temp)
|
||||
: BView(frame, kDeskbarItemName, B_FOLLOW_NONE, B_WILL_DRAW),
|
||||
: BView(frame, kDeskbarItemName, B_FOLLOW_TOP_BOTTOM,
|
||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||
fProcessControllerIcon(kSignature),
|
||||
fProcessorIcon(k_cpu_mini),
|
||||
fTrackerIcon(kTrackerSig),
|
||||
@@ -105,11 +152,12 @@ ProcessController::ProcessController(BRect frame, bool temp)
|
||||
{
|
||||
if (!temp) {
|
||||
Init();
|
||||
|
||||
frame.OffsetTo(B_ORIGIN);
|
||||
frame.top = frame.bottom - 7;
|
||||
frame.left = frame.right - 7;
|
||||
BDragger* dw = new BDragger(frame, this);
|
||||
AddChild(dw);
|
||||
BDragger* dragger = new BDragger(frame, this, B_FOLLOW_BOTTOM);
|
||||
AddChild(dragger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,10 +254,10 @@ ProcessController::MessageReceived(BMessage *message)
|
||||
|
||||
case 'KlTm':
|
||||
if (message->FindInt32("team", &team) == B_OK) {
|
||||
infosPack infos;
|
||||
if (get_team_info(team, &infos.tminfo) == B_OK) {
|
||||
info_pack infos;
|
||||
if (get_team_info(team, &infos.team_info) == B_OK) {
|
||||
get_team_name_and_icon(infos);
|
||||
sprintf(question, "Do you really want to kill the team \"%s\"?", infos.tmname);
|
||||
sprintf(question, "Do you really want to kill the team \"%s\"?", infos.team_name);
|
||||
alert = new BAlert("", question, "Cancel", "Yes, Kill this Team!", NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
if (alert->Go())
|
||||
@@ -360,6 +408,7 @@ ProcessController::DefaultColors()
|
||||
bool set = false;
|
||||
|
||||
if (gMimicPulse) {
|
||||
// TODO: remove this?
|
||||
BPath prefpath;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &prefpath) == B_OK) {
|
||||
BDirectory prefdir(prefpath.Path ());
|
||||
@@ -412,7 +461,6 @@ ProcessController::DefaultColors()
|
||||
frame_color = kBlack;
|
||||
mix_colors (memory_color, active_color, swap_color, 0.2);
|
||||
}
|
||||
// idle_color = kWhite;
|
||||
}
|
||||
|
||||
|
||||
@@ -428,49 +476,50 @@ ProcessController::AttachedToWindow()
|
||||
GebsPreferences tPreferences(kPreferencesFileName, NULL, false);
|
||||
tPreferences.ReadInt32(gMimicPulse, kMimicPulsePref);
|
||||
DefaultColors();
|
||||
system_info sys_info;
|
||||
get_system_info(&sys_info);
|
||||
gCPUcount = sys_info.cpu_count;
|
||||
|
||||
system_info info;
|
||||
get_system_info(&info);
|
||||
gCPUcount = info.cpu_count;
|
||||
Update();
|
||||
|
||||
gIdleColor = kIdleGreen;
|
||||
gIdleColorSelected = tint_color(gIdleColor, B_HIGHLIGHT_BACKGROUND_TINT);
|
||||
gKernelColor = kKernelBlue;
|
||||
gKernelColorSelected = tint_color(gKernelColor, B_HIGHLIGHT_BACKGROUND_TINT);
|
||||
// gKernelColor = tint_color(gUserColor, B_DARKEN_1_TINT);
|
||||
gUserColor = tint_color(gKernelColor, B_LIGHTEN_2_TINT);
|
||||
gUserColorSelected = tint_color(gUserColor, B_HIGHLIGHT_BACKGROUND_TINT);
|
||||
gFrameColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_HIGHLIGHT_BACKGROUND_TINT);
|
||||
gFrameColorSelected = tint_color(gFrameColor, B_HIGHLIGHT_BACKGROUND_TINT);
|
||||
gMenuBackColor = ui_color(B_MENU_BACKGROUND_COLOR);
|
||||
// Depending on which version of the system we use, choose the menu selection color...
|
||||
if (before_dano())
|
||||
gMenuBackColorSelected = tint_color(gMenuBackColor, B_HIGHLIGHT_BACKGROUND_TINT); // R5 & before
|
||||
else
|
||||
gMenuBackColorSelected = ui_color(B_MENU_SELECTION_BACKGROUND_COLOR); // Dano & up
|
||||
gMenuBackColorSelected = ui_color(B_MENU_SELECTION_BACKGROUND_COLOR);
|
||||
gWhiteSelected = tint_color(kWhite, B_HIGHLIGHT_BACKGROUND_TINT);
|
||||
|
||||
BMessenger messenger (this);
|
||||
BMessage message ('Puls');
|
||||
fMessageRunner = new BMessageRunner (messenger, &message, 250000, -1);
|
||||
BMessenger messenger(this);
|
||||
BMessage message('Puls');
|
||||
fMessageRunner = new BMessageRunner(messenger, &message, 250000, -1);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
float cpu_width;
|
||||
float cpu_inter;
|
||||
float mem_width;
|
||||
} layoutT;
|
||||
|
||||
layoutT layout[] = {
|
||||
{ 1, 1, 1 },
|
||||
{ 5, 1, 5 }, // 1
|
||||
{ 3, 1, 4 }, // 2
|
||||
{ 1, 1, 1 },
|
||||
{ 2, 0, 3 }, // 4
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 0, 3 } }; // 8
|
||||
void
|
||||
ProcessController::MouseDown(BPoint where)
|
||||
{
|
||||
if (atomic_add(&gPopupFlag, 1) > 0) {
|
||||
atomic_add(&gPopupFlag, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
Tpopup_param* param = new Tpopup_param;
|
||||
ConvertToScreen(&where);
|
||||
param->where = where;
|
||||
param->clickToOpenRect = Frame ();
|
||||
ConvertToScreen (¶m->clickToOpenRect);
|
||||
param->top = where.y < BScreen(this->Window()).Frame().bottom-50;
|
||||
|
||||
gPopupThreadID = spawn_thread(thread_popup, "Popup holder thread",
|
||||
B_URGENT_DISPLAY_PRIORITY, param);
|
||||
resume_thread(gPopupThreadID);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
@@ -484,126 +533,276 @@ ProcessController::Draw(BRect)
|
||||
void
|
||||
ProcessController::DoDraw(bool force)
|
||||
{
|
||||
//gCPUcount = 1;
|
||||
BRect bounds(Bounds());
|
||||
|
||||
float h = floorf(bounds.Height ()) - 2;
|
||||
float top = 1, left = 1;
|
||||
float bottom = top + h;
|
||||
float bar_width = layout[gCPUcount].cpu_width;
|
||||
float barWidth = layout[gCPUcount].cpu_width;
|
||||
// interspace
|
||||
float right = left + gCPUcount * (bar_width + layout[gCPUcount].cpu_inter) - layout[gCPUcount].cpu_inter; // right of CPU frame...
|
||||
float right = left + gCPUcount * (barWidth + layout[gCPUcount].cpu_inter)
|
||||
- layout[gCPUcount].cpu_inter; // right of CPU frame...
|
||||
if (force && Parent()) {
|
||||
SetHighColor (Parent ()->ViewColor ());
|
||||
FillRect (BRect (right + 1, top - 1, right + 2, bottom + 1));
|
||||
SetHighColor(Parent()->ViewColor ());
|
||||
FillRect(BRect(right + 1, top - 1, right + 2, bottom + 1));
|
||||
}
|
||||
|
||||
if (force) {
|
||||
SetHighColor (frame_color);
|
||||
StrokeRect (BRect (left - 1, top - 1, right, bottom + 1));
|
||||
SetHighColor(frame_color);
|
||||
StrokeRect(BRect(left - 1, top - 1, right, bottom + 1));
|
||||
if (gCPUcount == 2)
|
||||
StrokeLine (BPoint (left + bar_width, top), BPoint (left + bar_width, bottom));
|
||||
StrokeLine(BPoint(left + barWidth, top), BPoint(left + barWidth, bottom));
|
||||
}
|
||||
float leftMem = bounds.Width () - layout[gCPUcount].mem_width;
|
||||
float leftMem = bounds.Width() - layout[gCPUcount].mem_width;
|
||||
if (force)
|
||||
StrokeRect (BRect (leftMem - 1, top - 1, leftMem + layout[gCPUcount].mem_width, bottom + 1));
|
||||
StrokeRect(BRect(leftMem - 1, top - 1, leftMem + layout[gCPUcount].mem_width, bottom + 1));
|
||||
|
||||
for (int x = 0; x < gCPUcount; x++) {
|
||||
right = left + bar_width - 1;
|
||||
right = left + barWidth - 1;
|
||||
float rem = fCPUTimes[x] * (h + 1);
|
||||
float bar_height = floorf (rem);
|
||||
rem -= bar_height;
|
||||
float limit = bottom - bar_height; // horizontal line
|
||||
float previous_limit = bottom - fLastBarHeight[x];
|
||||
float idle_top = top;
|
||||
if (!force && previous_limit > top)
|
||||
idle_top = previous_limit - 1;
|
||||
if (limit > idle_top) {
|
||||
SetHighColor (idle_color);
|
||||
FillRect (BRect (left, idle_top, right, limit - 1));
|
||||
float barHeight = floorf (rem);
|
||||
rem -= barHeight;
|
||||
float limit = bottom - barHeight; // horizontal line
|
||||
float previousLimit = bottom - fLastBarHeight[x];
|
||||
float idleTop = top;
|
||||
|
||||
if (!force && previousLimit > top)
|
||||
idleTop = previousLimit - 1;
|
||||
if (limit > idleTop) {
|
||||
SetHighColor(idle_color);
|
||||
FillRect(BRect(left, idleTop, right, limit - 1));
|
||||
}
|
||||
if (bar_height <= h) {
|
||||
if (barHeight <= h) {
|
||||
rgb_color fraction_color;
|
||||
mix_colors (fraction_color, idle_color, active_color, rem);
|
||||
SetHighColor (fraction_color);
|
||||
StrokeLine (BPoint (left, bottom - bar_height), BPoint (right, bottom - bar_height));
|
||||
mix_colors(fraction_color, idle_color, active_color, rem);
|
||||
SetHighColor(fraction_color);
|
||||
StrokeLine(BPoint(left, bottom - barHeight), BPoint(right, bottom - barHeight));
|
||||
}
|
||||
float active_bottom = bottom;
|
||||
if (!force && previous_limit < bottom)
|
||||
active_bottom = previous_limit + 1;
|
||||
if (!force && previousLimit < bottom)
|
||||
active_bottom = previousLimit + 1;
|
||||
if (limit < active_bottom) {
|
||||
SetHighColor(active_color);
|
||||
FillRect(BRect(left, limit + 1, right, active_bottom));
|
||||
}
|
||||
left += layout[gCPUcount].cpu_width + layout[gCPUcount].cpu_inter;
|
||||
fLastBarHeight[x] = bar_height;
|
||||
fLastBarHeight[x] = barHeight;
|
||||
}
|
||||
|
||||
float rightMem = bounds.Width () - 1;
|
||||
float rem = fMemoryUsage * (h + 1);
|
||||
float bar_height = floorf (rem);
|
||||
rem -= bar_height;
|
||||
float barHeight = floorf (rem);
|
||||
rem -= barHeight;
|
||||
|
||||
rgb_color used_memory_color;
|
||||
float sq = fMemoryUsage * fMemoryUsage;
|
||||
sq *= sq;
|
||||
sq *= sq;
|
||||
mix_colors (used_memory_color, memory_color, swap_color, sq);
|
||||
mix_colors(used_memory_color, memory_color, swap_color, sq);
|
||||
|
||||
float limit = bottom - bar_height; // horizontal line
|
||||
float previous_limit = bottom - fLastMemoryHeight;
|
||||
float limit = bottom - barHeight; // horizontal line
|
||||
float previousLimit = bottom - fLastMemoryHeight;
|
||||
float free_top = top;
|
||||
if (!force && previous_limit > top)
|
||||
free_top = previous_limit - 1;
|
||||
if (!force && previousLimit > top)
|
||||
free_top = previousLimit - 1;
|
||||
if (limit > free_top) {
|
||||
SetHighColor (idle_color);
|
||||
FillRect (BRect (leftMem, free_top, rightMem, limit - 1));
|
||||
FillRect(BRect(leftMem, free_top, rightMem, limit - 1));
|
||||
}
|
||||
if (bar_height <= h) {
|
||||
if (barHeight <= h) {
|
||||
rgb_color fraction_color;
|
||||
mix_colors (fraction_color, idle_color, used_memory_color, rem);
|
||||
SetHighColor (fraction_color);
|
||||
StrokeLine (BPoint (leftMem, bottom - bar_height), BPoint (rightMem, bottom - bar_height));
|
||||
mix_colors(fraction_color, idle_color, used_memory_color, rem);
|
||||
SetHighColor(fraction_color);
|
||||
StrokeLine(BPoint(leftMem, bottom - barHeight), BPoint(rightMem, bottom - barHeight));
|
||||
}
|
||||
float used_bottom = bottom;
|
||||
// if (!force && previous_limit < bottom)
|
||||
// used_bottom = previous_limit + 1;
|
||||
if (limit < used_bottom) {
|
||||
SetHighColor (used_memory_color);
|
||||
FillRect (BRect (leftMem, limit + 1, rightMem, used_bottom));
|
||||
float usedBottom = bottom;
|
||||
// if (!force && previousLimit < bottom)
|
||||
// usedBottom = previousLimit + 1;
|
||||
if (limit < usedBottom) {
|
||||
SetHighColor(used_memory_color);
|
||||
FillRect(BRect(leftMem, limit + 1, rightMem, usedBottom));
|
||||
}
|
||||
fLastMemoryHeight = bar_height;
|
||||
fLastMemoryHeight = barHeight;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProcessController::Update()
|
||||
{
|
||||
system_info sys_info;
|
||||
get_system_info(&sys_info);
|
||||
system_info info;
|
||||
get_system_info(&info);
|
||||
bigtime_t now = system_time();
|
||||
|
||||
fMemoryUsage = float(sys_info.used_pages) / float(sys_info.max_pages);
|
||||
fMemoryUsage = float(info.used_pages) / float(info.max_pages);
|
||||
// Calculate work done since last call to Update() for each CPU
|
||||
for (int x = 0; x < gCPUcount; x++) {
|
||||
bigtime_t load = sys_info.cpu_infos[x].active_time - fPrevActive[x];
|
||||
bigtime_t passed = now - fPrevTime;
|
||||
float cpu_time = float(load) / float(passed);
|
||||
fPrevActive[x] = sys_info.cpu_infos[x].active_time;
|
||||
bigtime_t load = info.cpu_infos[x].active_time - fPrevActive[x];
|
||||
bigtime_t passed = now - fPrevTime;
|
||||
float cpuTime = float(load) / float(passed);
|
||||
|
||||
fPrevActive[x] = info.cpu_infos[x].active_time;
|
||||
if (load > passed)
|
||||
fPrevActive[x] -= load - passed; // save overload for next period...
|
||||
if (cpu_time < 0) cpu_time = 0;
|
||||
if (cpu_time > 1) cpu_time = 1;
|
||||
fCPUTimes[x] = cpu_time;
|
||||
if (cpuTime < 0)
|
||||
cpuTime = 0;
|
||||
if (cpuTime > 1)
|
||||
cpuTime = 1;
|
||||
fCPUTimes[x] = cpuTime;
|
||||
}
|
||||
fPrevTime = now;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
long
|
||||
thread_popup(void *arg)
|
||||
{
|
||||
Tpopup_param* param = (Tpopup_param*) arg;
|
||||
int32 mcookie, hcookie;
|
||||
long m, h;
|
||||
BMenuItem* item;
|
||||
bool top = param->top;
|
||||
|
||||
system_info systemInfo;
|
||||
get_system_info(&systemInfo);
|
||||
info_pack* infos = new info_pack[systemInfo.used_teams];
|
||||
// TODO: this doesn't necessarily get all teams
|
||||
for (m = 0, mcookie = 0; m < systemInfo.used_teams; m++) {
|
||||
infos[m].team_icon = NULL;
|
||||
infos[m].team_name[0] = 0;
|
||||
infos[m].thread_info = NULL;
|
||||
if (get_next_team_info(&mcookie, &infos[m].team_info) == B_OK) {
|
||||
infos[m].thread_info = new thread_info[infos[m].team_info.thread_count];
|
||||
for (h = 0, hcookie = 0; h < infos[m].team_info.thread_count; h++) {
|
||||
if (get_next_thread_info(infos[m].team_info.team, &hcookie, &infos[m].thread_info[h]) != B_OK)
|
||||
infos[m].thread_info[h].thread = -1;
|
||||
}
|
||||
get_team_name_and_icon(infos[m], true);
|
||||
} else {
|
||||
systemInfo.used_teams = m;
|
||||
infos[m].team_info.team = -1;
|
||||
}
|
||||
}
|
||||
|
||||
BPopUpMenu* popup = new BPopUpMenu("Global Popup", false, false);
|
||||
popup->SetFont(be_plain_font);
|
||||
|
||||
// Quit section
|
||||
BMenu* QuitPopup = new QuitMenu("Quit an Application", infos, systemInfo.used_teams);
|
||||
QuitPopup->SetFont(be_plain_font);
|
||||
popup->AddItem(QuitPopup);
|
||||
|
||||
// Memory Usage section
|
||||
MemoryBarMenu* MemoryPopup = new MemoryBarMenu("Memory Usage", infos, systemInfo);
|
||||
int commitedMemory = int(systemInfo.used_pages * B_PAGE_SIZE / 1024);
|
||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||
if (infos[m].team_info.team >= 0) {
|
||||
MemoryBarMenuItem* memoryItem = new MemoryBarMenuItem(infos[m].team_name, infos[m].team_info.team, infos[m].team_icon, false, NULL);
|
||||
MemoryPopup->AddItem(memoryItem);
|
||||
memoryItem->UpdateSituation(commitedMemory);
|
||||
}
|
||||
}
|
||||
|
||||
addtopbottom(MemoryPopup);
|
||||
|
||||
// CPU Load section
|
||||
TeamBarMenu* CPUPopup = new TeamBarMenu("Threads and CPU Usage", infos, systemInfo.used_teams);
|
||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||
if (infos[m].team_info.team >= 0) {
|
||||
ThreadBarMenu* TeamPopup = new ThreadBarMenu(infos[m].team_name, infos[m].team_info.team, infos[m].team_info.thread_count);
|
||||
BMessage* kill_team = new BMessage('KlTm');
|
||||
kill_team->AddInt32("team", infos[m].team_info.team);
|
||||
TeamBarMenuItem* item = new TeamBarMenuItem(TeamPopup, kill_team, infos[m].team_info.team, infos[m].team_icon, false);
|
||||
item->SetTarget(gPCView);
|
||||
CPUPopup->AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
addtopbottom(CPUPopup);
|
||||
addtopbottom(new BSeparatorItem());
|
||||
|
||||
// CPU on/off section
|
||||
if (gCPUcount > 1) {
|
||||
for (int i = 0; i < gCPUcount; i++) {
|
||||
char item_name[32];
|
||||
sprintf (item_name, "Processor %d", i + 1);
|
||||
BMessage* m = new BMessage ('CPU ');
|
||||
m->AddInt32 ("cpu", i);
|
||||
item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m);
|
||||
if (_kget_cpu_state_(i))
|
||||
item->SetMarked (true);
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
addtopbottom (new BSeparatorItem ());
|
||||
}
|
||||
|
||||
if (!be_roster->IsRunning(kTrackerSig)) {
|
||||
item = new IconMenuItem(gPCView->fTrackerIcon, "Launch Tracker", new BMessage('Trac'));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
if (!be_roster->IsRunning(kDeskbarSig)) {
|
||||
item = new IconMenuItem(gPCView->fDeskbarIcon, "Launch Deskbar", new BMessage('Dbar'));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
|
||||
item = new IconMenuItem(gPCView->fTerminalIcon, "New Terminal", new BMessage('Term'));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
|
||||
addtopbottom(new BSeparatorItem());
|
||||
|
||||
if (be_roster->IsRunning(kDeskbarSig)) {
|
||||
item = new BMenuItem("Live in the Deskbar", new BMessage('AlDb'));
|
||||
BDeskbar deskbar;
|
||||
item->SetMarked(gInDeskbar || deskbar.HasItem(kDeskbarItemName));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
}
|
||||
|
||||
#if 0
|
||||
item = new BMenuItem("Use Pulse's Settings for Colors", new BMessage ('Colo'));
|
||||
item->SetTarget (gPCView);
|
||||
item->SetMarked (gMimicPulse);
|
||||
addtopbottom (item);
|
||||
#endif
|
||||
|
||||
addtopbottom(new BSeparatorItem ());
|
||||
|
||||
item = new IconMenuItem(gPCView->fProcessControllerIcon, "About ProcessController",
|
||||
new BMessage(B_ABOUT_REQUESTED));
|
||||
item->SetTarget(gPCView);
|
||||
addtopbottom(item);
|
||||
|
||||
param->where.x -= 5;
|
||||
param->where.y -= 8;
|
||||
popup->Go(param->where, true, true, param->clickToOpenRect);
|
||||
|
||||
delete popup;
|
||||
for (m = 0; m < systemInfo.used_teams; m++) {
|
||||
if (infos[m].team_info.team >= 0) {
|
||||
delete[] infos[m].thread_info;
|
||||
delete infos[m].team_icon;
|
||||
}
|
||||
}
|
||||
delete[] infos;
|
||||
delete param;
|
||||
atomic_add (&gPopupFlag, -1);
|
||||
gPopupThreadID = 0;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
long
|
||||
thread_quit_application(void *arg)
|
||||
{
|
||||
BMessenger messenger (NULL, (team_id) arg);
|
||||
messenger.SendMessage (B_QUIT_REQUESTED);
|
||||
BMessenger messenger(NULL, (team_id)arg);
|
||||
messenger.SendMessage(B_QUIT_REQUESTED);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -614,9 +813,9 @@ thread_debug_thread(void *arg)
|
||||
Tdebug_thead_param* param = (Tdebug_thead_param*) arg;
|
||||
thread_info thinfo;
|
||||
get_thread_info(param->thread, &thinfo);
|
||||
char texte[4096];
|
||||
sprintf (texte, "db %d", int(param->thread));
|
||||
system (texte);
|
||||
char text[4096];
|
||||
sprintf(text, "db %d", int(param->thread));
|
||||
system(text);
|
||||
if (param->sem >= 0 && thinfo.state == B_THREAD_WAITING && param->sem == thinfo.sem) {
|
||||
snooze(1000000);
|
||||
get_thread_info(param->thread, &thinfo);
|
||||
@@ -626,28 +825,30 @@ thread_debug_thread(void *arg)
|
||||
// the thread has been waiting for this semaphore since the before the alert, not doing anything... Let's push it out of there!
|
||||
sem_info sinfo;
|
||||
thread_info thinfo;
|
||||
infosPack infos;
|
||||
info_pack infos;
|
||||
|
||||
if (get_sem_info(param->sem, &sinfo) == B_OK
|
||||
&& get_thread_info(param->thread, &thinfo) == B_OK
|
||||
&& get_team_info(thinfo.team, &infos.tminfo) == B_OK) {
|
||||
sprintf (texte, "This thread is waiting for the semaphore called \"%s\". As long as it waits for this semaphore, "
|
||||
&& get_team_info(thinfo.team, &infos.team_info) == B_OK) {
|
||||
sprintf (text, "This thread is waiting for the semaphore called \"%s\". As long as it waits for this semaphore, "
|
||||
"you won't be able to debug that thread.\n", sinfo.name);
|
||||
if (sinfo.team == thinfo.team)
|
||||
strcat (texte, "This semaphore belongs to the thread's team.\n\nShould I release this semaphore?\n");
|
||||
strcat(text, "This semaphore belongs to the thread's team.\n\nShould I release this semaphore?\n");
|
||||
else {
|
||||
get_team_name_and_icon (infos);
|
||||
char moretexte[1024];
|
||||
sprintf (moretexte, "\nWARNING! This semaphore belongs to the team \"%s\"!\n\nShould I release this semaphore anyway?\n", infos.tmname);
|
||||
strcat (texte, moretexte);
|
||||
get_team_name_and_icon(infos);
|
||||
char moreText[1024];
|
||||
sprintf(moreText, "\nWARNING! This semaphore belongs to the team \"%s\"!\n\nShould I release this semaphore anyway?\n",
|
||||
infos.team_name);
|
||||
strcat(text, moreText);
|
||||
}
|
||||
|
||||
BAlert* alert = new BAlert("", texte, "Cancel", "Release", NULL,
|
||||
BAlert* alert = new BAlert("", text, "Cancel", "Release", NULL,
|
||||
B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
if (alert->Go()) {
|
||||
get_thread_info (param->thread, &thinfo);
|
||||
if (thinfo.state == B_THREAD_WAITING && param->sem == thinfo.sem && param->totalTime == thinfo.user_time + thinfo.kernel_time)
|
||||
if (thinfo.state == B_THREAD_WAITING && param->sem == thinfo.sem
|
||||
&& param->totalTime == thinfo.user_time + thinfo.kernel_time)
|
||||
release_sem(param->sem);
|
||||
else {
|
||||
alert = new BAlert("", "The semaphore wasn't released, because it wasn't necessary anymore!", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
@@ -84,7 +84,6 @@ extern rgb_color gMenuBackColorSelected;
|
||||
extern rgb_color gWhiteSelected;
|
||||
extern ThreadBarMenu* gCurrentThreadBarMenu;
|
||||
extern thread_id gPopupThreadID;
|
||||
extern team_id gAppServerTeamID;
|
||||
extern const char* kDeskbarItemName;
|
||||
extern bool gInDeskbar;
|
||||
extern int32 gMimicPulse;
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
QuitMenu.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,62 +15,76 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "QuitMenu.h"
|
||||
#include "IconMenuItem.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <Roster.h>
|
||||
#include <Window.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "QuitMenu.h"
|
||||
#include "IconMenuItem.h"
|
||||
#include "PCView.h"
|
||||
|
||||
class QuitMenuItem : public IconMenuItem {
|
||||
public:
|
||||
QuitMenuItem(team_id team, BBitmap* icon, const char* title, BMessage* m, bool purge = false);
|
||||
team_id Team() { return fTeam; }
|
||||
|
||||
public:
|
||||
QuitMenuItem(team_id team, BBitmap* icon, const char* title, BMessage* m, bool purge = false);
|
||||
team_id Team() { return fTeam; }
|
||||
|
||||
private:
|
||||
team_id fTeam;
|
||||
private:
|
||||
team_id fTeam;
|
||||
};
|
||||
|
||||
|
||||
QuitMenuItem::QuitMenuItem(team_id team, BBitmap* icon, const char* title, BMessage* m, bool purge) :
|
||||
IconMenuItem(icon, title, m, true, purge), fTeam(team)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
QuitMenu::QuitMenu(const char* title, infosPack * infos, int infosCount) :
|
||||
BMenu(title), fInfos(infos), fInfosCount(infosCount), fMe(NULL)
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
QuitMenu::QuitMenu(const char* title, info_pack* infos, int infosCount)
|
||||
: BMenu(title),
|
||||
fInfos(infos),
|
||||
fInfosCount(infosCount),
|
||||
fMe(NULL)
|
||||
{
|
||||
SetTargetForItems(gPCView);
|
||||
}
|
||||
|
||||
void QuitMenu::AttachedToWindow()
|
||||
|
||||
void
|
||||
QuitMenu::AttachedToWindow()
|
||||
{
|
||||
if (!fMe)
|
||||
fMe = new BMessenger(this);
|
||||
|
||||
be_roster->StartWatching(*fMe, B_REQUEST_LAUNCHED | B_REQUEST_QUIT);
|
||||
BList apps;
|
||||
team_id tmid;
|
||||
BList apps;
|
||||
team_id tmid;
|
||||
be_roster->GetAppList(&apps);
|
||||
for (int t = CountItems() - 1; t >= 0; t--) {
|
||||
QuitMenuItem* item = (QuitMenuItem*) ItemAt(t);
|
||||
bool found = false;
|
||||
for (int a = 0; !found && (tmid = (team_id) apps.ItemAt(a)) != 0; a++)
|
||||
QuitMenuItem* item = (QuitMenuItem*)ItemAt(t);
|
||||
bool found = false;
|
||||
for (int a = 0; !found && (tmid = (team_id)apps.ItemAt(a)) != 0; a++)
|
||||
if (item->Team() == tmid)
|
||||
found = true;
|
||||
if (!found)
|
||||
RemoveItem(t);
|
||||
}
|
||||
for (int a = 0; (tmid = (team_id) apps.ItemAt(a)) != 0; a++)
|
||||
for (int a = 0; (tmid = (team_id) apps.ItemAt(a)) != 0; a++) {
|
||||
AddTeam(tmid);
|
||||
}
|
||||
|
||||
BMenu::AttachedToWindow();
|
||||
}
|
||||
|
||||
void QuitMenu::DetachedFromWindow()
|
||||
|
||||
void
|
||||
QuitMenu::DetachedFromWindow()
|
||||
{
|
||||
BMenu::DetachedFromWindow();
|
||||
be_roster->StopWatching(*fMe);
|
||||
@@ -82,57 +92,68 @@ void QuitMenu::DetachedFromWindow()
|
||||
fMe = NULL;
|
||||
}
|
||||
|
||||
void QuitMenu::AddTeam(team_id tmid)
|
||||
|
||||
void
|
||||
QuitMenu::AddTeam(team_id tmid)
|
||||
{
|
||||
int t = 0;
|
||||
QuitMenuItem* item;
|
||||
while ((item = (QuitMenuItem*) ItemAt(t++)) != NULL)
|
||||
QuitMenuItem* item;
|
||||
while ((item = (QuitMenuItem*) ItemAt(t++)) != NULL) {
|
||||
if (item->Team() == tmid)
|
||||
return;
|
||||
}
|
||||
|
||||
t = 0;
|
||||
while (t < fInfosCount && tmid != fInfos[t].tminfo.team)
|
||||
while (t < fInfosCount && tmid != fInfos[t].team_info.team) {
|
||||
t++;
|
||||
}
|
||||
|
||||
BMessage* message = new BMessage ('QtTm');
|
||||
message->AddInt32 ("team", tmid);
|
||||
item = NULL;
|
||||
if (t < fInfosCount)
|
||||
item = new QuitMenuItem (tmid, fInfos[t].tmicon, fInfos[t].tmname, message);
|
||||
item = new QuitMenuItem(tmid, fInfos[t].team_icon, fInfos[t].team_name, message);
|
||||
else {
|
||||
infosPack infos;
|
||||
if (get_team_info(tmid, &infos.tminfo) == B_OK && get_team_name_and_icon(infos, true))
|
||||
item = new QuitMenuItem (tmid, infos.tmicon, infos.tmname, message, true);
|
||||
info_pack infos;
|
||||
if (get_team_info(tmid, &infos.team_info) == B_OK
|
||||
&& get_team_name_and_icon(infos, true))
|
||||
item = new QuitMenuItem(tmid, infos.team_icon, infos.team_name, message, true);
|
||||
}
|
||||
if (item) {
|
||||
item->SetTarget (gPCView);
|
||||
AddItem (item);
|
||||
item->SetTarget(gPCView);
|
||||
AddItem(item);
|
||||
} else
|
||||
delete message;
|
||||
}
|
||||
|
||||
void QuitMenu::MessageReceived(BMessage *msg)
|
||||
|
||||
void
|
||||
QuitMenu::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case B_SOME_APP_LAUNCHED:
|
||||
{
|
||||
int32 tmid;
|
||||
int32 tmid;
|
||||
if (msg->FindInt32("be:team", &tmid) == B_OK)
|
||||
AddTeam(tmid);
|
||||
break;
|
||||
}
|
||||
case B_SOME_APP_QUIT:
|
||||
{
|
||||
int32 tmid;
|
||||
int32 tmid;
|
||||
if (msg->FindInt32("be:team", &tmid) == B_OK) {
|
||||
QuitMenuItem* item;
|
||||
QuitMenuItem* item;
|
||||
int t = 0;
|
||||
while ((item = (QuitMenuItem*) ItemAt(t++)) != NULL)
|
||||
while ((item = (QuitMenuItem*) ItemAt(t++)) != NULL) {
|
||||
if (item->Team() == tmid) {
|
||||
delete RemoveItem(--t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BMenu::MessageReceived(msg);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
QuitMenu.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,28 +15,29 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _QUIT_MENU_H_
|
||||
#define _QUIT_MENU_H_
|
||||
|
||||
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Menu.h>
|
||||
#include <Messenger.h>
|
||||
#include "PCUtils.h"
|
||||
|
||||
class QuitMenu : public BMenu
|
||||
{
|
||||
public:
|
||||
QuitMenu(const char* title, infosPack * infos, int infosCount);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
void AddTeam(team_id tmid);
|
||||
private:
|
||||
const infosPack *fInfos;
|
||||
int fInfosCount;
|
||||
BMessenger *fMe;
|
||||
|
||||
class QuitMenu : public BMenu {
|
||||
public:
|
||||
QuitMenu(const char* title, info_pack* infos, int infosCount);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
void AddTeam(team_id tmid);
|
||||
|
||||
private:
|
||||
const info_pack* fInfos;
|
||||
int fInfosCount;
|
||||
BMessenger* fMe;
|
||||
};
|
||||
|
||||
#endif // _QUIT_MENU_H_
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
/*
|
||||
|
||||
ReadableLong.cpp
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "ReadableLong.h"
|
||||
#include "ctype.h"
|
||||
#include "stdio.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
ulong value;
|
||||
} TBeValue;
|
||||
|
||||
const TBeValue bevalue[] = {
|
||||
{ "B_ERROR", 0xffff },
|
||||
{ "B_OK", 0 },
|
||||
// AppDefs.h
|
||||
{ "B_ABOUT_REQUESTED", '_ABR' },
|
||||
{ "B_APP_ACTIVATED", '_ACT' }, // Also B_WINDOW_ACTIVATED
|
||||
{ "B_ARGV_RECEIVED", '_ARG' },
|
||||
{ "B_QUIT_REQUESTED", '_QRQ' }, // Also B_CLOSE_REQUESTED
|
||||
{ "B_CANCEL", '_CNC' },
|
||||
{ "B_KEY_DOWN", '_KYD' },
|
||||
{ "B_KEY_UP", '_KYU' },
|
||||
{ "B_UNMAPPED_KEY_DOWN", '_UKD' },
|
||||
{ "B_UNMAPPED_KEY_UP", '_UKU' },
|
||||
{ "B_MODIFIERS_CHANGED", '_MCH' },
|
||||
{ "B_MINIMIZE", '_WMN' },
|
||||
{ "B_MOUSE_DOWN", '_MDN' },
|
||||
{ "B_MOUSE_MOVED", '_MMV' },
|
||||
{ "B_MOUSE_ENTER_EXIT", '_MEX' },
|
||||
{ "B_MOUSE_UP", '_MUP' },
|
||||
{ "B_OPEN_IN_WORKSPACE", '_OWS' },
|
||||
{ "B_PULSE", '_PUL' },
|
||||
{ "B_READY_TO_RUN", '_RTR' },
|
||||
{ "B_REFS_RECEIVED", '_RRC' },
|
||||
{ "B_SCREEN_CHANGED", '_SCH' },
|
||||
{ "B_VALUE_CHANGED", '_VCH' },
|
||||
{ "B_VIEW_MOVED", '_VMV' },
|
||||
{ "B_VIEW_RESIZED", '_VRS' },
|
||||
{ "B_WINDOW_MOVED", '_WMV' },
|
||||
{ "B_WINDOW_RESIZED", '_WRS' },
|
||||
{ "B_WORKSPACES_CHANGED", '_WCG' },
|
||||
{ "B_WORKSPACE_ACTIVATED", '_WAC' },
|
||||
{ "B_ZOOM", '_WZM' },
|
||||
{ "_APP_MENU_", '_AMN' },
|
||||
{ "_BROWSER_MENUS_", '_BRM' },
|
||||
{ "_MENU_EVENT_", '_MEV' },
|
||||
{ "_PING_", '_PBL' },
|
||||
{ "_QUIT_", '_QIT' },
|
||||
{ "_VOLUME_MOUNTED_", '_NVL' },
|
||||
{ "_VOLUME_UNMOUNTED_", '_VRM' },
|
||||
{ "_MESSAGE_DROPPED_", '_MDP' },
|
||||
{ "_DISPOSE_DRAG_", '_DPD' },
|
||||
{ "_MENUS_DONE_", '_MND' },
|
||||
{ "_SHOW_DRAG_HANDLES_", '_SDH' },
|
||||
{ "_EVENTS_PENDING_", '_EVP' },
|
||||
{ "_UPDATE_", '_UPD' },
|
||||
{ "_UPDATE_IF_NEEDED_", '_UPN' },
|
||||
{ "_PRINTER_INFO_", '_PIN' },
|
||||
{ "_SETUP_PRINTER_", '_SUP' },
|
||||
{ "_SELECT_PRINTER_", '_PSL' },
|
||||
{ "B_SET_PROPERTY", 'PSET' },
|
||||
{ "B_GET_PROPERTY", 'PGET' },
|
||||
{ "B_CREATE_PROPERTY", 'PCRT' },
|
||||
{ "B_DELETE_PROPERTY", 'PDEL' },
|
||||
{ "B_COUNT_PROPERTIES", 'PCNT' },
|
||||
{ "B_EXECUTE_PROPERTY", 'PEXE' },
|
||||
{ "B_GET_SUPPORTED_SUITES", 'SUIT' },
|
||||
{ "B_UNDO", 'UNDO' },
|
||||
{ "B_CUT", 'CCUT' },
|
||||
{ "B_COPY", 'COPY' },
|
||||
{ "B_PASTE", 'PSTE' },
|
||||
{ "B_SELECT_ALL", 'SALL' },
|
||||
{ "B_SAVE_REQUESTED", 'SAVE' },
|
||||
{ "B_MESSAGE_NOT_UNDERSTOOD", 'MNOT' },
|
||||
{ "B_NO_REPLY", 'NONE' },
|
||||
{ "B_REPLY", 'RPLY' },
|
||||
{ "B_SIMPLE_DATA", 'DATA' },
|
||||
{ "B_MIME_DATA", 'MIME' },
|
||||
{ "B_ARCHIVED_OBJECT", 'ARCV' },
|
||||
{ "B_UPDATE_STATUS_BAR", 'SBUP' },
|
||||
{ "B_RESET_STATUS_BAR", 'SBRS' },
|
||||
{ "B_NODE_MONITOR", 'NDMN' },
|
||||
{ "B_QUERY_UPDATE", 'QUPD' },
|
||||
{ "B_ENDORSABLE", 'ENDO' },
|
||||
{ "B_COPY_TARGET", 'DDCP' },
|
||||
{ "B_MOVE_TARGET", 'DDMV' },
|
||||
{ "B_TRASH_TARGET", 'DDRM' },
|
||||
{ "B_LINK_TARGET", 'DDLN' },
|
||||
{ "B_INPUT_DEVICES_CHANGED", 'IDCH' },
|
||||
{ "B_INPUT_METHOD_EVENT", 'IMEV' },
|
||||
{ "B_WINDOW_MOVE_TO", 'WDMT' },
|
||||
{ "B_WINDOW_MOVE_BY", 'WDMB' },
|
||||
{ "B_SILENT_RELAUNCH", 'AREL' },
|
||||
// Clipboard.h
|
||||
{ "B_CLIPBOARD_CHANGED", 'CLCH' },
|
||||
// MediaNode.h
|
||||
{ "B_NODE_FAILED_START", 'TRI0' },
|
||||
{ "B_NODE_FAILED_STOP", 'TRI1' },
|
||||
{ "B_NODE_FAILED_SEEK", 'TRI2' },
|
||||
{ "B_NODE_FAILED_SET_RUN_MODE", 'TRI3' },
|
||||
{ "B_NODE_FAILED_TIME_WARP", 'TRI4' },
|
||||
{ "B_NODE_FAILED_PREROLL", 'TRI5' },
|
||||
{ "B_NODE_FAILED_SET_TIME_SOURCE_FOR", 'TRI6' },
|
||||
{ "B_NODE_IN_DISTRESS", 'TRI7' },
|
||||
// TypeConstants.h
|
||||
{ "B_ANY_TYPE", 'ANYT' },
|
||||
{ "B_ASCII_TYPE", 'TEXT' },
|
||||
{ "B_BOOL_TYPE", 'BOOL' },
|
||||
{ "B_CHAR_TYPE", 'CHAR' },
|
||||
{ "B_COLOR_8_BIT_TYPE", 'CLRB' },
|
||||
{ "B_DOUBLE_TYPE", 'DBLE' },
|
||||
{ "B_FLOAT_TYPE", 'FLOT' },
|
||||
{ "B_GRAYSCALE_8_BIT_TYPE", 'GRYB' },
|
||||
{ "B_INT64_TYPE", 'LLNG' },
|
||||
{ "B_INT32_TYPE", 'LONG' },
|
||||
{ "B_INT16_TYPE", 'SHRT' },
|
||||
{ "B_INT8_TYPE", 'BYTE' },
|
||||
{ "B_MESSAGE_TYPE", 'MSGG' },
|
||||
{ "B_MESSENGER_TYPE", 'MSNG' },
|
||||
{ "B_MIME_TYPE", 'MIME' },
|
||||
{ "B_MONOCHROME_1_BIT_TYPE", 'MNOB' },
|
||||
{ "B_OBJECT_TYPE", 'OPTR' },
|
||||
{ "B_OFF_T_TYPE", 'OFFT' },
|
||||
{ "B_PATTERN_TYPE", 'PATN' },
|
||||
{ "B_POINTER_TYPE", 'PNTR' },
|
||||
{ "B_POINT_TYPE", 'BPNT' },
|
||||
{ "B_RAW_TYPE", 'RAWT' },
|
||||
{ "B_RECT_TYPE", 'RECT' },
|
||||
{ "B_REF_TYPE", 'RREF' },
|
||||
{ "B_RGB_32_BIT_TYPE", 'RGBB' },
|
||||
{ "B_RGB_COLOR_TYPE", 'RGBC' },
|
||||
{ "B_SIZE_T_TYPE", 'SIZT' },
|
||||
{ "B_SSIZE_T_TYPE", 'SSZT' },
|
||||
{ "B_STRING_TYPE", 'CSTR' },
|
||||
{ "B_TIME_TYPE", 'TIME' },
|
||||
{ "B_UINT64_TYPE", 'ULLG' },
|
||||
{ "B_UINT32_TYPE", 'ULNG' },
|
||||
{ "B_UINT16_TYPE", 'USHT' },
|
||||
{ "B_UINT8_TYPE", 'UBYT' },
|
||||
{ "B_MEDIA_PARAMETER_TYPE", 'BMCT' },
|
||||
{ "B_MEDIA_PARAMETER_WEB_TYPE", 'BMCW' },
|
||||
{ "B_MEDIA_PARAMETER_GROUP_TYPE", 'BMCG' },
|
||||
{ "_DEPRECATED_TYPE_1_", 'PATH' },
|
||||
// Mime.h
|
||||
{ "B_MIME_STRING_TYPE", 'MIMS' },
|
||||
{ "B_META_MIME_CHANGED", 'MMCH' },
|
||||
// NetPositive.h
|
||||
{ "B_NETPOSITIVE_OPEN_URL", 'NPOP'},
|
||||
{ "B_NETPOSITIVE_BACK", 'NPBK' },
|
||||
{ "B_NETPOSITIVE_FORWARD", 'NPFW' },
|
||||
{ "B_NETPOSITIVE_HOME", 'NPHM' },
|
||||
{ "B_NETPOSITIVE_RELOAD", 'NPRL' },
|
||||
{ "B_NETPOSITIVE_STOP", 'NPST' },
|
||||
// ParameterWeb.h
|
||||
{ "B_MEDIA_PARAMETER_TYPE", 'BMCT' },
|
||||
{ "B_MEDIA_PARAMETER_WEB_TYPE", 'BMCW' },
|
||||
{ "B_MEDIA_PARAMETER_GROUP_TYPE", 'BMCG' },
|
||||
// PropertyInfo.h
|
||||
{ "B_PROPERTY_INFO_TYPE", 'SCTD' },
|
||||
// ResourceStrings.h
|
||||
{ "RESOURCE_TYPE", 'CSTR' },
|
||||
// Roster.h
|
||||
{ "B_SOME_APP_LAUNCHED", 'BRAS' },
|
||||
{ "B_SOME_APP_QUIT", 'BRAQ' },
|
||||
{ "B_SOME_APP_ACTIVATED", 'BRAW' },
|
||||
// TranslatorFormats.h
|
||||
{ "B_TRANSLATOR_BITMAP", 'bits' },
|
||||
{ "B_TRANSLATOR_PICTURE", 'pict' },
|
||||
{ "B_TRANSLATOR_TEXT", 'TEXT' },
|
||||
{ "B_TRANSLATOR_SOUND", 'nois' },
|
||||
{ "B_TRANSLATOR_MIDI", 'midi' },
|
||||
{ "B_TRANSLATOR_MEDIA", 'mhi!' },
|
||||
{ "B_TRANSLATOR_NONE", 'none' },
|
||||
{ "B_GIF_FORMAT", 'GIF ' },
|
||||
{ "B_JPEG_FORMAT", 'JPEG' },
|
||||
{ "B_PNG_FORMAT", 'PNG ' },
|
||||
{ "B_PPM_FORMAT", 'PPM ' },
|
||||
{ "B_TGA_FORMAT", 'TGA ' },
|
||||
{ "B_BMP_FORMAT", 'BMP ' },
|
||||
{ "B_TIFF_FORMAT", 'TIFF' },
|
||||
{ "B_DXF_FORMAT", 'DXF ' },
|
||||
{ "B_EPS_FORMAT", 'EPS ' },
|
||||
{ "B_PICT_FORMAT", 'PICT' },
|
||||
{ "B_WAV_FORMAT", 'WAV ' },
|
||||
{ "B_AIFF_FORMAT", 'AIFF' },
|
||||
{ "B_CD_FORMAT", 'CD ' },
|
||||
{ "B_AU_FORMAT", 'AU ' },
|
||||
{ "B_STYLED_TEXT_FORMAT", 'STXT' },
|
||||
{ "STYLE_HEADER_MAGIC", 'STYL' },
|
||||
// TranslationUtils.h
|
||||
{ "B_TRANSLATION_MENU", 'BTMN' },
|
||||
// USB.h
|
||||
{ "USB_SUPPORT_DESCRIPTOR", '_USB' },
|
||||
// MediaDefs.h
|
||||
{ "B_MEDIA_NODE_CREATED", 'TRIA' },
|
||||
{ "B_MEDIA_NODE_DELETED", 'TRIB' },
|
||||
{ "B_MEDIA_CONNECTION_MADE", 'TRIC' },
|
||||
{ "B_MEDIA_CONNECTION_BROKEN", 'TRID' },
|
||||
{ "B_MEDIA_BUFFER_CREATED", 'TRIE' },
|
||||
{ "B_MEDIA_BUFFER_DELETED", 'TRIF' },
|
||||
{ "B_MEDIA_TRANSPORT_STATE", 'TRIG' },
|
||||
{ "B_MEDIA_PARAMETER_CHANGED", 'TRIH' },
|
||||
{ "B_MEDIA_FORMAT_CHANGED", 'TRII' },
|
||||
{ "B_MEDIA_WEB_CHANGED", 'TRIJ' },
|
||||
{ "B_MEDIA_DEFAULT_CHANGED", 'TRIK' },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
const char* long_to_string(ulong ulg)
|
||||
{
|
||||
static char string[10];
|
||||
// string[0]=(ulg >> 24) & 0xff;
|
||||
// string[1]=(ulg >> 16) & 0xff;
|
||||
// string[2]=(ulg >> 8) & 0xff;
|
||||
// string[3]=ulg & 0xff;
|
||||
// string[4]=0;
|
||||
string[6]=0;
|
||||
string[0]='\'';
|
||||
string[1]=(ulg >> 24) & 0xff;
|
||||
string[2]=(ulg >> 16) & 0xff;
|
||||
string[3]=(ulg >> 8) & 0xff;
|
||||
string[4]=ulg & 0xff;
|
||||
string[5]='\'';
|
||||
if (!(isprint(string[1]) && isprint(string[2]) && isprint(string[3]) && isprint(string[4])))
|
||||
sprintf(string, "0x%.8lX", ulg);
|
||||
return string;
|
||||
}
|
||||
|
||||
ulong string_to_long(void* st)
|
||||
{
|
||||
char* string=(char*) st;
|
||||
ulong ulg;
|
||||
ulg=string[3]+(string[2] << 8)+(string[1] << 16)+(string[0] << 24);
|
||||
return ulg;
|
||||
}
|
||||
|
||||
const char* long_to_be_string(ulong type)
|
||||
{
|
||||
int k=0;
|
||||
while (bevalue[k].name!=NULL) {
|
||||
if (bevalue[k].value==type)
|
||||
return bevalue[k].name;
|
||||
k++;
|
||||
}
|
||||
return long_to_string(type);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
|
||||
ReadableLong.h
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _READABLE_LONG_H_
|
||||
#define _READABLE_LONG_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
const char* long_to_string(ulong ulg);
|
||||
ulong string_to_long(void* st);
|
||||
const char* long_to_be_string(ulong type);
|
||||
|
||||
#endif // _READABLE_LONG_H_
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
TeamBarMenu.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,73 +15,85 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include <Roster.h>
|
||||
#include <Bitmap.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "TeamBarMenu.h"
|
||||
#include "ThreadBarMenu.h"
|
||||
#include "TeamBarMenuItem.h"
|
||||
#include "NoiseBarMenuItem.h"
|
||||
#include "PCView.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Roster.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define EXTRA 10
|
||||
|
||||
TeamBarMenu::TeamBarMenu (const char *title, infosPack *infos, int32 teamCount)
|
||||
:BMenu (title), fTeamCount (teamCount+EXTRA), fFirstShow (true)
|
||||
|
||||
TeamBarMenu::TeamBarMenu(const char* title, info_pack* infos, int32 teamCount)
|
||||
: BMenu(title),
|
||||
fTeamCount(teamCount+EXTRA),
|
||||
fFirstShow(true)
|
||||
{
|
||||
SetFlags (Flags () | B_PULSE_NEEDED);
|
||||
fTeamList = (team_id*) malloc (sizeof (team_id) * fTeamCount);
|
||||
SetFlags(Flags() | B_PULSE_NEEDED);
|
||||
fTeamList = (team_id*)malloc(sizeof(team_id) * fTeamCount);
|
||||
int k;
|
||||
for (k = 0; k < teamCount; k++)
|
||||
fTeamList[k] = infos[k].tminfo.team;
|
||||
while (k < fTeamCount)
|
||||
for (k = 0; k < teamCount; k++) {
|
||||
fTeamList[k] = infos[k].team_info.team;
|
||||
}
|
||||
while (k < fTeamCount) {
|
||||
fTeamList[k++] = -1;
|
||||
}
|
||||
fRecycleCount = EXTRA;
|
||||
fRecycleList = (TRecycleItem*) malloc (sizeof (TRecycleItem) * fRecycleCount);
|
||||
SetFont (be_plain_font);
|
||||
fRecycleList = (TRecycleItem*)malloc(sizeof(TRecycleItem) * fRecycleCount);
|
||||
SetFont(be_plain_font);
|
||||
gCurrentThreadBarMenu = NULL;
|
||||
fLastTotalTime = system_time ();
|
||||
AddItem (new NoiseBarMenuItem ());
|
||||
fLastTotalTime = system_time();
|
||||
AddItem(new NoiseBarMenuItem());
|
||||
}
|
||||
|
||||
TeamBarMenu::~TeamBarMenu ()
|
||||
|
||||
TeamBarMenu::~TeamBarMenu()
|
||||
{
|
||||
gCurrentThreadBarMenu = NULL;
|
||||
free (fTeamList);
|
||||
free (fRecycleList);
|
||||
free(fTeamList);
|
||||
free(fRecycleList);
|
||||
}
|
||||
|
||||
void TeamBarMenu::Draw (BRect updateRect)
|
||||
|
||||
void
|
||||
TeamBarMenu::Draw(BRect updateRect)
|
||||
{
|
||||
BMenu::Draw (updateRect);
|
||||
if (fFirstShow)
|
||||
{
|
||||
Pulse ();
|
||||
if (fFirstShow) {
|
||||
Pulse();
|
||||
fFirstShow = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TeamBarMenu::Pulse ()
|
||||
|
||||
void
|
||||
TeamBarMenu::Pulse()
|
||||
{
|
||||
// Window ()->SetPulseRate (50000);
|
||||
Window ()->BeginViewTransaction ();
|
||||
Window()->BeginViewTransaction();
|
||||
|
||||
// create the list of items to remove, for their team is gone. Update the old teams.
|
||||
int lastRecycle = 0;
|
||||
int firstRecycle = 0;
|
||||
int k;
|
||||
TeamBarMenuItem *item;
|
||||
double total = 0;
|
||||
for (k = 1; (item = (TeamBarMenuItem*) ItemAt(k)) != NULL; k++) {
|
||||
double total = 0;
|
||||
for (k = 1; (item = (TeamBarMenuItem*)ItemAt(k)) != NULL; k++) {
|
||||
item->BarUpdate();
|
||||
if (item->fKernel < 0) {
|
||||
if (lastRecycle == fRecycleCount) {
|
||||
fRecycleCount += EXTRA;
|
||||
fRecycleList = (TRecycleItem*) realloc(fRecycleList, sizeof(TRecycleItem)*fRecycleCount);
|
||||
fRecycleList = (TRecycleItem*)realloc(fRecycleList,
|
||||
sizeof(TRecycleItem)*fRecycleCount);
|
||||
}
|
||||
fRecycleList[lastRecycle].index = k;
|
||||
fRecycleList[lastRecycle++].item = item;
|
||||
@@ -100,16 +108,16 @@ void TeamBarMenu::Pulse ()
|
||||
}
|
||||
|
||||
// Look new teams that have appeared. Create an item for them, or recycle from the list.
|
||||
int32 cookie = 0;
|
||||
infosPack infos;
|
||||
int32 cookie = 0;
|
||||
info_pack infos;
|
||||
item = NULL;
|
||||
while (get_next_team_info(&cookie, &infos.tminfo) == B_OK) {
|
||||
while (get_next_team_info(&cookie, &infos.team_info) == B_OK) {
|
||||
int j = 0;
|
||||
while (j < fTeamCount && infos.tminfo.team != fTeamList[j])
|
||||
while (j < fTeamCount && infos.team_info.team != fTeamList[j])
|
||||
j++;
|
||||
if (infos.tminfo.team != fTeamList[j]) {
|
||||
if (infos.team_info.team != fTeamList[j]) {
|
||||
// new team
|
||||
team_info info;
|
||||
team_info info;
|
||||
j = 0;
|
||||
while (j < fTeamCount && fTeamList[j] != -1)
|
||||
if (get_team_info(fTeamList[j], &info) != B_OK)
|
||||
@@ -118,30 +126,31 @@ void TeamBarMenu::Pulse ()
|
||||
j++;
|
||||
if (j == fTeamCount) {
|
||||
fTeamCount += 10;
|
||||
fTeamList = (team_id*) realloc(fTeamList, sizeof(team_id)*fTeamCount);
|
||||
fTeamList = (team_id*)realloc(fTeamList, sizeof(team_id)*fTeamCount);
|
||||
}
|
||||
fTeamList[j] = infos.tminfo.team;
|
||||
fTeamList[j] = infos.team_info.team;
|
||||
if (!get_team_name_and_icon(infos, true)) {
|
||||
// the team is already gone!
|
||||
delete infos.tmicon;
|
||||
delete infos.team_icon;
|
||||
fTeamList[j] = -1;
|
||||
} else {
|
||||
if (!item && firstRecycle < lastRecycle) {
|
||||
item = fRecycleList[firstRecycle++].item;
|
||||
}
|
||||
if (item) {
|
||||
item->Reset(infos.tmname, infos.tminfo.team, infos.tmicon, true);
|
||||
item->Reset(infos.team_name, infos.team_info.team, infos.team_icon, true);
|
||||
} else {
|
||||
BMessage* kill_team = new BMessage('KlTm');
|
||||
kill_team->AddInt32("team", infos.tminfo.team);
|
||||
item = new TeamBarMenuItem(new ThreadBarMenu(infos.tmname, infos.tminfo.team, infos.tminfo.thread_count),
|
||||
kill_team, infos.tminfo.team, infos.tmicon, true);
|
||||
kill_team->AddInt32("team", infos.team_info.team);
|
||||
item = new TeamBarMenuItem(new ThreadBarMenu(infos.team_name,
|
||||
infos.team_info.team, infos.team_info.thread_count),
|
||||
kill_team, infos.team_info.team, infos.team_icon, true);
|
||||
item->SetTarget(gPCView);
|
||||
AddItem(item);
|
||||
item->BarUpdate();
|
||||
}
|
||||
if (item->fKernel >= 0) {
|
||||
total += item->fUser+item->fKernel;
|
||||
total += item->fUser + item->fKernel;
|
||||
item = NULL;
|
||||
} else {
|
||||
fTeamList[j] = -1;
|
||||
@@ -161,16 +170,14 @@ void TeamBarMenu::Pulse ()
|
||||
total /= gCPUcount;
|
||||
total = 1-total;
|
||||
|
||||
fLastTotalTime = system_time ();
|
||||
NoiseBarMenuItem *noiseItem;
|
||||
if ((noiseItem = (NoiseBarMenuItem*) ItemAt(0)) != NULL) {
|
||||
fLastTotalTime = system_time();
|
||||
NoiseBarMenuItem* noiseItem;
|
||||
if ((noiseItem = (NoiseBarMenuItem*)ItemAt(0)) != NULL) {
|
||||
noiseItem->fBusyWaiting = 0;
|
||||
noiseItem->fLost = (total >= 0 ? total : 0);
|
||||
noiseItem->DrawBar(false);
|
||||
}
|
||||
|
||||
// status_t st;
|
||||
// if (gCurrentThreadBarMenu && (st = gCurrentThreadBarMenu->LockLooperWithTimeout(50000)) == B_OK) {
|
||||
if (gCurrentThreadBarMenu && gCurrentThreadBarMenu->LockLooperWithTimeout(25000) == B_OK) {
|
||||
gCurrentThreadBarMenu->Window()->BeginViewTransaction();
|
||||
gCurrentThreadBarMenu->Update();
|
||||
@@ -178,9 +185,7 @@ void TeamBarMenu::Pulse ()
|
||||
gCurrentThreadBarMenu->Window()->Flush();
|
||||
gCurrentThreadBarMenu->UnlockLooper();
|
||||
}
|
||||
// else
|
||||
// if (st == B_TIMED_OUT)
|
||||
// beep();
|
||||
|
||||
Window()->EndViewTransaction();
|
||||
Window()->Flush();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
TeamBarMenu.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,16 +15,16 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _TEAM_BAR_MENU_H_
|
||||
#define _TEAM_BAR_MENU_H_
|
||||
|
||||
#include "PCUtils.h"
|
||||
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Menu.h>
|
||||
|
||||
|
||||
class TeamBarMenuItem;
|
||||
|
||||
typedef struct {
|
||||
@@ -36,20 +32,21 @@ typedef struct {
|
||||
int index;
|
||||
} TRecycleItem;
|
||||
|
||||
class TeamBarMenu : public BMenu
|
||||
{
|
||||
public:
|
||||
TeamBarMenu(const char *title, infosPack *infos, int32 teamCount);
|
||||
virtual ~TeamBarMenu();
|
||||
virtual void Draw (BRect updateRect);
|
||||
virtual void Pulse();
|
||||
|
||||
team_id* fTeamList;
|
||||
int fTeamCount;
|
||||
TRecycleItem* fRecycleList;
|
||||
int fRecycleCount;
|
||||
bigtime_t fLastTotalTime;
|
||||
bool fFirstShow;
|
||||
class TeamBarMenu : public BMenu {
|
||||
public:
|
||||
TeamBarMenu(const char* title, info_pack* infos, int32 teamCount);
|
||||
virtual ~TeamBarMenu();
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void Pulse();
|
||||
|
||||
team_id* fTeamList;
|
||||
int fTeamCount;
|
||||
TRecycleItem* fRecycleList;
|
||||
int fRecycleCount;
|
||||
bigtime_t fLastTotalTime;
|
||||
bool fFirstShow;
|
||||
};
|
||||
|
||||
#endif // _TEAM_BAR_MENU_H_
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
TeamBarMenuItem.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,55 +15,64 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "PCView.h"
|
||||
#include "TeamBarMenuItem.h"
|
||||
|
||||
#include "Colors.h"
|
||||
#include "ProcessController.h"
|
||||
#include "ThreadBarMenu.h"
|
||||
#include "ThreadBarMenuItem.h"
|
||||
#include "Colors.h"
|
||||
|
||||
#include <Bitmap.h>
|
||||
|
||||
|
||||
#define B_USAGE_SELF 0
|
||||
|
||||
// --------------------------------------------------------------
|
||||
TeamBarMenuItem::TeamBarMenuItem(BMenu *menu, BMessage *kill_team, team_id team, BBitmap* icon, bool DeleteIcon)
|
||||
:BMenuItem(menu, kill_team), fTeamID(team), fIcon(icon), fDeleteIcon(DeleteIcon)
|
||||
|
||||
TeamBarMenuItem::TeamBarMenuItem(BMenu *menu, BMessage *kill_team, team_id team,
|
||||
BBitmap* icon, bool deleteIcon)
|
||||
: BMenuItem(menu, kill_team),
|
||||
fTeamID(team),
|
||||
fIcon(icon),
|
||||
fDeleteIcon(deleteIcon)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::Init()
|
||||
|
||||
void
|
||||
TeamBarMenuItem::Init()
|
||||
{
|
||||
team_info tminfo;
|
||||
team_info tminfo;
|
||||
get_team_info(fTeamID, &tminfo);
|
||||
get_team_usage_info(fTeamID, B_USAGE_SELF, &fTeamUsageInfo);
|
||||
if (fTeamID == B_SYSTEM_TEAM) {
|
||||
thread_info thinfos;
|
||||
bigtime_t idle = 0;
|
||||
bigtime_t idle = 0;
|
||||
for (int t = 1; t <= gCPUcount; t++)
|
||||
if (get_thread_info(t, &thinfos) == B_OK)
|
||||
idle += thinfos.kernel_time + thinfos.user_time;
|
||||
fTeamUsageInfo.kernel_time += fTeamUsageInfo.user_time;
|
||||
fTeamUsageInfo.user_time = idle;
|
||||
}
|
||||
|
||||
fLastTime = system_time();
|
||||
fKernel = -1;
|
||||
fGrenze1 = -1;
|
||||
fGrenze2 = -1;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
TeamBarMenuItem::~TeamBarMenuItem()
|
||||
{
|
||||
if (fDeleteIcon)
|
||||
delete fIcon;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::DrawContent()
|
||||
|
||||
void
|
||||
TeamBarMenuItem::DrawContent()
|
||||
{
|
||||
BPoint loc;
|
||||
|
||||
@@ -82,45 +87,50 @@ void TeamBarMenuItem::DrawContent()
|
||||
BMenuItem::DrawContent();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::DrawIcon()
|
||||
{
|
||||
BPoint loc;
|
||||
|
||||
loc = ContentLocation();
|
||||
BRect frame = Frame();
|
||||
void
|
||||
TeamBarMenuItem::DrawIcon()
|
||||
{
|
||||
BPoint loc = ContentLocation();
|
||||
BRect frame = Frame();
|
||||
|
||||
loc.y = frame.top + (frame.bottom - frame.top - 15) / 2;
|
||||
BMenu* menu = Menu ();
|
||||
|
||||
BMenu* menu = Menu ();
|
||||
menu->SetDrawingMode(B_OP_OVER);
|
||||
if (fIcon)
|
||||
menu->DrawBitmap(fIcon, loc);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::DrawBar(bool force)
|
||||
|
||||
void
|
||||
TeamBarMenuItem::DrawBar(bool force)
|
||||
{
|
||||
bool selected = IsSelected ();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu ();
|
||||
bool selected = IsSelected ();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu ();
|
||||
frame.right -= 24;
|
||||
frame.left = frame.right-kBarWidth;
|
||||
frame.top += 5;
|
||||
frame.bottom = frame.top+8;
|
||||
|
||||
if (fKernel < 0)
|
||||
return;
|
||||
|
||||
if (fGrenze1 < 0)
|
||||
force = true;
|
||||
if (force) {
|
||||
if (selected)
|
||||
menu->SetHighColor (gFrameColorSelected);
|
||||
menu->SetHighColor(gFrameColorSelected);
|
||||
else
|
||||
menu->SetHighColor (gFrameColor);
|
||||
menu->SetHighColor(gFrameColor);
|
||||
menu->StrokeRect(frame);
|
||||
}
|
||||
|
||||
frame.InsetBy(1, 1);
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fKernel/gCPUcount;
|
||||
float grenze2 = frame.left+(frame.right-frame.left)*(fKernel+fUser)/gCPUcount;
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fKernel/gCPUcount;
|
||||
float grenze2 = frame.left+(frame.right-frame.left)*(fKernel+fUser)/gCPUcount;
|
||||
if (grenze1 > frame.right)
|
||||
grenze1 = frame.right;
|
||||
if (grenze2 > frame.right)
|
||||
@@ -130,44 +140,51 @@ void TeamBarMenuItem::DrawBar(bool force)
|
||||
r.left = fGrenze1;
|
||||
if (r.left < r.right) {
|
||||
if (selected)
|
||||
menu->SetHighColor (gKernelColorSelected);
|
||||
menu->SetHighColor(gKernelColorSelected);
|
||||
else
|
||||
menu->SetHighColor (gKernelColor);
|
||||
menu->SetHighColor(gKernelColor);
|
||||
menu->FillRect(r);
|
||||
}
|
||||
|
||||
r.left = grenze1;
|
||||
r.right = grenze2;
|
||||
|
||||
if (!force) {
|
||||
if (fGrenze2 > r.left && r.left >= fGrenze1)
|
||||
r.left = fGrenze2;
|
||||
if (fGrenze1 < r.right && r.right <= fGrenze2)
|
||||
r.right = fGrenze1;
|
||||
}
|
||||
|
||||
if (r.left < r.right) {
|
||||
if (selected)
|
||||
menu->SetHighColor(fTeamID == B_SYSTEM_TEAM ? gIdleColorSelected : gUserColorSelected);
|
||||
else
|
||||
menu->SetHighColor(fTeamID == B_SYSTEM_TEAM ? gIdleColor : gUserColor);
|
||||
menu->FillRect (r);
|
||||
menu->FillRect(r);
|
||||
}
|
||||
|
||||
r.left = grenze2;
|
||||
r.right = frame.right;
|
||||
|
||||
if (!force)
|
||||
r.right = fGrenze2;
|
||||
if (r.left < r.right) {
|
||||
if (selected)
|
||||
menu->SetHighColor (gWhiteSelected);
|
||||
menu->SetHighColor(gWhiteSelected);
|
||||
else
|
||||
menu->SetHighColor (kWhite);
|
||||
menu->FillRect (r);
|
||||
menu->SetHighColor(kWhite);
|
||||
menu->FillRect(r);
|
||||
}
|
||||
menu->SetHighColor (kBlack);
|
||||
|
||||
menu->SetHighColor(kBlack);
|
||||
fGrenze1 = grenze1;
|
||||
fGrenze2 = grenze2;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::GetContentSize(float* width, float* height)
|
||||
|
||||
void
|
||||
TeamBarMenuItem::GetContentSize(float* width, float* height)
|
||||
{
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
if (*height < 16)
|
||||
@@ -175,13 +192,14 @@ void TeamBarMenuItem::GetContentSize(float* width, float* height)
|
||||
*width += 40+kBarWidth;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::BarUpdate()
|
||||
|
||||
void
|
||||
TeamBarMenuItem::BarUpdate()
|
||||
{
|
||||
team_usage_info usage;
|
||||
if (get_team_usage_info(fTeamID, B_USAGE_SELF, &usage) == B_OK) {
|
||||
bigtime_t now = system_time();
|
||||
bigtime_t idle = 0;
|
||||
bigtime_t idle = 0;
|
||||
if (fTeamID == B_SYSTEM_TEAM) {
|
||||
thread_info thinfos;
|
||||
for (int t = 1; t <= gCPUcount; t++)
|
||||
@@ -202,15 +220,16 @@ void TeamBarMenuItem::BarUpdate()
|
||||
fKernel = -1;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void TeamBarMenuItem::Reset(char* name, team_id team, BBitmap* icon, bool DeleteIcon)
|
||||
|
||||
void
|
||||
TeamBarMenuItem::Reset(char* name, team_id team, BBitmap* icon, bool deleteIcon)
|
||||
{
|
||||
SetLabel(name);
|
||||
fTeamID = team;
|
||||
Init();
|
||||
if (fDeleteIcon)
|
||||
delete fIcon;
|
||||
fDeleteIcon = DeleteIcon;
|
||||
fDeleteIcon = deleteIcon;
|
||||
fIcon = icon;
|
||||
Message()->ReplaceInt32("team", team);
|
||||
((ThreadBarMenu*) Submenu())->Reset(team);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
TeamBarMenuItem.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,34 +15,34 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _TEAM_BAR_MENU_ITEM_H_
|
||||
#define _TEAM_BAR_MENU_ITEM_H_
|
||||
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
class BBitmap;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
class TeamBarMenuItem : public BMenuItem {
|
||||
public:
|
||||
TeamBarMenuItem(BMenu *menu, BMessage *kill_team,
|
||||
team_id team, BBitmap* icon, bool deleteIcon);
|
||||
virtual ~TeamBarMenuItem();
|
||||
|
||||
public:
|
||||
TeamBarMenuItem(BMenu *menu, BMessage *kill_team, team_id team, BBitmap* icon, bool DeleteIcon);
|
||||
virtual ~TeamBarMenuItem();
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
void DrawIcon();
|
||||
void DrawBar(bool force);
|
||||
void BarUpdate();
|
||||
void Init();
|
||||
void Reset(char* name, team_id team, BBitmap* icon, bool DeleteIcon);
|
||||
void Reset(char* name, team_id team, BBitmap* icon, bool deleteIcon);
|
||||
|
||||
double fUser;
|
||||
double fKernel;
|
||||
|
||||
private:
|
||||
private:
|
||||
team_id fTeamID;
|
||||
BBitmap* fIcon;
|
||||
team_usage_info fTeamUsageInfo;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
ThreadBarMenu.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,28 +15,33 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "ThreadBarMenu.h"
|
||||
#include "ThreadBarMenuItem.h"
|
||||
|
||||
#include "PriorityMenu.h"
|
||||
#include "PCView.h"
|
||||
#include "ProcessController.h"
|
||||
#include "ThreadBarMenuItem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define EXTRA 20
|
||||
|
||||
ThreadBarMenu::ThreadBarMenu(const char *title, team_id team, int32 thread_count):
|
||||
BMenu(title), fThreadsRecCount(thread_count+EXTRA), fTeam(team)
|
||||
|
||||
ThreadBarMenu::ThreadBarMenu(const char *title, team_id team, int32 threadCount)
|
||||
: BMenu(title),
|
||||
fThreadsRecCount(threadCount + EXTRA),
|
||||
fTeam(team)
|
||||
{
|
||||
SetFont(be_plain_font);
|
||||
fThreadsRec = (ThreadRec*) malloc(sizeof(ThreadRec)*fThreadsRecCount);
|
||||
fThreadsRec = (ThreadRec*) malloc(sizeof(ThreadRec) * fThreadsRecCount);
|
||||
Init();
|
||||
fRound = 0; // for syslog
|
||||
AddNew();
|
||||
}
|
||||
|
||||
|
||||
ThreadBarMenu::~ThreadBarMenu()
|
||||
{
|
||||
free(fThreadsRec);
|
||||
@@ -48,37 +49,47 @@ ThreadBarMenu::~ThreadBarMenu()
|
||||
gCurrentThreadBarMenu = NULL;
|
||||
}
|
||||
|
||||
void ThreadBarMenu::Init()
|
||||
|
||||
void
|
||||
ThreadBarMenu::Init()
|
||||
{
|
||||
int k = 0;
|
||||
int k = 0;
|
||||
while (k < fThreadsRecCount)
|
||||
fThreadsRec[k++].thread = -1;
|
||||
fRound = 1;
|
||||
}
|
||||
|
||||
void ThreadBarMenu::Reset(team_id team)
|
||||
|
||||
void
|
||||
ThreadBarMenu::Reset(team_id team)
|
||||
{
|
||||
fTeam = team;
|
||||
RemoveItems(0, CountItems(), true);
|
||||
Init();
|
||||
}
|
||||
|
||||
void ThreadBarMenu::AttachedToWindow()
|
||||
|
||||
void
|
||||
ThreadBarMenu::AttachedToWindow()
|
||||
{
|
||||
BMenu::AttachedToWindow();
|
||||
}
|
||||
|
||||
void ThreadBarMenu::Draw(BRect r)
|
||||
|
||||
void
|
||||
ThreadBarMenu::Draw(BRect r)
|
||||
{
|
||||
gCurrentThreadBarMenu = this;
|
||||
BMenu::Draw(r);
|
||||
}
|
||||
|
||||
void ThreadBarMenu::AddNew()
|
||||
|
||||
void
|
||||
ThreadBarMenu::AddNew()
|
||||
{
|
||||
thread_info info;
|
||||
int32 cookie = 0;
|
||||
int32 k = 0;
|
||||
int32 cookie = 0;
|
||||
int32 k = 0;
|
||||
while (get_next_thread_info(fTeam, &cookie, &info) == B_OK) {
|
||||
int lastk = k;
|
||||
while (k < fThreadsRecCount && fThreadsRec[k].thread != info.thread)
|
||||
@@ -118,12 +129,15 @@ void ThreadBarMenu::AddNew()
|
||||
fRound++;
|
||||
}
|
||||
|
||||
void ThreadBarMenu::Update()
|
||||
|
||||
void
|
||||
ThreadBarMenu::Update()
|
||||
{
|
||||
AddNew();
|
||||
int32 k, del;
|
||||
int32 k, del;
|
||||
del = -1;
|
||||
ThreadBarMenuItem *item;
|
||||
|
||||
for (k = 0; (item = (ThreadBarMenuItem*) ItemAt(k)) != NULL; k++) {
|
||||
item->BarUpdate();
|
||||
item->DrawBar(false);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
ThreadBarMenu.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,32 +15,31 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _THREAD_BAR_MENU_H_
|
||||
#define _THREAD_BAR_MENU_H_
|
||||
|
||||
|
||||
#include <Menu.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
thread_id thread;
|
||||
int last_round;
|
||||
} ThreadRec;
|
||||
|
||||
class ThreadBarMenu : public BMenu
|
||||
{
|
||||
public:
|
||||
ThreadBarMenu (const char *title, team_id team, int32 thread_count);
|
||||
virtual ~ThreadBarMenu ();
|
||||
virtual void AttachedToWindow ();
|
||||
virtual void Draw (BRect updateRect);
|
||||
void AddNew ();
|
||||
void Update ();
|
||||
void Init ();
|
||||
void Reset (team_id team);
|
||||
class ThreadBarMenu : public BMenu {
|
||||
public:
|
||||
ThreadBarMenu(const char *title, team_id team, int32 threadCount);
|
||||
virtual ~ThreadBarMenu();
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
void AddNew();
|
||||
void Update();
|
||||
void Init();
|
||||
void Reset(team_id team);
|
||||
|
||||
private:
|
||||
private:
|
||||
ThreadRec* fThreadsRec;
|
||||
int fThreadsRecCount;
|
||||
team_id fTeam;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
ThreadBarMenuItem.cpp
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,19 +15,20 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "PCView.h"
|
||||
#include "ThreadBarMenuItem.h"
|
||||
#include "PriorityMenu.h"
|
||||
|
||||
#include "Colors.h"
|
||||
#include "PCView.h"
|
||||
#include "PriorityMenu.h"
|
||||
#include "ProcessController.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// --------------------------------------------------------------
|
||||
ThreadBarMenuItem::ThreadBarMenuItem(const char* title, thread_id thread, BMenu *menu, BMessage* msg)
|
||||
:BMenuItem(menu, msg), fThreadID(thread)
|
||||
|
||||
ThreadBarMenuItem::ThreadBarMenuItem(const char* title, thread_id thread,
|
||||
BMenu *menu, BMessage* msg)
|
||||
: BMenuItem(menu, msg), fThreadID(thread)
|
||||
{
|
||||
SetLabel(title);
|
||||
get_thread_info(fThreadID, &fThreadInfo);
|
||||
@@ -41,8 +38,9 @@ ThreadBarMenuItem::ThreadBarMenuItem(const char* title, thread_id thread, BMenu
|
||||
fGrenze2 = -1;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void ThreadBarMenuItem::DrawContent()
|
||||
|
||||
void
|
||||
ThreadBarMenuItem::DrawContent()
|
||||
{
|
||||
if (fKernel < 0)
|
||||
BarUpdate();
|
||||
@@ -51,12 +49,13 @@ void ThreadBarMenuItem::DrawContent()
|
||||
BMenuItem::DrawContent();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void ThreadBarMenuItem::DrawBar(bool force)
|
||||
|
||||
void
|
||||
ThreadBarMenuItem::DrawBar(bool force)
|
||||
{
|
||||
bool selected = IsSelected ();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu ();
|
||||
bool selected = IsSelected();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu();
|
||||
frame.right -= 24;
|
||||
frame.left = frame.right-kBarWidth;
|
||||
frame.top += 3;
|
||||
@@ -73,9 +72,9 @@ void ThreadBarMenuItem::DrawBar(bool force)
|
||||
menu->StrokeRect(frame);
|
||||
}
|
||||
frame.InsetBy(1, 1);
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fKernel;
|
||||
float grenze2 = frame.left+(frame.right-frame.left)*(fKernel+fUser);
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fKernel;
|
||||
float grenze2 = frame.left+(frame.right-frame.left)*(fKernel+fUser);
|
||||
if (grenze1 > frame.right)
|
||||
grenze1 = frame.right;
|
||||
if (grenze2 > frame.right)
|
||||
@@ -121,8 +120,9 @@ void ThreadBarMenuItem::DrawBar(bool force)
|
||||
fGrenze2 = grenze2;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void ThreadBarMenuItem::GetContentSize(float* width, float* height)
|
||||
|
||||
void
|
||||
ThreadBarMenuItem::GetContentSize(float* width, float* height)
|
||||
{
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
// if (*height < 16)
|
||||
@@ -130,8 +130,9 @@ void ThreadBarMenuItem::GetContentSize(float* width, float* height)
|
||||
*width += 10+kBarWidth;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void ThreadBarMenuItem::Highlight(bool on)
|
||||
|
||||
void
|
||||
ThreadBarMenuItem::Highlight(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PriorityMenu * popup = (PriorityMenu *) Submenu ();
|
||||
@@ -141,12 +142,13 @@ void ThreadBarMenuItem::Highlight(bool on)
|
||||
BMenuItem::Highlight (on);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void ThreadBarMenuItem::BarUpdate()
|
||||
|
||||
void
|
||||
ThreadBarMenuItem::BarUpdate()
|
||||
{
|
||||
thread_info info;
|
||||
thread_info info;
|
||||
if (get_thread_info(fThreadID, &info) == B_OK) {
|
||||
bigtime_t now = system_time();
|
||||
bigtime_t now = system_time();
|
||||
fKernel = double(info.kernel_time-fThreadInfo.kernel_time)/double(now-fLastTime);
|
||||
fUser = double(info.user_time-fThreadInfo.user_time)/double(now-fLastTime);
|
||||
if (fThreadID <= gCPUcount) {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
ThreadBarMenuItem.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,29 +15,29 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _THREAD_BAR_MENU_ITEM_H_
|
||||
#define _THREAD_BAR_MENU_ITEM_H_
|
||||
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
class ThreadBarMenuItem : public BMenuItem {
|
||||
public:
|
||||
ThreadBarMenuItem(const char* title, thread_id thread,
|
||||
BMenu* menu, BMessage* msg);
|
||||
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
virtual void Highlight(bool on);
|
||||
void DrawBar(bool force);
|
||||
void BarUpdate();
|
||||
|
||||
public:
|
||||
ThreadBarMenuItem (const char* title, thread_id thread, BMenu *menu, BMessage* msg);
|
||||
virtual void DrawContent ();
|
||||
virtual void GetContentSize (float* width, float* height);
|
||||
virtual void Highlight(bool on);
|
||||
void DrawBar (bool force);
|
||||
void BarUpdate ();
|
||||
double fUser;
|
||||
double fKernel;
|
||||
|
||||
private:
|
||||
private:
|
||||
thread_id fThreadID;
|
||||
thread_info fThreadInfo;
|
||||
bigtime_t fLastTime;
|
||||
@@ -50,4 +46,3 @@ private:
|
||||
};
|
||||
|
||||
#endif // _THREAD_BAR_MENU_ITEM_H_
|
||||
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
|
||||
URLView.cpp
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "URLView.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <Roster.h>
|
||||
#include "Colors.h"
|
||||
|
||||
URLView::URLView(BRect frame, const char* url)
|
||||
: BView(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW)
|
||||
{
|
||||
if (url == NULL)
|
||||
url = "http://www.be.com";
|
||||
fUrl = strdup (url);
|
||||
}
|
||||
|
||||
URLView::~URLView()
|
||||
{
|
||||
free (fUrl);
|
||||
}
|
||||
|
||||
void URLView::AttachedToWindow()
|
||||
{
|
||||
rgb_color back = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
SetViewColor (back);
|
||||
SetLowColor (back);
|
||||
SetHighColor (kBlue);
|
||||
SetFont (be_plain_font);
|
||||
font_height height;
|
||||
GetFontHeight (&height);
|
||||
float width = StringWidth (fUrl);
|
||||
float r = width + 8;
|
||||
BRect frame = Frame ();
|
||||
BRect nframe = frame;
|
||||
if (frame.right == frame.left)
|
||||
nframe.right = nframe.left + r - 4;
|
||||
else if (frame.right == 0)
|
||||
{
|
||||
nframe.left -= r/2;
|
||||
nframe.right = nframe.left + r;
|
||||
}
|
||||
if (frame.bottom == 0)
|
||||
nframe.bottom = frame.top + height.ascent + height.descent + 2;
|
||||
if (frame.left != nframe.left || frame.top != nframe.top)
|
||||
MoveTo (nframe.left, nframe.top);
|
||||
if (frame.Width () != nframe.Width () || frame.Height () != nframe.Height ())
|
||||
ResizeTo (nframe.Width (), nframe.Height ());
|
||||
fLocation.x = ceil ((nframe.Width () - width) / 2) + 1;
|
||||
fLocation.y = floor ((nframe.Height () + height.ascent - height.descent) / 2);
|
||||
}
|
||||
|
||||
void URLView::Draw (BRect /*updateRect*/)
|
||||
{
|
||||
DrawString (fUrl, fLocation);
|
||||
}
|
||||
|
||||
void URLView::MouseDown (BPoint /*where*/)
|
||||
{
|
||||
BPoint pos;
|
||||
uint32 buttons;
|
||||
BRect bounds = Bounds ();
|
||||
bool inside = true;
|
||||
InvertRect (bounds);
|
||||
do
|
||||
{
|
||||
snooze (5000);
|
||||
GetMouse (&pos, &buttons);
|
||||
bool now = bounds.Contains (pos);
|
||||
if (now != inside)
|
||||
{
|
||||
InvertRect (bounds);
|
||||
Flush ();
|
||||
inside = now;
|
||||
}
|
||||
} while (buttons != 0);
|
||||
if (bounds.Contains (pos))
|
||||
OpenURL ();
|
||||
if (inside)
|
||||
InvertRect (bounds);
|
||||
}
|
||||
|
||||
void URLView::OpenURL ()
|
||||
{
|
||||
char* argv[2];
|
||||
argv[0] = fUrl;
|
||||
argv[1] = 0;
|
||||
be_roster->Launch ("text/html", 1, argv);
|
||||
}
|
||||
|
||||
mailtoView::mailtoView (BRect frame, const char* email, const char* subject, const char* texte)
|
||||
: URLView (frame, email)
|
||||
{
|
||||
if (subject)
|
||||
fSubject = strdup (subject);
|
||||
else
|
||||
fSubject = NULL;
|
||||
if (texte)
|
||||
fTexte = strdup (texte);
|
||||
else
|
||||
fTexte = NULL;
|
||||
}
|
||||
|
||||
mailtoView::~mailtoView()
|
||||
{
|
||||
if (fSubject)
|
||||
free (fSubject);
|
||||
if (fTexte)
|
||||
free (fTexte);
|
||||
}
|
||||
|
||||
void mailtoView::OpenURL ()
|
||||
{
|
||||
int total = 7;
|
||||
char** argv = new char*[total];
|
||||
memset (argv, 0, total * sizeof (char*));
|
||||
argv[0] = "email";
|
||||
int argc = 0;
|
||||
if (fUrl)
|
||||
{
|
||||
char email[256];
|
||||
strcpy (email, "mailto:");
|
||||
strcat (email, fUrl);
|
||||
argv[++argc] = email;
|
||||
}
|
||||
if (fSubject)
|
||||
{
|
||||
argv[++argc] = "-subject";
|
||||
argv[++argc] = fSubject;
|
||||
}
|
||||
if (fTexte)
|
||||
{
|
||||
argv[++argc] = "-body";
|
||||
argv[++argc] = fTexte;
|
||||
}
|
||||
argv[++argc] = 0;
|
||||
be_roster->Launch ("text/x-email", argc, argv);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
|
||||
URLView.h
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _URLVIEW_H_
|
||||
#define _URLVIEW_H_
|
||||
|
||||
#include <View.h>
|
||||
|
||||
class URLView : public BView {
|
||||
|
||||
public:
|
||||
URLView (BRect frame, const char* url);
|
||||
~URLView ();
|
||||
virtual void AttachedToWindow ();
|
||||
virtual void Draw (BRect updateRect);
|
||||
virtual void MouseDown (BPoint where);
|
||||
virtual void OpenURL ();
|
||||
|
||||
protected:
|
||||
char* fUrl;
|
||||
BPoint fLocation;
|
||||
};
|
||||
|
||||
class mailtoView : public URLView {
|
||||
public:
|
||||
mailtoView (BRect frame, const char* email, const char* subject = NULL, const char* texte = NULL);
|
||||
~mailtoView ();
|
||||
virtual void OpenURL ();
|
||||
|
||||
protected:
|
||||
char* fSubject;
|
||||
char* fTexte;
|
||||
};
|
||||
|
||||
#endif // _URLVIEW_H_
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "Utilities.h"
|
||||
#include "PCWorld.h"
|
||||
#include "ProcessController.h"
|
||||
#include "icons.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Deskbar.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Path.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
bool
|
||||
get_team_name_and_icon(info_pack& infoPack, bool icon)
|
||||
{
|
||||
BPath systemPath;
|
||||
find_directory(B_BEOS_SYSTEM_DIRECTORY, &systemPath);
|
||||
|
||||
bool nameFromArgs = false;
|
||||
bool tryTrackerIcon = true;
|
||||
|
||||
for (int len = strlen(infoPack.team_info.args) - 1;
|
||||
len >= 0 && infoPack.team_info.args[len] == ' '; len--) {
|
||||
infoPack.team_info.args[len] = 0;
|
||||
}
|
||||
|
||||
app_info info;
|
||||
status_t status = be_roster->GetRunningAppInfo(infoPack.team_info.team, &info);
|
||||
if (status == B_OK || infoPack.team_info.team == B_SYSTEM_TEAM) {
|
||||
if (infoPack.team_info.team == B_SYSTEM_TEAM) {
|
||||
// Get icon and name from kernel
|
||||
system_info systemInfo;
|
||||
get_system_info(&systemInfo);
|
||||
|
||||
BPath kernelPath(systemPath);
|
||||
kernelPath.Append(systemInfo.kernel_name);
|
||||
get_ref_for_path(kernelPath.Path(), &info.ref);
|
||||
nameFromArgs = true;
|
||||
}
|
||||
} else {
|
||||
BEntry entry(infoPack.team_info.args, true);
|
||||
status = entry.GetRef(&info.ref);
|
||||
if (status != B_OK
|
||||
|| strncmp(infoPack.team_info.args, systemPath.Path(), strlen(systemPath.Path())) != 0)
|
||||
nameFromArgs = true;
|
||||
tryTrackerIcon = (status == B_OK);
|
||||
}
|
||||
|
||||
strncpy(infoPack.team_name, nameFromArgs ? infoPack.team_info.args : info.ref.name,
|
||||
B_PATH_NAME_LENGTH - 1);
|
||||
|
||||
if (icon) {
|
||||
infoPack.team_icon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
|
||||
if (!tryTrackerIcon || BNodeInfo::GetTrackerIcon(&info.ref, infoPack.team_icon, B_MINI_ICON) != B_OK)
|
||||
infoPack.team_icon->SetBits(k_app_mini, 256, 0, B_COLOR_8_BIT);
|
||||
} else
|
||||
infoPack.team_icon = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
launch(const char* signature, const char* path)
|
||||
{
|
||||
status_t status = be_roster->Launch(signature);
|
||||
if (status != B_OK && path) {
|
||||
entry_ref ref;
|
||||
if (get_ref_for_path(path, &ref) == B_OK)
|
||||
status = be_roster->Launch(&ref);
|
||||
}
|
||||
return status == B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mix_colors(rgb_color &target, rgb_color & first, rgb_color & second, float mix)
|
||||
{
|
||||
target.red = (uint8)(second.red * mix + (1. - mix) * first.red);
|
||||
target.green = (uint8)(second.green * mix + (1. - mix) * first.green);
|
||||
target.blue = (uint8)(second.blue * mix + (1. - mix) * first.blue);
|
||||
target.alpha = (uint8)(second.alpha * mix + (1. - mix) * first.alpha);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
find_self(entry_ref& ref)
|
||||
{
|
||||
int32 cookie = 0;
|
||||
image_info info;
|
||||
while (get_next_image_info (0, &cookie, &info) == B_OK) {
|
||||
if (((uint32)info.text <= (uint32)move_to_deskbar
|
||||
&& (uint32)info.text + (uint32)info.text_size > (uint32)move_to_deskbar)
|
||||
|| ((uint32)info.data <= (uint32)move_to_deskbar
|
||||
&& (uint32)info.data + (uint32)info.data_size > (uint32)move_to_deskbar)) {
|
||||
if (get_ref_for_path (info.name, &ref) == B_OK)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This works, but not always... :(
|
||||
app_info appInfo;
|
||||
be_roster->GetAppInfo(kSignature, &appInfo);
|
||||
ref = appInfo.ref;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
move_to_deskbar(BDeskbar& deskbar)
|
||||
{
|
||||
entry_ref ref;
|
||||
find_self(ref);
|
||||
|
||||
deskbar.AddItem(&ref);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
make_window_visible(BWindow* window, bool mayResize)
|
||||
{
|
||||
uint32 flags = window->Flags();
|
||||
BRect screen = BScreen(window).Frame();
|
||||
BRect frame = window->Frame();
|
||||
screen.InsetBy(4, 8);
|
||||
screen.OffsetBy(0, 8);
|
||||
|
||||
if (mayResize) {
|
||||
float width = frame.Width();
|
||||
float height = frame.Height();
|
||||
if (screen.Width() < width && !(flags & B_NOT_H_RESIZABLE))
|
||||
width = screen.Width();
|
||||
if (screen.Height() < height && !(flags & B_NOT_V_RESIZABLE))
|
||||
height = screen.Height();
|
||||
if (width != frame.Width() || height != frame.Height()) {
|
||||
window->ResizeTo(width, height);
|
||||
frame.right = frame.left + width;
|
||||
frame.bottom = frame.top + height;
|
||||
}
|
||||
}
|
||||
if (frame.right > screen.right)
|
||||
window->MoveBy(screen.right-frame.right, 0);
|
||||
if (frame.bottom > screen.bottom)
|
||||
window->MoveBy(0, screen.bottom-frame.bottom);
|
||||
if (frame.left < screen.left)
|
||||
window->MoveTo(screen.left, frame.top);
|
||||
if (frame.top < screen.top)
|
||||
window->MoveBy(0, screen.top-frame.top);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
PCUtils.h
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,33 +15,35 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#ifndef UTILITIES_H
|
||||
#define UTILITIES_H
|
||||
|
||||
#ifndef _PCUTILS_H_
|
||||
#define _PCUTILS_H_
|
||||
|
||||
#include <OS.h>
|
||||
#include <GraphicsDefs.h>
|
||||
|
||||
|
||||
class BDeskbar;
|
||||
class BBitmap;
|
||||
class BWindow;
|
||||
struct entry_ref;
|
||||
|
||||
typedef struct {
|
||||
team_info tminfo;
|
||||
BBitmap *tmicon;
|
||||
char tmname[B_PATH_NAME_LENGTH];
|
||||
thread_info *thinfo;
|
||||
} infosPack;
|
||||
::team_info team_info;
|
||||
BBitmap* team_icon;
|
||||
char team_name[B_PATH_NAME_LENGTH];
|
||||
::thread_info* thread_info;
|
||||
} info_pack;
|
||||
|
||||
bool get_team_name_and_icon(infosPack &infopack, bool icon = false);
|
||||
bool launch (const char* mime, const char* path);
|
||||
void mix_colors (rgb_color &target, rgb_color & first, rgb_color & second, float mix);
|
||||
void find_self (entry_ref & ref);
|
||||
void move_to_deskbar (BDeskbar & db);
|
||||
bool get_team_name_and_icon(info_pack& infoPack, bool icon = false);
|
||||
bool launch(const char* mime, const char* path);
|
||||
void mix_colors(rgb_color& target, rgb_color& first, rgb_color& second, float mix);
|
||||
void find_self(entry_ref& ref);
|
||||
void move_to_deskbar(BDeskbar& deskbar);
|
||||
void make_window_visible(BWindow* window, bool mayResize = false);
|
||||
|
||||
extern const uchar k_cpu_mini[];
|
||||
extern const uchar k_app_mini[];
|
||||
|
||||
#endif // _PCUTILS_H_
|
||||
#endif // UTILITIES_H
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
|
||||
WindowsTools.cpp
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "WindowsTools.h"
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
|
||||
_EXPORT void visible_window (BWindow* window, bool mayResize)
|
||||
{
|
||||
uint32 flags = window->Flags ();
|
||||
BRect screen = BScreen (window).Frame ();
|
||||
BRect frame = window->Frame ();
|
||||
screen.InsetBy (4, 8);
|
||||
screen.OffsetBy (0, 8);
|
||||
if (mayResize)
|
||||
{
|
||||
float width = frame.Width ();
|
||||
float height = frame.Height ();
|
||||
if (screen.Width () < width && !(flags & B_NOT_H_RESIZABLE))
|
||||
width = screen.Width ();
|
||||
if (screen.Height () < height && !(flags & B_NOT_V_RESIZABLE))
|
||||
height = screen.Height ();
|
||||
if (width != frame.Width () || height != frame.Height ())
|
||||
{
|
||||
window->ResizeTo (width, height);
|
||||
frame.right = frame.left + width;
|
||||
frame.bottom = frame.top + height;
|
||||
}
|
||||
}
|
||||
if (frame.right > screen.right)
|
||||
window->MoveBy (screen.right-frame.right, 0);
|
||||
if (frame.bottom > screen.bottom)
|
||||
window->MoveBy (0, screen.bottom-frame.bottom);
|
||||
if (frame.left < screen.left)
|
||||
window->MoveTo (screen.left, frame.top);
|
||||
if (frame.top < screen.top)
|
||||
window->MoveBy (0, screen.top-frame.top);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
|
||||
WindowsTools.h
|
||||
|
||||
ProcessController
|
||||
(c) 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _WINDOWS_TOOLS_H_
|
||||
#define _WINDOWS_TOOLS_H_
|
||||
|
||||
#include "Colors.h"
|
||||
class BWindow;
|
||||
|
||||
void visible_window(BWindow* window, bool mayResize = false);
|
||||
|
||||
#endif // _WINDOWS_TOOLS_H_
|
||||
@@ -1,9 +1,5 @@
|
||||
/*
|
||||
|
||||
icons.data
|
||||
|
||||
ProcessController
|
||||
© 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved.
|
||||
Copyright (C) 2004 beunited.org
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -19,7 +15,6 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
const uchar k_app_mini[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
Reference in New Issue
Block a user