Added a 'cursespp' namespace, and removed all 'using' statements from

header files in the app source.
This commit is contained in:
casey 2016-05-24 22:17:00 -07:00
parent c6c12cbab6
commit dcb3d6bfb3
71 changed files with 707 additions and 629 deletions

View File

@ -36,55 +36,51 @@
#include <boost/shared_ptr.hpp>
#include <core/sdk/IBuffer.h>
//////////////////////////////////////////////////////////////////////////////
namespace musik { namespace core { namespace audio {
//////////////////////////////////////////////////////////////////////////////
class Buffer;
class Stream;
typedef std::shared_ptr<Buffer> BufferPtr;
class Buffer;
class Stream;
typedef std::shared_ptr<Buffer> BufferPtr;
//////////////////////////////////////////
///\brief
///Buffer is the only implementation of the IBuffer and is used
///in the audioengine to pass along the raw audio data
//////////////////////////////////////////
class Buffer : public IBuffer {
private:
Buffer(void);
//////////////////////////////////////////
///\brief
///Buffer is the only implementation of the IBuffer and is used
///in the audioengine to pass along the raw audio data
//////////////////////////////////////////
class Buffer : public IBuffer {
private:
Buffer(void);
public:
static BufferPtr Create();
~Buffer(void);
public:
static BufferPtr Create();
~Buffer(void);
virtual long SampleRate() const;
virtual void SetSampleRate(long sampleRate);
virtual int Channels() const;
virtual void SetChannels(int channels);
virtual float* BufferPointer() const;
virtual long Samples() const;
virtual void SetSamples(long samples);
virtual long Bytes() const;
virtual double Position() const;
virtual long SampleRate() const;
virtual void SetSampleRate(long sampleRate);
virtual int Channels() const;
virtual void SetChannels(int channels);
virtual float* BufferPointer() const;
virtual long Samples() const;
virtual void SetSamples(long samples);
virtual long Bytes() const;
virtual double Position() const;
bool Append(BufferPtr appendBuffer);
void CopyFormat(BufferPtr fromBuffer);
bool Append(BufferPtr appendBuffer);
void CopyFormat(BufferPtr fromBuffer);
private:
void ResizeBuffer();
private:
void ResizeBuffer();
private:
float *buffer;
long sampleSize;
long internalBufferSize;
long sampleRate;
int channels;
private:
float *buffer;
long sampleSize;
long internalBufferSize;
long sampleRate;
int channels;
protected:
friend class Stream;
double position;
};
protected:
friend class Stream;
double position;
};
//////////////////////////////////////////////////////////////////////////////
} } }
//////////////////////////////////////////////////////////////////////////////

View File

