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
+210 -199
View File
@@ -1,199 +1,210 @@
#ifndef _Output_h /*
#include "Output.h" * Copyright BeNet Team (Original Project)
#endif * Copyright 2010 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
* Copyright 2010 Dan-Matei Epure, [email protected]
#include <Looper.h> * All rights reserved. Distributed under the terms of the MIT License.
#include <String.h> */
#include <stdio.h> #ifndef _Output_h
#include "Output.h"
/* #endif
#ifndef _Preferences_h
#include "Preferences.h" #include <Looper.h>
#endif #include <String.h>
*/ #include <stdio.h>
/****************************************************************/ /*
/* OutputView */ #ifndef _Preferences_h
/****************************************************************/ #include "Preferences.h"
#endif
OutputView::OutputView(BRect frame) : */
BView(frame, "OutputView", B_FOLLOW_ALL, B_WILL_DRAW)
{
SetViewColor(216,216,216); OutputView::OutputView(BRect frame)
rgb_color color = {255,255,255}; :
BView(frame, "OutputView", B_FOLLOW_ALL, B_WILL_DRAW)
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)); SetViewColor(216, 216, 216);
m_pTextView->SetViewColor(0,0,100); rgb_color color = {255, 255, 255};
m_pTextView->MakeEditable(false);
BRect b = Bounds();
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(fTextView = 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));
void fTextView->SetViewColor(0, 0, 100);
OutputView::FrameResized(float width, float height) fTextView->MakeEditable(false);
{
BView::FrameResized(width, height); AddChild(fScrollBar = new BScrollBar(BRect(b.right - B_V_SCROLL_BAR_WIDTH - 5,
m_pTextView->SetTextRect(BRect(0,0,width,height)); b.top + 5, b.right - 5, b.bottom - 5),
} "outputScroll", fTextView, 0, 0, B_VERTICAL));
}
/****************************************************************/
/* Output */ void
/****************************************************************/ OutputView::FrameResized(float width, float height)
{
// Singleton implementation BView::FrameResized(width, height);
Output* Output::m_instance = 0; fTextView->SetTextRect(BRect(0, 0, width, height));
}
Output::Output() :
BWindow(BRect(200,200,800,800), "Output", B_TITLED_WINDOW, B_NOT_ZOOMABLE)
{ // Singleton implementation
BRect b = Bounds(); Output* Output::sInstance = 0;
fTabsList = new BList(20); Output::Output()
fOutputViewsList = new BList(20); :
BWindow(BRect(200, 200, 800, 800), "Output", B_TITLED_WINDOW, B_NOT_ZOOMABLE)
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); BRect b = Bounds();
resetView->AddChild(m_pReset = new BButton(BRect(1,1,61,20), "reset all", "Clear", new BMessage(MSG_OUTPUT_RESET), B_FOLLOW_BOTTOM));
resetView->AddChild(m_pResetAll = new BButton(BRect(70,1,130,20), "reset", "Clear all", new BMessage(MSG_OUTPUT_RESET_ALL), B_FOLLOW_BOTTOM)); fTabsList = new BList(20);
AddChild(resetView); fOutputViewsList = new BList(20);
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 ); BView* resetView = new BView(BRect(b.left, b.bottom - 25, b.right, b.bottom),
fTabView->SetViewColor(216,216,216); "resetView", B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
resetView->SetViewColor(216, 216, 216);
fBounds = fTabView->Bounds(); resetView->AddChild(fReset = new BButton(BRect(1, 1, 61, 20), "reset all",
fBounds.bottom -= fTabView->TabHeight(); "Clear", new BMessage(kMsgOutputReset), B_FOLLOW_BOTTOM));
resetView->AddChild(fResetAll = new BButton(BRect(70, 1, 130, 20), "reset",
fTabView->AddTab(m_pAll = new OutputView(fBounds), m_pAllTab = new BTab()); "Clear all", new BMessage(kMsgOutputResetAll), B_FOLLOW_BOTTOM));
m_pAllTab->SetLabel("All"); AddChild(resetView);
AddChild(fTabView); 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
MoveTo( Preferences::Instance()->OutputX(), | B_NAVIGABLE_JUMP );
Preferences::Instance()->OutputY()); fTabView->SetViewColor(216, 216, 216);
*/
} fBounds = fTabView->Bounds();
fBounds.bottom -= fTabView->TabHeight();
void
Output::AddTab(const char* text, int32 index) fTabView->AddTab(fAll = new OutputView(fBounds), fAllTab = new BTab());
{ fAllTab->SetLabel("All");
OutputView* customOutput;
BTab* customTab; AddChild(fTabView);
/*
Lock(); MoveTo( Preferences::Instance()->OutputX(),
fTabView->AddTab(customOutput = new OutputView(fBounds), customTab = new BTab()); Preferences::Instance()->OutputY());
customTab->SetLabel( text ); */
fTabView->Invalidate(); }
Unlock();
fTabsList->AddItem(customTab, index); void
fOutputViewsList->AddItem(customOutput, index); Output::AddTab(const char* text, int32 index)
{
} OutputView* customOutput;
BTab* customTab;
Output::~Output()
{ Lock();
/* BWindow::~BWindow();*/ fTabView->AddTab(customOutput = new OutputView(fBounds), customTab =
new BTab());
delete fTabsList; customTab->SetLabel(text);
delete fOutputViewsList; fTabView->Invalidate();
} Unlock();
fTabsList->AddItem(customTab, index);
Output* fOutputViewsList->AddItem(customOutput, index);
Output::Instance() }
{
if (!m_instance)
m_instance = new Output; Output::~Output()
return m_instance; {
} /* BWindow::~BWindow();*/
delete fTabsList;
bool delete fOutputViewsList;
Output::QuitRequested() }
{
Hide();
return false; Output*
} Output::Instance()
{
if (!sInstance)
void sInstance = new Output;
Output::MessageReceived(BMessage* msg) return sInstance;
{ }
switch(msg->what)
{
case MSG_OUTPUT_RESET: bool
Output::QuitRequested()
for (int32 index = 0 ; index<fTabsList->CountItems() ; index++) { {
if (fTabsList->ItemAt(index) != NULL && ((BTab*)fTabsList->ItemAt(index))->IsSelected() ) Hide();
((OutputView*)fOutputViewsList->ItemAt(index))->Clear(); return false;
}
}
break; void
case MSG_OUTPUT_RESET_ALL: Output::MessageReceived(BMessage* msg)
m_pAll->Clear(); {
switch(msg->what) {
for (int32 index = 0 ; index<fTabsList->CountItems() ; index++) { case kMsgOutputReset:
if (fTabsList->ItemAt(index) != NULL ) for (int32 index = 0; index<fTabsList->CountItems(); index++) {
((OutputView*)fOutputViewsList->ItemAt(index))->Clear(); if (fTabsList->ItemAt(index) != NULL && ((BTab*)fTabsList
} ->ItemAt(index))->IsSelected())
break; ((OutputView*)fOutputViewsList->ItemAt(index))->Clear();
default: }
BWindow::MessageReceived(msg); break;
break; case kMsgOutputResetAll:
} {
} fAll->Clear();
for (int32 index = 0; index<fTabsList->CountItems(); index++) {
if (fTabsList->ItemAt(index) != NULL )
void ((OutputView*)fOutputViewsList->ItemAt(index))->Clear();
Output::FrameMoved(BPoint point) }
{ break;
/* Preferences::Instance()->OutputX(point.x); }
Preferences::Instance()->OutputY(point.y); default:
*/ BWindow::MessageReceived(msg);
} break;
}
}
int
Output::Postf(uint32 index, const char *format, ...)
{ void
char string[200]; Output::FrameMoved(BPoint point)
va_list arg; {
int done; /* Preferences::Instance()->OutputX(point.x);
Preferences::Instance()->OutputY(point.y);
va_start (arg, format); */
done = vsprintf (string, format, arg); }
va_end (arg);
Post(string, index); int
Output::Postf(uint32 index, const char* format, ...)
return done; {
} char string[200];
va_list arg;
int done;
void
Output::Post(const char* text, uint32 index) va_start (arg, format);
{ done = vsprintf (string, format, arg);
Lock(); va_end (arg);
OutputView* view = (OutputView*) fOutputViewsList->ItemAt(index);
Post(string, index);
if (view != NULL)
Add(text, view ); return done;
else }
// Note that the view should be added before this!
// Dropping twice to the main
Add(text, m_pAll ); void
Output::Post(const char* text, uint32 index)
Unlock(); {
} Lock();
OutputView* view = (OutputView*) fOutputViewsList->ItemAt(index);
void if (view != NULL)
Output::Add(const char* text, OutputView* view) Add(text, view);
{ else
view->Add(text); // Note that the view should be added before this!
m_pAll->Add(text); // Dropping twice to the main
} Add(text, fAll);
Unlock();
}
void
Output::Add(const char* text, OutputView* view)
{
view->Add(text);
fAll->Add(text);
}
+75 -64
View File
@@ -1,64 +1,75 @@
#ifndef _Output_h /*
#define _Output_h * Copyright 2010 Oliver Ruiz Dorantes
* Copyright 2010 Dan-Matei Epure, [email protected]
#include <Window.h> * Copyright BeNet Team (Original Project)
#include <TextView.h> * All rights reserved. Distributed under the terms of the MIT License.
#include <ScrollBar.h> */
#include <Button.h> #ifndef _Output_h
#include <TabView.h> #define _Output_h
const uint32 MSG_OUTPUT_RESET = 'outr'; #include <Window.h>
const uint32 MSG_OUTPUT_RESET_ALL = 'opra'; #include <TextView.h>
#include <ScrollBar.h>
class OutputView : public BView #include <Button.h>
{ #include <TabView.h>
public:
OutputView(BRect frame); const uint32 kMsgOutputReset = 'outr';
virtual void FrameResized(float width, float height); const uint32 kMsgOutputResetAll = 'opra';
void Add(const char* text) {m_pTextView->Insert(text);}
void Clear() {m_pTextView->Delete(0,m_pTextView->TextLength());} class OutputView : public BView
{
private: public:
BTextView* m_pTextView; OutputView(BRect frame);
BScrollBar* m_pScrollBar; virtual void FrameResized(float width, float height);
};
void Add(const char* text) {fTextView->Insert(text);}
void Clear() {fTextView->Delete(0, fTextView->TextLength());}
class Output : public BWindow private:
{ BTextView* fTextView;
public: BScrollBar* fScrollBar;
static Output* Instance(); };
~Output();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* msg); class Output : public BWindow
virtual void FrameMoved(BPoint point); {
public:
void AddTab(const char* text, int32 index); static Output* Instance();
void Post(const char* text, uint32 index); ~Output();
int Postf(uint32 index, const char *format, ...);
virtual bool QuitRequested();
private: // functions virtual void MessageReceived(BMessage* msg);
Output(); virtual void FrameMoved(BPoint point);
void Add(const char* text, OutputView* view);
void AddTab(const char* text, int32 index);
private: // data
static Output* m_instance; void Post(const char* text, uint32 index);
BTab* m_pAllTab; int Postf(uint32 index, const char* format, ...);
OutputView* m_pAll; private:
// functions
BButton* m_pReset; Output();
BButton* m_pResetAll; void Add(const char* text, OutputView* view);
BTabView* fTabView; private:
// data
BList* fTabsList; static Output* sInstance;
BList* fOutputViewsList; BTab* fAllTab;
BRect fBounds; // Bounds for tabs
}; OutputView* fAll;
BButton* fReset;
#endif // _Output_h BButton* fResetAll;
BTabView* fTabView;
BList* fTabsList;
BList* fOutputViewsList;
BRect fBounds;
// Bounds for tabs
};
#endif // _Output_h