Patch by Hamish Morrison as part of GCI. Refactor Bluetooth server output window gui code to use the Layout API. One small change by me as well.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40204 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright BeNet Team (Original Project)
|
* Copyright 2011 Hamish Morrison, [email protected]
|
||||||
* Copyright 2010 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
* Copyright 2010 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
* Copyright 2010 Dan-Matei Epure, [email protected]
|
* Copyright 2010 Dan-Matei Epure, [email protected]
|
||||||
|
* Copyright BeNet Team (Original Project)
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _Output_h
|
#ifndef _Output_h
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
|
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -19,68 +21,51 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
OutputView::OutputView(BRect frame)
|
OutputView::OutputView()
|
||||||
:
|
:
|
||||||
BView(frame, "OutputView", B_FOLLOW_ALL, B_WILL_DRAW)
|
BGroupView("OutputView", B_VERTICAL, B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
SetViewColor(216, 216, 216);
|
rgb_color textColor = {255, 255, 255};
|
||||||
rgb_color color = {255, 255, 255};
|
fTextView = new BTextView("Output", NULL, &textColor, B_WILL_DRAW);
|
||||||
|
|
||||||
BRect b = Bounds();
|
|
||||||
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));
|
|
||||||
fTextView->SetViewColor(0, 0, 100);
|
fTextView->SetViewColor(0, 0, 100);
|
||||||
fTextView->MakeEditable(false);
|
fTextView->MakeEditable(false);
|
||||||
|
BScrollView* scrollView = new BScrollView("ScrollView", fTextView, 0, false, true);
|
||||||
AddChild(fScrollBar = new BScrollBar(BRect(b.right - B_V_SCROLL_BAR_WIDTH - 5,
|
|
||||||
b.top + 5, b.right - 5, b.bottom - 5),
|
BLayoutBuilder::Group<>(this).Add(scrollView);
|
||||||
"outputScroll", fTextView, 0, 0, B_VERTICAL));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
OutputView::FrameResized(float width, float height)
|
|
||||||
{
|
|
||||||
BView::FrameResized(width, height);
|
|
||||||
fTextView->SetTextRect(BRect(0, 0, width, height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Singleton implementation
|
// Singleton implementation
|
||||||
Output* Output::sInstance = 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();
|
|
||||||
|
|
||||||
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),
|
fReset = new BButton("reset all", "Clear",
|
||||||
"resetView", B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
|
new BMessage(kMsgOutputReset), B_WILL_DRAW);
|
||||||
resetView->SetViewColor(216, 216, 216);
|
fResetAll = new BButton("reset", "Clear all",
|
||||||
resetView->AddChild(fReset = new BButton(BRect(1, 1, 61, 20), "reset all",
|
new BMessage(kMsgOutputResetAll), B_WILL_DRAW);
|
||||||
"Clear", new BMessage(kMsgOutputReset), B_FOLLOW_BOTTOM));
|
|
||||||
resetView->AddChild(fResetAll = new BButton(BRect(70, 1, 130, 20), "reset",
|
fTabView = new BTabView("tab_view", B_WIDTH_FROM_LABEL,
|
||||||
"Clear all", new BMessage(kMsgOutputResetAll), B_FOLLOW_BOTTOM));
|
B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_NAVIGABLE_JUMP);
|
||||||
AddChild(resetView);
|
|
||||||
|
|
||||||
fTabView = new BTabView(BRect(b.left, b.top, b.right, b.bottom - 25), "tab_view",
|
fTabView->AddTab(fAll = new OutputView(), fAllTab = new BTab());
|
||||||
B_WIDTH_FROM_LABEL ,B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW
|
fAllTab->SetLabel("All");
|
||||||
| B_NAVIGABLE_JUMP );
|
|
||||||
fTabView->SetViewColor(216, 216, 216);
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 5)
|
||||||
|
.Add(fTabView)
|
||||||
fBounds = fTabView->Bounds();
|
.AddGroup(B_HORIZONTAL, 0)
|
||||||
fBounds.bottom -= fTabView->TabHeight();
|
.Add(fReset)
|
||||||
|
.AddGlue()
|
||||||
fTabView->AddTab(fAll = new OutputView(fBounds), fAllTab = new BTab());
|
.Add(fResetAll)
|
||||||
fAllTab->SetLabel("All");
|
.End()
|
||||||
|
.SetInsets(5, 5, 5, 5);
|
||||||
AddChild(fTabView);
|
|
||||||
/*
|
/*
|
||||||
MoveTo( Preferences::Instance()->OutputX(),
|
MoveTo( Preferences::Instance()->OutputX(),
|
||||||
Preferences::Instance()->OutputY());
|
Preferences::Instance()->OutputY());
|
||||||
@@ -95,8 +80,7 @@ Output::AddTab(const char* text, int32 index)
|
|||||||
BTab* customTab;
|
BTab* customTab;
|
||||||
|
|
||||||
Lock();
|
Lock();
|
||||||
fTabView->AddTab(customOutput = new OutputView(fBounds), customTab =
|
fTabView->AddTab(customOutput = new OutputView(), customTab = new BTab());
|
||||||
new BTab());
|
|
||||||
customTab->SetLabel(text);
|
customTab->SetLabel(text);
|
||||||
fTabView->Invalidate();
|
fTabView->Invalidate();
|
||||||
Unlock();
|
Unlock();
|
||||||
@@ -176,7 +160,7 @@ Output::Postf(uint32 index, const char* format, ...)
|
|||||||
int done;
|
int done;
|
||||||
|
|
||||||
va_start (arg, format);
|
va_start (arg, format);
|
||||||
done = vsprintf (string, format, arg);
|
done = vsnprintf(string, 200, format, arg);
|
||||||
va_end (arg);
|
va_end (arg);
|
||||||
|
|
||||||
Post(string, index);
|
Post(string, index);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2011 Hamish Morrison, [email protected]
|
||||||
* Copyright 2010 Oliver Ruiz Dorantes
|
* Copyright 2010 Oliver Ruiz Dorantes
|
||||||
* Copyright 2010 Dan-Matei Epure, [email protected]
|
* Copyright 2010 Dan-Matei Epure, [email protected]
|
||||||
* Copyright BeNet Team (Original Project)
|
* Copyright BeNet Team (Original Project)
|
||||||
@@ -7,28 +8,27 @@
|
|||||||
#ifndef _Output_h
|
#ifndef _Output_h
|
||||||
#define _Output_h
|
#define _Output_h
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <TextView.h>
|
|
||||||
#include <ScrollBar.h>
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
|
#include <ScrollView.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
const uint32 kMsgOutputReset = 'outr';
|
const uint32 kMsgOutputReset = 'outr';
|
||||||
const uint32 kMsgOutputResetAll = 'opra';
|
const uint32 kMsgOutputResetAll = 'opra';
|
||||||
|
|
||||||
|
|
||||||
class OutputView : public BView
|
class OutputView : public BGroupView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OutputView(BRect frame);
|
OutputView();
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
|
|
||||||
void Add(const char* text) {fTextView->Insert(text);}
|
void Add(const char* text) {fTextView->Insert(text);}
|
||||||
void Clear() {fTextView->Delete(0, fTextView->TextLength());}
|
void Clear() {fTextView->Delete(0, fTextView->TextLength());}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTextView* fTextView;
|
BTextView* fTextView;
|
||||||
BScrollBar* fScrollBar;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -67,8 +67,6 @@ private:
|
|||||||
|
|
||||||
BList* fTabsList;
|
BList* fTabsList;
|
||||||
BList* fOutputViewsList;
|
BList* fOutputViewsList;
|
||||||
BRect fBounds;
|
|
||||||
// Bounds for tabs
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user