@ -45,11 +45,11 @@
namespace musik { namespace core { namespace audio {
class Stream;
class Player;
class Stream;
class Player;
typedef std::shared_ptr<Stream> StreamPtr;
class Stream {
class Stream {
public:
static StreamPtr Create(unsigned int options=0);

View File

@ -59,13 +59,10 @@
#define IDLE_TIMEOUT_MS 0
using musik::core::audio::Transport;
using musik::core::LibraryFactory;
using musik::box::LibraryLayout;
using musik::box::MainLayout;
using musik::box::PlaybackService;
using musik::box::GlobalHotkeys;
using namespace musik::core;
using namespace musik::core::audio;
using namespace musik::box;
using namespace cursespp;
struct WindowState {
ILayoutPtr layout;

View File

@ -15,6 +15,13 @@ using namespace musik::core::library::constants;
using namespace musik::box;
using musik::core::LibraryPtr;
using musik::core::audio::Transport;
using cursespp::LayoutBase;
using cursespp::ListWindow;
using cursespp::Screen;
LibraryLayout::LibraryLayout(PlaybackService& playback, LibraryPtr library)
: LayoutBase()
, playback(playback)

View File

@ -12,14 +12,14 @@
#include <sigslot/sigslot.h>
using musik::core::LibraryPtr;
using musik::core::audio::Transport;
namespace musik {
namespace box {
class LibraryLayout : public LayoutBase, public sigslot::has_slots<> {
class LibraryLayout : public cursespp::LayoutBase, public sigslot::has_slots<> {
public:
LibraryLayout(PlaybackService& playback, LibraryPtr library);
LibraryLayout(
PlaybackService& playback,
musik::core::LibraryPtr library);
virtual ~LibraryLayout();
virtual void Layout();
@ -38,8 +38,8 @@ namespace musik {
ListWindow *view, size_t selectedIndex);
PlaybackService& playback;
Transport& transport;
LibraryPtr library;
musik::core::audio::Transport& transport;
musik::core::LibraryPtr library;
std::shared_ptr<CategoryListView> categoryList;
std::shared_ptr<TrackListView> trackList;
std::shared_ptr<TransportWindow> transportView;

View File

@ -8,7 +8,10 @@
#define MESSAGE_TYPE_UPDATE 1001
#define UPDATE_INTERVAL_MS 1000
using namespace musik::core;
using namespace musik::core::audio;
using namespace musik::box;
using namespace cursespp;
MainLayout::MainLayout(Transport& transport, LibraryPtr library)
: LayoutBase() {

View File

@ -13,18 +13,19 @@
#include <core/playback/Transport.h>
#include <boost/shared_ptr.hpp>
using musik::core::audio::Transport;
namespace musik {
namespace box {
class MainLayout : public LayoutBase {
class MainLayout : public cursespp::LayoutBase {
public:
MainLayout(Transport& transport, LibraryPtr library);
MainLayout(
musik::core::audio::Transport& transport,
musik::core::LibraryPtr library);
~MainLayout();
virtual void Layout();
virtual void Show();
virtual void ProcessMessage(IMessage &message);
virtual void ProcessMessage(cursespp::IMessage &message);
private:
void UpdateWindows();

View File

@ -13,6 +13,7 @@
using musik::core::db::Statement;
using musik::core::db::Row;
using namespace musik::core::db;
using namespace musik::core::library::constants;
using namespace musik::box;

View File

@ -4,12 +4,9 @@
#include <core/db/Connection.h>
#include <memory>
using musik::core::query::QueryBase;
using musik::core::db::Connection;
namespace musik {
namespace box {
class CategoryListViewQuery : public QueryBase {
class CategoryListViewQuery : public musik::core::query::QueryBase {
public:
struct Result {
std::string displayValue;
@ -27,7 +24,7 @@ namespace musik {
virtual ResultList GetResult();
protected:
virtual bool OnRun(Connection &db);
virtual bool OnRun(musik::core::db::Connection &db);
std::string trackField;
ResultList result;

View File

@ -13,6 +13,7 @@ using musik::core::TrackPtr;
using musik::core::LibraryTrack;
using namespace musik::core::library::constants;
using namespace musik::core::db;
using namespace musik::box;
SingleTrackQuery::SingleTrackQuery(const std::string& filename) {

View File

@ -5,26 +5,21 @@
#include <core/library/track/Track.h>
#include "CategoryListViewQuery.h"
using musik::core::query::QueryBase;
using musik::core::db::Connection;
using musik::core::TrackPtr;
using musik::core::LibraryPtr;
namespace musik {
namespace box {
class SingleTrackQuery : public QueryBase {
class SingleTrackQuery : public musik::core::query::QueryBase {
public:
SingleTrackQuery(const std::string& path);
virtual ~SingleTrackQuery();
virtual std::string Name() { return "SingleTrackQuery"; }
virtual TrackPtr GetResult();
virtual musik::core::TrackPtr GetResult();
protected:
virtual bool OnRun(Connection &db);
virtual bool OnRun(musik::core::db::Connection &db);
private:
TrackPtr result;
musik::core::TrackPtr result;
std::string filename;
};
}

View File

@ -11,7 +11,9 @@ using musik::core::db::Statement;
using musik::core::db::Row;
using musik::core::TrackPtr;
using musik::core::LibraryTrack;
using musik::core::LibraryPtr;
using namespace musik::core::db;
using namespace musik::core::library::constants;
using namespace musik::box;

View File

@ -5,18 +5,17 @@
#include <core/library/track/Track.h>
#include "CategoryListViewQuery.h"
using musik::core::query::QueryBase;
using musik::core::db::Connection;
using musik::core::TrackPtr;
using musik::core::LibraryPtr;
namespace musik {
namespace box {
class TrackListViewQuery : public QueryBase {
class TrackListViewQuery : public musik::core::query::QueryBase {
public:
typedef std::shared_ptr<std::vector<TrackPtr>> Result;
typedef std::shared_ptr<
std::vector<musik::core::TrackPtr>> Result;
TrackListViewQuery(
musik::core::LibraryPtr library,
const std::string& column, DBID id);
TrackListViewQuery(LibraryPtr library, const std::string& column, DBID id);
virtual ~TrackListViewQuery();
std::string Name() { return "TrackListViewQuery"; }
@ -24,12 +23,12 @@ namespace musik {
virtual Result GetResult();
protected:
virtual bool OnRun(Connection &db);
virtual bool OnRun(musik::core::db::Connection &db);
Result result;
private:
LibraryPtr library;
musik::core::LibraryPtr library;
std::string column;
DBID id;
};

View File

@ -15,10 +15,6 @@ using namespace musik::box;
#define URI_AT_INDEX(x) this->playlist.at(x)->URI()
#define PREVIOUS_GRACE_PERIOD 2.0f
class StreamEvent : public IMessage {
};
PlaybackService::PlaybackService(Transport& transport)
: transport(transport) {
transport.StreamEvent.connect(this, &PlaybackService::OnStreamEvent);

View File

@ -10,6 +10,9 @@
using musik::core::TrackPtr;
using musik::core::audio::Transport;
using cursespp::IMessageTarget;
using cursespp::IMessage;
namespace musik {
namespace box {
class PlaybackService : public IMessageTarget, public sigslot::has_slots<> {

View File

@ -5,22 +5,22 @@
#include <app/service/PlaybackService.h>
#include <core/library/ILibrary.h>
using musik::core::audio::Transport;
using musik::core::LibraryPtr;
namespace musik {
namespace box {
class GlobalHotkeys {
public:
GlobalHotkeys(PlaybackService& playback, LibraryPtr library);
GlobalHotkeys(
PlaybackService& playback,
musik::core::LibraryPtr library);
~GlobalHotkeys(); /* non-virtual; do not use as a base class */
bool Handle(int64 ch);
private:
PlaybackService& playback;
Transport& transport;
LibraryPtr library;
musik::core::audio::Transport& transport;
musik::core::LibraryPtr library;
};
}
}

View File

@ -4,8 +4,6 @@
#include <core/playback/Transport.h>
using musik::core::audio::Transport;
namespace musik {
namespace box {
namespace text {

View File

@ -18,6 +18,7 @@ using musik::core::LibraryPtr;
using musik::core::IQuery;
using namespace musik::core::library::constants;
using namespace musik::box;
using cursespp::SingleLineEntry;
#define WINDOW_MESSAGE_QUERY_COMPLETED 1002

View File

@ -13,6 +13,11 @@
using musik::core::QueryPtr;
using musik::core::LibraryPtr;
using cursespp::IMessage;
using cursespp::ListWindow;
using cursespp::IScrollAdapter;
using cursespp::ScrollAdapterBase;
namespace musik {
namespace box {
class CategoryListView : public ListWindow, public sigslot::has_slots<> {

View File

@ -28,7 +28,9 @@ using musik::core::LibraryPtr;
using musik::core::TrackPtr;
using musik::core::QueryPtr;
using namespace musik::core::audio;
using namespace musik::box;
using namespace cursespp;
template <class T>
bool tostr(T& t, const std::string& s) {

View File

@ -7,18 +7,18 @@
#include <core/library/LibraryFactory.h>
#include "OutputWindow.h"
using musik::core::LibraryPtr;
using musik::core::QueryPtr;
using namespace musik::core::audio;
namespace musik {
namespace box {
class CommandWindow : public Window, public IInput, public sigslot::has_slots<> {
class CommandWindow :
public cursespp::Window,
public cursespp::IInput,
public sigslot::has_slots<>
{
public:
CommandWindow(
IWindow *parent,
Transport& transport,
LibraryPtr library,
cursespp::IWindow *parent,
musik::core::audio::Transport& transport,
musik::core::LibraryPtr library,
OutputWindow& output);
~CommandWindow();
@ -41,8 +41,8 @@ namespace musik {
char* buffer;
int bufferPosition;
OutputWindow* output;
Transport* transport;
LibraryPtr library;
musik::core::audio::Transport* transport;
musik::core::LibraryPtr library;
bool paused;
};
}

View File

@ -9,6 +9,7 @@
#include <cursespp/Screen.h>
using namespace musik::box;
using namespace cursespp;
typedef IScrollAdapter::IEntry IEntry;

View File

@ -11,15 +11,15 @@
namespace musik {
namespace box {
class LogWindow : public ScrollableWindow, public sigslot::has_slots<> {
class LogWindow : public cursespp::ScrollableWindow, public sigslot::has_slots<> {
public:
LogWindow(IWindow *parent = NULL);
LogWindow(cursespp::IWindow *parent = NULL);
~LogWindow();
void Update();
protected:
virtual IScrollAdapter& GetScrollAdapter();
virtual cursespp::IScrollAdapter& GetScrollAdapter();
private:
void OnLogged(
@ -35,7 +35,7 @@ namespace musik {
boost::mutex pendingMutex;
std::vector<LogEntry*> pending;
SimpleScrollAdapter* adapter;
cursespp::SimpleScrollAdapter* adapter;
};
}
}

View File

@ -9,6 +9,7 @@
#include <cursespp/MultiLineEntry.h>
using namespace musik::box;
using namespace cursespp;
typedef IScrollAdapter::EntryPtr EntryPtr;

View File

@ -7,16 +7,16 @@
namespace musik {
namespace box {
class OutputWindow : public ScrollableWindow {
class OutputWindow : public cursespp::ScrollableWindow {
public:
OutputWindow(IWindow *parent = NULL);
OutputWindow(cursespp::IWindow *parent = NULL);
~OutputWindow();
void WriteLine(const std::string& line, int64 attrs = -1);
virtual IScrollAdapter& GetScrollAdapter();
virtual cursespp::IScrollAdapter& GetScrollAdapter();
private:
SimpleScrollAdapter* adapter;
cursespp::SimpleScrollAdapter* adapter;
};
}
}

View File

@ -12,6 +12,7 @@
#include <core/debug.h>
using namespace musik::box;
using namespace cursespp;
#define BYTES_PER_MEGABYTE 1048576.0f

View File

@ -7,9 +7,9 @@
namespace musik {
namespace box {
class ResourcesWindow : public Window {
class ResourcesWindow : public cursespp::Window {
public:
ResourcesWindow(IWindow *parent = NULL);
ResourcesWindow(cursespp::IWindow *parent = NULL);
virtual ~ResourcesWindow();
virtual void Update();

View File

@ -20,18 +20,18 @@
#define WINDOW_MESSAGE_QUERY_COMPLETED 1002
using musik::core::IQuery;
using musik::core::audio::Transport;
using namespace musik::core::library::constants;
using namespace musik::core;
using namespace musik::core::audio;
using namespace musik::core::library;
using namespace musik::box;
using namespace cursespp;
using boost::io::group;
using std::setw;
using std::setfill;
using std::setiosflags;
TrackListView::TrackListView(PlaybackService& playback, LibraryPtr library, IWindow *parent)
: ListWindow(parent)
TrackListView::TrackListView(PlaybackService& playback, LibraryPtr library)
: ListWindow(NULL)
, playback(playback) {
this->SetContentColor(BOX_COLOR_WHITE_ON_BLACK);
this->library = library;
@ -105,12 +105,11 @@ IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) {
int64 attrs = (index == parent.GetSelectedIndex()) ? COLOR_PAIR(BOX_COLOR_BLACK_ON_GREEN) : -1;
TrackPtr track = parent.metadata->at(index);
std::string trackNum = track->GetValue(Track::TRACK_NUM);
std::string artist = track->GetValue(Track::ARTIST_ID);
std::string album = track->GetValue(Track::ALBUM_ID);
std::string title = track->GetValue(Track::TITLE);
std::string duration = track->GetValue(Track::DURATION);
std::string trackNum = track->GetValue(constants::Track::TRACK_NUM);
std::string artist = track->GetValue(constants::Track::ARTIST_ID);
std::string album = track->GetValue(constants::Track::ALBUM_ID);
std::string title = track->GetValue(constants::Track::TITLE);
std::string duration = track->GetValue(constants::Track::DURATION);
int column0Width = DISPLAY_WIDTH(TRACK_COL_WIDTH, trackNum);
int column2Width = DISPLAY_WIDTH(DURATION_COL_WIDTH, duration);

View File

@ -11,36 +11,35 @@
#include <core/playback/Transport.h>
#include <core/library/ILibrary.h>
using musik::core::QueryPtr;
using musik::core::LibraryPtr;
using musik::core::audio::Transport;
namespace musik {
namespace box {
class TrackListView : public ListWindow, public sigslot::has_slots<> {
class TrackListView : public cursespp::ListWindow, public sigslot::has_slots<> {
public:
TrackListView(PlaybackService& playback, LibraryPtr library, IWindow *parent = NULL);
TrackListView(
PlaybackService& playback,
musik::core::LibraryPtr library);
~TrackListView();
virtual void ProcessMessage(IMessage &message);
virtual void ProcessMessage(cursespp::IMessage &message);
virtual bool KeyPress(int64 ch);
void Requery(const std::string& column, DBID id);
protected:
virtual IScrollAdapter& GetScrollAdapter();
void OnQueryCompleted(QueryPtr query);
virtual cursespp::IScrollAdapter& GetScrollAdapter();
void OnQueryCompleted(musik::core::QueryPtr query);
class Adapter : public ScrollAdapterBase {
public:
Adapter(TrackListView &parent);
class Adapter : public cursespp::ScrollAdapterBase {
public:
Adapter(TrackListView &parent);
virtual size_t GetEntryCount();
virtual EntryPtr GetEntry(size_t index);
virtual size_t GetEntryCount();
virtual EntryPtr GetEntry(size_t index);
private:
TrackListView &parent;
IScrollAdapter::ScrollPosition spos;
private:
TrackListView &parent;
IScrollAdapter::ScrollPosition spos;
};
private:
@ -48,7 +47,7 @@ namespace musik {
std::shared_ptr<std::vector<TrackPtr>> metadata;
Adapter* adapter;
PlaybackService& playback;
LibraryPtr library;
musik::core::LibraryPtr library;
};
}
}

View File

@ -18,16 +18,14 @@
#include <boost/algorithm/string.hpp>
#include <boost/chrono.hpp>
using musik::core::audio::Transport;
using musik::core::TrackPtr;
using musik::core::LibraryTrack;
using musik::core::NonLibraryTrackHelper;
using musik::core::QueryPtr;
using namespace musik::core::library::constants;
using namespace musik::core;
using namespace musik::core::audio;
using namespace musik::core::library;
using namespace musik::core::query;
using namespace musik::core::db;
using namespace musik::box;
using namespace boost::chrono;
using namespace cursespp;
#define REFRESH_TRANSPORT_READOUT 1001
#define REFRESH_INTERVAL_MS 1000
@ -101,9 +99,9 @@ void TransportWindow::Update() {
std::string title, album, duration;
if (this->currentTrack) {
title = this->currentTrack->GetValue(Track::TITLE);
album = this->currentTrack->GetValue(Track::ALBUM);
duration = this->currentTrack->GetValue(Track::DURATION);
title = this->currentTrack->GetValue(constants::Track::TITLE);
album = this->currentTrack->GetValue(constants::Track::ALBUM);
duration = this->currentTrack->GetValue(constants::Track::DURATION);
}
title = title.size() ? title : "song title";

View File

@ -8,19 +8,17 @@
#include <sigslot/sigslot.h>
#include "OutputWindow.h"
using namespace musik::core::audio;
using musik::core::TrackPtr;
using musik::core::LibraryPtr;
using musik::core::QueryPtr;
namespace musik {
namespace box {
class TransportWindow : public Window, public sigslot::has_slots<> {
class TransportWindow : public cursespp::Window, public sigslot::has_slots<> {
public:
TransportWindow(LibraryPtr library, Transport& transport);
TransportWindow(
musik::core::LibraryPtr library,
musik::core::audio::Transport& transport);
~TransportWindow();
virtual void ProcessMessage(IMessage &message);
virtual void ProcessMessage(cursespp::IMessage &message);
virtual void Show();
void Update();
@ -28,12 +26,12 @@ namespace musik {
void OnTransportStreamEvent(int eventType, std::string url);
void OnTransportVolumeChanged();
void OnTransportTimeChanged(double time);
void OnQueryCompleted(QueryPtr query);
void OnQueryCompleted(musik::core::QueryPtr query);
bool paused;
LibraryPtr library;
Transport* transport;
TrackPtr currentTrack;
musik::core::LibraryPtr library;
musik::core::audio::Transport* transport;
musik::core::TrackPtr currentTrack;
std::shared_ptr<SingleTrackQuery> trackQuery;
};
}

View File

@ -3,6 +3,8 @@
#include <stdafx.h>
#include "Colors.h"
using namespace cursespp;
Colors::Colors() {
}

View File

@ -14,10 +14,12 @@
#define BOX_COLOR_GREEN_ON_BLACK 10
#define BOX_COLOR_BLACK_ON_BLACK 11
class Colors {
private:
Colors();
namespace cursespp {
class Colors {
private:
Colors();
public:
static void Init();
};
public:
static void Init();
};
}

View File

@ -1,9 +1,11 @@
#pragma once
class IDisplayable {
public:
virtual ~IDisplayable() = 0 { }
namespace cursespp {
class IDisplayable {
public:
virtual ~IDisplayable() = 0 { }
virtual void Show() = 0;
virtual void Hide() = 0;
};
}
virtual void Show() = 0;
virtual void Hide() = 0;
};

View File

@ -2,9 +2,10 @@
#include <stdafx.h>
class IInput {
public:
virtual ~IInput() = 0 { }
virtual void WriteChar(int64 ch) = 0;
};
namespace cursespp {
class IInput {
public:
virtual ~IInput() = 0 { }
virtual void WriteChar(int64 ch) = 0;
};
}

View File

@ -2,8 +2,10 @@
#include <stdafx.h>
class IKeyHandler {
public:
virtual ~IKeyHandler() = 0 { }
virtual bool KeyPress(int64 ch) = 0;
};
namespace cursespp {
class IKeyHandler {
public:
virtual ~IKeyHandler() = 0 { }
virtual bool KeyPress(int64 ch) = 0;
};
}

View File

@ -5,17 +5,19 @@
#include "IKeyHandler.h"
#include <memory>
class ILayoutStack;
namespace cursespp {
class ILayoutStack;
class ILayout : public IWindowGroup, public IKeyHandler, public IOrderable, public IDisplayable {
public:
virtual ~ILayout() = 0 { }
virtual IWindowPtr FocusNext() = 0;
virtual IWindowPtr FocusPrev() = 0;
virtual IWindowPtr GetFocus() = 0;
virtual ILayoutStack* GetLayoutStack() = 0;
virtual void SetLayoutStack(ILayoutStack* stack) = 0;
virtual void Layout() = 0;
};
class ILayout : public IWindowGroup, public IKeyHandler, public IOrderable, public IDisplayable {
public:
virtual ~ILayout() = 0 { }
virtual IWindowPtr FocusNext() = 0;
virtual IWindowPtr FocusPrev() = 0;
virtual IWindowPtr GetFocus() = 0;
virtual ILayoutStack* GetLayoutStack() = 0;
virtual void SetLayoutStack(ILayoutStack* stack) = 0;
virtual void Layout() = 0;
};
typedef std::shared_ptr<ILayout> ILayoutPtr;
typedef std::shared_ptr<ILayout> ILayoutPtr;
}

View File

@ -3,11 +3,13 @@
#include <stdafx.h>
#include "ILayout.h"
class ILayoutStack {
public:
virtual ~ILayoutStack() = 0 { }
virtual bool Push(ILayoutPtr layout) = 0;
virtual bool Pop(ILayoutPtr layout) = 0;
virtual bool BringToTop(ILayoutPtr layout) = 0;
virtual bool SendToBottom(ILayoutPtr layout) = 0;
};
namespace cursespp {
class ILayoutStack {
public:
virtual ~ILayoutStack() = 0 { }
virtual bool Push(ILayoutPtr layout) = 0;
virtual bool Pop(ILayoutPtr layout) = 0;
virtual bool BringToTop(ILayoutPtr layout) = 0;
virtual bool SendToBottom(ILayoutPtr layout) = 0;
};
}

View File

@ -3,15 +3,18 @@
#include <stdafx.h>
#include <memory>
class IMessageTarget;
namespace cursespp {
class IMessage {
public:
virtual ~IMessage() = 0 { }
virtual IMessageTarget* Target() = 0;
virtual int MessageType() = 0;
virtual int64 UserData1() = 0;
virtual int64 UserData2() = 0;
};
class IMessageTarget;
typedef std::shared_ptr<IMessage> IMessagePtr;
class IMessage {
public:
virtual ~IMessage() = 0 { }
virtual IMessageTarget* Target() = 0;
virtual int MessageType() = 0;
virtual int64 UserData1() = 0;
virtual int64 UserData2() = 0;
};
typedef std::shared_ptr<IMessage> IMessagePtr;
}

View File

@ -2,8 +2,10 @@
#include "IMessage.h"
class IMessageTarget {
public:
virtual bool IsAcceptingMessages() = 0;
virtual void ProcessMessage(IMessage &message) = 0;
};
namespace cursespp {
class IMessageTarget {
public:
virtual bool IsAcceptingMessages() = 0;
virtual void ProcessMessage(IMessage &message) = 0;
};
}

View File

@ -1,8 +1,10 @@
#pragma once
class IOrderable {
public:
virtual ~IOrderable() = 0 { }
virtual void BringToTop() = 0;
virtual void SendToBottom() = 0;
};
namespace cursespp {
class IOrderable {
public:
virtual ~IOrderable() = 0 { }
virtual void BringToTop() = 0;
virtual void SendToBottom() = 0;
};
}

View File

@ -2,42 +2,44 @@
#include <stdafx.h>
class IScrollAdapter {
public:
virtual ~IScrollAdapter() = 0 { }
struct ScrollPosition {
ScrollPosition() {
firstVisibleEntryIndex = 0;
visibleEntryCount = 0;
lineCount = 0;
logicalIndex = 0;
totalEntries = 0;
}
size_t firstVisibleEntryIndex;
size_t visibleEntryCount;
size_t lineCount;
size_t totalEntries;
size_t logicalIndex;
};
class IEntry {
namespace cursespp {
class IScrollAdapter {
public:
virtual ~IEntry() = 0 { }
virtual size_t GetLineCount() = 0;
virtual std::string GetLine(size_t line) = 0;
virtual std::string GetValue() = 0;
virtual void SetWidth(size_t width) = 0;
virtual void SetAttrs(int64 attrs) = 0;
virtual int64 GetAttrs() = 0;
};
virtual ~IScrollAdapter() = 0 { }
typedef std::shared_ptr<IEntry> EntryPtr;
struct ScrollPosition {
ScrollPosition() {
firstVisibleEntryIndex = 0;
visibleEntryCount = 0;
lineCount = 0;
logicalIndex = 0;
totalEntries = 0;
}
virtual void SetDisplaySize(size_t width, size_t height) = 0;
virtual size_t GetEntryCount() = 0;
virtual EntryPtr GetEntry(size_t index) = 0;
virtual void DrawPage(WINDOW* window, size_t index, ScrollPosition *result = NULL) = 0;
};
size_t firstVisibleEntryIndex;
size_t visibleEntryCount;
size_t lineCount;
size_t totalEntries;
size_t logicalIndex;
};
class IEntry {
public:
virtual ~IEntry() = 0 { }
virtual size_t GetLineCount() = 0;
virtual std::string GetLine(size_t line) = 0;
virtual std::string GetValue() = 0;
virtual void SetWidth(size_t width) = 0;
virtual void SetAttrs(int64 attrs) = 0;
virtual int64 GetAttrs() = 0;
};
typedef std::shared_ptr<IEntry> EntryPtr;
virtual void SetDisplaySize(size_t width, size_t height) = 0;
virtual size_t GetEntryCount() = 0;
virtual EntryPtr GetEntry(size_t index) = 0;
virtual void DrawPage(WINDOW* window, size_t index, ScrollPosition *result = NULL) = 0;
};
}

View File

@ -1,12 +1,14 @@
#pragma once
class IScrollable {
public:
virtual ~IScrollable() = 0 { }
virtual void ScrollToTop() = 0;
virtual void ScrollToBottom() = 0;
virtual void ScrollUp(int delta = 1) = 0;
virtual void ScrollDown(int delta = 1) = 0;
virtual void PageUp() = 0;
virtual void PageDown() = 0;
};
namespace cursespp {
class IScrollable {
public:
virtual ~IScrollable() = 0 { }
virtual void ScrollToTop() = 0;
virtual void ScrollToBottom() = 0;
virtual void ScrollUp(int delta = 1) = 0;
virtual void ScrollDown(int delta = 1) = 0;
virtual void PageUp() = 0;
virtual void PageDown() = 0;
};
}

View File

@ -5,32 +5,34 @@
#include "IOrderable.h"
#include "IMessageTarget.h"
class IMessage;
namespace cursespp {
class IMessage;
class IWindow : public IOrderable, public IDisplayable, public IMessageTarget {
public:
virtual ~IWindow() = 0 { }
virtual void Repaint() = 0;
virtual void SetParent(IWindow* parent) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void Focus() = 0;
virtual void Blur() = 0;
virtual void SetContentColor(int64 color) = 0;
virtual void SetFrameColor(int64 color) = 0;
virtual void SetSize(int width, int height) = 0;
virtual void SetPosition(int x, int y) = 0;
virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual int GetContentHeight() const = 0;
virtual int GetContentWidth() const = 0;
virtual int GetX() const = 0;
virtual int GetY() const = 0;
virtual int GetId() const = 0;
virtual int GetFocusOrder() = 0;
virtual void SetFocusOrder(int order = -1) = 0;
virtual WINDOW* GetFrame() const = 0;
virtual WINDOW* GetContent() const = 0;
};
class IWindow : public IOrderable, public IDisplayable, public IMessageTarget {
public:
virtual ~IWindow() = 0 { }
virtual void Repaint() = 0;
virtual void SetParent(IWindow* parent) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void Focus() = 0;
virtual void Blur() = 0;
virtual void SetContentColor(int64 color) = 0;
virtual void SetFrameColor(int64 color) = 0;
virtual void SetSize(int width, int height) = 0;
virtual void SetPosition(int x, int y) = 0;
virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual int GetContentHeight() const = 0;
virtual int GetContentWidth() const = 0;
virtual int GetX() const = 0;
virtual int GetY() const = 0;
virtual int GetId() const = 0;
virtual int GetFocusOrder() = 0;
virtual void SetFocusOrder(int order = -1) = 0;
virtual WINDOW* GetFrame() const = 0;
virtual WINDOW* GetContent() const = 0;
};
typedef std::shared_ptr<IWindow> IWindowPtr;
typedef std::shared_ptr<IWindow> IWindowPtr;
}

View File

@ -2,11 +2,13 @@
#include "IWindow.h"
class IWindowGroup {
public:
virtual ~IWindowGroup() = 0 { }
virtual bool AddWindow(IWindowPtr window) = 0;
virtual bool RemoveWindow(IWindowPtr window) = 0;
virtual size_t GetWindowCount() = 0;
virtual IWindowPtr GetWindowAt(size_t position) = 0;
};
namespace cursespp {
class IWindowGroup {
public:
virtual ~IWindowGroup() = 0 { }
virtual bool AddWindow(IWindowPtr window) = 0;
virtual bool RemoveWindow(IWindowPtr window) = 0;
virtual size_t GetWindowCount() = 0;
virtual IWindowPtr GetWindowAt(size_t position) = 0;
};
}

View File

@ -3,6 +3,8 @@
#include "LayoutStack.h"
#include "Colors.h"
using namespace cursespp;
template <typename T> static int find(std::vector<T>& haystack, T& needle) {
int i = 0;
std::vector<T>::iterator it = haystack.begin();

View File

@ -6,46 +6,48 @@
#include <vector>
class LayoutBase : public Window, public ILayout {
public:
LayoutBase(IWindow* parent = NULL);
virtual ~LayoutBase();
namespace cursespp {
class LayoutBase : public Window, public ILayout {
public:
LayoutBase(IWindow* parent = NULL);
virtual ~LayoutBase();
/* IWindow */
virtual void Show();
virtual void Hide();
virtual void Repaint();
/* IWindow */
virtual void Show();
virtual void Hide();
virtual void Repaint();
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() = 0;
virtual void Layout() = 0;
/* IKeyHandler */
virtual bool KeyPress(int64 ch);
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
/* IKeyHandler */
virtual bool KeyPress(int64 ch);
private:
void AddFocusable(IWindowPtr window);
void RemoveFocusable(IWindowPtr window);
void SortFocusables();
void IndexFocusables();
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
ILayoutStack* layoutStack;
std::vector<IWindowPtr> children;
std::vector<IWindowPtr> focusable;
int focused;
};
private:
void AddFocusable(IWindowPtr window);
void RemoveFocusable(IWindowPtr window);
void SortFocusables();
void IndexFocusables();
ILayoutStack* layoutStack;
std::vector<IWindowPtr> children;
std::vector<IWindowPtr> focusable;
int focused;
};
}

View File

@ -3,6 +3,8 @@
#include <stdafx.h>
#include "LayoutStack.h"
using namespace cursespp;
LayoutStack::LayoutStack() {
this->visible = false;
this->stack = 0;

View File

@ -5,44 +5,46 @@
#include <memory>
class LayoutStack : public ILayout, public ILayoutStack {
public:
LayoutStack();
virtual ~LayoutStack();
namespace cursespp {
class LayoutStack : public ILayout, public ILayoutStack {
public:
LayoutStack();
virtual ~LayoutStack();
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() { }
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() { }
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* IDisplayable */
virtual void Show();
virtual void Hide();
/* IDisplayable */
virtual void Show();
virtual void Hide();
/* IKeyHandler */
virtual bool KeyPress(int64 ch);
/* IKeyHandler */
virtual bool KeyPress(int64 ch);
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
/* ILayoutStack */
virtual bool Push(ILayoutPtr layout);
virtual bool Pop(ILayoutPtr layout);
virtual bool BringToTop(ILayoutPtr layout);
virtual bool SendToBottom(ILayoutPtr layout);
/* ILayoutStack */
virtual bool Push(ILayoutPtr layout);
virtual bool Pop(ILayoutPtr layout);
virtual bool BringToTop(ILayoutPtr layout);
virtual bool SendToBottom(ILayoutPtr layout);
private:
std::deque<ILayoutPtr> layouts;
ILayoutStack* stack;
bool visible;
};
private:
std::deque<ILayoutPtr> layouts;
ILayoutStack* stack;
bool visible;
};
}

View File

@ -1,6 +1,8 @@
#include <stdafx.h>
#include "ListWindow.h"
using namespace cursespp;
typedef IScrollAdapter::ScrollPosition ScrollPos;
size_t ListWindow::NO_SELECTION = (size_t) -1;

View File

@ -5,35 +5,37 @@
#include "ScrollableWindow.h"
#include <sigslot/sigslot.h>
class ListWindow : public ScrollableWindow {
public:
static size_t NO_SELECTION;
namespace cursespp {
class ListWindow : public ScrollableWindow {
public:
static size_t NO_SELECTION;
sigslot::signal3<ListWindow*, size_t, size_t> SelectionChanged;
sigslot::signal2<ListWindow*, size_t> Invalidated;
sigslot::signal3<ListWindow*, size_t, size_t> SelectionChanged;
sigslot::signal2<ListWindow*, size_t> Invalidated;
ListWindow(IWindow *parent = NULL);
virtual ~ListWindow();
ListWindow(IWindow *parent = NULL);
virtual ~ListWindow();
virtual void ScrollToTop();
virtual void ScrollToBottom();
virtual void ScrollUp(int delta = 1);
virtual void ScrollDown(int delta = 1);
virtual void PageUp();
virtual void PageDown();
virtual void Focus();
virtual void ScrollToTop();
virtual void ScrollToBottom();
virtual void ScrollUp(int delta = 1);
virtual void ScrollDown(int delta = 1);
virtual void PageUp();
virtual void PageDown();
virtual void Focus();
virtual size_t GetSelectedIndex();
virtual size_t GetSelectedIndex();
protected:
virtual void SetSelectedIndex(size_t index);
virtual void OnAdapterChanged();
virtual void OnSelectionChanged(size_t newIndex, size_t oldIndex);
virtual void OnInvalidated();
protected:
virtual void SetSelectedIndex(size_t index);
virtual void OnAdapterChanged();
virtual void OnSelectionChanged(size_t newIndex, size_t oldIndex);
virtual void OnInvalidated();
virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
private:
IScrollAdapter::ScrollPosition scrollPosition;
size_t selectedIndex;
};
private:
IScrollAdapter::ScrollPosition scrollPosition;
size_t selectedIndex;
};
}

View File

@ -1,6 +1,8 @@
#include <stdafx.h>
#include "Message.h"
using namespace cursespp;
IMessagePtr Message::Create(
IMessageTarget* target,
int messageType,

View File

@ -2,28 +2,30 @@
#include "IMessage.h"
class Message : public IMessage {
private:
Message(
IMessageTarget* target,
int messageType,
int64 data1,
int64 data2);
public:
static IMessagePtr Create(
IMessageTarget* target,
int messageType,
int64 data1,
int64 data2);
virtual IMessageTarget* Target();
virtual int MessageType();
virtual int64 UserData1();
virtual int64 UserData2();
namespace cursespp {
class Message : public IMessage {
private:
Message(
IMessageTarget* target,
int messageType,
int64 data1,
int64 data2);
private:
IMessageTarget* target;
int messageType;
int64 data1, data2;
};
public:
static IMessagePtr Create(
IMessageTarget* target,
int messageType,
int64 data1,
int64 data2);
virtual IMessageTarget* Target();
virtual int MessageType();
virtual int64 UserData1();
virtual int64 UserData2();
private:
IMessageTarget* target;
int messageType;
int64 data1, data2;
};
}

View File

@ -2,6 +2,7 @@
#include "MessageQueue.h"
using namespace boost::chrono;
using namespace cursespp;
MessageQueue MessageQueue::instance;

View File

@ -6,27 +6,27 @@
#include <boost/thread/recursive_mutex.hpp>
#include <boost/chrono.hpp>
class MessageQueue {
public:
static MessageQueue& Instance();
namespace cursespp {
class MessageQueue {
public:
static MessageQueue& Instance();
void Post(IMessagePtr message, int64 delayMs = 0);
void Remove(IMessageTarget *target, int type = -1);
void Dispatch();
void Post(IMessagePtr message, int64 delayMs = 0);
void Remove(IMessageTarget *target, int type = -1);
void Dispatch();
private:
static MessageQueue instance;
private:
static MessageQueue instance;
struct EnqueuedMessage {
IMessagePtr message;
boost::chrono::milliseconds time;
};
struct EnqueuedMessage {
IMessagePtr message;
boost::chrono::milliseconds time;
};
boost::recursive_mutex queueMutex;
std::list<EnqueuedMessage*> queue;
boost::recursive_mutex queueMutex;
std::list<EnqueuedMessage*> queue;
MessageQueue();
void Dispatch(IMessagePtr message);
};
MessageQueue();
void Dispatch(IMessagePtr message);
};
}

View File

@ -2,6 +2,8 @@
#include "MultiLineEntry.h"
#include <boost/algorithm/string.hpp>
using namespace cursespp;
MultiLineEntry::MultiLineEntry(const std::string& value, int64 attrs) {
this->value = value;
this->charCount = value.size();

View File

@ -2,24 +2,26 @@
#include "IScrollAdapter.h"
class MultiLineEntry : public IScrollAdapter::IEntry {
public:
MultiLineEntry(const std::string& value, int64 attrs = -1);
namespace cursespp {
class MultiLineEntry : public IScrollAdapter::IEntry {
public:
MultiLineEntry(const std::string& value, int64 attrs = -1);
size_t GetIndex();
void SetIndex(size_t index);
size_t GetLineCount();
std::string GetLine(size_t line);
std::string GetValue();
void SetWidth(size_t width);
void SetAttrs(int64 attrs);
int64 GetAttrs();
size_t GetIndex();
void SetIndex(size_t index);
size_t GetLineCount();
std::string GetLine(size_t line);
std::string GetValue();
void SetWidth(size_t width);
void SetAttrs(int64 attrs);
int64 GetAttrs();
private:
size_t index;
std::string value;
std::vector<std::string> lines;
size_t charCount;
int64 attrs;
size_t width;
};
private:
size_t index;
std::string value;
std::vector<std::string> lines;
size_t charCount;
int64 attrs;
size_t width;
};
}

View File

@ -3,6 +3,8 @@
#include <stdafx.h>
#include "Screen.h"
using namespace cursespp;
Screen::Screen() {
}

View File

@ -2,11 +2,13 @@
#include "curses_config.h"
class Screen {
private:
Screen();
namespace cursespp {
class Screen {
private:
Screen();
public:
static int GetWidth();
static int GetHeight();
};
public:
static int GetWidth();
static int GetHeight();
};
}

View File

@ -2,6 +2,8 @@
#include "ScrollAdapterBase.h"
#include "MultiLineEntry.h"
using namespace cursespp;
typedef IScrollAdapter::EntryPtr EntryPtr;
ScrollAdapterBase::ScrollAdapterBase() {

View File

@ -4,24 +4,26 @@
#include "IScrollAdapter.h"
#include <deque>
class ScrollAdapterBase : public IScrollAdapter {
public:
ScrollAdapterBase();
virtual ~ScrollAdapterBase();
namespace cursespp {
class ScrollAdapterBase : public IScrollAdapter {
public:
ScrollAdapterBase();
virtual ~ScrollAdapterBase();
virtual void SetDisplaySize(size_t width, size_t height);
virtual size_t GetLineCount();
virtual void DrawPage(WINDOW* window, size_t index, ScrollPosition *result = NULL);
virtual void SetDisplaySize(size_t width, size_t height);
virtual size_t GetLineCount();
virtual void DrawPage(WINDOW* window, size_t index, ScrollPosition *result = NULL);
virtual size_t GetEntryCount() = 0;
virtual EntryPtr GetEntry(size_t index) = 0;
virtual size_t GetEntryCount() = 0;
virtual EntryPtr GetEntry(size_t index) = 0;
protected:
void GetVisibleItems(size_t desired, std::deque<EntryPtr>& target, size_t& start);
protected:
void GetVisibleItems(size_t desired, std::deque<EntryPtr>& target, size_t& start);
size_t GetWidth() { return this->width; }
size_t GetHeight() { return this->height; }
size_t GetWidth() { return this->width; }
size_t GetHeight() { return this->height; }
private:
size_t width, height;
};
private:
size_t width, height;
};
}

View File

@ -7,6 +7,8 @@
#include <core/debug.h>
using namespace cursespp;
typedef IScrollAdapter::ScrollPosition ScrollPos;
ScrollableWindow::ScrollableWindow(IWindow *parent)

View File

@ -6,31 +6,33 @@
#include "IScrollable.h"
#include "IKeyHandler.h"
class ScrollableWindow : public IScrollable, public IKeyHandler, public Window {
public:
ScrollableWindow(IWindow *parent = NULL);
virtual ~ScrollableWindow();
namespace cursespp {
class ScrollableWindow : public IScrollable, public IKeyHandler, public Window {
public:
ScrollableWindow(IWindow *parent = NULL);
virtual ~ScrollableWindow();
virtual void Show();
virtual void SetSize(int width, int height);
virtual void Show();
virtual void SetSize(int width, int height);
virtual bool KeyPress(int64 ch);
virtual bool KeyPress(int64 ch);
virtual void ScrollToTop();
virtual void ScrollToBottom();
virtual void ScrollUp(int delta = 1);
virtual void ScrollDown(int delta = 1);
virtual void PageUp();
virtual void PageDown();
virtual void ScrollToTop();
virtual void ScrollToBottom();
virtual void ScrollUp(int delta = 1);
virtual void ScrollDown(int delta = 1);
virtual void PageUp();
virtual void PageDown();
protected:
virtual IScrollAdapter& GetScrollAdapter() = 0;
virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
virtual void OnAdapterChanged();
protected:
virtual IScrollAdapter& GetScrollAdapter() = 0;
virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
virtual void OnAdapterChanged();
size_t GetPreviousPageEntryIndex();
bool IsLastItemVisible();
size_t GetPreviousPageEntryIndex();
bool IsLastItemVisible();
private:
IScrollAdapter::ScrollPosition scrollPosition;
};
private:
IScrollAdapter::ScrollPosition scrollPosition;
};
}

View File

@ -6,6 +6,8 @@
#include <boost/algorithm/string.hpp>
#include <utf8/utf8/unchecked.h>
using namespace cursespp;
#define MAX_ENTRY_COUNT 0xffffffff
typedef IScrollAdapter::EntryPtr EntryPtr;

View File

@ -4,21 +4,23 @@
#include "ScrollAdapterBase.h"
#include <deque>
class SimpleScrollAdapter : public ScrollAdapterBase {
public:
SimpleScrollAdapter();
virtual ~SimpleScrollAdapter();
namespace cursespp {
class SimpleScrollAdapter : public ScrollAdapterBase {
public:
SimpleScrollAdapter();
virtual ~SimpleScrollAdapter();
virtual void AddEntry(EntryPtr entry);
virtual void SetMaxEntries(const size_t size = 500);
virtual void AddEntry(EntryPtr entry);
virtual void SetMaxEntries(const size_t size = 500);
virtual size_t GetEntryCount();
virtual EntryPtr GetEntry(size_t index);
virtual size_t GetEntryCount();
virtual EntryPtr GetEntry(size_t index);
private:
typedef std::deque<EntryPtr> EntryList;
typedef EntryList::iterator Iterator;
private:
typedef std::deque<EntryPtr> EntryList;
typedef EntryList::iterator Iterator;
EntryList entries;
size_t maxEntries;
};
EntryList entries;
size_t maxEntries;
};
}

View File

@ -2,6 +2,8 @@
#include "SingleLineEntry.h"
#include <boost/algorithm/string.hpp>
using namespace cursespp;
SingleLineEntry::SingleLineEntry(const std::string& value) {
this->value = value;
this->attrs = -1;

View File

@ -2,22 +2,24 @@
#include "IScrollAdapter.h"
class SingleLineEntry : public IScrollAdapter::IEntry {
public:
SingleLineEntry(const std::string& value);
namespace cursespp {
class SingleLineEntry : public IScrollAdapter::IEntry {
public:
SingleLineEntry(const std::string& value);
size_t GetIndex();
void SetIndex(size_t index);
void SetWidth(size_t width);
void SetAttrs(int64 attrs);
int64 GetAttrs();
size_t GetIndex();
void SetIndex(size_t index);
void SetWidth(size_t width);
void SetAttrs(int64 attrs);
int64 GetAttrs();
size_t GetLineCount();
std::string GetLine(size_t line);
std::string GetValue();
size_t GetLineCount();
std::string GetLine(size_t line);
std::string GetValue();
private:
size_t index, width;
std::string value;
int64 attrs;
};
private:
size_t index, width;
std::string value;
int64 attrs;
};
}

View File

@ -6,6 +6,8 @@
#include "Message.h"
#include "MessageQueue.h"
using namespace cursespp;
static int NEXT_ID = 0;
static bool drawPending = false;

View File

@ -3,70 +3,72 @@
#include "curses_config.h"
#include "IWindow.h"
class Window : public IWindow, public std::enable_shared_from_this<IWindow> {
public:
Window(IWindow* parent = NULL);
virtual ~Window();
namespace cursespp {
class Window : public IWindow, public std::enable_shared_from_this<IWindow> {
public:
Window(IWindow* parent = NULL);
virtual ~Window();
virtual void SetParent(IWindow* parent);
virtual void SetParent(IWindow* parent);
virtual void Show();
virtual void Hide();
virtual void Show();
virtual void Hide();
virtual void Repaint();
virtual void Repaint();
void SetFrameVisible(bool enabled);
bool IsFrameVisible();
void SetFrameVisible(bool enabled);
bool IsFrameVisible();
virtual void Focus();
virtual void Blur();
virtual void Focus();
virtual void Blur();
virtual void SetContentColor(int64 color);
virtual void SetFrameColor(int64 color);
virtual void SetSize(int width, int height);
virtual void SetPosition(int x, int y);
virtual void SetContentColor(int64 color);
virtual void SetFrameColor(int64 color);
virtual void SetSize(int width, int height);
virtual void SetPosition(int x, int y);
virtual int GetWidth() const;
virtual int GetHeight() const;
virtual int GetContentHeight() const;
virtual int GetContentWidth() const;
virtual int GetX() const;
virtual int GetY() const;
virtual int GetId() const;
virtual int GetWidth() const;
virtual int GetHeight() const;
virtual int GetContentHeight() const;
virtual int GetContentWidth() const;
virtual int GetX() const;
virtual int GetY() const;
virtual int GetId() const;
virtual void BringToTop();
virtual void SendToBottom();
virtual void BringToTop();
virtual void SendToBottom();
virtual void ProcessMessage(IMessage &message);
virtual bool IsAcceptingMessages();
virtual void ProcessMessage(IMessage &message);
virtual bool IsAcceptingMessages();
virtual WINDOW* GetFrame() const;
virtual WINDOW* GetContent() const;
virtual WINDOW* GetFrame() const;
virtual WINDOW* GetContent() const;
virtual int GetFocusOrder();
virtual void SetFocusOrder(int order = -1);
virtual int GetFocusOrder();
virtual void SetFocusOrder(int order = -1);
static void WriteToScreen();
static void WriteToScreen();
protected:
IWindow* GetParent() const;
void PostMessage(int messageType, int64 user1 = 0, int64 user2 = 0, int64 delay = 0);
void RemoveMessage(int messageType);
bool IsVisible();
void Create();
void Destroy();
void Clear();
protected:
IWindow* GetParent() const;
void PostMessage(int messageType, int64 user1 = 0, int64 user2 = 0, int64 delay = 0);
void RemoveMessage(int messageType);
bool IsVisible();
void Create();
void Destroy();
void Clear();
private:
IWindow* parent;
PANEL* framePanel;
WINDOW* frame;
PANEL* contentPanel;
WINDOW* content;
bool drawFrame;
bool isVisible;
int focusOrder;
int id;
int64 contentColor, frameColor;
int width, height, x, y;
};
private:
IWindow* parent;
PANEL* framePanel;
WINDOW* frame;
PANEL* contentPanel;
WINDOW* content;
bool drawFrame;
bool isVisible;
int focusOrder;
int id;
int64 contentColor, frameColor;
int width, height, x, y;
};
}

View File

@ -4,6 +4,8 @@
#include "WindowLayout.h"
#include "LayoutStack.h"
using namespace cursespp;
WindowLayout::WindowLayout(IWindowPtr window) {
this->window = window;
this->stack = 0;

View File

@ -2,37 +2,39 @@
#include "ILayout.h"
class WindowLayout : public ILayout, public std::enable_shared_from_this<ILayout> {
public:
WindowLayout(IWindowPtr window);
virtual ~WindowLayout();
namespace cursespp {
class WindowLayout : public ILayout, public std::enable_shared_from_this<ILayout> {
public:
WindowLayout(IWindowPtr window);
virtual ~WindowLayout();
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() { }
/* ILayout */
virtual IWindowPtr FocusNext();
virtual IWindowPtr FocusPrev();
virtual IWindowPtr GetFocus();
virtual ILayoutStack* GetLayoutStack();
virtual void SetLayoutStack(ILayoutStack* stack);
virtual void Layout() { }
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* IOrderable */
virtual void BringToTop();
virtual void SendToBottom();
/* IDisplayable */
virtual void Show();
virtual void Hide();
/* IDisplayable */
virtual void Show();
virtual void Hide();
/* IKeyHandler */
virtual bool KeyPress(int64 ch);
/* IKeyHandler */
virtual bool KeyPress(int64 ch);
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
/* IWindowGroup */
virtual bool AddWindow(IWindowPtr window);
virtual bool RemoveWindow(IWindowPtr window);
virtual size_t GetWindowCount();
virtual IWindowPtr GetWindowAt(size_t position);
private:
ILayoutStack* stack;
IWindowPtr window;
};
private:
ILayoutStack* stack;
IWindowPtr window;
};
}