- The CPU clock speed string was assumed to be shorter than processor name string.
The best font size for speed is now dynamically computed to fit too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16933 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -112,7 +112,7 @@ NormalPulseView::~NormalPulseView()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NormalPulseView::CalculateFontSize()
|
NormalPulseView::CalculateFontSizes()
|
||||||
{
|
{
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
@@ -201,20 +201,26 @@ NormalPulseView::Draw(BRect rect)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Draw processor type and speed
|
// Draw processor type and speed
|
||||||
|
SetDrawingMode(B_OP_OVER);
|
||||||
|
SetHighColor(240, 240, 240);
|
||||||
|
|
||||||
|
SetFontSize(fProcessorFontSize);
|
||||||
|
float width = StringWidth(fProcessor);
|
||||||
|
MovePenTo(10 + (32 - width / 2), 48);
|
||||||
|
DrawString(fProcessor);
|
||||||
|
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
int32 cpuSpeed = get_rounded_cpu_speed();
|
int32 cpuSpeed = get_rounded_cpu_speed();
|
||||||
if (cpuSpeed > 1000 && (cpuSpeed % 10) == 0)
|
if (cpuSpeed > 1000 && (cpuSpeed % 10) == 0)
|
||||||
snprintf(buffer, sizeof(buffer), "%.2f GHz", cpuSpeed / 1000.0f);
|
snprintf(buffer, sizeof(buffer), "%.2f GHz", cpuSpeed / 1000.0f);
|
||||||
else
|
else
|
||||||
snprintf(buffer, sizeof(buffer), "%ld MHz", cpuSpeed);
|
snprintf(buffer, sizeof(buffer), "%ld MHz", cpuSpeed);
|
||||||
SetDrawingMode(B_OP_OVER);
|
|
||||||
SetHighColor(240, 240, 240);
|
|
||||||
SetFontSize(fProcessorFontSize);
|
|
||||||
|
|
||||||
float width = StringWidth(fProcessor);
|
|
||||||
MovePenTo(10 + (32 - width / 2), 48);
|
|
||||||
DrawString(fProcessor);
|
|
||||||
|
|
||||||
|
// We can't assume anymore that a CPU clock speed is always static.
|
||||||
|
// Let's compute the best font size for the CPU speed string each time...
|
||||||
|
BFont font;
|
||||||
|
GetFont(&font);
|
||||||
|
SetFontSize(max_font_size(font, buffer, 11.0f, 46.0f));
|
||||||
width = StringWidth(buffer);
|
width = StringWidth(buffer);
|
||||||
MovePenTo(10 + (32 - width / 2), 60);
|
MovePenTo(10 + (32 - width / 2), 60);
|
||||||
DrawString(buffer);
|
DrawString(buffer);
|
||||||
@@ -246,7 +252,7 @@ void
|
|||||||
NormalPulseView::AttachedToWindow()
|
NormalPulseView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
SetFont(be_bold_font);
|
SetFont(be_bold_font);
|
||||||
CalculateFontSize();
|
CalculateFontSizes();
|
||||||
|
|
||||||
fPreviousTime = system_time();
|
fPreviousTime = system_time();
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class NormalPulseView : public PulseView {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void DetermineVendorAndProcessor();
|
void DetermineVendorAndProcessor();
|
||||||
void CalculateFontSize();
|
void CalculateFontSizes();
|
||||||
|
|
||||||
char fVendor[32], fProcessor[32];
|
char fVendor[32], fProcessor[32];
|
||||||
bigtime_t fPreviousTime;
|
bigtime_t fPreviousTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user