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,7 +34,7 @@ AutoIcon::~AutoIcon()
|
||||
|
||||
|
||||
BBitmap*
|
||||
AutoIcon::bitmap()
|
||||
AutoIcon::Bitmap()
|
||||
{
|
||||
if (fBitmap == NULL) {
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
@@ -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);
|
||||
}
|
||||
return fBitmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,29 @@ 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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
: 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,11 +131,12 @@ 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)
|
||||
@@ -143,7 +150,7 @@ void IconMenuItem::DefaultIcon(const char* mime)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
old_version = (date->tm_year < 101 || date->tm_year == 101 && date->tm_mon < 10);
|
||||
}
|
||||
|
||||
return old_version;
|
||||
}
|
||||
|
||||
@@ -21,29 +21,31 @@
|
||||
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);
|
||||
IconMenuItem(BBitmap*, BMenu*,
|
||||
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();
|
||||
|
||||
private:
|
||||
|
||||
@@ -28,6 +28,7 @@ class KernelMemoryBarMenuItem : public BMenuItem {
|
||||
KernelMemoryBarMenuItem(system_info& systemInfo);
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* _width, float* _height);
|
||||
|
||||
void DrawBar(bool force);
|
||||
void UpdateSituation(float commitedMemory, float totalWriteMemory);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,15 +27,16 @@
|
||||
|
||||
class MemoryBarMenuItem;
|
||||
|
||||
|
||||
typedef struct {
|
||||
MemoryBarMenuItem* item;
|
||||
int index;
|
||||
} MRecycleItem;
|
||||
|
||||
|
||||
class MemoryBarMenu : public BMenu {
|
||||
public:
|
||||
MemoryBarMenu(const char* name, info_pack* infos,
|
||||
system_info& systemInfo);
|
||||
MemoryBarMenu(const char* name, info_pack* infos, system_info& systemInfo);
|
||||
virtual ~MemoryBarMenu();
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,10 @@ NoiseBarMenuItem::DrawBar(bool force)
|
||||
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;
|
||||
|
||||
@@ -27,19 +27,34 @@
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
class NoiseBarMenuItem : public BMenuItem {
|
||||
|
||||
public:
|
||||
NoiseBarMenuItem();
|
||||
|
||||
virtual void DrawContent();
|
||||
virtual void GetContentSize(float* width, float* height);
|
||||
|
||||
void DrawBar(bool force);
|
||||
double fBusyWaiting;
|
||||
double fLost;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
@@ -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,7 +229,7 @@ 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;
|
||||
@@ -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,7 +254,7 @@ 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;
|
||||
@@ -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,20 +21,19 @@
|
||||
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 {
|
||||
|
||||
class Preferences : 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 ();
|
||||
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);
|
||||
@@ -49,6 +48,8 @@ public:
|
||||
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;
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
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;
|
||||
|
||||
@@ -173,8 +173,11 @@ TeamBarMenu::Pulse()
|
||||
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"
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
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,8 +242,10 @@ 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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -62,8 +62,10 @@ ThreadBarMenuItem::DrawBar(bool force)
|
||||
frame.bottom = frame.top + 8;
|
||||
if (fKernel < 0)
|
||||
return;
|
||||
|
||||
if (fGrenze1 < 0)
|
||||
force = true;
|
||||
|
||||
if (force) {
|
||||
if (selected)
|
||||
menu->SetHighColor(gFrameColorSelected);
|
||||
@@ -71,6 +73,7 @@ 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;
|
||||
@@ -80,8 +83,10 @@ ThreadBarMenuItem::DrawBar(bool force)
|
||||
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) {
|
||||
@@ -167,4 +173,3 @@ ThreadBarMenuItem::BarUpdate()
|
||||
} else
|
||||
fKernel = -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user