Styling from GCI task

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39766 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2010-12-08 17:40:29 +00:00
parent fefd3ba588
commit cdd9fd4da1
2 changed files with 285 additions and 263 deletions
+49 -38
View File
@@ -1,3 +1,9 @@
/*
* Copyright BeNet Team (Original Project)
* Copyright 2010 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* Copyright 2010 Dan-Matei Epure, [email protected]
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _Output_h #ifndef _Output_h
#include "Output.h" #include "Output.h"
#endif #endif
@@ -12,22 +18,25 @@
#endif #endif
*/ */
/****************************************************************/
/* OutputView */
/****************************************************************/
OutputView::OutputView(BRect frame) : OutputView::OutputView(BRect frame)
:
BView(frame, "OutputView", B_FOLLOW_ALL, B_WILL_DRAW) BView(frame, "OutputView", B_FOLLOW_ALL, B_WILL_DRAW)
{ {
SetViewColor(216, 216, 216); SetViewColor(216, 216, 216);
rgb_color color = {255, 255, 255}; rgb_color color = {255, 255, 255};
BRect b = Bounds(); BRect b = Bounds();
AddChild(m_pTextView = new BTextView(BRect(b.left+5,b.top+5,b.right-B_V_SCROLL_BAR_WIDTH-6,b.bottom-5), "Output", BRect(b.left+5,b.top+5,b.right-B_V_SCROLL_BAR_WIDTH-6,b.bottom-5), NULL, &color, B_FOLLOW_ALL_SIDES, B_WILL_DRAW)); AddChild(fTextView = new BTextView(BRect(b.left + 5, b.top + 5, b.right -
m_pTextView->SetViewColor(0,0,100); B_V_SCROLL_BAR_WIDTH - 6, b.bottom - 5), "Output", BRect(b.left + 5,
m_pTextView->MakeEditable(false); b.top + 5, b.right - B_V_SCROLL_BAR_WIDTH - 6, b.bottom - 5), NULL,
&color, B_FOLLOW_ALL_SIDES, B_WILL_DRAW));
fTextView->SetViewColor(0, 0, 100);
fTextView->MakeEditable(false);
AddChild(m_pScrollBar = new BScrollBar(BRect(b.right-B_V_SCROLL_BAR_WIDTH-5,b.top+5,b.right-5, b.bottom-5), "outputScroll", m_pTextView, 0, 0, B_VERTICAL)); AddChild(fScrollBar = new BScrollBar(BRect(b.right - B_V_SCROLL_BAR_WIDTH - 5,
b.top + 5, b.right - 5, b.bottom - 5),
"outputScroll", fTextView, 0, 0, B_VERTICAL));
} }
@@ -35,18 +44,15 @@ void
OutputView::FrameResized(float width, float height) OutputView::FrameResized(float width, float height)
{ {
BView::FrameResized(width, height); BView::FrameResized(width, height);
m_pTextView->SetTextRect(BRect(0,0,width,height)); fTextView->SetTextRect(BRect(0, 0, width, height));
} }
/****************************************************************/
/* Output */
/****************************************************************/
// Singleton implementation // Singleton implementation
Output* Output::m_instance = 0; Output* Output::sInstance = 0;
Output::Output() : Output::Output()
:
BWindow(BRect(200, 200, 800, 800), "Output", B_TITLED_WINDOW, B_NOT_ZOOMABLE) BWindow(BRect(200, 200, 800, 800), "Output", B_TITLED_WINDOW, B_NOT_ZOOMABLE)
{ {
BRect b = Bounds(); BRect b = Bounds();
@@ -54,20 +60,25 @@ Output::Output() :
fTabsList = new BList(20); fTabsList = new BList(20);
fOutputViewsList = new BList(20); fOutputViewsList = new BList(20);
BView* resetView = new BView(BRect(b.left,b.bottom-25,b.right,b.bottom), "resetView", B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT , B_WILL_DRAW); BView* resetView = new BView(BRect(b.left, b.bottom - 25, b.right, b.bottom),
"resetView", B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
resetView->SetViewColor(216, 216, 216); resetView->SetViewColor(216, 216, 216);
resetView->AddChild(m_pReset = new BButton(BRect(1,1,61,20), "reset all", "Clear", new BMessage(MSG_OUTPUT_RESET), B_FOLLOW_BOTTOM)); resetView->AddChild(fReset = new BButton(BRect(1, 1, 61, 20), "reset all",
resetView->AddChild(m_pResetAll = new BButton(BRect(70,1,130,20), "reset", "Clear all", new BMessage(MSG_OUTPUT_RESET_ALL), B_FOLLOW_BOTTOM)); "Clear", new BMessage(kMsgOutputReset), B_FOLLOW_BOTTOM));
resetView->AddChild(fResetAll = new BButton(BRect(70, 1, 130, 20), "reset",
"Clear all", new BMessage(kMsgOutputResetAll), B_FOLLOW_BOTTOM));
AddChild(resetView); AddChild(resetView);
fTabView = new BTabView(BRect(b.left,b.top,b.right,b.bottom-25), "tab_view", B_WIDTH_FROM_LABEL ,B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_NAVIGABLE_JUMP ); fTabView = new BTabView(BRect(b.left, b.top, b.right, b.bottom - 25), "tab_view",
B_WIDTH_FROM_LABEL ,B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW
| B_NAVIGABLE_JUMP );
fTabView->SetViewColor(216, 216, 216); fTabView->SetViewColor(216, 216, 216);
fBounds = fTabView->Bounds(); fBounds = fTabView->Bounds();
fBounds.bottom -= fTabView->TabHeight(); fBounds.bottom -= fTabView->TabHeight();
fTabView->AddTab(m_pAll = new OutputView(fBounds), m_pAllTab = new BTab()); fTabView->AddTab(fAll = new OutputView(fBounds), fAllTab = new BTab());
m_pAllTab->SetLabel("All"); fAllTab->SetLabel("All");
AddChild(fTabView); AddChild(fTabView);
/* /*
@@ -76,6 +87,7 @@ Output::Output() :
*/ */
} }
void void
Output::AddTab(const char* text, int32 index) Output::AddTab(const char* text, int32 index)
{ {
@@ -83,16 +95,17 @@ Output::AddTab(const char* text, int32 index)
BTab* customTab; BTab* customTab;
Lock(); Lock();
fTabView->AddTab(customOutput = new OutputView(fBounds), customTab = new BTab()); fTabView->AddTab(customOutput = new OutputView(fBounds), customTab =
new BTab());
customTab->SetLabel(text); customTab->SetLabel(text);
fTabView->Invalidate(); fTabView->Invalidate();
Unlock(); Unlock();
fTabsList->AddItem(customTab, index); fTabsList->AddItem(customTab, index);
fOutputViewsList->AddItem(customOutput, index); fOutputViewsList->AddItem(customOutput, index);
} }
Output::~Output() Output::~Output()
{ {
/* BWindow::~BWindow();*/ /* BWindow::~BWindow();*/
@@ -105,9 +118,9 @@ Output::~Output()
Output* Output*
Output::Instance() Output::Instance()
{ {
if (!m_instance) if (!sInstance)
m_instance = new Output; sInstance = new Output;
return m_instance; return sInstance;
} }
@@ -122,25 +135,23 @@ Output::QuitRequested()
void void
Output::MessageReceived(BMessage* msg) Output::MessageReceived(BMessage* msg)
{ {
switch(msg->what) switch(msg->what) {
{ case kMsgOutputReset:
case MSG_OUTPUT_RESET:
for (int32 index = 0; index<fTabsList->CountItems(); index++) { for (int32 index = 0; index<fTabsList->CountItems(); index++) {
if (fTabsList->ItemAt(index) != NULL && ((BTab*)fTabsList->ItemAt(index))->IsSelected() ) if (fTabsList->ItemAt(index) != NULL && ((BTab*)fTabsList
->ItemAt(index))->IsSelected())
((OutputView*)fOutputViewsList->ItemAt(index))->Clear(); ((OutputView*)fOutputViewsList->ItemAt(index))->Clear();
} }
break; break;
case MSG_OUTPUT_RESET_ALL: case kMsgOutputResetAll:
m_pAll->Clear(); {
fAll->Clear();
for (int32 index = 0; index<fTabsList->CountItems(); index++) { for (int32 index = 0; index<fTabsList->CountItems(); index++) {
if (fTabsList->ItemAt(index) != NULL ) if (fTabsList->ItemAt(index) != NULL )
((OutputView*)fOutputViewsList->ItemAt(index))->Clear(); ((OutputView*)fOutputViewsList->ItemAt(index))->Clear();
} }
break; break;
}
default: default:
BWindow::MessageReceived(msg); BWindow::MessageReceived(msg);
break; break;
@@ -185,7 +196,7 @@ Output::Post(const char* text, uint32 index)
else else
// Note that the view should be added before this! // Note that the view should be added before this!
// Dropping twice to the main // Dropping twice to the main
Add(text, m_pAll ); Add(text, fAll);
Unlock(); Unlock();
} }
@@ -195,5 +206,5 @@ void
Output::Add(const char* text, OutputView* view) Output::Add(const char* text, OutputView* view)
{ {
view->Add(text); view->Add(text);
m_pAll->Add(text); fAll->Add(text);
} }
+26 -15
View File
@@ -1,3 +1,9 @@
/*
* Copyright 2010 Oliver Ruiz Dorantes
* Copyright 2010 Dan-Matei Epure, [email protected]
* Copyright BeNet Team (Original Project)
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _Output_h #ifndef _Output_h
#define _Output_h #define _Output_h
@@ -7,8 +13,9 @@
#include <Button.h> #include <Button.h>
#include <TabView.h> #include <TabView.h>
const uint32 MSG_OUTPUT_RESET = 'outr'; const uint32 kMsgOutputReset = 'outr';
const uint32 MSG_OUTPUT_RESET_ALL = 'opra'; const uint32 kMsgOutputResetAll = 'opra';
class OutputView : public BView class OutputView : public BView
{ {
@@ -16,21 +23,22 @@ public:
OutputView(BRect frame); OutputView(BRect frame);
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
void Add(const char* text) {m_pTextView->Insert(text);} void Add(const char* text) {fTextView->Insert(text);}
void Clear() {m_pTextView->Delete(0,m_pTextView->TextLength());} void Clear() {fTextView->Delete(0, fTextView->TextLength());}
private: private:
BTextView* m_pTextView; BTextView* fTextView;
BScrollBar* m_pScrollBar; BScrollBar* fScrollBar;
}; };
class Output : public BWindow class Output : public BWindow
{ {
public: public:
static Output* Instance(); static Output* Instance();
~Output(); ~Output();
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);
virtual void FrameMoved(BPoint point); virtual void FrameMoved(BPoint point);
@@ -40,24 +48,27 @@ public:
void Post(const char* text, uint32 index); void Post(const char* text, uint32 index);
int Postf(uint32 index, const char* format, ...); int Postf(uint32 index, const char* format, ...);
private: // functions private:
// functions
Output(); Output();
void Add(const char* text, OutputView* view); void Add(const char* text, OutputView* view);
private: // data private:
static Output* m_instance; // data
BTab* m_pAllTab; static Output* sInstance;
BTab* fAllTab;
OutputView* m_pAll; OutputView* fAll;
BButton* m_pReset; BButton* fReset;
BButton* m_pResetAll; BButton* fResetAll;
BTabView* fTabView; BTabView* fTabView;
BList* fTabsList; BList* fTabsList;
BList* fOutputViewsList; BList* fOutputViewsList;
BRect fBounds; // Bounds for tabs BRect fBounds;
// Bounds for tabs
}; };