Codestyle fixes, patch created by Freemann2430 during GCI2012

This commit is contained in:
barrett 2013-01-04 13:52:14 +00:00
parent 101006a459
commit 6572adb23b
18 changed files with 237 additions and 138 deletions

View File

@ -13,14 +13,14 @@
class Action class Action
{ {
public: public:
Action() { fActionID = 0; } Action() { fActionID = 0; }
virtual ~Action() {} virtual ~Action() {}
virtual status_t Perform(BMessage* errors) = 0; virtual status_t Perform(BMessage* errors) = 0;
virtual BString GetDescription() = 0; virtual BString GetDescription() = 0;
void SetActionID(const ActionID id) { fActionID = id; } void SetActionID(const ActionID id) { fActionID = id; }
ActionID GetActionID() const { return fActionID; } ActionID GetActionID() const { return fActionID; }
private: private:
ActionID fActionID; ActionID fActionID;

View File

@ -170,18 +170,21 @@ ActionDownload::Perform(BMessage* errors)
return status; return status;
} }
BString BString
ActionDownload::GetDescription() ActionDownload::GetDescription()
{ {
return "HTTP File download"; return "HTTP File download";
} }
BString BString
ActionDownload::GetLocalPath() ActionDownload::GetLocalPath()
{ {
return BPath(&fDest).Path(); return BPath(&fDest).Path();
} }
void void
ActionDownload::fillMessage(ActionDownload* ad, BMessage* msg) ActionDownload::fillMessage(ActionDownload* ad, BMessage* msg)
{ {
@ -196,7 +199,6 @@ ActionDownload::fillMessage(ActionDownload* ad, BMessage* msg)
} }
void void
ActionDownload::sendProgressX(ActionDownload* ad, double max, double current) ActionDownload::sendProgressX(ActionDownload* ad, double max, double current)
{ {
@ -253,6 +255,7 @@ ActionDownload::sendError(BLooper* looper,uint32 amsg,Status st,BString descr){
*/ */
// //
int int
ActionDownload::callback(void* data, ActionDownload::callback(void* data,
double dltotal, double dltotal,
@ -267,6 +270,7 @@ ActionDownload::callback(void* data,
return 0; return 0;
} }
size_t size_t
ActionDownload::save_file( void* ptr, size_t size, size_t nmemb, void* data) ActionDownload::save_file( void* ptr, size_t size, size_t nmemb, void* data)
{ {
@ -280,6 +284,7 @@ ActionDownload::save_file( void* ptr, size_t size, size_t nmemb, void* data)
} }
} }
BFile* file = ad->file; BFile* file = ad->file;
if (ad->ShouldStop()) return 0; if (ad->ShouldStop())
return 0;
return file->Write(ptr, size * nmemb); return file->Write(ptr, size * nmemb);
} }

View File

@ -27,55 +27,77 @@ public:
OK_DOWNLOADED // 5 OK_DOWNLOADED // 5
}; };
ActionDownload(BString URL, entry_ref dest, ActionDownload(BString URL, entry_ref dest,
bool allowResume, BLooper* target = NULL, uint32 msg = 0); bool allowResume, BLooper* target = NULL, uint32 msg = 0);
virtual ~ActionDownload(); virtual ~ActionDownload();
status_t Perform(BMessage* errors); status_t Perform(BMessage* errors);
BString GetDescription(); BString GetDescription();
BString GetLocalPath(); BString GetLocalPath();
void SetLooper(BLooper* loop, uint32 msg) { void
SetLooper(BLooper* loop, uint32 msg)
{
fTarget = loop; fTarget = loop;
fMsg = msg; fMsg = msg;
}; };
BLooper* Looper() {
BLooper*
Looper()
{
return fTarget; return fTarget;
} }
uint32 MessageWhat() {
uint32
MessageWhat()
{
return fMsg; return fMsg;
} }
// For compatibility: // For compatibility:
void SetExtraData(BString extra) { void
SetExtraData(BString extra)
{
extraInfo.AddString("extra", extra); extraInfo.AddString("extra", extra);
} }
void SetKey(BString key, BString data) { void
SetKey(BString key, BString data)
{
extraInfo.AddString(key.String(), data); extraInfo.AddString(key.String(), data);
} }
void SetRef(BString key, entry_ref* ref) { void
SetRef(BString key, entry_ref* ref)
{
extraInfo.AddRef(key.String(), ref); extraInfo.AddRef(key.String(), ref);
} }
status_t GetRef(BString key, entry_ref* ref) { status_t
GetRef(BString key, entry_ref* ref)
{
return extraInfo.FindRef(key.String(), ref); return extraInfo.FindRef(key.String(), ref);
} }
BString GetKey(BString key) { BString GetKey(BString key)
{
BString data; BString data;
extraInfo.FindString(key.String(), &data); extraInfo.FindString(key.String(), &data);
return data; return data;
} }
void SetShouldStop(bool stop) { void
SetShouldStop(bool stop)
{
fShouldStop = stop; fShouldStop = stop;
} }
bool ShouldStop() {
bool
ShouldStop()
{
return fShouldStop; return fShouldStop;
} }
void SetDownloadManager(DownloadManager* downloadManager); void SetDownloadManager(DownloadManager* downloadManager);
@ -87,7 +109,8 @@ private:
//curl callbacks: //curl callbacks:
static size_t save_file ( void* ptr, size_t size, size_t nmemb, void* stream); static size_t save_file ( void* ptr, size_t size, size_t nmemb, void* stream);
static int callback (void* clientp, double dltotal, double dlnow, double , double); static int callback (void* clientp, double dltotal,
double dlnow, double , double);
CURL* curl; CURL* curl;
BString fUrl; BString fUrl;

