Patch by Vasilis Kaoutsis:
* Style cleanup. * Renamed class GebsPreferences to Preferences. * Made NoiseBarMenuItem::fBusyWaiting/fLost private and added getters and setters. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23498 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -34,13 +34,13 @@ AutoIcon::~AutoIcon()
|
||||
|
||||
|
||||
BBitmap*
|
||||
AutoIcon::bitmap()
|
||||
AutoIcon::Bitmap()
|
||||
{
|
||||
if (fBitmap == NULL) {
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
fBitmap = new BBitmap (BRect (0, 0, 15, 15), B_RGBA32);
|
||||
fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32);
|
||||
#else
|
||||
fBitmap = new BBitmap (BRect (0, 0, 15, 15), B_CMAP8);
|
||||
fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
|
||||
#endif
|
||||
if (fSignature) {
|
||||
entry_ref ref;
|
||||
@@ -48,9 +48,9 @@ AutoIcon::bitmap()
|
||||
if (BNodeInfo::GetTrackerIcon(&ref, fBitmap, B_MINI_ICON) != B_OK)
|
||||
fBitmap->SetBits(k_app_mini, 256, 0, B_CMAP8);
|
||||
}
|
||||
|
||||
if (fbits)
|
||||
fBitmap->SetBits (fbits, 256, 0, B_CMAP8);
|
||||
fBitmap->SetBits(fbits, 256, 0, B_CMAP8);
|
||||
}
|
||||
return fBitmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,18 +28,34 @@ class BBitmap;
|
||||
class AutoIcon {
|
||||
public:
|
||||
AutoIcon(const char* signature)
|
||||
: fSignature (signature), fbits (0), fBitmap (0) {}
|
||||
:
|
||||
fSignature(signature),
|
||||
fbits(0),
|
||||
fBitmap(0)
|
||||
{
|
||||
}
|
||||
|
||||
AutoIcon(const uchar* bits)
|
||||
: fSignature (0), fbits (bits), fBitmap (0) {}
|
||||
:
|
||||
fSignature(0),
|
||||
fbits(bits),
|
||||
fBitmap(0)
|
||||
{
|
||||
}
|
||||
|
||||
~AutoIcon();
|
||||
|
||||
operator BBitmap*() { return bitmap(); }
|
||||
BBitmap* bitmap();
|
||||
operator BBitmap*()
|
||||
{
|
||||
return Bitmap();
|
||||
}
|
||||
|
||||
BBitmap* Bitmap();
|
||||
|
||||
private:
|
||||
const char* fSignature;
|
||||
const uchar* fbits;
|
||||
BBitmap * fBitmap;
|
||||
BBitmap* fBitmap;
|
||||
};
|
||||
|
||||
#endif // _AUTO_ICON_H_
|
||||
|
||||
@@ -29,44 +29,47 @@
|
||||
#include <Roster.h>
|
||||
#include <parsedate.h>
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
IconMenuItem::IconMenuItem(BBitmap* icon, const char* title,
|
||||
BMessage* msg, bool drawText, bool purge)
|
||||
:BMenuItem(title, msg), fIcon(icon), fDrawText(drawText), fPurge(purge)
|
||||
|
||||
BMessage* msg, bool drawText, bool purge)
|
||||
: BMenuItem(title, msg),
|
||||
fIcon(icon),
|
||||
fDrawText(drawText),
|
||||
fPurge(purge)
|
||||
{
|
||||
if (!fIcon)
|
||||
DefaultIcon(NULL);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
IconMenuItem::IconMenuItem(BBitmap* icon, BMenu* menu, bool drawText, bool purge)
|
||||
:BMenuItem(menu), fIcon(icon), fDrawText(drawText), fPurge(purge)
|
||||
: BMenuItem(menu),
|
||||
fIcon(icon),
|
||||
fDrawText(drawText),
|
||||
fPurge(purge)
|
||||
|
||||
{
|
||||
if (!fIcon)
|
||||
DefaultIcon(NULL);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
IconMenuItem::IconMenuItem(const char* mime, const char* title, BMessage* msg, bool drawText)
|
||||
:BMenuItem(title, msg), fIcon(NULL), fDrawText(drawText)
|
||||
|
||||
: BMenuItem(title, msg),
|
||||
fIcon(NULL),
|
||||
fDrawText(drawText)
|
||||
{
|
||||
DefaultIcon(mime);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
IconMenuItem::~IconMenuItem()
|
||||
{
|
||||
if (fPurge && fIcon)
|
||||
delete fIcon;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
void IconMenuItem::DrawContent()
|
||||
{
|
||||
BPoint loc;
|
||||
@@ -80,15 +83,17 @@ void IconMenuItem::DrawContent()
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void IconMenuItem::Highlight(bool hilited)
|
||||
|
||||
void
|
||||
IconMenuItem::Highlight(bool hilited)
|
||||
{
|
||||
BMenuItem::Highlight(hilited);
|
||||
DrawIcon();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void IconMenuItem::DrawIcon()
|
||||
|
||||
void
|
||||
IconMenuItem::DrawIcon()
|
||||
{
|
||||
// TODO: exact code duplication with TeamBarMenuItem::DrawIcon()
|
||||
if (!fIcon)
|
||||
@@ -112,8 +117,9 @@ void IconMenuItem::DrawIcon()
|
||||
menu->SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void IconMenuItem::GetContentSize(float* width, float* height)
|
||||
|
||||
void
|
||||
IconMenuItem::GetContentSize(float* width, float* height)
|
||||
{
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
int limit = IconMenuItem::MinHeight();
|
||||
@@ -125,25 +131,26 @@ void IconMenuItem::GetContentSize(float* width, float* height)
|
||||
*width = 16;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
void IconMenuItem::DefaultIcon(const char* mime)
|
||||
|
||||
void
|
||||
IconMenuItem::DefaultIcon(const char* mime)
|
||||
{
|
||||
BRect r(0, 0, 15, 15);
|
||||
fIcon = new BBitmap(r, B_COLOR_8_BIT);
|
||||
BRect rect(0, 0, 15, 15);
|
||||
fIcon = new BBitmap(rect, B_COLOR_8_BIT);
|
||||
if (mime) {
|
||||
BMimeType mimeType(mime);
|
||||
if (mimeType.GetIcon(fIcon, B_MINI_ICON)!=B_OK)
|
||||
BMimeType mimeType(mime);
|
||||
if (mimeType.GetIcon(fIcon, B_MINI_ICON) != B_OK)
|
||||
fDrawText = true;
|
||||
} else {
|
||||
app_info info;
|
||||
app_info info;
|
||||
be_app->GetAppInfo(&info);
|
||||
if (BNodeInfo::GetTrackerIcon(&info.ref, fIcon, B_MINI_ICON)!=B_OK)
|
||||
if (BNodeInfo::GetTrackerIcon(&info.ref, fIcon, B_MINI_ICON) != B_OK)
|
||||
fDrawText = true;
|
||||
}
|
||||
fPurge = true;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
int IconMenuItem::MinHeight()
|
||||
{
|
||||
static int minheight = -1;
|
||||
@@ -152,17 +159,18 @@ int IconMenuItem::MinHeight()
|
||||
return minheight;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
bool before_dano()
|
||||
|
||||
bool
|
||||
before_dano()
|
||||
{
|
||||
static int old_version = -1;
|
||||
if (old_version < 0)
|
||||
{
|
||||
static int old_version = -1;
|
||||
if (old_version < 0) {
|
||||
system_info sys_info;
|
||||
get_system_info(&sys_info);
|
||||
time_t kernelTime = parsedate(sys_info.kernel_build_date, time(NULL));
|
||||
struct tm * date = gmtime(&kernelTime);
|
||||
time_t kernelTime = parsedate(sys_info.kernel_build_date, time(NULL));
|
||||
struct tm* date = gmtime(&kernelTime);
|
||||
old_version = (date->tm_year < 101 || date->tm_year == 101 && date->tm_mon < 10);
|
||||
}
|
||||
|
||||
return old_version;
|
||||
}
|
||||
|
||||
@@ -21,38 +21,40 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ICON_MENU_ITEM_H_
|
||||
#define _ICON_MENU_ITEM_H_
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
|
||||
class BBitmap;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
class IconMenuItem : public BMenuItem {
|
||||
public:
|
||||
IconMenuItem(BBitmap*, const char* title,
|
||||
BMessage*, bool drawText = true, bool purge = false);
|
||||
|
||||
public:
|
||||
IconMenuItem(BBitmap*, const char* title,
|
||||
BMessage*, bool drawText = true, bool purge = false);
|
||||
IconMenuItem(BBitmap*, BMenu*,
|
||||
bool drawText = true, bool purge = false);
|
||||
IconMenuItem(const char* mime, const char* title, BMessage*,
|
||||
bool drawText = true);
|
||||
virtual ~IconMenuItem();
|
||||
virtual void DrawContent();
|
||||
virtual void Highlight(bool isHighlighted);
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
static int MinHeight();
|
||||
IconMenuItem(BBitmap*, BMenu*, bool drawText = true,
|
||||
bool purge = false);
|
||||
|
||||
private:
|
||||
void DefaultIcon(const char* mime);
|
||||
void DrawIcon();
|
||||
IconMenuItem(const char* mime, const char* title, BMessage*,
|
||||
bool drawText = true);
|
||||
|
||||
BBitmap* fIcon;
|
||||
bool fDrawText;
|
||||
bool fPurge;
|
||||
virtual ~IconMenuItem();
|
||||
virtual void DrawContent();
|
||||
virtual void Highlight(bool isHighlighted);
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
|
||||
static int MinHeight();
|
||||
|
||||
private:
|
||||
void DefaultIcon(const char* mime);
|
||||
void DrawIcon();
|
||||
|
||||
BBitmap* fIcon;
|
||||
bool fDrawText;
|
||||
bool fPurge;
|
||||
};
|
||||
|
||||
bool before_dano();
|
||||
|
||||
@@ -25,19 +25,20 @@
|
||||
|
||||
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);
|
||||
void UpdateSituation(float commitedMemory, float totalWriteMemory);
|
||||
|
||||
private:
|
||||
float fTotalWriteMemory;
|
||||
float fPhsysicalMemory;
|
||||
float fCommitedMemory;
|
||||
double fLastSum;
|
||||
float fGrenze1;
|
||||
float fGrenze2;
|
||||
float fTotalWriteMemory;
|
||||
float fPhsysicalMemory;
|
||||
float fCommitedMemory;
|
||||
double fLastSum;
|
||||
float fGrenze1;
|
||||
float fGrenze2;
|
||||
};
|
||||
|
||||
#endif // _KERNEL_MEMORY_BAR_MENU_ITEM_H_
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
float gMemoryTextWidth;
|
||||
|
||||
|
||||
MemoryBarMenu::MemoryBarMenu(const char* name, info_pack* infos,
|
||||
system_info& systemInfo)
|
||||
MemoryBarMenu::MemoryBarMenu(const char* name, info_pack* infos, system_info& systemInfo)
|
||||
: BMenu(name),
|
||||
fFirstShow(true)
|
||||
{
|
||||
@@ -94,7 +93,7 @@ MemoryBarMenu::Pulse()
|
||||
int lastRecycle = 0;
|
||||
int firstRecycle = 0;
|
||||
int k;
|
||||
MemoryBarMenuItem *item;
|
||||
MemoryBarMenuItem* item;
|
||||
int total = 0;
|
||||
for (k = 1; (item = (MemoryBarMenuItem*)ItemAt(k)) != NULL; k++) {
|
||||
int m = item->UpdateSituation(commitedMemory);
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
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 _MEMORY_BAR_MENU_H_
|
||||
#define _MEMORY_BAR_MENU_H_
|
||||
#ifndef MEMORY_BAR_MENU_H
|
||||
#define MEMORY_BAR_MENU_H
|
||||
|
||||
|
||||
#include "Utilities.h"
|
||||
@@ -27,16 +27,17 @@
|
||||
|
||||
class MemoryBarMenuItem;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MemoryBarMenuItem* item;
|
||||
int index;
|
||||
} MRecycleItem;
|
||||
|
||||
|
||||
class MemoryBarMenu : public BMenu {
|
||||
public:
|
||||
MemoryBarMenu(const char* name, info_pack* infos,
|
||||
system_info& systemInfo);
|
||||
virtual ~MemoryBarMenu();
|
||||
MemoryBarMenu(const char* name, info_pack* infos, system_info& systemInfo);
|
||||
virtual ~MemoryBarMenu();
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void Pulse();
|
||||
@@ -52,4 +53,4 @@ class MemoryBarMenu : public BMenu {
|
||||
|
||||
extern float gMemoryTextWidth;
|
||||
|
||||
#endif // _MEMORY_BAR_MENU_H_
|
||||
#endif // MEMORY_BAR_MENU_H
|
||||
|
||||
@@ -244,20 +244,20 @@ MemoryBarMenuItem::UpdateSituation(int commitedMemory)
|
||||
void
|
||||
MemoryBarMenuItem::BarUpdate()
|
||||
{
|
||||
area_info ainfo;
|
||||
area_info areaInfo;
|
||||
int32 cookie = 0;
|
||||
size_t lram_size = 0;
|
||||
size_t lwram_size = 0;
|
||||
bool exists = false;
|
||||
|
||||
while (get_next_area_info(fTeamID, &cookie, &ainfo) == B_OK) {
|
||||
while (get_next_area_info(fTeamID, &cookie, &areaInfo) == B_OK) {
|
||||
exists = true;
|
||||
lram_size += ainfo.ram_size;
|
||||
lram_size += areaInfo.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) != 0)
|
||||
lwram_size += ainfo.ram_size;
|
||||
// int zone = (int (areaInfo.address) & 0xf0000000) >> 24;
|
||||
if ((areaInfo.protection & B_WRITE_AREA) != 0)
|
||||
lwram_size += areaInfo.ram_size;
|
||||
// && (zone & 0xf0) != 0xA0 // Exclude media buffers
|
||||
// && (fTeamID != gAppServerTeamID || zone != 0x90)) // Exclude app_server side of bitmaps
|
||||
}
|
||||
@@ -287,4 +287,3 @@ MemoryBarMenuItem::Reset(char* name, team_id team, BBitmap* icon,
|
||||
fIcon = icon;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,17 +46,19 @@ NoiseBarMenuItem::DrawContent()
|
||||
void
|
||||
NoiseBarMenuItem::DrawBar(bool force)
|
||||
{
|
||||
bool selected = IsSelected ();
|
||||
bool selected = IsSelected();
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu ();
|
||||
BMenu* menu = Menu();
|
||||
frame.right -= 24;
|
||||
frame.left = frame.right-kBarWidth;
|
||||
frame.left = frame.right - kBarWidth;
|
||||
frame.top += 5;
|
||||
frame.bottom = frame.top+8;
|
||||
frame.bottom = frame.top + 8;
|
||||
if (fBusyWaiting < 0)
|
||||
return;
|
||||
|
||||
if (fGrenze1 < 0)
|
||||
force = true;
|
||||
|
||||
if (force) {
|
||||
if (selected)
|
||||
menu->SetHighColor(gFrameColorSelected);
|
||||
@@ -64,6 +66,7 @@ NoiseBarMenuItem::DrawBar(bool force)
|
||||
menu->SetHighColor(gFrameColor);
|
||||
menu->StrokeRect(frame);
|
||||
}
|
||||
|
||||
frame.InsetBy(1, 1);
|
||||
BRect r = frame;
|
||||
float grenze1 = frame.left+(frame.right-frame.left)*fBusyWaiting;
|
||||
@@ -119,5 +122,5 @@ NoiseBarMenuItem::GetContentSize(float* width, float* height)
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
if (*height < 16)
|
||||
*height = 16;
|
||||
*width += 20+kBarWidth;
|
||||
*width += 20 + kBarWidth;
|
||||
}
|
||||
|
||||
@@ -27,21 +27,36 @@
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
class NoiseBarMenuItem : public BMenuItem {
|
||||
public:
|
||||
NoiseBarMenuItem();
|
||||
|
||||
public:
|
||||
NoiseBarMenuItem();
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
void DrawBar(bool force);
|
||||
double fBusyWaiting;
|
||||
double fLost;
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
|
||||
private:
|
||||
float fGrenze1;
|
||||
float fGrenze2;
|
||||
void DrawBar(bool force);
|
||||
|
||||
double BusyWaiting() const
|
||||
{
|
||||
return fBusyWaiting;
|
||||
}
|
||||
|
||||
void SetBusyWaiting(double busyWaiting)
|
||||
{
|
||||
fBusyWaiting = busyWaiting;
|
||||
}
|
||||
|
||||
void SetLost(double lost)
|
||||
{
|
||||
fLost = lost;
|
||||
}
|
||||
|
||||
private:
|
||||
double fBusyWaiting;
|
||||
double fLost;
|
||||
float fGrenze1;
|
||||
float fGrenze2;
|
||||
};
|
||||
|
||||
#endif // _NOISE_BAR_MENU_ITEM_H_
|
||||
|
||||
@@ -36,7 +36,7 @@ PCWindow::PCWindow()
|
||||
: BWindow(BRect(100, 150, 131, 181), "ProcessController", B_TITLED_WINDOW,
|
||||
B_NOT_H_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
GebsPreferences preferences(kPreferencesFileName);
|
||||
Preferences preferences(kPreferencesFileName);
|
||||
preferences.SaveInt32(kCurrentVersion, kVersionName);
|
||||
preferences.LoadWindowPosition(this, kPosPrefName);
|
||||
|
||||
@@ -70,11 +70,10 @@ PCWindow::~PCWindow()
|
||||
bool
|
||||
PCWindow::QuitRequested()
|
||||
{
|
||||
GebsPreferences tPreferences(kPreferencesFileName);
|
||||
Preferences tPreferences(kPreferencesFileName);
|
||||
tPreferences.SaveInt32(kCurrentVersion, kVersionName);
|
||||
tPreferences.SaveWindowPosition(this, kPosPrefName);
|
||||
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ PCApplication::~PCApplication()
|
||||
void
|
||||
PCApplication::ReadyToRun()
|
||||
{
|
||||
GebsPreferences preferences(kPreferencesFileName);
|
||||
Preferences preferences(kPreferencesFileName);
|
||||
int32 version = 0;
|
||||
preferences.ReadInt32(version, kVersionName);
|
||||
if (version != kCurrentVersion) {
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "Preferences.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
@@ -29,12 +33,8 @@
|
||||
#include <Mime.h>
|
||||
#include <Path.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
GebsPreferences::GebsPreferences(const char* name, const char* signature, bool doSave)
|
||||
Preferences::Preferences(const char* name, const char* signature, bool doSave)
|
||||
: BMessage('Pref'), BLocker("Preferences", true),
|
||||
fSavePreferences(doSave)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ GebsPreferences::GebsPreferences(const char* name, const char* signature, bool d
|
||||
}
|
||||
|
||||
|
||||
GebsPreferences::GebsPreferences(const entry_ref &ref, const char* signature, bool doSave)
|
||||
Preferences::Preferences(const entry_ref &ref, const char* signature, bool doSave)
|
||||
: BMessage('Pref'), BLocker("Preferences", true),
|
||||
fSavePreferences(doSave)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ GebsPreferences::GebsPreferences(const entry_ref &ref, const char* signature, bo
|
||||
}
|
||||
|
||||
|
||||
GebsPreferences::~GebsPreferences()
|
||||
Preferences::~Preferences()
|
||||
{
|
||||
if (fSavePreferences) {
|
||||
BFile file;
|
||||
@@ -101,7 +101,7 @@ GebsPreferences::~GebsPreferences()
|
||||
Flatten(&file);
|
||||
if (fSignature) {
|
||||
file.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0, fSignature,
|
||||
strlen(fSignature)+1);
|
||||
strlen(fSignature) + 1);
|
||||
}
|
||||
} else {
|
||||
// implement saving somewhere else!
|
||||
@@ -119,7 +119,7 @@ GebsPreferences::~GebsPreferences()
|
||||
|
||||
|
||||
status_t
|
||||
GebsPreferences::MakeEmpty()
|
||||
Preferences::MakeEmpty()
|
||||
{
|
||||
Lock();
|
||||
status_t status = BMessage::MakeEmpty();
|
||||
@@ -129,7 +129,7 @@ GebsPreferences::MakeEmpty()
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveWindowPosition(BWindow* window, const char* name)
|
||||
Preferences::SaveWindowPosition(BWindow* window, const char* name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
@@ -144,7 +144,7 @@ GebsPreferences::SaveWindowPosition(BWindow* window, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::LoadWindowPosition(BWindow* window, const char* name)
|
||||
Preferences::LoadWindowPosition(BWindow* window, const char* name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
@@ -159,7 +159,7 @@ GebsPreferences::LoadWindowPosition(BWindow* window, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveWindowFrame(BWindow* window, const char* name)
|
||||
Preferences::SaveWindowFrame(BWindow* window, const char* name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
@@ -174,7 +174,7 @@ GebsPreferences::SaveWindowFrame(BWindow* window, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::LoadWindowFrame(BWindow* window, const char* name)
|
||||
Preferences::LoadWindowFrame(BWindow* window, const char* name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
@@ -190,7 +190,7 @@ GebsPreferences::LoadWindowFrame(BWindow* window, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveInt32(int32 value, const char* name)
|
||||
Preferences::SaveInt32(int32 value, const char* name)
|
||||
{
|
||||
Lock();
|
||||
|
||||
@@ -204,7 +204,7 @@ GebsPreferences::SaveInt32(int32 value, const char* name)
|
||||
|
||||
|
||||
bool
|
||||
GebsPreferences::ReadInt32(int32 &val, const char* name)
|
||||
Preferences::ReadInt32(int32 &val, const char* name)
|
||||
{
|
||||
Lock();
|
||||
int32 readVal;
|
||||
@@ -217,7 +217,7 @@ GebsPreferences::ReadInt32(int32 &val, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveFloat(float val, const char* name)
|
||||
Preferences::SaveFloat(float val, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasFloat(name))
|
||||
@@ -229,11 +229,11 @@ GebsPreferences::SaveFloat(float val, const char* name)
|
||||
|
||||
|
||||
bool
|
||||
GebsPreferences::ReadFloat(float &val, const char* name)
|
||||
Preferences::ReadFloat(float &val, const char* name)
|
||||
{
|
||||
Lock();
|
||||
float readVal;
|
||||
bool found = FindFloat(name, &readVal)==B_OK;
|
||||
bool found = FindFloat(name, &readVal) == B_OK;
|
||||
if (found)
|
||||
val = readVal;
|
||||
Unlock();
|
||||
@@ -242,7 +242,7 @@ GebsPreferences::ReadFloat(float &val, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveRect(BRect &rect, const char* name)
|
||||
Preferences::SaveRect(BRect& rect, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasRect(name))
|
||||
@@ -254,11 +254,11 @@ GebsPreferences::SaveRect(BRect &rect, const char* name)
|
||||
|
||||
|
||||
BRect &
|
||||
GebsPreferences::ReadRect(BRect &rect, const char* name)
|
||||
Preferences::ReadRect(BRect& rect, const char* name)
|
||||
{
|
||||
Lock();
|
||||
BRect loaded;
|
||||
if (FindRect(name, &loaded)==B_OK)
|
||||
if (FindRect(name, &loaded) == B_OK)
|
||||
rect = loaded;
|
||||
Unlock();
|
||||
return rect;
|
||||
@@ -266,7 +266,7 @@ GebsPreferences::ReadRect(BRect &rect, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveString(BString &string, const char* name)
|
||||
Preferences::SaveString(BString &string, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasString(name))
|
||||
@@ -278,7 +278,7 @@ GebsPreferences::SaveString(BString &string, const char* name)
|
||||
|
||||
|
||||
void
|
||||
GebsPreferences::SaveString(const char* string, const char* name)
|
||||
Preferences::SaveString(const char* string, const char* name)
|
||||
{
|
||||
Lock();
|
||||
if (HasString(name))
|
||||
@@ -290,7 +290,7 @@ GebsPreferences::SaveString(const char* string, const char* name)
|
||||
|
||||
|
||||
bool
|
||||
GebsPreferences::ReadString(BString &string, const char* name)
|
||||
Preferences::ReadString(BString &string, const char* name)
|
||||
{
|
||||
Lock();
|
||||
bool loaded = FindString(name, &string) == B_OK;
|
||||
|
||||
@@ -21,42 +21,43 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#ifndef PREFERENCES_H
|
||||
#define PREFERENCES_H
|
||||
|
||||
#ifndef _Preferences_H_
|
||||
#define _Preferences_H_
|
||||
|
||||
#include <Window.h>
|
||||
#include <Message.h>
|
||||
#include <Locker.h>
|
||||
#include <Message.h>
|
||||
#include <Window.h>
|
||||
|
||||
class GebsPreferences : public BMessage, public BLocker {
|
||||
|
||||
public:
|
||||
GebsPreferences (const char* thename, const char* thesignature=NULL, bool doSave=true);
|
||||
GebsPreferences (const entry_ref &ref, const char* thesignature=NULL, bool doSave=true);
|
||||
~GebsPreferences ();
|
||||
status_t MakeEmpty ();
|
||||
void SaveWindowPosition (BWindow* window, const char* name);
|
||||
void LoadWindowPosition (BWindow* window, const char* name);
|
||||
void SaveWindowFrame (BWindow* window, const char* name);
|
||||
void LoadWindowFrame (BWindow* window, const char* name);
|
||||
void SaveInt32 (int32 val, const char* name);
|
||||
bool ReadInt32 (int32 &val, const char* name);
|
||||
void SaveFloat (float val, const char* name);
|
||||
bool ReadFloat (float &val, const char* name);
|
||||
void SaveRect (BRect &rect, const char* name);
|
||||
BRect& ReadRect (BRect &rect, const char* name);
|
||||
void SaveString (BString &string, const char* name);
|
||||
void SaveString (const char* string, const char* name);
|
||||
bool ReadString (BString &string, const char* name);
|
||||
bool fNewPreferences;
|
||||
bool fSavePreferences;
|
||||
char *fName;
|
||||
char *fSignature;
|
||||
entry_ref *fSettingsFile;
|
||||
class Preferences : public BMessage, public BLocker {
|
||||
public:
|
||||
Preferences(const char* thename, const char* thesignature = NULL, bool doSave = true);
|
||||
Preferences(const entry_ref& ref, const char* thesignature = NULL, bool doSave = true);
|
||||
~Preferences();
|
||||
status_t MakeEmpty();
|
||||
void SaveWindowPosition(BWindow* window, const char* name);
|
||||
void LoadWindowPosition(BWindow* window, const char* name);
|
||||
void SaveWindowFrame(BWindow* window, const char* name);
|
||||
void LoadWindowFrame(BWindow* window, const char* name);
|
||||
void SaveInt32(int32 val, const char* name);
|
||||
bool ReadInt32(int32& val, const char* name);
|
||||
void SaveFloat(float val, const char* name);
|
||||
bool ReadFloat(float& val, const char* name);
|
||||
void SaveRect(BRect& rect, const char* name);
|
||||
BRect& ReadRect(BRect& rect, const char* name);
|
||||
void SaveString(BString& string, const char* name);
|
||||
void SaveString(const char* string, const char* name);
|
||||
bool ReadString(BString& string, const char* name);
|
||||
|
||||
private:
|
||||
bool fNewPreferences;
|
||||
bool fSavePreferences;
|
||||
char* fName;
|
||||
char* fSignature;
|
||||
entry_ref* fSettingsFile;
|
||||
};
|
||||
|
||||
extern GebsPreferences gPreferences;
|
||||
extern Preferences gPreferences;
|
||||
|
||||
// ggPreferences.LoadWindowPosition(this, kPosPrefName);
|
||||
// ggPreferences.SaveWindowPosition(this, kPosPrefName);
|
||||
@@ -64,4 +65,4 @@ extern GebsPreferences gPreferences;
|
||||
// ggPreferences.LoadWindowFrame(this, frame);
|
||||
// ggPreferences.SaveWindowFrame(this, frame);
|
||||
|
||||
#endif // _Preferences_H_
|
||||
#endif // PREFERENCES_H
|
||||
|
||||
@@ -417,7 +417,7 @@ ProcessController::AttachedToWindow()
|
||||
else
|
||||
SetViewColor(kBlack);
|
||||
|
||||
GebsPreferences tPreferences(kPreferencesFileName, NULL, false);
|
||||
Preferences tPreferences(kPreferencesFileName, NULL, false);
|
||||
DefaultColors();
|
||||
|
||||
system_info info;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
class QuitMenu : public BMenu {
|
||||
public:
|
||||
QuitMenu(const char* title, info_pack* infos, int infosCount);
|
||||
QuitMenu(const char* title, info_pack* infos, int infosCount);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
@@ -103,7 +103,7 @@ TeamBarMenu::Pulse()
|
||||
k -= lastRecycle;
|
||||
lastRecycle = 0;
|
||||
}
|
||||
total += item->fUser+item->fKernel;
|
||||
total += item->fUser + item->fKernel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ 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.team_info.team;
|
||||
if (!get_team_name_and_icon(infos, true)) {
|
||||
@@ -165,16 +165,19 @@ TeamBarMenu::Pulse()
|
||||
|
||||
// Delete the items that haven't been recycled.
|
||||
if (firstRecycle < lastRecycle)
|
||||
RemoveItems(IndexOf(fRecycleList[firstRecycle].item), lastRecycle-firstRecycle, true);
|
||||
RemoveItems(IndexOf(fRecycleList[firstRecycle].item), lastRecycle - firstRecycle, true);
|
||||
|
||||
total /= gCPUcount;
|
||||
total = 1-total;
|
||||
total = 1 - total;
|
||||
|
||||
fLastTotalTime = system_time();
|
||||
NoiseBarMenuItem* noiseItem;
|
||||
if ((noiseItem = (NoiseBarMenuItem*)ItemAt(0)) != NULL) {
|
||||
noiseItem->fBusyWaiting = 0;
|
||||
noiseItem->fLost = (total >= 0 ? total : 0);
|
||||
noiseItem->SetBusyWaiting(0);
|
||||
if (total >= 0)
|
||||
noiseItem->SetLost(total);
|
||||
else
|
||||
noiseItem->SetLost(0);
|
||||
noiseItem->DrawBar(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "TeamBarMenuItem.h"
|
||||
|
||||
#include "Colors.h"
|
||||
@@ -30,8 +31,8 @@
|
||||
#define B_USAGE_SELF 0
|
||||
|
||||
|
||||
TeamBarMenuItem::TeamBarMenuItem(BMenu *menu, BMessage *kill_team, team_id team,
|
||||
BBitmap* icon, bool deleteIcon)
|
||||
TeamBarMenuItem::TeamBarMenuItem(BMenu* menu, BMessage* kill_team, team_id team,
|
||||
BBitmap* icon, bool deleteIcon)
|
||||
: BMenuItem(menu, kill_team),
|
||||
fTeamID(team),
|
||||
fIcon(icon),
|
||||
@@ -44,8 +45,8 @@ TeamBarMenuItem::TeamBarMenuItem(BMenu *menu, BMessage *kill_team, team_id team,
|
||||
void
|
||||
TeamBarMenuItem::Init()
|
||||
{
|
||||
team_info tminfo;
|
||||
get_team_info(fTeamID, &tminfo);
|
||||
team_info teamInfo;
|
||||
get_team_info(fTeamID, &teamInfo);
|
||||
get_team_usage_info(fTeamID, B_USAGE_SELF, &fTeamUsageInfo);
|
||||
if (fTeamID == B_SYSTEM_TEAM) {
|
||||
thread_info thinfos;
|
||||
@@ -139,8 +140,8 @@ TeamBarMenuItem::DrawBar(bool force)
|
||||
|
||||
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;
|
||||
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)
|
||||
@@ -199,7 +200,7 @@ TeamBarMenuItem::GetContentSize(float* width, float* height)
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
if (*height < 16)
|
||||
*height = 16;
|
||||
*width += 40+kBarWidth;
|
||||
*width += 40 + kBarWidth;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,8 +220,12 @@ TeamBarMenuItem::BarUpdate()
|
||||
usage.user_time = idle;
|
||||
idle -= fTeamUsageInfo.user_time;
|
||||
}
|
||||
fKernel = double(usage.kernel_time-fTeamUsageInfo.kernel_time-idle)/double(now-fLastTime);
|
||||
fUser = double(usage.user_time-fTeamUsageInfo.user_time)/double(now-fLastTime);
|
||||
|
||||
fKernel = double(usage.kernel_time - fTeamUsageInfo.kernel_time - idle)
|
||||
/ double(now - fLastTime);
|
||||
|
||||
fUser = double(usage.user_time - fTeamUsageInfo.user_time) / double(now - fLastTime);
|
||||
|
||||
if (fKernel < 0)
|
||||
fKernel = 0;
|
||||
fLastTime = now;
|
||||
@@ -237,11 +242,13 @@ TeamBarMenuItem::Reset(char* name, team_id team, BBitmap* icon, bool deleteIcon)
|
||||
SetLabel(name);
|
||||
fTeamID = team;
|
||||
Init();
|
||||
|
||||
if (fDeleteIcon)
|
||||
delete fIcon;
|
||||
|
||||
fDeleteIcon = deleteIcon;
|
||||
fIcon = icon;
|
||||
Message()->ReplaceInt32("team", team);
|
||||
((ThreadBarMenu*) Submenu())->Reset(team);
|
||||
((ThreadBarMenu*)Submenu())->Reset(team);
|
||||
BarUpdate();
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@ class BBitmap;
|
||||
|
||||
class TeamBarMenuItem : public BMenuItem {
|
||||
public:
|
||||
TeamBarMenuItem(BMenu *menu, BMessage *kill_team,
|
||||
team_id team, BBitmap* icon, bool deleteIcon);
|
||||
TeamBarMenuItem(BMenu* menu, BMessage* kill_team, team_id team,
|
||||
BBitmap* icon, bool deleteIcon);
|
||||
|
||||
virtual ~TeamBarMenuItem();
|
||||
|
||||
virtual void DrawContent();
|
||||
|
||||
@@ -57,13 +57,15 @@ ThreadBarMenuItem::DrawBar(bool force)
|
||||
BRect frame = Frame();
|
||||
BMenu* menu = Menu();
|
||||
frame.right -= 24;
|
||||
frame.left = frame.right-kBarWidth;
|
||||
frame.left = frame.right - kBarWidth;
|
||||
frame.top += 3;
|
||||
frame.bottom = frame.top+8;
|
||||
frame.bottom = frame.top + 8;
|
||||
if (fKernel < 0)
|
||||
return;
|
||||
|
||||
if (fGrenze1 < 0)
|
||||
force = true;
|
||||
|
||||
if (force) {
|
||||
if (selected)
|
||||
menu->SetHighColor(gFrameColorSelected);
|
||||
@@ -71,17 +73,20 @@ ThreadBarMenuItem::DrawBar(bool force)
|
||||
menu->SetHighColor(gFrameColor);
|
||||
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);
|
||||
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)
|
||||
grenze2 = frame.right;
|
||||
r.right = grenze1;
|
||||
|
||||
if (!force)
|
||||
r.left = fGrenze1;
|
||||
|
||||
if (r.left < r.right) {
|
||||
if (selected)
|
||||
menu->SetHighColor(gKernelColorSelected);
|
||||
@@ -89,6 +94,7 @@ ThreadBarMenuItem::DrawBar(bool force)
|
||||
menu->SetHighColor(gKernelColor);
|
||||
menu->FillRect(r);
|
||||
}
|
||||
|
||||
r.left = grenze1;
|
||||
r.right = grenze2;
|
||||
if (!force) {
|
||||
@@ -127,7 +133,7 @@ ThreadBarMenuItem::GetContentSize(float* width, float* height)
|
||||
BMenuItem::GetContentSize(width, height);
|
||||
// if (*height < 16)
|
||||
// *height = 16;
|
||||
*width += 10+kBarWidth;
|
||||
*width += 10 + kBarWidth;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,11 +141,11 @@ void
|
||||
ThreadBarMenuItem::Highlight(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PriorityMenu * popup = (PriorityMenu *) Submenu ();
|
||||
PriorityMenu* popup = (PriorityMenu*)Submenu();
|
||||
if (popup)
|
||||
popup->Update (fThreadInfo.priority);
|
||||
popup->Update(fThreadInfo.priority);
|
||||
}
|
||||
BMenuItem::Highlight (on);
|
||||
BMenuItem::Highlight(on);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,8 +155,8 @@ ThreadBarMenuItem::BarUpdate()
|
||||
thread_info info;
|
||||
if (get_thread_info(fThreadID, &info) == B_OK) {
|
||||
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);
|
||||
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) {
|
||||
fUser += fKernel;
|
||||
fKernel = 0;
|
||||
@@ -159,7 +165,7 @@ ThreadBarMenuItem::BarUpdate()
|
||||
fThreadInfo.kernel_time = info.kernel_time;
|
||||
fLastTime = now;
|
||||
if (IsSelected ()) {
|
||||
PriorityMenu * popup = (PriorityMenu *) Submenu ();
|
||||
PriorityMenu* popup = (PriorityMenu*)Submenu();
|
||||
if (popup && info.priority != fThreadInfo.priority)
|
||||
popup->Update (info.priority);
|
||||
}
|
||||
@@ -167,4 +173,3 @@ ThreadBarMenuItem::BarUpdate()
|
||||
} else
|
||||
fKernel = -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user