2008-03-03 22:52:07 +00:00
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Interface [StatusView.cpp]
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef STATUS_VIEW_H
|
|
|
|
#include "StatusView.h"
|
|
|
|
#endif
|
|
|
|
|
2009-11-22 12:26:19 +00:00
|
|
|
#include <ScrollView.h>
|
2021-05-21 19:20:33 +00:00
|
|
|
#include <ControlLook.h>
|
2009-11-22 12:26:19 +00:00
|
|
|
|
2008-03-03 22:52:07 +00:00
|
|
|
StatusView::StatusView(const char *name)
|
2019-06-02 09:03:17 +00:00
|
|
|
: BView(name, B_WILL_DRAW) {
|
2008-03-03 22:52:07 +00:00
|
|
|
SetFont(be_plain_font);
|
2021-05-21 19:20:33 +00:00
|
|
|
|
|
|
|
float viewSize = be_control_look->GetScrollBarWidth();
|
|
|
|
float fontSize = 9.0f;
|
|
|
|
|
|
|
|
// calculate a font Size that fits into the alocated space
|
|
|
|
while (fontSize < 48) {
|
|
|
|
SetFontSize(fontSize + 1);
|
|
|
|
GetFontHeight(&_fh);
|
|
|
|
_height = _fh.ascent + _fh.descent + 1.0f;
|
|
|
|
if (_height < viewSize) {
|
|
|
|
fontSize = fontSize +1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (_height > viewSize) {
|
|
|
|
SetFontSize(fontSize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (_height == viewSize)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetExplicitSize(BSize(B_SIZE_UNSET, viewSize));
|
|
|
|
SetExplicitMinSize(BSize(B_SIZE_UNSET, viewSize));
|
2008-03-03 22:52:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 18:22:34 +00:00
|
|
|
StatusView::~StatusView() {
|
|
|
|
}
|
2008-03-03 22:52:07 +00:00
|
|
|
|
2019-06-06 18:22:34 +00:00
|
|
|
void StatusView::AttachedToWindow() {
|
|
|
|
}
|
2008-03-03 22:52:07 +00:00
|
|
|
|
2019-06-06 18:22:34 +00:00
|
|
|
void StatusView::Draw(__attribute__((unused)) BRect rect) {
|
2008-03-03 22:52:07 +00:00
|
|
|
// draw name
|
2021-05-21 19:20:33 +00:00
|
|
|
SetHighUIColor(B_PANEL_TEXT_COLOR);
|
|
|
|
DrawString(_current_message.c_str(), BPoint(5, _height -(_fh.descent + 1)));
|
2008-03-03 22:52:07 +00:00
|
|
|
}
|
2008-04-07 19:32:07 +00:00
|
|
|
|
|
|
|
void StatusView::SetMessage(std::string message) {
|
2008-03-03 22:52:07 +00:00
|
|
|
_current_message = message;
|
2008-04-07 19:32:07 +00:00
|
|
|
|
2008-03-03 22:52:07 +00:00
|
|
|
// redraw self
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2008-04-07 19:32:07 +00:00
|
|
|
const std::string StatusView::Message() const {
|
2008-03-03 22:52:07 +00:00
|
|
|
return _current_message;
|
|
|
|
}
|
|
|
|
|
2019-06-04 17:35:35 +00:00
|
|
|
float StatusView::GetHeight() const {
|
2008-03-03 22:52:07 +00:00
|
|
|
return _height;
|
|
|
|
}
|