View File

@ -13,20 +13,25 @@
#define DEFAULT_ITEMS_DOWNLOAD 1 #define DEFAULT_ITEMS_DOWNLOAD 1
DownloadManager::DownloadManager(BLooper* target): fTarget(target) DownloadManager::DownloadManager(BLooper* target)
:
fTarget(target)
{ {
} }
void void
DownloadManager::Enqueue(QueueType type, ActionDownload* ad) DownloadManager::Enqueue(QueueType type, ActionDownload* ad)
{ {
if (!fQueue[type]) { if (!fQueue[type]) {
fQueue[type] = new QueueFileDownload("queue_downloads", DEFAULT_ITEMS_DOWNLOAD, fTarget, DOWNLOAD_INFO); fQueue[type] = new QueueFileDownload("queue_downloads",
DEFAULT_ITEMS_DOWNLOAD, fTarget, DOWNLOAD_INFO);
} }
ad->SetDownloadManager(this); ad->SetDownloadManager(this);
fQueue[type]->AddAction(ad); fQueue[type]->AddAction(ad);
} }
void void
DownloadManager::TryStopCurrentAction(QueueType type, BString key, BString value) DownloadManager::TryStopCurrentAction(QueueType type, BString key, BString value)
{ {
@ -46,6 +51,7 @@ DownloadManager::TryStopCurrentAction(QueueType type, BString key, BString value
} }
} }
bool bool
DownloadManager::RemoveFromQueue(QueueType type , BString key, BString value) DownloadManager::RemoveFromQueue(QueueType type , BString key, BString value)
{ {
@ -78,6 +84,7 @@ DownloadManager::RemoveFromQueue(QueueType type , BString key, BString value)
return false; return false;
} }
void void
DownloadManager::RemoveQueue(QueueType type, BList* removed) DownloadManager::RemoveQueue(QueueType type, BList* removed)
{ {
@ -103,6 +110,7 @@ DownloadManager::RemoveQueue(QueueType type, BList* removed)
} }
} }
void void
DownloadManager::LoadProxySetting(BMessage* data) DownloadManager::LoadProxySetting(BMessage* data)
{ {
@ -158,6 +166,7 @@ DownloadManager::FinishCurl(CURL* curl)
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD , fUserpwd.String() ); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD , fUserpwd.String() );
} }
thread_id thread_id
DownloadManager::SingleThreadAction(ActionDownload* action) DownloadManager::SingleThreadAction(ActionDownload* action)
{ {
@ -165,11 +174,13 @@ DownloadManager::SingleThreadAction(ActionDownload* action)
if (action->Looper() == NULL) { if (action->Looper() == NULL) {
action->SetLooper(fTarget, DOWNLOAD_INFO); action->SetLooper(fTarget, DOWNLOAD_INFO);
} }
thread_id id = spawn_thread(DownloadManager::SingleThreadPerform, "single_action_thread", B_NORMAL_PRIORITY, (void*)action); thread_id id = spawn_thread(DownloadManager::SingleThreadPerform,
"single_action_thread", B_NORMAL_PRIORITY, (void*)action);
resume_thread(id); resume_thread(id);
return id; return id;
} }
int32 int32
DownloadManager::SingleThreadPerform(void* a) DownloadManager::SingleThreadPerform(void* a)
{ {

View File

@ -19,11 +19,9 @@ class ActionDownload;
class DownloadManager class DownloadManager
{ {
public: public:
enum QueueType { enum QueueType {DOWNLOADS_QUEUE = 0};
DOWNLOADS_QUEUE = 0
};
DownloadManager(BLooper* target); DownloadManager(BLooper* target);
void Enqueue(QueueType, ActionDownload*); void Enqueue(QueueType, ActionDownload*);

View File

@ -14,18 +14,21 @@ void
QueueFileDownload::ActionReadyToPerform(Action* action) QueueFileDownload::ActionReadyToPerform(Action* action)
{ {
ActionDownload* ad = dynamic_cast<ActionDownload*>(action); ActionDownload* ad = dynamic_cast<ActionDownload*>(action);
if (!ad) return; if (!ad)
return;
ad->SetLooper(fLooper, fMsg); ad->SetLooper(fLooper, fMsg);
} }
void void
QueueFileDownload::ActionPerformed(Action* action, status_t state, BMessage* msg) QueueFileDownload::ActionPerformed(Action* action, status_t state, BMessage* msg)
{ {
ActionDownload* ad = dynamic_cast<ActionDownload*>(action); ActionDownload* ad = dynamic_cast<ActionDownload*>(action);
if (!ad) return; if (!ad)
return;
BMessage notify(*msg); BMessage notify(*msg);
notify.what = fMsg; notify.what = fMsg;
@ -36,11 +39,13 @@ QueueFileDownload::ActionPerformed(Action* action, status_t state, BMessage* msg
return; return;
} }
void void
QueueFileDownload::SuppressAction(Action* action) QueueFileDownload::SuppressAction(Action* action)
{ {
ActionDownload* ad = dynamic_cast<ActionDownload*>(action); ActionDownload* ad = dynamic_cast<ActionDownload*>(action);
if (!ad) return; if (!ad)
return;
ad->SetShouldStop(true); ad->SetShouldStop(true);
} }

View File

@ -69,6 +69,7 @@ QueueMultiActions::Lock()
return (value == B_NO_ERROR); return (value == B_NO_ERROR);
} }
void void
QueueMultiActions::Unlock() QueueMultiActions::Unlock()
{ {
@ -76,6 +77,7 @@ QueueMultiActions::Unlock()
release_sem(fLock); release_sem(fLock);
} }
void void
QueueMultiActions::SetDownloadCount(int fProposedCount) QueueMultiActions::SetDownloadCount(int fProposedCount)
{ {
@ -138,6 +140,7 @@ QueueMultiActions::AddAction(Action* a)
} }
} }
Action* Action*
QueueMultiActions::CurrentAction(int index) QueueMultiActions::CurrentAction(int index)
{ {
@ -145,6 +148,7 @@ QueueMultiActions::CurrentAction(int index)
return fCurrentAction[index]; return fCurrentAction[index];
} }
void void
QueueMultiActions::SetCurrentAction(Action* action, int index) QueueMultiActions::SetCurrentAction(Action* action, int index)
{ {
@ -152,6 +156,7 @@ QueueMultiActions::SetCurrentAction(Action* action, int index)
fCurrentAction[index] = action; fCurrentAction[index] = action;
} }
int32 int32
QueueMultiActions::CountActions() QueueMultiActions::CountActions()
{ {
@ -159,6 +164,7 @@ QueueMultiActions::CountActions()
return fList.CountItems(); return fList.CountItems();
} }
Action* Action*
QueueMultiActions::ActionAt(int32 pos) QueueMultiActions::ActionAt(int32 pos)
{ {
@ -166,6 +172,7 @@ QueueMultiActions::ActionAt(int32 pos)
return fList.ItemAt(pos); return fList.ItemAt(pos);
} }
void void
QueueMultiActions::RemoveActionAt(int32 pos) QueueMultiActions::RemoveActionAt(int32 pos)
{ {
@ -173,18 +180,21 @@ QueueMultiActions::RemoveActionAt(int32 pos)
fList.RemoveItemAt(pos); fList.RemoveItemAt(pos);
} }
bool bool
QueueMultiActions::IsLocked() QueueMultiActions::IsLocked()
{ {
return fLocked; return fLocked;
} }
void void
QueueMultiActions::KIllThread(int id) QueueMultiActions::KIllThread(int id)
{ {
fID[id] = 0; fID[id] = 0;
} }
int32 int32
QueueMultiActions::ManageTheQueue(void* data) QueueMultiActions::ManageTheQueue(void* data)
{ {

View File

@ -19,35 +19,37 @@ class QueueMultiActions
public: public:
QueueMultiActions(const char* name, int count); QueueMultiActions(const char* name, int count);
virtual ~QueueMultiActions(); virtual ~QueueMultiActions();
void AddAction(Action* ); void AddAction(Action* );
//BEFORE CALLING CurrentAction, you MUST Lock() the Queue! //BEFORE CALLING CurrentAction, you MUST Lock() the Queue!
Action* CurrentAction(int index); Action* CurrentAction(int index);
int32 CountActions(); int32 CountActions();
int CountThreads() {
int CountThreads() {
return fCount; return fCount;
} }
Action* ActionAt(int32 pos); Action* ActionAt(int32 pos);
void RemoveActionAt(int32 pos); void RemoveActionAt(int32 pos);
void SetDownloadCount(int count); void SetDownloadCount(int count);
bool Lock(); bool Lock();
void Unlock(); void Unlock();
bool IsLocked(); bool IsLocked();
protected: protected:
static int32 ManageTheQueue(void*); static int32 ManageTheQueue(void*);
virtual void ActionReadyToPerform(Action*) = 0; virtual void ActionReadyToPerform(Action*) = 0;
virtual void ActionPerformed(Action*, status_t, BMessage*) = 0; virtual void ActionPerformed(Action*, status_t, BMessage*) = 0;
virtual void SuppressAction(Action*) = 0; virtual void SuppressAction(Action*) = 0;

View File

@ -16,30 +16,45 @@ enum {
RTV_HIDE_TOOLTIP RTV_HIDE_TOOLTIP
}; };
ReflowingTextView::ReflowingTextView(BRect frame, const char* name, BRect textRect, uint32 resizeMask, uint32 flags) : BTextView(frame, name, textRect, resizeMask, flags), _showTipRunner(NULL), _canShow(false), _urlTip(NULL), _currentLinkStart(-1)
ReflowingTextView::ReflowingTextView(BRect frame, const char* name,
BRect textRect, uint32 resizeMask, uint32 flags)
:
BTextView(frame, name, textRect, resizeMask, flags),
_showTipRunner(NULL),
_canShow(false),
_urlTip(NULL),
_currentLinkStart(-1)
{ {
// empty // empty
} }
ReflowingTextView::~ReflowingTextView() ReflowingTextView::~ReflowingTextView()
{ {
if ((_urlTip) && (_urlTip->Lock())) _urlTip->Quit(); if ((_urlTip) && (_urlTip->Lock())) _urlTip->Quit();
delete _showTipRunner; delete _showTipRunner;
} }
void ReflowingTextView::AttachedToWindow()
void
ReflowingTextView::AttachedToWindow()
{ {
BTextView::AttachedToWindow(); BTextView::AttachedToWindow();
// FixTextRect(); // FixTextRect();
} }
void ReflowingTextView::FrameResized(float w, float h)
void
ReflowingTextView::FrameResized(float w, float h)
{ {
BTextView::FrameResized(w, h); BTextView::FrameResized(w, h);
// FixTextRect(); // FixTextRect();
} }
void ReflowingTextView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
void
ReflowingTextView::MouseMoved(BPoint where, uint32 code, const BMessage* msg)
{ {
const URLLink* link = NULL; const URLLink* link = NULL;
if (code == B_INSIDE_VIEW) { if (code == B_INSIDE_VIEW) {
@ -89,7 +104,9 @@ void ReflowingTextView::MouseMoved(BPoint where, uint32 code, const BMessage* ms
BTextView::MouseMoved(where, code, msg); BTextView::MouseMoved(where, code, msg);
} }
void ReflowingTextView::MessageReceived(BMessage* msg)
void
ReflowingTextView::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case RTV_SHOW_TOOLTIP: case RTV_SHOW_TOOLTIP:
@ -112,12 +129,18 @@ void ReflowingTextView::MessageReceived(BMessage* msg)
} }
} }
void ReflowingTextView::UpdateToolTip()
void
ReflowingTextView::UpdateToolTip()
{ {
if ((_canShow) && (_currentLinkStart >= 0)) { if ((_canShow) && (_currentLinkStart >= 0)) {
if (_urlTip == NULL) { if (_urlTip == NULL) {
_urlTip = new BWindow(BRect(0, 0, 5, 5), NULL, B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AVOID_FOCUS); _urlTip = new BWindow(BRect(0, 0, 5, 5), NULL,
BView* blackBorder = new BView(_urlTip->Bounds(), NULL, B_FOLLOW_ALL_SIDES, 0); B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE |
B_AVOID_FOCUS);
BView* blackBorder = new BView(_urlTip->Bounds(), NULL,
B_FOLLOW_ALL_SIDES, 0);
const rgb_color black = {0, 0, 0, 255}; const rgb_color black = {0, 0, 0, 255};
blackBorder->SetViewColor(black); blackBorder->SetViewColor(black);
_urlTip->AddChild(blackBorder); _urlTip->AddChild(blackBorder);
@ -130,7 +153,8 @@ void ReflowingTextView::UpdateToolTip()
yellowInterior->SetViewColor(hiliteYellow); yellowInterior->SetViewColor(hiliteYellow);
blackBorder->AddChild(yellowInterior); blackBorder->AddChild(yellowInterior);
_urlStringView = new BStringView(yellowInterior->Bounds(), NULL, "", B_FOLLOW_ALL_SIDES); _urlStringView = new BStringView(yellowInterior->Bounds(), NULL, "",
B_FOLLOW_ALL_SIDES);
_urlStringView->SetLowColor(hiliteYellow); _urlStringView->SetLowColor(hiliteYellow);
_urlStringView->SetViewColor(hiliteYellow); _urlStringView->SetViewColor(hiliteYellow);
yellowInterior->AddChild(_urlStringView); yellowInterior->AddChild(_urlStringView);
@ -140,13 +164,15 @@ void ReflowingTextView::UpdateToolTip()
_urlStringView->GetFontHeight(&ttfh); _urlStringView->GetFontHeight(&ttfh);
float urlHeight = 20.0f; float urlHeight = 20.0f;
BPoint pt = PointAt(_currentLinkStart, &urlHeight); BPoint pt = PointAt(_currentLinkStart, &urlHeight);
_urlTip->MoveTo(ConvertToScreen(pt) + BPoint(15.0f, -(ttfh.ascent + ttfh.descent + 3.0f))); _urlTip->MoveTo(ConvertToScreen(pt) + BPoint(15.0f,
-(ttfh.ascent + ttfh.descent + 3.0f)));
_urlTip->ResizeTo(muscleMin(_urlStringView->StringWidth(_currentURLString.String()) + 4.0f, 400.0f), ttfh.ascent + ttfh.descent + 2.0f); _urlTip->ResizeTo(muscleMin(_urlStringView->StringWidth(_currentURLString.String())
+ 4.0f, 400.0f), ttfh.ascent + ttfh.descent + 2.0f);
_urlStringView->SetText(_currentURLString.String()); _urlStringView->SetText(_currentURLString.String());
_urlTip->SetWorkspaces(B_CURRENT_WORKSPACE); _urlTip->SetWorkspaces(B_CURRENT_WORKSPACE);
if (_urlTip->IsHidden()) _urlTip->Show(); if (_urlTip->IsHidden()) _urlTip->Show();
_urlTip->Unlock(); _urlTip->Unlock();
} }
} else if (_urlTip) { } else if (_urlTip) {
if (_urlTip->Lock()) { if (_urlTip->Lock()) {
@ -156,9 +182,12 @@ void ReflowingTextView::UpdateToolTip()
} }
} }
void ReflowingTextView::MouseDown(BPoint where)
void
ReflowingTextView::MouseDown(BPoint where)
{ {
if (IsFocus() == false) MakeFocus(); if (IsFocus() == false)
MakeFocus();
const URLLink* url = GetURLAt(where); const URLLink* url = GetURLAt(where);
if (url) { if (url) {
char* allocBuf = NULL; char* allocBuf = NULL;
@ -197,36 +226,47 @@ void ReflowingTextView::MouseDown(BPoint where)
BTextView::MouseDown(where); BTextView::MouseDown(where);
} }
void ReflowingTextView::FixTextRect()
void
ReflowingTextView::FixTextRect()
{ {
BRect t(Frame()); BRect t(Frame());
SetTextRect(t); SetTextRect(t);
} }
void ReflowingTextView::Clear()
void
ReflowingTextView::Clear()
{ {
Delete(0, TextLength() - 1); Delete(0, TextLength() - 1);
_urls.Clear(); _urls.Clear();
} }
void ReflowingTextView::AddURLRegion(uint32 start, uint32 len, const BString& optHiddenURL)
void
ReflowingTextView::AddURLRegion(uint32 start, uint32 len, const BString& optHiddenURL)
{ {
_urls.AddTail(URLLink(start, len, optHiddenURL)); _urls.AddTail(URLLink(start, len, optHiddenURL));
} }
void ReflowingTextView::SetCommandURLTarget(const BMessenger& target, const BMessage& queryMsg, const BMessage& privMsg)
void
ReflowingTextView::SetCommandURLTarget(const BMessenger& target, const BMessage& queryMsg, const BMessage& privMsg)
{ {
_commandTarget = target; _commandTarget = target;
_queryMessage = queryMsg; _queryMessage = queryMsg;
_privMessage = privMsg; _privMessage = privMsg;
} }
const ReflowingTextView::URLLink* ReflowingTextView::GetURLAt(BPoint pt) const
const
ReflowingTextView::URLLink* ReflowingTextView::GetURLAt(BPoint pt) const
{ {
uint32 offset = (uint32) OffsetAt(pt); uint32 offset = (uint32) OffsetAt(pt);
for (int i = _urls.GetNumItems() - 1; i >= 0; i--) { for (int i = _urls.GetNumItems() - 1; i >= 0; i--) {
const URLLink& url = _urls[i]; const URLLink& url = _urls[i];
if ((offset >= url.GetStart()) && (offset < url.GetStart() + url.GetLength())) return &url; if ((offset >= url.GetStart()) && (offset < url.GetStart() + url.GetLength()))
return &url;
} }
return NULL; return NULL;
} }

View File

@ -7,16 +7,18 @@
#include <Bitmap.h> #include <Bitmap.h>
BitmapMenuItem::BitmapMenuItem(const char *label, BMessage *msg, BitmapMenuItem::BitmapMenuItem(const char *label, BMessage *msg,
BBitmap *bitmap, char shortcut, BBitmap *bitmap, char shortcut,
uint32 modifiers) uint32 modifiers)
: BMenuItem(label,msg,shortcut,modifiers), :
fBitmap(bitmap) BMenuItem(label,msg,shortcut,modifiers),
fBitmap(bitmap)
{ {
} }
BitmapMenuItem::BitmapMenuItem(BMessage *data) BitmapMenuItem::BitmapMenuItem(BMessage *data)
: BMenuItem(data) :
BMenuItem(data)
{ {
fBitmap = (BBitmap*) BBitmap::Instantiate(data); fBitmap = (BBitmap*) BBitmap::Instantiate(data);
} }
@ -73,12 +75,13 @@ BitmapMenuItem::DrawContent(void)
drawrect.bottom--; drawrect.bottom--;
drawrect.top++; drawrect.top++;
drawrect.left = ContentLocation().x; drawrect.left = ContentLocation().x;
if (fBitmap) { if (fBitmap) {
// Scale the fBitmap down to completely fit within the field's height // Scale the fBitmap down to completely fit within the field's height
if (fBitmap->Bounds().Height() > drawrect.Height()) { if (fBitmap->Bounds().Height() > drawrect.Height()) {
drawrect.right = drawrect.left + drawrect.right = drawrect.left +
(fBitmap->Bounds().Width() * (fBitmap->Bounds().Width() *
(Frame().Height() / fBitmap->Bounds().Height())); (Frame().Height() / fBitmap->Bounds().Height()));
} else { } else {
drawrect.right = drawrect.left + fBitmap->Bounds().Width(); drawrect.right = drawrect.left + fBitmap->Bounds().Width();
} }

View File

@ -16,25 +16,24 @@
BitmapMenuItems -- the bitmap does not obscure the checkmark. BitmapMenuItems -- the bitmap does not obscure the checkmark.
*/ */
class BitmapMenuItem : public BMenuItem class BitmapMenuItem : public BMenuItem {
{
public: public:
BitmapMenuItem(const char *label, BMessage *msg, BitmapMenuItem(const char *label, BMessage *msg,
BBitmap *bitmap, char shortcut = 0, BBitmap *bitmap, char shortcut = 0,
uint32 modifiers = 0); uint32 modifiers = 0);
BitmapMenuItem(BMessage *data); BitmapMenuItem(BMessage *data);
virtual ~BitmapMenuItem(void); virtual ~BitmapMenuItem(void);
virtual status_t Archive(BMessage *data, bool deep = true) const; virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void GetContentSize(float *width, float *height); virtual void GetContentSize(float *width, float *height);
virtual void DrawContent(void); virtual void DrawContent(void);
virtual void SetBitmap(BBitmap *bitmap); virtual void SetBitmap(BBitmap *bitmap);
BBitmap * Bitmap(void) const; BBitmap* Bitmap(void) const;
private: private:
BBitmap *fBitmap; BBitmap *fBitmap;
float fBaselineOffset; float fBaselineOffset;
}; };
#endif #endif

View File

@ -23,7 +23,7 @@ BBitmap*
ReadNodeIcon(const char* name, icon_size size, bool followSymlink) ReadNodeIcon(const char* name, icon_size size, bool followSymlink)
{ {
BEntry entry(name, followSymlink); BEntry entry(name, followSymlink);
entry_ref ref; entry_ref ref;
entry.GetRef(&ref); entry.GetRef(&ref);
@ -32,8 +32,8 @@ ReadNodeIcon(const char* name, icon_size size, bool followSymlink)
BBitmap* ret = new BBitmap(BRect(0, 0, (float)size - 1, (float)size - 1), B_RGBA32); BBitmap* ret = new BBitmap(BRect(0, 0, (float)size - 1, (float)size - 1), B_RGBA32);
if (BIconUtils::GetIcon(&node, BEOS_ICON_ATTRIBUTE, BEOS_MINI_ICON_ATTRIBUTE, if (BIconUtils::GetIcon(&node, BEOS_ICON_ATTRIBUTE, BEOS_MINI_ICON_ATTRIBUTE,
BEOS_LARGE_ICON_ATTRIBUTE, size, ret) != B_OK) { BEOS_LARGE_ICON_ATTRIBUTE, size, ret) != B_OK) {
delete ret; delete ret;
ret = NULL; ret = NULL;
} }
return ret; return ret;
@ -127,7 +127,7 @@ RescaleBitmap(const BBitmap* src, float width, float height)
for (int32 x = 0; x <= width; x++) for (int32 x = 0; x <= width; x++)
memcpy((void*)((uint32)dstRow + (x * bpp)), (void*)((uint32)srcRow memcpy((void*)((uint32)dstRow + (x * bpp)), (void*)((uint32)srcRow
+ ((uint32)(x * dx) * bpp)), bpp); + ((uint32)(x * dx) * bpp)), bpp);
} }
return res; return res;

View File

@ -11,29 +11,29 @@ class BBitmap;
class BitmapView : public BView { class BitmapView : public BView {
public: public:
BitmapView(const char* name = NULL, uint32 flags BitmapView(const char* name = NULL,
= B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
~BitmapView(); ~BitmapView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
status_t InitCheck(); status_t InitCheck();
BBitmap* Bitmap() const; BBitmap* Bitmap() const;
status_t SetBitmap(const char* filename); status_t SetBitmap(const char* filename);
status_t SetBitmap(const BBitmap* bitmap); status_t SetBitmap(const BBitmap* bitmap);
virtual BSize MinSize(); virtual BSize MinSize();
virtual BSize MaxSize(); virtual BSize MaxSize();
virtual BSize PreferredSize(); virtual BSize PreferredSize();
virtual void Draw(BRect frame); virtual void Draw(BRect frame);
private: private:
BBitmap* fBitmap; BBitmap* fBitmap;
float fWidth; float fWidth;
float fHeight; float fHeight;
}; };
#endif // _BITMAP_VIEW_H #endif // _BITMAP_VIEW_H

View File

@ -12,7 +12,8 @@ class BMessenger;
class Divider : public BView { class Divider : public BView {
public: public:
Divider(const char* name, uint32 flags = B_FRAME_EVENTS | B_WILL_DRAW); Divider(const char* name, uint32 flags =
B_FRAME_EVENTS | B_WILL_DRAW);
virtual ~Divider(); virtual ~Divider();
Divider(BMessage* archive); Divider(BMessage* archive);

View File

@ -23,7 +23,7 @@ NotifyingTextView::NotifyingTextView(const char* name, uint32 flags)
NotifyingTextView::~NotifyingTextView() NotifyingTextView::~NotifyingTextView()
{ {
if (fMessenger != NULL) if (fMessenger != NULL)
delete fMessenger; delete fMessenger;
} }
@ -51,8 +51,8 @@ NotifyingTextView::SetMessage(BMessage* msg)
void void
NotifyingTextView::InsertText(const char* text, int32 length, int32 offset, NotifyingTextView::InsertText(const char* text, int32 length,
const text_run_array* runs) int32 offset, const text_run_array* runs)
{ {
if ((fMessenger != NULL) && fMessenger->IsValid()) { if ((fMessenger != NULL) && fMessenger->IsValid()) {
BMessage msg(*fMessage); BMessage msg(*fMessage);

View File

@ -14,23 +14,23 @@ class BMessenger;
class NotifyingTextView : public BTextView { class NotifyingTextView : public BTextView {
public: public:
NotifyingTextView(const char* name, uint32 flags NotifyingTextView(const char* name, uint32 flags
= B_WILL_DRAW | B_PULSE_NEEDED); = B_WILL_DRAW | B_PULSE_NEEDED);
~NotifyingTextView(); ~NotifyingTextView();
void SetTarget(const BHandler* handler); void SetTarget(const BHandler* handler);
BMessage* Message() const; BMessage* Message() const;
void SetMessage(BMessage* msg); void SetMessage(BMessage* msg);
protected: protected:
virtual void InsertText(const char* text, int32 length, int32 offset, virtual void InsertText(const char* text, int32 length,
const text_run_array* runs = NULL); int32 offset, const text_run_array* runs = NULL);
virtual void DeleteText(int32 start, int32 finish); virtual void DeleteText(int32 start, int32 finish);
private: private:
BMessenger* fMessenger; BMessenger* fMessenger;
BMessage* fMessage; BMessage* fMessage;
}; };
#endif // _NOTIFYING_TEXT_VIEW_H #endif // _NOTIFYING_TEXT_VIEW_H

View File

@ -12,7 +12,7 @@ class BBitmap;
class PictureView : public BView { class PictureView : public BView {
public: public:
PictureView(const char* name, const char* filename, PictureView(const char* name, const char* filename,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
~PictureView(); ~PictureView();
status_t InitCheck(); status_t InitCheck();

View File

@ -28,35 +28,37 @@ const uint32 kToolbarIconSize = 16;
// this should go on BControlLook // this should go on BControlLook
ToolButton::ToolButton(const char* name, const char* label, BMessage* message, ToolButton::ToolButton(const char* name, const char* label,
uint32 flags) BMessage* message, uint32 flags)
: :
BControl(name, label, message, BControl(name, label, message,
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
fBitmap(NULL), fBitmap(NULL),
fMenu(NULL), fMenu(NULL),
fPreferredSize(-1, -1) fPreferredSize(-1, -1)
{ {
SetFontSize(be_plain_font->Size() * 0.85f); SetFontSize(be_plain_font->Size() * 0.85f);
} }
ToolButton::ToolButton(const char* label, BMessage* message) ToolButton::ToolButton(const char* label, BMessage* message)
: BControl(NULL, label, message, :
BControl(NULL, label, message,
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE), B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
fBitmap(NULL), fBitmap(NULL),
fMenu(NULL), fMenu(NULL),
fPreferredSize(-1, -1) fPreferredSize(-1, -1)
{ {
SetFontSize(be_plain_font->Size() * 0.85f); SetFontSize(be_plain_font->Size() * 0.85f);
} }
ToolButton::ToolButton(BMessage* archive) ToolButton::ToolButton(BMessage* archive)
: BControl(archive), :
fBitmap(NULL), BControl(archive),
fMenu(NULL), fBitmap(NULL),
fPreferredSize(-1, -1) fMenu(NULL),
fPreferredSize(-1, -1)
{ {
SetFontSize(be_plain_font->Size() * 0.85f); SetFontSize(be_plain_font->Size() * 0.85f);
} }