Codestyle fixes, patch created by Freemann2430 during GCI2012
This commit is contained in:
parent
101006a459
commit
6572adb23b
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,45 +35,67 @@ public:
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,9 +19,7 @@ class ActionDownload;
|
||||||
class DownloadManager
|
class DownloadManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum QueueType {
|
enum QueueType {DOWNLOADS_QUEUE = 0};
|
||||||
DOWNLOADS_QUEUE = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
DownloadManager(BLooper* target);
|
DownloadManager(BLooper* target);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
Action* CurrentAction(int index);
|
Action* CurrentAction(int index);
|
||||||
|
|
||||||
int32 CountActions();
|
int32 CountActions();
|
||||||
|
|
||||||
|
|
||||||
int CountThreads() {
|
int CountThreads() {
|
||||||
return fCount;
|
return fCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,9 +164,11 @@ 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();
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,16 @@
|
||||||
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),
|
:
|
||||||
|
BMenuItem(label,msg,shortcut,modifiers),
|
||||||
fBitmap(bitmap)
|
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,6 +75,7 @@ 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()) {
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
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,
|
||||||
|
|
|
@ -11,8 +11,8 @@ 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();
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -24,8 +24,8 @@ public:
|
||||||
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:
|
||||||
|
|
|
@ -28,8 +28,8 @@ 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),
|
||||||
|
@ -42,7 +42,8 @@ ToolButton::ToolButton(const char* name, const char* label, BMessage* message,
|
||||||
|
|
||||||
|
|
||||||
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),
|
||||||
|
@ -53,7 +54,8 @@ ToolButton::ToolButton(const char* label, BMessage* message)
|
||||||
|
|
||||||
|
|
||||||
ToolButton::ToolButton(BMessage* archive)
|
ToolButton::ToolButton(BMessage* archive)
|
||||||
: BControl(archive),
|
:
|
||||||
|
BControl(archive),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fMenu(NULL),
|
fMenu(NULL),
|
||||||
fPreferredSize(-1, -1)
|
fPreferredSize(-1, -1)
|
||||||
|
|
Ŝarĝante…
Reference in New Issue