diff --git a/higan/emulator/emulator.hpp b/higan/emulator/emulator.hpp index f6be2504..75af4a47 100755 --- a/higan/emulator/emulator.hpp +++ b/higan/emulator/emulator.hpp @@ -3,7 +3,7 @@ namespace Emulator { static const char Name[] = "higan"; - static const char Version[] = "092.02"; + static const char Version[] = "092.03"; static const char Author[] = "byuu"; static const char License[] = "GPLv3"; } diff --git a/higan/nall/Makefile b/higan/nall/Makefile index f422f49d..bc8ba566 100755 --- a/higan/nall/Makefile +++ b/higan/nall/Makefile @@ -38,7 +38,7 @@ ifeq ($(compiler),) ifeq ($(platform),win) compiler := g++ else ifeq ($(platform),osx) - compiler := g++-mp-4.7 + compiler := clang else compiler := g++-4.7 endif diff --git a/higan/nall/beat/delta.hpp b/higan/nall/beat/delta.hpp index ce120537..3fc400fa 100644 --- a/higan/nall/beat/delta.hpp +++ b/higan/nall/beat/delta.hpp @@ -97,7 +97,7 @@ bool bpsdelta::create(const string &filename, const string &metadata) { for(unsigned n = 0; n < markupSize; n++) write(metadata[n]); Node *sourceTree[65536], *targetTree[65536]; - for(unsigned n = 0; n < 65536; n++) sourceTree[n] = 0, targetTree[n] = 0; + for(unsigned n = 0; n < 65536; n++) sourceTree[n] = nullptr, targetTree[n] = nullptr; //source tree creation for(unsigned offset = 0; offset < sourceSize; offset++) { diff --git a/higan/nall/compositor.hpp b/higan/nall/compositor.hpp index 6b9245f6..c5aa8757 100755 --- a/higan/nall/compositor.hpp +++ b/higan/nall/compositor.hpp @@ -27,10 +27,10 @@ struct compositor { bool compositor::enabled_metacity() { FILE *fp = popen("gconftool-2 --get /apps/metacity/general/compositing_manager", "r"); - if(fp == 0) return false; + if(!fp) return false; char buffer[512]; - if(fgets(buffer, sizeof buffer, fp) == 0) return false; + if(!fgets(buffer, sizeof buffer, fp)) return false; if(!memcmp(buffer, "true", 4)) return true; return false; @@ -43,7 +43,7 @@ bool compositor::enable_metacity(bool status) { } else { fp = popen("gconftool-2 --set --type bool /apps/metacity/general/compositing_manager false", "r"); } - if(fp == 0) return false; + if(!fp) return false; pclose(fp); return true; } @@ -52,10 +52,10 @@ bool compositor::enable_metacity(bool status) { bool compositor::enabled_xfwm4() { FILE *fp = popen("xfconf-query -c xfwm4 -p '/general/use_compositing'", "r"); - if(fp == 0) return false; + if(!fp) return false; char buffer[512]; - if(fgets(buffer, sizeof buffer, fp) == 0) return false; + if(!fgets(buffer, sizeof buffer, fp)) return false; if(!memcmp(buffer, "true", 4)) return true; return false; @@ -68,7 +68,7 @@ bool compositor::enable_xfwm4(bool status) { } else { fp = popen("xfconf-query -c xfwm4 -p '/general/use_compositing' -t 'bool' -s 'false'", "r"); } - if(fp == 0) return false; + if(!fp) return false; pclose(fp); return true; } @@ -112,11 +112,11 @@ bool compositor::enable(bool status) { bool compositor::enabled() { HMODULE module = GetModuleHandleW(L"dwmapi"); - if(module == 0) module = LoadLibraryW(L"dwmapi"); - if(module == 0) return false; + if(module == nullptr) module = LoadLibraryW(L"dwmapi"); + if(module == nullptr) return false; auto pDwmIsCompositionEnabled = (HRESULT (WINAPI*)(BOOL*))GetProcAddress(module, "DwmIsCompositionEnabled"); - if(pDwmIsCompositionEnabled == 0) return false; + if(pDwmIsCompositionEnabled == nullptr) return false; BOOL result; if(pDwmIsCompositionEnabled(&result) != S_OK) return false; @@ -125,11 +125,11 @@ bool compositor::enabled() { bool compositor::enable(bool status) { HMODULE module = GetModuleHandleW(L"dwmapi"); - if(module == 0) module = LoadLibraryW(L"dwmapi"); - if(module == 0) return false; + if(module == nullptr) module = LoadLibraryW(L"dwmapi"); + if(module == nullptr) return false; auto pDwmEnableComposition = (HRESULT (WINAPI*)(UINT))GetProcAddress(module, "DwmEnableComposition"); - if(pDwmEnableComposition == 0) return false; + if(pDwmEnableComposition == nullptr) return false; if(pDwmEnableComposition(status) != S_OK) return false; return true; diff --git a/higan/nall/dl.hpp b/higan/nall/dl.hpp index 3bd7d4d2..4732918c 100755 --- a/higan/nall/dl.hpp +++ b/higan/nall/dl.hpp @@ -17,7 +17,8 @@ namespace nall { struct library { - bool opened() const { return handle; } + explicit operator bool() const { return open(); } + bool open() const { return handle; } bool open(const char*, const char* = ""); bool open_absolute(const char*); void* sym(const char*); @@ -48,7 +49,7 @@ namespace nall { } inline void* library::sym(const char *name) { - if(!handle) return 0; + if(!handle) return nullptr; return dlsym((void*)handle, name); } @@ -72,7 +73,7 @@ namespace nall { } inline void* library::sym(const char *name) { - if(!handle) return 0; + if(!handle) return nullptr; return dlsym((void*)handle, name); } @@ -96,7 +97,7 @@ namespace nall { } inline void* library::sym(const char *name) { - if(!handle) return 0; + if(!handle) return nullptr; return (void*)GetProcAddress((HMODULE)handle, name); } @@ -107,7 +108,8 @@ namespace nall { } #else inline bool library::open(const char*, const char*) { return false; } - inline void* library::sym(const char*) { return 0; } + inline bool library::open_absolute(const char*) { return false; } + inline void* library::sym(const char*) { return nullptr; } inline void library::close() {} #endif }; diff --git a/higan/nall/dsp/buffer.hpp b/higan/nall/dsp/buffer.hpp index 4386d0e9..19bc561d 100755 --- a/higan/nall/dsp/buffer.hpp +++ b/higan/nall/dsp/buffer.hpp @@ -1,16 +1,18 @@ #ifdef NALL_DSP_INTERNAL_HPP struct Buffer { - double **sample; - uint16_t rdoffset; - uint16_t wroffset; - unsigned channels; + double **sample = nullptr; + uint16_t rdoffset = 0; + uint16_t wroffset = 0; + unsigned channels = 0; void setChannels(unsigned channels) { - for(unsigned c = 0; c < this->channels; c++) { - if(sample[c]) delete[] sample[c]; + if(sample) { + for(unsigned c = 0; c < this->channels; c++) { + if(sample[c]) delete[] sample[c]; + } + delete[] sample; } - if(sample) delete[] sample; this->channels = channels; if(channels == 0) return; @@ -40,7 +42,6 @@ struct Buffer { } Buffer() { - channels = 0; } ~Buffer() { diff --git a/higan/nall/dsp/core.hpp b/higan/nall/dsp/core.hpp index a5b967b1..353f77d3 100755 --- a/higan/nall/dsp/core.hpp +++ b/higan/nall/dsp/core.hpp @@ -69,7 +69,7 @@ protected: real intensityInverse; } settings; - Resampler *resampler; + Resampler *resampler = nullptr; inline void write(real channel[]); #include "buffer.hpp" diff --git a/higan/nall/dsp/resample/lib/sinc.hpp b/higan/nall/dsp/resample/lib/sinc.hpp index 3e953679..67c793d6 100755 --- a/higan/nall/dsp/resample/lib/sinc.hpp +++ b/higan/nall/dsp/resample/lib/sinc.hpp @@ -584,7 +584,7 @@ void ResampleUtility::normalize(double* io, int size, double gain) void* ResampleUtility::make_aligned(void* ptr, unsigned boundary) { - unsigned char* null_ptr = (unsigned char *)NULL; + unsigned char* null_ptr = (unsigned char *)nullptr; unsigned char* uc_ptr = (unsigned char *)ptr; uc_ptr += (boundary - ((uc_ptr - null_ptr) & (boundary - 1))) & (boundary - 1); diff --git a/higan/nall/dsp/resample/sinc.hpp b/higan/nall/dsp/resample/sinc.hpp index a77a1eeb..64e247eb 100755 --- a/higan/nall/dsp/resample/sinc.hpp +++ b/higan/nall/dsp/resample/sinc.hpp @@ -39,7 +39,7 @@ void ResampleSinc::sample() { } ResampleSinc::ResampleSinc(DSP &dsp) : Resampler(dsp) { - for(unsigned n = 0; n < 8; n++) sinc_resampler[n] = 0; + for(unsigned n = 0; n < 8; n++) sinc_resampler[n] = nullptr; } void ResampleSinc::remakeSinc() { diff --git a/higan/nall/file.hpp b/higan/nall/file.hpp index 80b918a8..e51be466 100755 --- a/higan/nall/file.hpp +++ b/higan/nall/file.hpp @@ -264,6 +264,10 @@ namespace nall { return fp; } + explicit operator bool() const { + return open(); + } + bool open(const string &filename, mode mode_) { if(fp) return false; @@ -293,17 +297,14 @@ namespace nall { if(!fp) return; buffer_flush(); fclose(fp); - fp = 0; + fp = nullptr; } file() { - memset(buffer, 0, sizeof buffer); - buffer_offset = -1; //invalidate buffer - buffer_dirty = false; - fp = 0; - file_offset = 0; - file_size = 0; - file_mode = mode::read; + } + + file(const string &filename, mode mode_) { + open(filename, mode_); } ~file() { @@ -315,13 +316,13 @@ namespace nall { private: enum { buffer_size = 1 << 12, buffer_mask = buffer_size - 1 }; - char buffer[buffer_size]; - int buffer_offset; - bool buffer_dirty; - FILE *fp; - unsigned file_offset; - unsigned file_size; - mode file_mode; + char buffer[buffer_size] = {0}; + int buffer_offset = -1; //invalidate buffer + bool buffer_dirty = false; + FILE *fp = nullptr; + unsigned file_offset = 0; + unsigned file_size = 0; + mode file_mode = mode::read; void buffer_sync() { if(!fp) return; //file not open diff --git a/higan/nall/filemap.hpp b/higan/nall/filemap.hpp index f57d933c..f4875f24 100755 --- a/higan/nall/filemap.hpp +++ b/higan/nall/filemap.hpp @@ -22,14 +22,15 @@ namespace nall { public: enum class mode : unsigned { read, write, readwrite, writeread }; + explicit operator bool() const { return open(); } bool open() const { return p_open(); } bool open(const char *filename, mode mode_) { return p_open(filename, mode_); } void close() { return p_close(); } unsigned size() const { return p_size; } uint8_t* data() { return p_handle; } const uint8_t* data() const { return p_handle; } - filemap() : p_size(0), p_handle(0) { p_ctor(); } - filemap(const char *filename, mode mode_) : p_size(0), p_handle(0) { p_ctor(); p_open(filename, mode_); } + filemap() : p_size(0), p_handle(nullptr) { p_ctor(); } + filemap(const char *filename, mode mode_) : p_size(0), p_handle(nullptr) { p_ctor(); p_open(filename, mode_); } ~filemap() { p_dtor(); } private: @@ -49,7 +50,7 @@ namespace nall { bool p_open(const char *filename, mode mode_) { if(file::exists(filename) && file::size(filename) == 0) { - p_handle = 0; + p_handle = nullptr; p_size = 0; return true; } @@ -85,13 +86,13 @@ namespace nall { break; } - p_filehandle = CreateFileW(utf16_t(filename), desired_access, FILE_SHARE_READ, NULL, - creation_disposition, FILE_ATTRIBUTE_NORMAL, NULL); + p_filehandle = CreateFileW(utf16_t(filename), desired_access, FILE_SHARE_READ, nullptr, + creation_disposition, FILE_ATTRIBUTE_NORMAL, nullptr); if(p_filehandle == INVALID_HANDLE_VALUE) return false; - p_size = GetFileSize(p_filehandle, NULL); + p_size = GetFileSize(p_filehandle, nullptr); - p_maphandle = CreateFileMapping(p_filehandle, NULL, flprotect, 0, p_size, NULL); + p_maphandle = CreateFileMapping(p_filehandle, nullptr, flprotect, 0, p_size, nullptr); if(p_maphandle == INVALID_HANDLE_VALUE) { CloseHandle(p_filehandle); p_filehandle = INVALID_HANDLE_VALUE; @@ -105,7 +106,7 @@ namespace nall { void p_close() { if(p_handle) { UnmapViewOfFile(p_handle); - p_handle = 0; + p_handle = nullptr; } if(p_maphandle != INVALID_HANDLE_VALUE) { @@ -141,7 +142,7 @@ namespace nall { bool p_open(const char *filename, mode mode_) { if(file::exists(filename) && file::size(filename) == 0) { - p_handle = 0; + p_handle = nullptr; p_size = 0; return true; } @@ -175,9 +176,9 @@ namespace nall { fstat(p_fd, &p_stat); p_size = p_stat.st_size; - p_handle = (uint8_t*)mmap(0, p_size, mmap_flags, MAP_SHARED, p_fd, 0); + p_handle = (uint8_t*)mmap(nullptr, p_size, mmap_flags, MAP_SHARED, p_fd, 0); if(p_handle == MAP_FAILED) { - p_handle = 0; + p_handle = nullptr; ::close(p_fd); p_fd = -1; return false; @@ -189,7 +190,7 @@ namespace nall { void p_close() { if(p_handle) { munmap(p_handle, p_size); - p_handle = 0; + p_handle = nullptr; } if(p_fd >= 0) { diff --git a/higan/nall/function.hpp b/higan/nall/function.hpp index ca574b8c..3fbb337a 100755 --- a/higan/nall/function.hpp +++ b/higan/nall/function.hpp @@ -34,7 +34,7 @@ namespace nall { }; public: - operator bool() const { return callback; } + explicit operator bool() const { return callback; } R operator()(P... p) const { return (*callback)(std::forward

(p)...); } void reset() { if(callback) { delete callback; callback = nullptr; } } diff --git a/higan/nall/http.hpp b/higan/nall/http.hpp index 48aeb097..f7700cea 100755 --- a/higan/nall/http.hpp +++ b/higan/nall/http.hpp @@ -24,7 +24,7 @@ struct http { string header; inline void download(const string &path, uint8_t *&data, unsigned &size) { - data = 0; + data = nullptr; size = 0; send({ @@ -147,7 +147,7 @@ struct http { inline void disconnect() { close(serversocket); freeaddrinfo(serverinfo); - serverinfo = 0; + serverinfo = nullptr; serversocket = -1; } diff --git a/higan/nall/inflate.hpp b/higan/nall/inflate.hpp index cbbf6d29..8e75ce76 100755 --- a/higan/nall/inflate.hpp +++ b/higan/nall/inflate.hpp @@ -89,7 +89,7 @@ inline int stored(state *s) { ) return 2; if(s->incnt + len > s->inlen) return 2; - if(s->out != 0) { + if(s->out != nullptr) { if(s->outcnt + len > s->outlen) return 1; while(len--) s->out[s->outcnt++] = s->in[s->incnt++]; } else { @@ -186,7 +186,7 @@ inline int codes(state *s, huffman *lencode, huffman *distcode) { symbol = decode(s, lencode); if(symbol < 0) return symbol; if(symbol < 256) { - if(s->out != 0) { + if(s->out != nullptr) { if(s->outcnt == s->outlen) return 1; s->out[s->outcnt] = symbol; } @@ -203,7 +203,7 @@ inline int codes(state *s, huffman *lencode, huffman *distcode) { if(dist > s->outcnt) return -11; #endif - if(s->out != 0) { + if(s->out != nullptr) { if(s->outcnt + len > s->outlen) return 1; while(len--) { s->out[s->outcnt] = diff --git a/higan/nall/lzss.hpp b/higan/nall/lzss.hpp index fb3e0ba6..d595f911 100755 --- a/higan/nall/lzss.hpp +++ b/higan/nall/lzss.hpp @@ -61,7 +61,7 @@ bool lzss::compress(const string &filename) { if(targetFile.open(filename, file::mode::write) == false) return false; for(unsigned n = 0; n < 32; n += 8) targetFile.write(sourceSize >> n); - for(unsigned n = 0; n < 65536; n++) tree[n] = 0; + for(unsigned n = 0; n < 65536; n++) tree[n] = nullptr; uint8_t buffer[25]; unsigned sourceOffset = 0; @@ -81,7 +81,7 @@ bool lzss::compress(const string &filename) { while(node) { if(node->offset < sourceOffset - 0x80000) { //out-of-range: all subsequent nodes will also be, so free up their memory - if(node->next) { delete node->next; node->next = 0; } + if(node->next) { delete node->next; node->next = nullptr; } break; } diff --git a/higan/nall/png.hpp b/higan/nall/png.hpp index f5ebaab4..ef864228 100755 --- a/higan/nall/png.hpp +++ b/higan/nall/png.hpp @@ -69,7 +69,7 @@ bool png::decode(const uint8_t *sourceData, unsigned sourceSize) { if(read(sourceData + 0, 4) != 0x89504e47) return false; if(read(sourceData + 4, 4) != 0x0d0a1a0a) return false; - uint8_t *compressedData = 0; + uint8_t *compressedData = nullptr; unsigned compressedSize = 0; unsigned offset = 8; @@ -150,7 +150,7 @@ bool png::decode(const uint8_t *sourceData, unsigned sourceSize) { if(filter(data, interlacedData, info.width, info.height) == false) { delete[] interlacedData; delete[] data; - data = 0; + data = nullptr; return false; } } else { @@ -159,7 +159,7 @@ bool png::decode(const uint8_t *sourceData, unsigned sourceSize) { if(deinterlace(passData, pass) == false) { delete[] interlacedData; delete[] data; - data = 0; + data = nullptr; return false; } } @@ -172,13 +172,13 @@ bool png::decode(const uint8_t *sourceData, unsigned sourceSize) { unsigned png::interlace(unsigned pass, unsigned index) { static const unsigned data[7][4] = { //x-distance, y-distance, x-origin, y-origin - { 8, 8, 0, 0 }, - { 8, 8, 4, 0 }, - { 4, 8, 0, 4 }, - { 4, 4, 2, 0 }, - { 2, 4, 0, 2 }, - { 2, 2, 1, 0 }, - { 1, 2, 0, 1 }, + {8, 8, 0, 0}, + {8, 8, 4, 0}, + {4, 8, 0, 4}, + {4, 4, 2, 0}, + {2, 4, 0, 2}, + {2, 2, 1, 0}, + {1, 2, 0, 1}, }; return data[pass][index]; } diff --git a/higan/nall/serializer.hpp b/higan/nall/serializer.hpp index fcb39456..a616cbdf 100755 --- a/higan/nall/serializer.hpp +++ b/higan/nall/serializer.hpp @@ -86,7 +86,7 @@ namespace nall { return *this; } - serializer(const serializer &s) : idata(0) { + serializer(const serializer &s) : idata(nullptr) { operator=(s); } @@ -99,7 +99,7 @@ namespace nall { isize = s.isize; icapacity = s.icapacity; - s.idata = 0; + s.idata = nullptr; return *this; } @@ -110,7 +110,7 @@ namespace nall { //construction serializer() { imode = Size; - idata = 0; + idata = nullptr; isize = 0; icapacity = 0; } diff --git a/higan/nall/string/base.hpp b/higan/nall/string/base.hpp index d5f85ca4..7a1e55fb 100755 --- a/higan/nall/string/base.hpp +++ b/higan/nall/string/base.hpp @@ -22,6 +22,7 @@ namespace nall { }; struct string { + //deprecated: use string text = file::read(filename); inline static string read(const string &filename); inline static string date(); @@ -71,7 +72,7 @@ namespace nall { template inline string& ltrim(const char *key = " "); template inline string& rtrim(const char *key = " "); - template inline string& trim(const char *key = " ", const char *rkey = 0); + template inline string& trim(const char *key = " ", const char *rkey = nullptr); inline string& strip(); inline optional position(const char *key) const; @@ -79,6 +80,7 @@ namespace nall { inline optional qposition(const char *key) const; inline optional iqposition(const char *key) const; + inline explicit operator bool() const; inline operator const char*() const; inline char* operator()(); inline char& operator[](int); @@ -197,7 +199,7 @@ namespace nall { //trim.hpp template inline char* ltrim(char *str, const char *key = " "); template inline char* rtrim(char *str, const char *key = " "); - template inline char* trim(char *str, const char *key = " ", const char *rkey = 0); + template inline char* trim(char *str, const char *key = " ", const char *rkey = nullptr); inline char* strip(char *s); //utility.hpp diff --git a/higan/nall/string/cast.hpp b/higan/nall/string/cast.hpp index 7c7e276b..eee42177 100755 --- a/higan/nall/string/cast.hpp +++ b/higan/nall/string/cast.hpp @@ -116,6 +116,32 @@ template<> struct stringify { stringify(long double value) { fp(data, value); } }; +// arrays + +template<> struct stringify> { + char *text; + operator const char*() const { return text; } + stringify(vector value) { + text = new char[value.size() + 1](); + memcpy(text, value.data(), value.size()); + } + ~stringify() { + delete[] text; + } +}; + +template<> struct stringify&> { + char *text; + operator const char*() const { return text; } + stringify(const vector &value) { + text = new char[value.size() + 1](); + memcpy(text, value.data(), value.size()); + } + ~stringify() { + delete[] text; + } +}; + // strings template<> struct stringify { diff --git a/higan/nall/string/convert.hpp b/higan/nall/string/convert.hpp index f5a2a780..27448770 100755 --- a/higan/nall/string/convert.hpp +++ b/higan/nall/string/convert.hpp @@ -3,7 +3,7 @@ namespace nall { char* strlower(char *str) { - if(!str) return 0; + if(!str) return nullptr; int i = 0; while(str[i]) { str[i] = chrlower(str[i]); @@ -13,7 +13,7 @@ char* strlower(char *str) { } char* strupper(char *str) { - if(!str) return 0; + if(!str) return nullptr; int i = 0; while(str[i]) { str[i] = chrupper(str[i]); @@ -23,7 +23,7 @@ char* strupper(char *str) { } char* qstrlower(char *s) { - if(!s) return 0; + if(!s) return nullptr; bool quoted = false; while(*s) { if(*s == '\"' || *s == '\'') quoted ^= 1; @@ -33,7 +33,7 @@ char* qstrlower(char *s) { } char* qstrupper(char *s) { - if(!s) return 0; + if(!s) return nullptr; bool quoted = false; while(*s) { if(*s == '\"' || *s == '\'') quoted ^= 1; diff --git a/higan/nall/string/core.hpp b/higan/nall/string/core.hpp index 64c9250d..043c575b 100755 --- a/higan/nall/string/core.hpp +++ b/higan/nall/string/core.hpp @@ -55,6 +55,10 @@ string& string::append_(const char *s) { return *this; } +string::operator bool() const { + return !empty(); +} + string::operator const char*() const { return data; } diff --git a/higan/nall/string/datetime.hpp b/higan/nall/string/datetime.hpp index 5382fdfd..438631bf 100644 --- a/higan/nall/string/datetime.hpp +++ b/higan/nall/string/datetime.hpp @@ -3,7 +3,7 @@ namespace nall { string string::date() { - time_t timestamp = ::time(0); + time_t timestamp = ::time(nullptr); tm *info = localtime(×tamp); return { decimal<4, '0'>(1900 + info->tm_year), "-", @@ -13,7 +13,7 @@ string string::date() { } string string::time() { - time_t timestamp = ::time(0); + time_t timestamp = ::time(nullptr); tm *info = localtime(×tamp); return { decimal<2, '0'>(info->tm_hour), ":", diff --git a/higan/nall/string/markup/bml.hpp b/higan/nall/string/markup/bml.hpp index 338ca406..26bf6685 100644 --- a/higan/nall/string/markup/bml.hpp +++ b/higan/nall/string/markup/bml.hpp @@ -80,7 +80,7 @@ protected: parseName(p); parseData(p); parseAttributes(p); - if(*p++ != '\n') throw "Missing line feed"; + if(*p && *p++ != '\n') throw "Missing line feed"; while(*p) { if(*p == '\n') { p++; continue; } diff --git a/higan/nall/string/platform.hpp b/higan/nall/string/platform.hpp index 90b6d6b8..0129f4d2 100755 --- a/higan/nall/string/platform.hpp +++ b/higan/nall/string/platform.hpp @@ -39,7 +39,7 @@ string userpath() { string result; #ifdef _WIN32 wchar_t path[PATH_MAX] = L""; - SHGetFolderPathW(0, CSIDL_PROFILE | CSIDL_FLAG_CREATE, 0, 0, path); + SHGetFolderPathW(nullptr, CSIDL_PROFILE | CSIDL_FLAG_CREATE, nullptr, 0, path); result = (const char*)utf8_t(path); result.transform("\\", "/"); #else @@ -59,7 +59,7 @@ string configpath() { string result; #ifdef _WIN32 wchar_t path[PATH_MAX] = L""; - SHGetFolderPathW(0, CSIDL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, path); + SHGetFolderPathW(nullptr, CSIDL_APPDATA | CSIDL_FLAG_CREATE, nullptr, 0, path); result = (const char*)utf8_t(path); result.transform("\\", "/"); #else diff --git a/higan/nall/string/utility.hpp b/higan/nall/string/utility.hpp index 657383f8..2379e7fb 100755 --- a/higan/nall/string/utility.hpp +++ b/higan/nall/string/utility.hpp @@ -232,7 +232,7 @@ unsigned fp(char *str, long double value) { string fp(long double value) { string temp; - temp.reserve(fp(0, value)); + temp.reserve(fp(nullptr, value)); fp(temp(), value); return temp; } diff --git a/higan/nall/string/wildcard.hpp b/higan/nall/string/wildcard.hpp index 9d2359d5..ea11490a 100755 --- a/higan/nall/string/wildcard.hpp +++ b/higan/nall/string/wildcard.hpp @@ -3,7 +3,7 @@ namespace nall { bool wildcard(const char *s, const char *p) { - const char *cp = 0, *mp = 0; + const char *cp = nullptr, *mp = nullptr; while(*s && *p != '*') { if(*p != '?' && *s != *p) return false; p++, s++; @@ -23,7 +23,7 @@ bool wildcard(const char *s, const char *p) { } bool iwildcard(const char *s, const char *p) { - const char *cp = 0, *mp = 0; + const char *cp = nullptr, *mp = nullptr; while(*s && *p != '*') { if(*p != '?' && chrlower(*s) != chrlower(*p)) return false; p++, s++; diff --git a/higan/nall/thread.hpp b/higan/nall/thread.hpp index de894f2d..2ac730a0 100644 --- a/higan/nall/thread.hpp +++ b/higan/nall/thread.hpp @@ -14,7 +14,7 @@ namespace nall { struct thread { thread(function entryPoint) : entryPoint(entryPoint), completed(false), dead(false) { initialize(); - pthread_create(&pthread, NULL, thread_entry_point, (void*)this); + pthread_create(&pthread, nullptr, thread_entry_point, (void*)this); } ~thread() { @@ -28,7 +28,7 @@ namespace nall { void join() { if(dead) return; dead = true; - pthread_join(pthread, NULL); + pthread_join(pthread, nullptr); } static bool primary() { @@ -59,7 +59,7 @@ namespace nall { thread *context = (thread*)parameter; context->entryPoint(); context->completed = true; - pthread_exit(0); + pthread_exit(nullptr); } } #elif defined(PLATFORM_WIN) @@ -69,7 +69,7 @@ namespace nall { struct thread { thread(function entryPoint) : entryPoint(entryPoint), completed(false), dead(false) { initialize(); - hthread = CreateThread(NULL, 0, thread_entry_point, (void*)this, 0, NULL); + hthread = CreateThread(nullptr, 0, thread_entry_point, (void*)this, 0, nullptr); } ~thread() { diff --git a/higan/nall/vector.hpp b/higan/nall/vector.hpp index 6818c69d..ea714b7b 100755 --- a/higan/nall/vector.hpp +++ b/higan/nall/vector.hpp @@ -21,7 +21,7 @@ namespace nall { unsigned objectsize; public: - operator bool() const { return pool; } + explicit operator bool() const { return pool; } T* data() { return pool; } const T* data() const { return pool; } diff --git a/higan/nall/windows/guid.hpp b/higan/nall/windows/guid.hpp index 386cfc75..adee891d 100755 --- a/higan/nall/windows/guid.hpp +++ b/higan/nall/windows/guid.hpp @@ -9,7 +9,7 @@ namespace nall { //generate unique GUID inline string guid() { random_lfsr lfsr; - lfsr.seed(time(0)); + lfsr.seed(time(nullptr)); for(unsigned n = 0; n < 256; n++) lfsr(); string output; diff --git a/higan/nall/windows/registry.hpp b/higan/nall/windows/registry.hpp index 0774e04a..cb035e19 100755 --- a/higan/nall/windows/registry.hpp +++ b/higan/nall/windows/registry.hpp @@ -31,7 +31,7 @@ struct registry { if(RegOpenKeyExW(rootKey, utf16_t(path), 0, NWR_FLAGS | KEY_READ, &handle) == ERROR_SUCCESS) { wchar_t data[NWR_SIZE] = L""; DWORD size = NWR_SIZE * sizeof(wchar_t); - LONG result = RegQueryValueExW(handle, utf16_t(node), NULL, NULL, (LPBYTE)&data, (LPDWORD)&size); + LONG result = RegQueryValueExW(handle, utf16_t(node), nullptr, nullptr, (LPBYTE)&data, (LPDWORD)&size); RegCloseKey(handle); if(result == ERROR_SUCCESS) return true; } @@ -46,7 +46,7 @@ struct registry { if(RegOpenKeyExW(rootKey, utf16_t(path), 0, NWR_FLAGS | KEY_READ, &handle) == ERROR_SUCCESS) { wchar_t data[NWR_SIZE] = L""; DWORD size = NWR_SIZE * sizeof(wchar_t); - LONG result = RegQueryValueExW(handle, utf16_t(node), NULL, NULL, (LPBYTE)&data, (LPDWORD)&size); + LONG result = RegQueryValueExW(handle, utf16_t(node), nullptr, nullptr, (LPBYTE)&data, (LPDWORD)&size); RegCloseKey(handle); if(result == ERROR_SUCCESS) return (const char*)utf8_t(data); } @@ -60,7 +60,7 @@ struct registry { DWORD disposition; for(unsigned n = 0; n < part.size(); n++) { path.append(part[n]); - if(RegCreateKeyExW(rootKey, utf16_t(path), 0, NULL, 0, NWR_FLAGS | KEY_ALL_ACCESS, NULL, &handle, &disposition) == ERROR_SUCCESS) { + if(RegCreateKeyExW(rootKey, utf16_t(path), 0, nullptr, 0, NWR_FLAGS | KEY_ALL_ACCESS, nullptr, &handle, &disposition) == ERROR_SUCCESS) { if(n == part.size() - 1) { RegSetValueExW(handle, utf16_t(node), 0, REG_SZ, (BYTE*)(wchar_t*)utf16_t(data), (data.length() + 1) * sizeof(wchar_t)); } @@ -86,17 +86,17 @@ struct registry { string path = part.concatenate("\\"); if(RegOpenKeyExW(rootKey, utf16_t(path), 0, NWR_FLAGS | KEY_READ, &handle) == ERROR_SUCCESS) { DWORD folders, nodes; - RegQueryInfoKey(handle, NULL, NULL, NULL, &folders, NULL, NULL, &nodes, NULL, NULL, NULL, NULL); + RegQueryInfoKey(handle, nullptr, nullptr, nullptr, &folders, nullptr, nullptr, &nodes, nullptr, nullptr, nullptr, nullptr); for(unsigned n = 0; n < folders; n++) { wchar_t name[NWR_SIZE] = L""; DWORD size = NWR_SIZE * sizeof(wchar_t); - RegEnumKeyEx(handle, n, (wchar_t*)&name, &size, NULL, NULL, NULL, NULL); + RegEnumKeyEx(handle, n, (wchar_t*)&name, &size, nullptr, nullptr, nullptr, nullptr); result.append({(const char*)utf8_t(name), "/"}); } for(unsigned n = 0; n < nodes; n++) { wchar_t name[NWR_SIZE] = L""; DWORD size = NWR_SIZE * sizeof(wchar_t); - RegEnumValueW(handle, n, (wchar_t*)&name, &size, NULL, NULL, NULL, NULL); + RegEnumValueW(handle, n, (wchar_t*)&name, &size, nullptr, nullptr, nullptr, nullptr); result.append((const char*)utf8_t(name)); } RegCloseKey(handle); @@ -111,7 +111,7 @@ private: if(name == "HKCU") return HKEY_CURRENT_USER; if(name == "HKLM") return HKEY_LOCAL_MACHINE; if(name == "HKU" ) return HKEY_USERS; - return NULL; + return nullptr; } }; diff --git a/higan/nall/windows/utf8.hpp b/higan/nall/windows/utf8.hpp index b1374943..05f89660 100755 --- a/higan/nall/windows/utf8.hpp +++ b/higan/nall/windows/utf8.hpp @@ -30,7 +30,7 @@ namespace nall { utf16_t(const char *s = "") { if(!s) s = ""; - unsigned length = MultiByteToWideChar(CP_UTF8, 0, s, -1, 0, 0); + unsigned length = MultiByteToWideChar(CP_UTF8, 0, s, -1, nullptr, 0); buffer = new wchar_t[length + 1](); MultiByteToWideChar(CP_UTF8, 0, s, -1, buffer, length); } @@ -56,9 +56,9 @@ namespace nall { utf8_t(const wchar_t *s = L"") { if(!s) s = L""; - unsigned length = WideCharToMultiByte(CP_UTF8, 0, s, -1, 0, 0, (const char*)0, (BOOL*)0); + unsigned length = WideCharToMultiByte(CP_UTF8, 0, s, -1, nullptr, 0, nullptr, nullptr); buffer = new char[length + 1](); - WideCharToMultiByte(CP_UTF8, 0, s, -1, buffer, length, (const char*)0, (BOOL*)0); + WideCharToMultiByte(CP_UTF8, 0, s, -1, buffer, length, nullptr, nullptr); } ~utf8_t() { diff --git a/higan/nall/zip.hpp b/higan/nall/zip.hpp index 0a73ccdd..2cc673ce 100755 --- a/higan/nall/zip.hpp +++ b/higan/nall/zip.hpp @@ -11,7 +11,7 @@ namespace nall { struct zip { zip(const string &filename) { fp.open(filename, file::mode::write); - time_t currentTime = time(0); + time_t currentTime = time(nullptr); tm *info = localtime(¤tTime); dosTime = (info->tm_hour << 11) | (info->tm_min << 5) | (info->tm_sec >> 1); dosDate = ((info->tm_year - 80) << 9) | ((1 + info->tm_mon) << 5) + (info->tm_mday); diff --git a/higan/phoenix/cocoa/action/action.cpp b/higan/phoenix/cocoa/action/action.cpp new file mode 100644 index 00000000..41578414 --- /dev/null +++ b/higan/phoenix/cocoa/action/action.cpp @@ -0,0 +1,21 @@ +namespace phoenix { + +void pAction::setEnabled(bool enabled) { + @autoreleasepool { + [cocoaAction setEnabled:enabled]; + } +} + +void pAction::setVisible(bool visible) { + @autoreleasepool { + [cocoaAction setHidden:!visible]; + } +} + +void pAction::constructor() { +} + +void pAction::destructor() { +} + +} diff --git a/higan/phoenix/cocoa/action/action.hpp b/higan/phoenix/cocoa/action/action.hpp new file mode 100644 index 00000000..f8a7325c --- /dev/null +++ b/higan/phoenix/cocoa/action/action.hpp @@ -0,0 +1,15 @@ +namespace phoenix { + +struct pAction : public pObject { + Action &action; + NSMenuItem *cocoaAction; + + void setEnabled(bool enabled); + void setVisible(bool visible); + + pAction(Action &action) : pObject(action), action(action) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/action/check-item.cpp b/higan/phoenix/cocoa/action/check-item.cpp new file mode 100644 index 00000000..57c2ef0f --- /dev/null +++ b/higan/phoenix/cocoa/action/check-item.cpp @@ -0,0 +1,55 @@ +@implementation CocoaCheckItem : NSMenuItem + +-(id) initWith :(phoenix::CheckItem&)checkItemReference { + if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) { + checkItem = &checkItemReference; + + [self setTarget:self]; + } + return self; +} + +-(void) activate { + checkItem->state.checked = !checkItem->state.checked; + auto state = checkItem->state.checked ? NSOnState : NSOffState; + [self setState:state]; + if(checkItem->onToggle) checkItem->onToggle(); +} + +@end + +namespace phoenix { + +bool pCheckItem::checked() { + @autoreleasepool { + return [cocoaAction state] != NSOffState; + } +} + +void pCheckItem::setChecked(bool checked) { + @autoreleasepool { + auto state = checked ? NSOnState : NSOffState; + [cocoaAction setState:state]; + } +} + +void pCheckItem::setText(const string &text) { + @autoreleasepool { + [cocoaAction setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pCheckItem::constructor() { + @autoreleasepool { + cocoaAction = cocoaCheckItem = [[CocoaCheckItem alloc] initWith:checkItem]; + setText(checkItem.state.text); + } +} + +void pCheckItem::destructor() { + @autoreleasepool { + [cocoaAction release]; + } +} + +} diff --git a/higan/phoenix/cocoa/action/check-item.hpp b/higan/phoenix/cocoa/action/check-item.hpp new file mode 100644 index 00000000..b3db94e5 --- /dev/null +++ b/higan/phoenix/cocoa/action/check-item.hpp @@ -0,0 +1,24 @@ +@interface CocoaCheckItem : NSMenuItem { +@public + phoenix::CheckItem *checkItem; +} +-(id) initWith :(phoenix::CheckItem&)checkItem; +-(void) activate; +@end + +namespace phoenix { + +struct pCheckItem : public pAction { + CheckItem &checkItem; + CocoaCheckItem *cocoaCheckItem; + + bool checked(); + void setChecked(bool checked); + void setText(const string &text); + + pCheckItem(CheckItem &checkItem) : pAction(checkItem), checkItem(checkItem) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/action/item.cpp b/higan/phoenix/cocoa/action/item.cpp new file mode 100644 index 00000000..5ceea8ea --- /dev/null +++ b/higan/phoenix/cocoa/action/item.cpp @@ -0,0 +1,45 @@ +@implementation CocoaItem : NSMenuItem + +-(id) initWith :(phoenix::Item&)itemReference { + if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) { + item = &itemReference; + + [self setTarget:self]; + } + return self; +} + +-(void) activate { + if(item->onActivate) item->onActivate(); +} + +@end + +namespace phoenix { + +void pItem::setImage(const image &image) { + @autoreleasepool { + unsigned size = 15; //there is no API to retrieve the optimal size + [cocoaAction setImage:NSMakeImage(image, size, size)]; + } +} + +void pItem::setText(const string &text) { + @autoreleasepool { + [cocoaAction setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pItem::constructor() { + @autoreleasepool { + cocoaAction = cocoaItem = [[CocoaItem alloc] initWith:item]; + } +} + +void pItem::destructor() { + @autoreleasepool { + [cocoaAction release]; + } +} + +} diff --git a/higan/phoenix/cocoa/action/item.hpp b/higan/phoenix/cocoa/action/item.hpp new file mode 100644 index 00000000..44ca7727 --- /dev/null +++ b/higan/phoenix/cocoa/action/item.hpp @@ -0,0 +1,23 @@ +@interface CocoaItem : NSMenuItem { +@public + phoenix::Item *item; +} +-(id) initWith :(phoenix::Item&)item; +-(void) activate; +@end + +namespace phoenix { + +struct pItem : public pAction { + Item &item; + CocoaItem *cocoaItem; + + void setImage(const image &image); + void setText(const string &text); + + pItem(Item &item) : pAction(item), item(item) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/action/menu.cpp b/higan/phoenix/cocoa/action/menu.cpp new file mode 100644 index 00000000..3ce66289 --- /dev/null +++ b/higan/phoenix/cocoa/action/menu.cpp @@ -0,0 +1,61 @@ +@implementation CocoaMenu : NSMenuItem + +-(id) initWith :(phoenix::Menu&)menuReference { + if(self = [super initWithTitle:@"" action:nil keyEquivalent:@""]) { + menu = &menuReference; + + cocoaMenu = [[NSMenu alloc] initWithTitle:@""]; + [self setSubmenu:cocoaMenu]; + } + return self; +} + +-(NSMenu*) cocoaMenu { + return cocoaMenu; +} + +@end + +namespace phoenix { + +void pMenu::append(Action &action) { + @autoreleasepool { + [[cocoaAction cocoaMenu] addItem:action.p.cocoaAction]; + } +} + +void pMenu::remove(Action &action) { + @autoreleasepool { + [[cocoaAction cocoaMenu] removeItem:action.p.cocoaAction]; + } +} + +void pMenu::setImage(const image &image) { + @autoreleasepool { + unsigned size = 15; //there is no API to retrieve the optimal size + [cocoaAction setImage:NSMakeImage(image, size, size)]; + } +} + +void pMenu::setText(const string &text) { + @autoreleasepool { + [[cocoaAction cocoaMenu] setTitle:[NSString stringWithUTF8String:text]]; + [cocoaAction setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pMenu::constructor() { + @autoreleasepool { + cocoaAction = cocoaMenu = [[CocoaMenu alloc] initWith:menu]; + setText(menu.state.text); + } +} + +void pMenu::destructor() { + @autoreleasepool { + [[cocoaAction cocoaMenu] release]; + [cocoaAction release]; + } +} + +} diff --git a/higan/phoenix/cocoa/action/menu.hpp b/higan/phoenix/cocoa/action/menu.hpp new file mode 100644 index 00000000..51b3bf63 --- /dev/null +++ b/higan/phoenix/cocoa/action/menu.hpp @@ -0,0 +1,26 @@ +@interface CocoaMenu : NSMenuItem { +@public + phoenix::Menu *menu; + NSMenu *cocoaMenu; +} +-(id) initWith :(phoenix::Menu&)menu; +-(NSMenu*) cocoaMenu; +@end + +namespace phoenix { + +struct pMenu : public pAction { + Menu &menu; + CocoaMenu *cocoaMenu; + + void append(Action &action); + void remove(Action &action); + void setImage(const image &image); + void setText(const string &text); + + pMenu(Menu &menu) : pAction(menu), menu(menu) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/action/radio-item.cpp b/higan/phoenix/cocoa/action/radio-item.cpp new file mode 100644 index 00000000..2fa3f207 --- /dev/null +++ b/higan/phoenix/cocoa/action/radio-item.cpp @@ -0,0 +1,59 @@ +@implementation CocoaRadioItem : NSMenuItem + +-(id) initWith :(phoenix::RadioItem&)radioItemReference { + if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) { + radioItem = &radioItemReference; + + [self setTarget:self]; + [self setOnStateImage:[NSImage imageNamed:@"NSMenuRadio"]]; + } + return self; +} + +-(void) activate { + radioItem->setChecked(); + if(radioItem->onActivate) radioItem->onActivate(); +} + +@end + +namespace phoenix { + +bool pRadioItem::checked() { + @autoreleasepool { + return [cocoaAction state] != NSOffState; + } +} + +void pRadioItem::setChecked() { + @autoreleasepool { + for(auto &item : radioItem.state.group) { + auto state = (&item == &radioItem) ? NSOnState : NSOffState; + [item.p.cocoaAction setState:state]; + } + } +} + +void pRadioItem::setGroup(const set &group) { +} + +void pRadioItem::setText(const string &text) { + @autoreleasepool { + [cocoaAction setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pRadioItem::constructor() { + @autoreleasepool { + cocoaAction = cocoaRadioItem = [[CocoaRadioItem alloc] initWith:radioItem]; + setText(radioItem.state.text); + } +} + +void pRadioItem::destructor() { + @autoreleasepool { + [cocoaAction release]; + } +} + +} diff --git a/higan/phoenix/cocoa/action/radio-item.hpp b/higan/phoenix/cocoa/action/radio-item.hpp new file mode 100644 index 00000000..41d16669 --- /dev/null +++ b/higan/phoenix/cocoa/action/radio-item.hpp @@ -0,0 +1,25 @@ +@interface CocoaRadioItem : NSMenuItem { +@public + phoenix::RadioItem *radioItem; +} +-(id) initWith :(phoenix::RadioItem&)radioItem; +-(void) activate; +@end + +namespace phoenix { + +struct pRadioItem : public pAction { + RadioItem &radioItem; + CocoaRadioItem *cocoaRadioItem; + + bool checked(); + void setChecked(); + void setGroup(const set &group); + void setText(const string &text); + + pRadioItem(RadioItem &radioItem) : pAction(radioItem), radioItem(radioItem) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/action/separator.cpp b/higan/phoenix/cocoa/action/separator.cpp new file mode 100644 index 00000000..3b418389 --- /dev/null +++ b/higan/phoenix/cocoa/action/separator.cpp @@ -0,0 +1,26 @@ +@implementation CocoaSeparator : NSMenuItem + +-(id) initWith :(phoenix::Separator&)separatorReference { + if(self = [super separatorItem]) { + separator = &separatorReference; + } + return self; +} + +@end + +namespace phoenix { + +void pSeparator::constructor() { + @autoreleasepool { + cocoaAction = cocoaSeparator = [[CocoaSeparator alloc] initWith:separator]; + } +} + +void pSeparator::destructor() { + @autoreleasepool { + [cocoaAction release]; + } +} + +} diff --git a/higan/phoenix/cocoa/action/separator.hpp b/higan/phoenix/cocoa/action/separator.hpp new file mode 100644 index 00000000..e232b157 --- /dev/null +++ b/higan/phoenix/cocoa/action/separator.hpp @@ -0,0 +1,19 @@ +@interface CocoaSeparator : NSMenuItem { +@public + phoenix::Separator *separator; +} +-(id) initWith :(phoenix::Separator&)separator; +@end + +namespace phoenix { + +struct pSeparator : public pAction { + Separator &separator; + CocoaSeparator *cocoaSeparator; + + pSeparator(Separator &separator) : pAction(separator), separator(separator) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/application.cpp b/higan/phoenix/cocoa/application.cpp new file mode 100644 index 00000000..0c57c72b --- /dev/null +++ b/higan/phoenix/cocoa/application.cpp @@ -0,0 +1,69 @@ +@implementation CocoaDelegate : NSObject + +-(NSApplicationTerminateReply) applicationShouldTerminate :(NSApplication*)sender { + using phoenix::Application; + if(Application::Cocoa::onQuit) Application::Cocoa::onQuit(); + else Application::quit(); + return NSTerminateCancel; +} + +-(void) run :(NSTimer*)timer { + using phoenix::Application; + if(Application::main) Application::main(); +} + +@end + +CocoaDelegate *cocoaDelegate = nullptr; + +namespace phoenix { + +void pApplication::run() { + if(Application::main) { + NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:cocoaDelegate selector:@selector(run:) userInfo:nil repeats:YES]; + } + @autoreleasepool { + [NSApp run]; + } +} + +bool pApplication::pendingEvents() { + bool result = false; + @autoreleasepool { + NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:NO]; + if(event != nil) result = true; + } + return result; +} + +void pApplication::processEvents() { + @autoreleasepool { + while(applicationState.quit == false) { + NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; + if(event == nil) break; + [event retain]; + [NSApp sendEvent:event]; + [event release]; + } + } +} + +void pApplication::quit() { + @autoreleasepool { + [NSApp stop:nil]; + NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0.0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]; + [NSApp postEvent:event atStart:true]; + } +} + +void pApplication::initialize() { + @autoreleasepool { + [NSApplication sharedApplication]; + cocoaDelegate = [[CocoaDelegate alloc] init]; + [NSApp setDelegate:cocoaDelegate]; + //every window has the default application menu; call this so it is displayed at startup + [NSApp setMainMenu:[Window::none().p.cocoaWindow menu]]; + } +} + +} diff --git a/higan/phoenix/cocoa/application.hpp b/higan/phoenix/cocoa/application.hpp new file mode 100644 index 00000000..6f34d728 --- /dev/null +++ b/higan/phoenix/cocoa/application.hpp @@ -0,0 +1,18 @@ +@interface CocoaDelegate : NSObject { +} +-(NSApplicationTerminateReply) applicationShouldTerminate :(NSApplication*)sender; +-(void) run :(NSTimer*)timer; +@end + +namespace phoenix { + +struct pApplication { + static void run(); + static bool pendingEvents(); + static void processEvents(); + static void quit(); + + static void initialize(); +}; + +} diff --git a/higan/phoenix/cocoa/desktop.cpp b/higan/phoenix/cocoa/desktop.cpp new file mode 100644 index 00000000..f42cf43c --- /dev/null +++ b/higan/phoenix/cocoa/desktop.cpp @@ -0,0 +1,18 @@ +namespace phoenix { + +Size pDesktop::size() { + @autoreleasepool { + NSRect primary = [[[NSScreen screens] objectAtIndex:0] frame]; + return {primary.size.width, primary.size.height}; + } +} + +Geometry pDesktop::workspace() { + @autoreleasepool { + auto screen = Desktop::size(); + NSRect area = [[[NSScreen screens] objectAtIndex:0] visibleFrame]; + return {area.origin.x, screen.height - area.size.height - area.origin.y, area.size.width, area.size.height}; + } +} + +} diff --git a/higan/phoenix/cocoa/desktop.hpp b/higan/phoenix/cocoa/desktop.hpp new file mode 100644 index 00000000..fed9ab6a --- /dev/null +++ b/higan/phoenix/cocoa/desktop.hpp @@ -0,0 +1,8 @@ +namespace phoenix { + +struct pDesktop { + static Size size(); + static Geometry workspace(); +}; + +} diff --git a/higan/phoenix/cocoa/dialog-window.cpp b/higan/phoenix/cocoa/dialog-window.cpp new file mode 100644 index 00000000..e182a21a --- /dev/null +++ b/higan/phoenix/cocoa/dialog-window.cpp @@ -0,0 +1,66 @@ +namespace phoenix { + +string pDialogWindow::fileOpen(Window &parent, const string &path, const lstring &filter) { + string result; + + @autoreleasepool { + NSMutableArray *filters = [[NSMutableArray alloc] init]; + for(auto &rule : filter) { + string pattern = rule.split<1>("(")(1).rtrim<1>(")"); + if(!pattern.empty()) [filters addObject:[NSString stringWithUTF8String:pattern]]; + } + NSOpenPanel *panel = [NSOpenPanel openPanel]; + [panel setCanChooseDirectories:NO]; + [panel setCanChooseFiles:YES]; + [panel setAllowedFileTypes:filters]; + if([panel runModalForDirectory:[NSString stringWithUTF8String:path] file:nil] == NSOKButton) { + NSArray *filenames = [panel filenames]; + const char *filename = [[filenames objectAtIndex:0] UTF8String]; + if(filename) result = filename; + } + [filters release]; + } + + return result; +} + +string pDialogWindow::fileSave(Window &parent, const string &path, const lstring &filter) { + string result; + + @autoreleasepool { + NSMutableArray *filters = [[NSMutableArray alloc] init]; + for(auto &rule : filter) { + string pattern = rule.split<1>("(")(1).rtrim<1>(")"); + if(!pattern.empty()) [filters addObjects:[NSString stringWithUTF8String:pattern]]; + } + NSSavePanel *panel = [NSSavePanel savePanel]; + [panel setAllowedFileTypes:filters]; + if([panel runModalForDirectory:[NSString stringWithUTF8String:path] file:nil] == NSOKButton) { + NSArray *filenames = [panel filenames]; + const char *filename = [[filenames objectAtIndex:0] UTF8String]; + if(filename) result = filename; + } + [filters release]; + } + + return result; +} + +string pDialogWindow::folderSelect(Window &parent, const string &path) { + string result; + + @autoreleasepool { + NSOpenPanel *panel = [NSOpenPanel openPanel]; + [panel setCanChooseDirectories:YES]; + [panel setCanChooseFiles:NO]; + if([panel runModalForDirectory:[NSString stringWithUTF8String:path] file:nil] == NSOKButton) { + NSArray *filenames = [panel filenames]; + const char *filename = [[filenames objectAtIndex:0] UTF8String]; + if(filename) result = filename; + } + } + + return result; +} + +} diff --git a/higan/phoenix/cocoa/dialog-window.hpp b/higan/phoenix/cocoa/dialog-window.hpp new file mode 100644 index 00000000..758ba2f5 --- /dev/null +++ b/higan/phoenix/cocoa/dialog-window.hpp @@ -0,0 +1,9 @@ +namespace phoenix { + +struct pDialogWindow { + static string fileOpen(Window &parent, const string &path, const lstring &filter); + static string fileSave(Window &parent, const string &path, const lstring &filter); + static string folderSelect(Window &parent, const string &path); +}; + +} diff --git a/higan/phoenix/cocoa/font.cpp b/higan/phoenix/cocoa/font.cpp new file mode 100644 index 00000000..7766a7a1 --- /dev/null +++ b/higan/phoenix/cocoa/font.cpp @@ -0,0 +1,59 @@ +namespace phoenix { + +string pFont::serif(unsigned size, string style) { + if(size == 0) size = 12; + if(style == "") style = "Normal"; + return {"Georgia, ", size, ", ", style}; +} + +string pFont::sans(unsigned size, string style) { + if(size == 0) size = 12; + if(style == "") style = "Normal"; + return {"Lucida Grande, ", size, ", ", style}; +} + +string pFont::monospace(unsigned size, string style) { + if(size == 0) size = 12; + if(style == "") style = "Normal"; + return {"Menlo, ", size, ", ", style}; +} + +Size pFont::size(const string &font, const string &text) { + @autoreleasepool { + if(NSFont *nsFont = cocoaFont(font)) { + return size(nsFont, text); + } + } + return {0, 0}; +} + +NSFont* pFont::cocoaFont(const string &description) { + lstring part = description.split<2>(","); + for(auto &item : part) item.strip(); + + NSString *family = @"Lucida Grande"; + NSFontTraitMask traits = 0; + CGFloat size = 12; + + if(!part(0).empty()) family = [NSString stringWithUTF8String:part(0)]; + if(!part(1).empty()) size = fp(part(1)); + if(part(2).iposition("bold")) traits |= NSBoldFontMask; + if(part(2).iposition("italic")) traits |= NSItalicFontMask; + if(part(2).iposition("narrow")) traits |= NSNarrowFontMask; + if(part(2).iposition("expanded")) traits |= NSExpandedFontMask; + if(part(2).iposition("condensed")) traits |= NSCondensedFontMask; + if(part(2).iposition("smallcaps")) traits |= NSSmallCapsFontMask; + + return [[NSFontManager sharedFontManager] fontWithFamily:family traits:traits weight:5 size:size]; +} + +Size pFont::size(NSFont *font, const string &text) { + @autoreleasepool { + NSString *cocoaText = [NSString stringWithUTF8String:text]; + NSDictionary *fontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]; + NSSize size = [cocoaText sizeWithAttributes:fontAttributes]; + return {size.width, size.height}; + } +} + +} diff --git a/higan/phoenix/cocoa/font.hpp b/higan/phoenix/cocoa/font.hpp new file mode 100644 index 00000000..50edac32 --- /dev/null +++ b/higan/phoenix/cocoa/font.hpp @@ -0,0 +1,13 @@ +namespace phoenix { + +struct pFont { + static string serif(unsigned size, string style); + static string sans(unsigned size, string style); + static string monospace(unsigned size, string style); + static Size size(const string &font, const string &text); + + static NSFont* cocoaFont(const string &description); + static Size size(NSFont *font, const string &text); +}; + +} diff --git a/higan/phoenix/cocoa/header.hpp b/higan/phoenix/cocoa/header.hpp new file mode 100644 index 00000000..7e7f4999 --- /dev/null +++ b/higan/phoenix/cocoa/header.hpp @@ -0,0 +1,4 @@ +#define decimal CocoaDecimal +#import +#import +#undef decimal diff --git a/higan/phoenix/cocoa/keyboard.cpp b/higan/phoenix/cocoa/keyboard.cpp new file mode 100644 index 00000000..adc28c87 --- /dev/null +++ b/higan/phoenix/cocoa/keyboard.cpp @@ -0,0 +1,14 @@ +namespace phoenix { + +bool pKeyboard::pressed(Keyboard::Scancode scancode) { + return false; +} + +vector pKeyboard::state() { + vector output; + output.resize((unsigned)Keyboard::Scancode::Limit); + for(auto &n : output) n = false; + return output; +} + +} diff --git a/higan/phoenix/cocoa/keyboard.hpp b/higan/phoenix/cocoa/keyboard.hpp new file mode 100644 index 00000000..2c0a42ae --- /dev/null +++ b/higan/phoenix/cocoa/keyboard.hpp @@ -0,0 +1,8 @@ +namespace phoenix { + +struct pKeyboard { + static bool pressed(Keyboard::Scancode scancode); + static vector state(); +}; + +} diff --git a/higan/phoenix/cocoa/message-window.cpp b/higan/phoenix/cocoa/message-window.cpp new file mode 100644 index 00000000..9337ea4e --- /dev/null +++ b/higan/phoenix/cocoa/message-window.cpp @@ -0,0 +1,76 @@ +namespace phoenix { + +MessageWindow::Response pMessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) { + return message(parent, text, buttons, Type::Information); +} + +MessageWindow::Response pMessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) { + return message(parent, text, buttons, Type::Question); +} + +MessageWindow::Response pMessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) { + return message(parent, text, buttons, Type::Warning); +} + +MessageWindow::Response pMessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) { + return message(parent, text, buttons, Type::Critical); +} + +MessageWindow::Response pMessageWindow::message(Window &parent, const string &text, MessageWindow::Buttons buttons, Type type) { + @autoreleasepool { + NSAlert *alert = [[[NSAlert alloc] init] autorelease]; + [alert setMessageText:[NSString stringWithUTF8String:text]]; + + switch(buttons) { + case MessageWindow::Buttons::Ok: + [alert addButtonWithTitle:@"Ok"]; + break; + case MessageWindow::Buttons::OkCancel: + [alert addButtonWithTitle:@"Ok"]; + [alert addButtonWithTitle:@"Cancel"]; + break; + case MessageWindow::Buttons::YesNo: + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + break; + case MessageWindow::Buttons::YesNoCancel: + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + [alert addButtonWithTitle:@"Cancel"]; + break; + } + + switch(type) { + case Type::Information: [alert setAlertStyle:NSInformationalAlertStyle]; break; + case Type::Question: [alert setAlertStyle:NSInformationalAlertStyle]; break; + case Type::Warning: [alert setAlertStyle:NSWarningAlertStyle]; break; + case Type::Critical: [alert setAlertStyle:NSCriticalAlertStyle]; break; + } + + NSInteger response = [alert runModal]; + //[alert beginSheetModalForWindow:parent.p.cocoaWindow modalDelegate:self didEndSelector:@selector(...) contextInfo:nil]; + + switch(buttons) { + case MessageWindow::Buttons::Ok: + if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Ok; + break; + case MessageWindow::Buttons::OkCancel: + if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Ok; + if(response == NSAlertSecondButtonReturn) return MessageWindow::Response::Cancel; + break; + case MessageWindow::Buttons::YesNo: + if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Yes; + if(response == NSAlertSecondButtonReturn) return MessageWindow::Response::No; + break; + case MessageWindow::Buttons::YesNoCancel: + if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Yes; + if(response == NSAlertSecondButtonReturn) return MessageWindow::Response::No; + if(response == NSAlertThirdButtonReturn) return MessageWindow::Response::Cancel; + break; + } + } + + return MessageWindow::Response::Ok; +} + +} diff --git a/higan/phoenix/cocoa/message-window.hpp b/higan/phoenix/cocoa/message-window.hpp new file mode 100644 index 00000000..ef470b1c --- /dev/null +++ b/higan/phoenix/cocoa/message-window.hpp @@ -0,0 +1,13 @@ +namespace phoenix { + +struct pMessageWindow { + static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons); + static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons); + static MessageWindow::Response warning(Window &parent, const string &text, MessageWindow::Buttons buttons); + static MessageWindow::Response critical(Window &parent, const string &text, MessageWindow::Buttons buttons); + + enum class Type : unsigned { Information, Question, Warning, Critical }; + static MessageWindow::Response message(Window &parent, const string &text, MessageWindow::Buttons buttons, Type type); +}; + +} diff --git a/higan/phoenix/cocoa/mouse.cpp b/higan/phoenix/cocoa/mouse.cpp new file mode 100644 index 00000000..ca5e8556 --- /dev/null +++ b/higan/phoenix/cocoa/mouse.cpp @@ -0,0 +1,11 @@ +namespace phoenix { + +Position pMouse::position() { + return {0, 0}; +} + +bool pMouse::pressed(Mouse::Button button) { + return false; +} + +} diff --git a/higan/phoenix/cocoa/mouse.hpp b/higan/phoenix/cocoa/mouse.hpp new file mode 100644 index 00000000..7e21f2ea --- /dev/null +++ b/higan/phoenix/cocoa/mouse.hpp @@ -0,0 +1,8 @@ +namespace phoenix { + +struct pMouse { + static Position position(); + static bool pressed(Mouse::Button button); +}; + +} diff --git a/higan/phoenix/cocoa/object.hpp b/higan/phoenix/cocoa/object.hpp new file mode 100644 index 00000000..f5102b5b --- /dev/null +++ b/higan/phoenix/cocoa/object.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pObject { + Object &object; + bool locked; + + pObject(Object &object) : object(object), locked(false) {} + virtual ~pObject() {} + + void constructor() {} + void destructor() {} +}; + +} diff --git a/higan/phoenix/cocoa/platform.cpp b/higan/phoenix/cocoa/platform.cpp new file mode 100644 index 00000000..fd7affbb --- /dev/null +++ b/higan/phoenix/cocoa/platform.cpp @@ -0,0 +1,38 @@ +#include "platform.hpp" +#include "utility.cpp" + +#include "desktop.cpp" +#include "keyboard.cpp" +#include "mouse.cpp" +#include "dialog-window.cpp" +#include "message-window.cpp" +#include "font.cpp" +#include "timer.cpp" +#include "window.cpp" + +#include "action/action.cpp" +#include "action/menu.cpp" +#include "action/separator.cpp" +#include "action/item.cpp" +#include "action/check-item.cpp" +#include "action/radio-item.cpp" + +#include "widget/widget.cpp" +#include "widget/button.cpp" +#include "widget/canvas.cpp" +#include "widget/check-button.cpp" +#include "widget/combo-button.cpp" +#include "widget/hex-edit.cpp" +#include "widget/horizontal-scroller.cpp" +#include "widget/horizontal-slider.cpp" +#include "widget/label.cpp" +#include "widget/line-edit.cpp" +#include "widget/list-view.cpp" +#include "widget/progress-bar.cpp" +#include "widget/radio-button.cpp" +#include "widget/text-edit.cpp" +#include "widget/vertical-scroller.cpp" +#include "widget/vertical-slider.cpp" +#include "widget/viewport.cpp" + +#include "application.cpp" diff --git a/higan/phoenix/cocoa/platform.hpp b/higan/phoenix/cocoa/platform.hpp new file mode 100644 index 00000000..fab4a5c6 --- /dev/null +++ b/higan/phoenix/cocoa/platform.hpp @@ -0,0 +1,46 @@ +namespace phoenix { + struct pFont; + struct pWindow; + struct pMenu; + struct pLayout; + struct pWidget; +} + +#include "font.hpp" +#include "desktop.hpp" +#include "keyboard.hpp" +#include "mouse.hpp" +#include "dialog-window.hpp" +#include "message-window.hpp" +#include "object.hpp" +#include "timer.hpp" +#include "window.hpp" + +#include "action/action.hpp" +#include "action/menu.hpp" +#include "action/separator.hpp" +#include "action/item.hpp" +#include "action/check-item.hpp" +#include "action/radio-item.hpp" + +#include "widget/sizable.hpp" +#include "widget/layout.hpp" +#include "widget/widget.hpp" +#include "widget/button.hpp" +#include "widget/canvas.hpp" +#include "widget/check-button.hpp" +#include "widget/combo-button.hpp" +#include "widget/hex-edit.hpp" +#include "widget/horizontal-scroller.hpp" +#include "widget/horizontal-slider.hpp" +#include "widget/label.hpp" +#include "widget/line-edit.hpp" +#include "widget/list-view.hpp" +#include "widget/progress-bar.hpp" +#include "widget/radio-button.hpp" +#include "widget/text-edit.hpp" +#include "widget/vertical-scroller.hpp" +#include "widget/vertical-slider.hpp" +#include "widget/viewport.hpp" + +#include "application.hpp" diff --git a/higan/phoenix/cocoa/timer.cpp b/higan/phoenix/cocoa/timer.cpp new file mode 100644 index 00000000..1b85bd65 --- /dev/null +++ b/higan/phoenix/cocoa/timer.cpp @@ -0,0 +1,60 @@ +@implementation CocoaTimer : NSObject + +-(id) initWith :(phoenix::Timer&)timerReference { + if(self = [super init]) { + timer = &timerReference; + instance = nil; + } + return self; +} + +-(NSTimer*) instance { + return instance; +} + +-(void) update { + if(instance) { + [instance invalidate]; + instance = nil; + } + if(timer->state.enabled == false) return; + instance = [NSTimer + scheduledTimerWithTimeInterval:timer->state.milliseconds / 1000.0 + target:self selector:@selector(run:) userInfo:nil repeats:YES + ]; +} + +-(void) run :(NSTimer*)instance { + if(timer->onActivate) timer->onActivate(); +} + +@end + +namespace phoenix { + +void pTimer::setEnabled(bool enabled) { + @autoreleasepool { + [cocoaTimer update]; + } +} + +void pTimer::setInterval(unsigned milliseconds) { + @autoreleasepool { + [cocoaTimer update]; + } +} + +void pTimer::constructor() { + @autoreleasepool { + cocoaTimer = [[CocoaTimer alloc] initWith:timer]; + } +} + +void pTimer::destructor() { + @autoreleasepool { + if([cocoaTimer instance]) [[cocoaTimer instance] invalidate]; + [cocoaTimer release]; + } +} + +} diff --git a/higan/phoenix/cocoa/timer.hpp b/higan/phoenix/cocoa/timer.hpp new file mode 100644 index 00000000..a4874bc0 --- /dev/null +++ b/higan/phoenix/cocoa/timer.hpp @@ -0,0 +1,26 @@ +@interface CocoaTimer : NSObject { +@public + phoenix::Timer *timer; + NSTimer *instance; +} +-(id) initWith :(phoenix::Timer&)timer; +-(NSTimer*) instance; +-(void) update; +-(void) run :(NSTimer*)instance; +@end + +namespace phoenix { + +struct pTimer : public pObject { + Timer &timer; + CocoaTimer *cocoaTimer; + + void setEnabled(bool enabled); + void setInterval(unsigned milliseconds); + + pTimer(Timer &timer) : pObject(timer), timer(timer) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/utility.cpp b/higan/phoenix/cocoa/utility.cpp new file mode 100644 index 00000000..ad5a6cb0 --- /dev/null +++ b/higan/phoenix/cocoa/utility.cpp @@ -0,0 +1,17 @@ +NSImage* NSMakeImage(nall::image image, unsigned width = 0, unsigned height = 0) { + if(image.empty()) return nil; + if(width && height) image.scale(width, height, Interpolation::Linear); + image.transform(0, 32, 255u << 24, 255u << 0, 255u << 8, 255u << 16); + NSImage *cocoaImage = [[[NSImage alloc] initWithSize:NSMakeSize(image.width, image.height)] autorelease]; + NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:nil + pixelsWide:image.width pixelsHigh:image.height + bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES + isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace + bitmapFormat:NSAlphaNonpremultipliedBitmapFormat + bytesPerRow:image.pitch bitsPerPixel:32 + ] autorelease]; + memcpy([bitmap bitmapData], image.data, image.height * image.pitch); + [cocoaImage addRepresentation:bitmap]; + return cocoaImage; +} diff --git a/higan/phoenix/cocoa/widget/button.cpp b/higan/phoenix/cocoa/widget/button.cpp new file mode 100644 index 00000000..24797731 --- /dev/null +++ b/higan/phoenix/cocoa/widget/button.cpp @@ -0,0 +1,70 @@ +@implementation CocoaButton : NSButton + +-(id) initWith :(phoenix::Button&)buttonReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + button = &buttonReference; + [self setTarget:self]; + [self setAction:@selector(activate:)]; + //NSRoundedBezelStyle has a fixed height; which breaks both icons and larger/smaller text + [self setBezelStyle:NSRegularSquareBezelStyle]; + } + return self; +} + +-(IBAction) activate :(id)sender { + if(button->onActivate) button->onActivate(); +} + +@end + +namespace phoenix { + +Size pButton::minimumSize() { + Size size = Font::size(button.font(), button.state.text); + + if(button.state.orientation == Orientation::Horizontal) { + size.width += button.state.image.width; + size.height = max(button.state.image.height, size.height); + } + + if(button.state.orientation == Orientation::Vertical) { + size.width = max(button.state.image.width, size.width); + size.height += button.state.image.height; + } + + return {size.width + 24, size.height + 8}; +} + +void pButton::setImage(const image &image, Orientation orientation) { + @autoreleasepool { + if(image.empty()) { + [cocoaView setImage:nil]; + return; + } + + [cocoaView setImage:NSMakeImage(image)]; + + if(orientation == Orientation::Horizontal) [cocoaView setImagePosition:NSImageLeft]; + if(orientation == Orientation::Vertical ) [cocoaView setImagePosition:NSImageAbove]; + } +} + +void pButton::setText(const string &text) { + @autoreleasepool { + [cocoaView setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pButton::constructor() { + @autoreleasepool { + cocoaView = cocoaButton = [[CocoaButton alloc] initWith:button]; + } +} + +void pButton::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/button.hpp b/higan/phoenix/cocoa/widget/button.hpp new file mode 100644 index 00000000..367ca19a --- /dev/null +++ b/higan/phoenix/cocoa/widget/button.hpp @@ -0,0 +1,24 @@ +@interface CocoaButton : NSButton { +@public + phoenix::Button *button; +} +-(id) initWith :(phoenix::Button&)button; +-(IBAction) activate :(id)sender; +@end + +namespace phoenix { + +struct pButton : public pWidget { + Button &button; + CocoaButton *cocoaButton; + + Size minimumSize(); + void setImage(const image &image, Orientation orientation); + void setText(const string &text); + + pButton(Button &button) : pWidget(button), button(button) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/canvas.cpp b/higan/phoenix/cocoa/widget/canvas.cpp new file mode 100644 index 00000000..d7d654c5 --- /dev/null +++ b/higan/phoenix/cocoa/widget/canvas.cpp @@ -0,0 +1,125 @@ +@implementation CocoaCanvas : NSImageView + +-(id) initWith :(phoenix::Canvas&)canvasReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + canvas = &canvasReference; + [self setEditable:NO]; //disable image drag-and-drop functionality + NSTrackingArea *area = [[[NSTrackingArea alloc] initWithRect:[self frame] + options:NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect + owner:self userInfo:nil + ] autorelease]; + [self addTrackingArea:area]; + } + return self; +} + +-(void) mouseButton :(NSEvent*)event down:(BOOL)isDown { + if(auto &callback = isDown ? canvas->onMousePress : canvas->onMouseRelease) { + switch([event buttonNumber]) { + case 0: return callback(phoenix::Mouse::Button::Left); + case 1: return callback(phoenix::Mouse::Button::Right); + case 2: return callback(phoenix::Mouse::Button::Middle); + } + } +} + +-(void) mouseExited :(NSEvent*)event { + if(canvas->onMouseLeave) canvas->onMouseLeave(); +} + +-(void) mouseMove :(NSEvent*)event { + if([event window] == nil) return; + NSPoint location = [self convertPoint:[event locationInWindow] fromView:nil]; + if(canvas->onMouseMove) canvas->onMouseMove({location.x, [self frame].size.height - 1 - location.y}); +} + +-(void) mouseDown :(NSEvent*)event { + [self mouseButton:event down:YES]; +} + +-(void) mouseUp :(NSEvent*)event { + [self mouseButton:event down:NO]; +} + +-(void) mouseDragged :(NSEvent*)event { + [self mouseMove:event]; +} + +-(void) rightMouseDown :(NSEvent*)event { + [self mouseButton:event down:YES]; +} + +-(void) rightMouseUp :(NSEvent*)event { + [self mouseButton:event down:NO]; +} + +-(void) rightMouseDragged :(NSEvent*)event { + [self mouseMove:event]; +} + +-(void) otherMouseDown :(NSEvent*)event { + [self mouseButton:event down:YES]; +} + +-(void) otherMouseUp :(NSEvent*)event { + [self mouseButton:event down:NO]; +} + +-(void) otherMouseDragged :(NSEvent*)event { + [self mouseMove:event]; +} + +@end + +namespace phoenix { + +void pCanvas::setSize(const Size &size) { + @autoreleasepool { + NSImage *image = [[[NSImage alloc] initWithSize:NSMakeSize(size.width, size.height)] autorelease]; + NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:nil + pixelsWide:size.width pixelsHigh:size.height + bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES + isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace + bitmapFormat:NSAlphaNonpremultipliedBitmapFormat + bytesPerRow:size.width * 4 bitsPerPixel:32 + ] autorelease]; + + [image addRepresentation:bitmap]; + [cocoaView setImage:image]; + } +} + +void pCanvas::update() { + @autoreleasepool { + if(NSBitmapImageRep *bitmap = [[[cocoaView image] representations] objectAtIndex:0]) { + uint8_t *target = [bitmap bitmapData]; + uint32_t *source = canvas.state.data; + + for(unsigned n = 0; n < canvas.state.width * canvas.state.height; n++) { + *target++ = *source >> 16; + *target++ = *source >> 8; + *target++ = *source >> 0; + *target++ = *source >> 24; + source++; + } + + [cocoaView setNeedsDisplay:YES]; + } + } +} + +void pCanvas::constructor() { + @autoreleasepool { + cocoaView = cocoaCanvas = [[CocoaCanvas alloc] initWith:canvas]; + setSize(canvas.size()); + } +} + +void pCanvas::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/canvas.hpp b/higan/phoenix/cocoa/widget/canvas.hpp new file mode 100644 index 00000000..d3fb3936 --- /dev/null +++ b/higan/phoenix/cocoa/widget/canvas.hpp @@ -0,0 +1,34 @@ +@interface CocoaCanvas : NSImageView { +@public + phoenix::Canvas *canvas; +} +-(id) initWith:(phoenix::Canvas&)canvas; +-(void) mouseButton :(NSEvent*)event down:(BOOL)isDown; +-(void) mouseExited :(NSEvent*)event; +-(void) mouseMove :(NSEvent*)event; +-(void) mouseDown :(NSEvent*)event; +-(void) mouseUp :(NSEvent*)event; +-(void) mouseDragged :(NSEvent*)event; +-(void) rightMouseDown :(NSEvent*)event; +-(void) rightMouseUp :(NSEvent*)event; +-(void) rightMouseDragged :(NSEvent*)event; +-(void) otherMouseDown :(NSEvent*)event; +-(void) otherMouseUp :(NSEvent*)event; +-(void) otherMouseDragged :(NSEvent*)event; +@end + +namespace phoenix { + +struct pCanvas : public pWidget { + Canvas &canvas; + CocoaCanvas *cocoaCanvas; + + void setSize(const Size &size); + void update(); + + pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/check-button.cpp b/higan/phoenix/cocoa/widget/check-button.cpp new file mode 100644 index 00000000..68afe838 --- /dev/null +++ b/higan/phoenix/cocoa/widget/check-button.cpp @@ -0,0 +1,60 @@ +@implementation CocoaCheckButton : NSButton + +-(id) initWith :(phoenix::CheckButton&)checkButtonReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + checkButton = &checkButtonReference; + + [self setTarget:self]; + [self setAction:@selector(activate:)]; + [self setButtonType:NSSwitchButton]; + } + return self; +} + +-(IBAction) activate :(id)sender { + checkButton->state.checked = [self state] != NSOffState; + if(checkButton->onToggle) checkButton->onToggle(); +} + +@end + +namespace phoenix { + +bool pCheckButton::checked() { + @autoreleasepool { + return [cocoaView state] != NSOffState; + } +} + +Size pCheckButton::minimumSize() { + Size size = Font::size(checkButton.font(), checkButton.state.text); + return {size.width + 24, size.height + 8}; +} + +void pCheckButton::setChecked(bool checked) { + @autoreleasepool { + [cocoaView setState:checked ? NSOnState : NSOffState]; + } +} + +void pCheckButton::setText(const string &text) { + @autoreleasepool { + [cocoaView setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pCheckButton::constructor() { + @autoreleasepool { + cocoaView = cocoaCheckButton = [[CocoaCheckButton alloc] initWith:checkButton]; + setChecked(checkButton.state.checked); + setText(checkButton.state.text); + } +} + +void pCheckButton::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/check-button.hpp b/higan/phoenix/cocoa/widget/check-button.hpp new file mode 100644 index 00000000..52d240e5 --- /dev/null +++ b/higan/phoenix/cocoa/widget/check-button.hpp @@ -0,0 +1,25 @@ +@interface CocoaCheckButton : NSButton { +@public + phoenix::CheckButton *checkButton; +} +-(id) initWith :(phoenix::CheckButton&)checkButton; +-(IBAction) activate :(id)sender; +@end + +namespace phoenix { + +struct pCheckButton : public pWidget { + CheckButton &checkButton; + CocoaCheckButton *cocoaCheckButton; + + bool checked(); + Size minimumSize(); + void setChecked(bool checked); + void setText(const string &text); + + pCheckButton(CheckButton &checkButton) : pWidget(checkButton), checkButton(checkButton) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/combo-button.cpp b/higan/phoenix/cocoa/widget/combo-button.cpp new file mode 100644 index 00000000..72226cdb --- /dev/null +++ b/higan/phoenix/cocoa/widget/combo-button.cpp @@ -0,0 +1,76 @@ +@implementation CocoaComboButton : NSPopUpButton + +-(id) initWith :(phoenix::ComboButton&)comboButtonReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0) pullsDown:NO]) { + comboButton = &comboButtonReference; + + [self setTarget:self]; + [self setAction:@selector(activate:)]; + } + return self; +} + +-(IBAction) activate :(id)sender { + if(comboButton->onChange) comboButton->onChange(); +} + +@end + +namespace phoenix { + +void pComboButton::append(const string &text) { + @autoreleasepool { + [cocoaView addItemWithTitle:[NSString stringWithUTF8String:text]]; + } +} + +Size pComboButton::minimumSize() { + unsigned maximumWidth = 0; + for(auto &text : comboButton.state.text) maximumWidth = max(maximumWidth, Font::size(comboButton.font(), text).width); + Size size = Font::size(comboButton.font(), " "); + return {maximumWidth + 40, size.height + 8}; +} + +void pComboButton::modify(unsigned row, const string &text) { + @autoreleasepool { + [[cocoaView itemAtIndex:row] setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pComboButton::remove(unsigned row) { + @autoreleasepool { + [cocoaView removeItemAtIndex:row]; + } +} + +void pComboButton::reset() { + @autoreleasepool { + [cocoaView removeAllItems]; + } +} + +unsigned pComboButton::selection() { + @autoreleasepool { + return [cocoaView indexOfSelectedItem]; + } +} + +void pComboButton::setSelection(unsigned row) { + @autoreleasepool { + [cocoaView selectItemAtIndex:row]; + } +} + +void pComboButton::constructor() { + @autoreleasepool { + cocoaView = cocoaComboButton = [[CocoaComboButton alloc] initWith:comboButton]; + } +} + +void pComboButton::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/combo-button.hpp b/higan/phoenix/cocoa/widget/combo-button.hpp new file mode 100644 index 00000000..7701155c --- /dev/null +++ b/higan/phoenix/cocoa/widget/combo-button.hpp @@ -0,0 +1,28 @@ +@interface CocoaComboButton : NSPopUpButton { +@public + phoenix::ComboButton *comboButton; +} +-(id) initWith :(phoenix::ComboButton&)comboButton; +-(IBAction) activate :(id)sender; +@end + +namespace phoenix { + +struct pComboButton : public pWidget { + ComboButton &comboButton; + CocoaComboButton *cocoaComboButton; + + void append(const string &text); + Size minimumSize(); + void modify(unsigned row, const string &text); + void remove(unsigned row); + void reset(); + unsigned selection(); + void setSelection(unsigned row); + + pComboButton(ComboButton &comboButton) : pWidget(comboButton), comboButton(comboButton) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/hex-edit.cpp b/higan/phoenix/cocoa/widget/hex-edit.cpp new file mode 100644 index 00000000..95d8b72a --- /dev/null +++ b/higan/phoenix/cocoa/widget/hex-edit.cpp @@ -0,0 +1,21 @@ +namespace phoenix { + +void pHexEdit::setColumns(unsigned columns) { +} + +void pHexEdit::setLength(unsigned length) { +} + +void pHexEdit::setOffset(unsigned offset) { +} + +void pHexEdit::setRows(unsigned rows) { +} + +void pHexEdit::update() { +} + +void pHexEdit::constructor() { +} + +} diff --git a/higan/phoenix/cocoa/widget/hex-edit.hpp b/higan/phoenix/cocoa/widget/hex-edit.hpp new file mode 100644 index 00000000..5819ee4d --- /dev/null +++ b/higan/phoenix/cocoa/widget/hex-edit.hpp @@ -0,0 +1,16 @@ +namespace phoenix { + +struct pHexEdit : public pWidget { + HexEdit &hexEdit; + + void setColumns(unsigned columns); + void setLength(unsigned length); + void setOffset(unsigned offset); + void setRows(unsigned rows); + void update(); + + pHexEdit(HexEdit &hexEdit) : pWidget(hexEdit), hexEdit(hexEdit) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/horizontal-scroller.cpp b/higan/phoenix/cocoa/widget/horizontal-scroller.cpp new file mode 100644 index 00000000..67b59ffe --- /dev/null +++ b/higan/phoenix/cocoa/widget/horizontal-scroller.cpp @@ -0,0 +1,91 @@ +@implementation CocoaHorizontalScroller : NSScroller + +-(id) initWith :(phoenix::HorizontalScroller&)horizontalScrollerReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) { + horizontalScroller = &horizontalScrollerReference; + + [self setTarget:self]; + [self setAction:@selector(scroll:)]; + + [self setControlSize:NSRegularControlSize]; + [self setScrollerStyle:NSScrollerStyleLegacy]; + [self setEnabled:YES]; + + [self update]; + } + return self; +} + +-(void) update { + double d = 1.0 / horizontalScroller->state.length; + double f = d * horizontalScroller->state.position; + + [self setDoubleValue:f]; + [self setKnobProportion:d]; +} + +-(IBAction) scroll :(id)sender { + auto &state = horizontalScroller->state; + + switch([self hitPart]) { + case NSScrollerIncrementLine: + case NSScrollerIncrementPage: + if(state.position < state.length - 1) state.position++; + [self update]; + break; + + case NSScrollerDecrementLine: + case NSScrollerDecrementPage: + if(state.position) state.position--; + [self update]; + break; + + case NSScrollerKnob: + state.position = [self doubleValue] * state.length; + break; + } + + if(horizontalScroller->onChange) horizontalScroller->onChange(); +} + +@end + +namespace phoenix { + +Size pHorizontalScroller::minimumSize() { + @autoreleasepool { + return {32, [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy]}; + } +} + +unsigned pHorizontalScroller::position() { + @autoreleasepool { + return [cocoaView doubleValue] * horizontalScroller.state.length; + } +} + +void pHorizontalScroller::setLength(unsigned length) { + @autoreleasepool { + [cocoaView update]; + } +} + +void pHorizontalScroller::setPosition(unsigned position) { + @autoreleasepool { + [cocoaView update]; + } +} + +void pHorizontalScroller::constructor() { + @autoreleasepool { + cocoaView = cocoaHorizontalScroller = [[CocoaHorizontalScroller alloc] initWith:horizontalScroller]; + } +} + +void pHorizontalScroller::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/horizontal-scroller.hpp b/higan/phoenix/cocoa/widget/horizontal-scroller.hpp new file mode 100644 index 00000000..1756705b --- /dev/null +++ b/higan/phoenix/cocoa/widget/horizontal-scroller.hpp @@ -0,0 +1,26 @@ +@interface CocoaHorizontalScroller : NSScroller { +@public + phoenix::HorizontalScroller *horizontalScroller; +} +-(id) initWith :(phoenix::HorizontalScroller&)horizontalScroller; +-(void) update; +-(IBAction) scroll :(id)sender; +@end + +namespace phoenix { + +struct pHorizontalScroller : public pWidget { + HorizontalScroller &horizontalScroller; + CocoaHorizontalScroller *cocoaHorizontalScroller; + + Size minimumSize(); + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pHorizontalScroller(HorizontalScroller &horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/horizontal-slider.cpp b/higan/phoenix/cocoa/widget/horizontal-slider.cpp new file mode 100644 index 00000000..aa0976ed --- /dev/null +++ b/higan/phoenix/cocoa/widget/horizontal-slider.cpp @@ -0,0 +1,60 @@ +@implementation CocoaHorizontalSlider : NSSlider + +-(id) initWith :(phoenix::HorizontalSlider&)horizontalSliderReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) { + horizontalSlider = &horizontalSliderReference; + + [self setTarget:self]; + [self setAction:@selector(activate:)]; + [self setMinValue:0]; + } + return self; +} + +-(IBAction) activate :(id)sender { + horizontalSlider->state.position = [self doubleValue]; + if(horizontalSlider->onChange) horizontalSlider->onChange(); +} + +@end + +namespace phoenix { + +Size pHorizontalSlider::minimumSize() { + return {64, 24}; +} + +unsigned pHorizontalSlider::position() { + @autoreleasepool { + return [cocoaView doubleValue]; + } +} + +void pHorizontalSlider::setLength(unsigned length) { + @autoreleasepool { + [cocoaView setMaxValue:length]; + } +} + +void pHorizontalSlider::setPosition(unsigned position) { + @autoreleasepool { + [cocoaView setDoubleValue:position]; + } +} + +void pHorizontalSlider::constructor() { + @autoreleasepool { + cocoaView = cocoaHorizontalSlider = [[CocoaHorizontalSlider alloc] initWith:horizontalSlider]; + + setLength(horizontalSlider.state.length); + setPosition(horizontalSlider.state.position); + } +} + +void pHorizontalSlider::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/horizontal-slider.hpp b/higan/phoenix/cocoa/widget/horizontal-slider.hpp new file mode 100644 index 00000000..d60b6a0c --- /dev/null +++ b/higan/phoenix/cocoa/widget/horizontal-slider.hpp @@ -0,0 +1,25 @@ +@interface CocoaHorizontalSlider : NSSlider { +@public + phoenix::HorizontalSlider *horizontalSlider; +} +-(id) initWith :(phoenix::HorizontalSlider&)horizontalSlider; +-(IBAction) activate :(id)sender; +@end + +namespace phoenix { + +struct pHorizontalSlider : public pWidget { + HorizontalSlider &horizontalSlider; + CocoaHorizontalSlider *cocoaHorizontalSlider; + + Size minimumSize(); + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pHorizontalSlider(HorizontalSlider &horizontalSlider) : pWidget(horizontalSlider), horizontalSlider(horizontalSlider) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/label.cpp b/higan/phoenix/cocoa/widget/label.cpp new file mode 100644 index 00000000..24eb5e0e --- /dev/null +++ b/higan/phoenix/cocoa/widget/label.cpp @@ -0,0 +1,43 @@ +@implementation CocoaLabel : NSTextField + +-(id) initWith :(phoenix::Label&)labelReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + label = &labelReference; + + [self setAlignment:NSLeftTextAlignment]; + [self setBordered:NO]; + [self setDrawsBackground:NO]; + [self setEditable:NO]; + } + return self; +} + +@end + +namespace phoenix { + +Size pLabel::minimumSize() { + Size size = Font::size(label.font(), label.state.text); + return {size.width, size.height}; +} + +void pLabel::setText(const string &text) { + @autoreleasepool { + [cocoaView setStringValue:[NSString stringWithUTF8String:text]]; + } +} + +void pLabel::constructor() { + @autoreleasepool { + cocoaView = cocoaLabel = [[CocoaLabel alloc] initWith:label]; + setText(label.state.text); + } +} + +void pLabel::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/label.hpp b/higan/phoenix/cocoa/widget/label.hpp new file mode 100644 index 00000000..69466ebf --- /dev/null +++ b/higan/phoenix/cocoa/widget/label.hpp @@ -0,0 +1,22 @@ +@interface CocoaLabel : NSTextField { +@public + phoenix::Label *label; +} +-(id) initWith :(phoenix::Label&)label; +@end + +namespace phoenix { + +struct pLabel : public pWidget { + Label &label; + CocoaLabel *cocoaLabel; + + Size minimumSize(); + void setText(const string &text); + + pLabel(Label &label) : pWidget(label), label(label) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/layout.hpp b/higan/phoenix/cocoa/widget/layout.hpp new file mode 100644 index 00000000..100b7463 --- /dev/null +++ b/higan/phoenix/cocoa/widget/layout.hpp @@ -0,0 +1,9 @@ +namespace phoenix { + +struct pLayout : public pSizable { + Layout &layout; + + pLayout(Layout &layout) : pSizable(layout), layout(layout) {} +}; + +} diff --git a/higan/phoenix/cocoa/widget/line-edit.cpp b/higan/phoenix/cocoa/widget/line-edit.cpp new file mode 100644 index 00000000..9e68cfe7 --- /dev/null +++ b/higan/phoenix/cocoa/widget/line-edit.cpp @@ -0,0 +1,65 @@ +@implementation CocoaLineEdit : NSTextField + +-(id) initWith :(phoenix::LineEdit&)lineEditReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + lineEdit = &lineEditReference; + + [self setDelegate:self]; + [self setTarget:self]; + [self setAction:@selector(activate:)]; + + //prevent focus changes from generating activate event + [[self cell] setSendsActionOnEndEditing:NO]; + } + return self; +} + +-(void) textDidChange :(NSNotification*)n { + if(lineEdit->onChange) lineEdit->onChange(); +} + +-(IBAction) activate :(id)sender { + if(lineEdit->onActivate) lineEdit->onActivate(); +} + +@end + +namespace phoenix { + +Size pLineEdit::minimumSize() { + Size size = Font::size(lineEdit.font(), lineEdit.state.text); + return {size.width + 10, size.height + 8}; +} + +void pLineEdit::setEditable(bool editable) { + @autoreleasepool { + [cocoaView setEditable:editable]; + } +} + +void pLineEdit::setText(const string &text) { + @autoreleasepool { + [cocoaView setStringValue:[NSString stringWithUTF8String:text]]; + } +} + +string pLineEdit::text() { + @autoreleasepool { + return [[cocoaView stringValue] UTF8String]; + } +} + +void pLineEdit::constructor() { + @autoreleasepool { + cocoaView = cocoaLineEdit = [[CocoaLineEdit alloc] initWith:lineEdit]; + setEditable(lineEdit.state.editable); + } +} + +void pLineEdit::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/line-edit.hpp b/higan/phoenix/cocoa/widget/line-edit.hpp new file mode 100644 index 00000000..97cfe7c6 --- /dev/null +++ b/higan/phoenix/cocoa/widget/line-edit.hpp @@ -0,0 +1,26 @@ +@interface CocoaLineEdit : NSTextField { +@public + phoenix::LineEdit *lineEdit; +} +-(id) initWith :(phoenix::LineEdit&)lineEdit; +-(void) textDidChange :(NSNotification*)n; +-(IBAction) activate :(id)sender; +@end + +namespace phoenix { + +struct pLineEdit : public pWidget { + LineEdit &lineEdit; + CocoaLineEdit *cocoaLineEdit; + + Size minimumSize(); + void setEditable(bool editable); + void setText(const string &text); + string text(); + + pLineEdit(LineEdit &lineEdit) : pWidget(lineEdit), lineEdit(lineEdit) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/list-view.cpp b/higan/phoenix/cocoa/widget/list-view.cpp new file mode 100644 index 00000000..f8bf1042 --- /dev/null +++ b/higan/phoenix/cocoa/widget/list-view.cpp @@ -0,0 +1,326 @@ +@implementation CocoaListView : NSScrollView + +-(id) initWith :(phoenix::ListView&)listViewReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + listView = &listViewReference; + content = [[CocoaListViewContent alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; + + [self setDocumentView:content]; + [self setBorderType:NSBezelBorder]; + [self setHasVerticalScroller:YES]; + + [content setDataSource:self]; + [content setDelegate:self]; + [content setTarget:self]; + [content setDoubleAction:@selector(activate:)]; + + [content setAllowsColumnReordering:NO]; + [content setAllowsColumnResizing:YES]; + [content setAllowsColumnSelection:NO]; + [content setAllowsEmptySelection:YES]; + [content setAllowsMultipleSelection:NO]; + [content setColumnAutoresizingStyle:NSTableViewNoColumnAutoresizing]; + + font = nil; + [self setFont:nil]; + } + return self; +} + +-(void) dealloc { + [content release]; + [font release]; + [super dealloc]; +} + +-(CocoaListViewContent*) content { + return content; +} + +-(NSFont*) font { + return font; +} + +-(void) setFont :(NSFont*)fontPointer { + if(!fontPointer) fontPointer = [NSFont systemFontOfSize:12]; + [fontPointer retain]; + if(font) [font release]; + font = fontPointer; + + unsigned fontHeight = phoenix::pFont::size(font, " ").height; + [content setFont:font]; + [content setRowHeight:fontHeight]; + [self reloadColumns]; +} + +-(void) reloadColumns { + while([[content tableColumns] count]) { + [content removeTableColumn:[[content tableColumns] lastObject]]; + } + + if(listView->state.checkable) { + NSTableColumn *tableColumn = [[NSTableColumn alloc] initWithIdentifier:@"check"]; + NSTableHeaderCell *headerCell = [[NSTableHeaderCell alloc] initTextCell:@""]; + NSButtonCell *dataCell = [[NSButtonCell alloc] initTextCell:@""]; + + [dataCell setButtonType:NSSwitchButton]; + [dataCell setControlSize:NSSmallControlSize]; + [dataCell setRefusesFirstResponder:YES]; + + [tableColumn setResizingMask:NSTableColumnNoResizing]; + [tableColumn setHeaderCell:headerCell]; + [tableColumn setDataCell:dataCell]; + [tableColumn setWidth:20.0]; + + [content addTableColumn:tableColumn]; + } + + lstring headers = listView->state.headerText; + if(headers.size() == 0) headers.append(""); + [content setUsesAlternatingRowBackgroundColors:headers.size() >= 2]; + + for(unsigned column = 0; column < headers.size(); column++) { + NSTableColumn *tableColumn = [[NSTableColumn alloc] initWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]]; + NSTableHeaderCell *headerCell = [[NSTableHeaderCell alloc] initTextCell:[NSString stringWithUTF8String:headers(column)]]; + CocoaListViewCell *dataCell = [[CocoaListViewCell alloc] initTextCell:@""]; + + [dataCell setEditable:NO]; + + [tableColumn setResizingMask:NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask]; + [tableColumn setHeaderCell:headerCell]; + [tableColumn setDataCell:dataCell]; + + [content addTableColumn:tableColumn]; + } +} + +-(NSInteger) numberOfRowsInTableView :(NSTableView*)table { + return listView->state.text.size(); +} + +-(id) tableView :(NSTableView*)table objectValueForTableColumn :(NSTableColumn*)tableColumn row:(NSInteger)row { + if([[tableColumn identifier] isEqualToString:@"check"]) { + auto checked = listView->state.checked(row) ? NSOnState : NSOffState; + return [NSNumber numberWithInteger:checked]; + } + + NSInteger column = [[tableColumn identifier] integerValue]; + unsigned height = [table rowHeight]; + + NSString *text = [NSString stringWithUTF8String:listView->state.text(row)(column)]; + NSImage *image = NSMakeImage(listView->state.image(row)(column), height, height); + + if(image) return @{ @"text":text, @"image":image }; + return @{ @"text":text }; +} + +-(void) tableView :(NSTableView*)table setObjectValue:(id)object forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row { + if([[tableColumn identifier] isEqualToString:@"check"]) { + listView->state.checked(row) = [object integerValue] != NSOffState; + if(listView->onToggle) listView->onToggle(row); + } +} + +-(void) tableView :(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row { + [cell setFont:[self font]]; +} + +-(void) tableViewSelectionDidChange :(NSNotification*)notification { + if(listView->onChange) listView->onChange(); +} + +-(IBAction) activate :(id)sender { + if([content clickedRow] < 0) return; + if(listView->onActivate) listView->onActivate(); +} + +@end + +@implementation CocoaListViewContent : NSTableView + +-(void) keyDown :(NSEvent*)event { + [super keyDown:event]; + + auto character = [[event characters] characterAtIndex:0]; + if(character == NSEnterCharacter || character == NSCarriageReturnCharacter) { + [[self delegate] activate:self]; + } +} + +@end + +@implementation CocoaListViewCell : NSTextFieldCell + +//used by type-ahead +-(NSString*) stringValue { + return [[self objectValue] objectForKey:@"text"]; +} + +-(void) drawWithFrame :(NSRect)frame inView:(NSView*)view { + NSString *text = [[self objectValue] objectForKey:@"text"]; + NSImage *image = [[self objectValue] objectForKey:@"image"]; + unsigned textDisplacement = 0; + + if(image) { + NSGraphicsContext *context = [NSGraphicsContext currentContext]; + [context saveGraphicsState]; + + NSRect targetRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height); + NSRect sourceRect = NSMakeRect(0, 0, [image size].width, [image size].height); + [image drawInRect:targetRect fromRect:sourceRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil]; + + [context restoreGraphicsState]; + textDisplacement = frame.size.height + 2; + } + + NSRect textRect = NSMakeRect( + frame.origin.x + textDisplacement, frame.origin.y, + frame.size.width - textDisplacement, frame.size.height + ); + + NSColor *textColor = [self isHighlighted] + ? [NSColor alternateSelectedControlTextColor] + : [NSColor textColor]; + + [text drawInRect:textRect withAttributes:@{ + NSForegroundColorAttributeName:textColor, + NSFontAttributeName:[self font] + }]; +} + +@end + +namespace phoenix { + +void pListView::append(const lstring &text) { + @autoreleasepool { + [[cocoaView content] reloadData]; + } +} + +void pListView::autoSizeColumns() { + @autoreleasepool { + if(listView.state.checkable) { + NSTableColumn *tableColumn = [[cocoaView content] tableColumnWithIdentifier:@"check"]; + [tableColumn setWidth:20.0]; + } + + unsigned height = [[cocoaView content] rowHeight]; + for(unsigned column = 0; column < listView.state.headerText.size(); column++) { + NSTableColumn *tableColumn = [[cocoaView content] tableColumnWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]]; + unsigned minimumWidth = pFont::size([[tableColumn headerCell] font], listView.state.headerText(column)).width + 4; + for(unsigned row = 0; row < listView.state.text.size(); row++) { + unsigned width = pFont::size([cocoaView font], listView.state.text(row)(column)).width + 2; + if(listView.state.image(row)(height).empty() == false) width += height + 2; + if(width > minimumWidth) minimumWidth = width; + } + [tableColumn setWidth:minimumWidth]; + } + } +} + +bool pListView::checked(unsigned row) { + return listView.state.checked(row); +} + +void pListView::modify(unsigned row, const lstring &text) { + @autoreleasepool { + [[cocoaView content] reloadData]; + } +} + +void pListView::remove(unsigned row) { + @autoreleasepool { + [[cocoaView content] reloadData]; + } +} + +void pListView::reset() { + @autoreleasepool { + [[cocoaView content] reloadData]; + } +} + +bool pListView::selected() { + @autoreleasepool { + return [[cocoaView content] selectedRow] >= 0; + } +} + +unsigned pListView::selection() { + if(selected() == false) return 0; + + @autoreleasepool { + return [[cocoaView content] selectedRow]; + } +} + +void pListView::setCheckable(bool checkable) { + @autoreleasepool { + [cocoaView reloadColumns]; + } +} + +void pListView::setChecked(unsigned row, bool checked) { + @autoreleasepool { + [[cocoaView content] reloadData]; + } +} + +void pListView::setFont(const string &font) { + @autoreleasepool { + [cocoaView setFont:pFont::cocoaFont(font)]; + } +} + +void pListView::setHeaderText(const lstring &text) { + @autoreleasepool { + [cocoaView reloadColumns]; + } +} + +void pListView::setHeaderVisible(bool visible) { + @autoreleasepool { + if(visible) { + [[cocoaView content] setHeaderView:[[[NSTableHeaderView alloc] init] autorelease]]; + } else { + [[cocoaView content] setHeaderView:nil]; + } + } +} + +void pListView::setImage(unsigned row, unsigned column, const image &image) { + @autoreleasepool { + [[cocoaView content] reloadData]; + } +} + +void pListView::setSelected(bool selected) { + @autoreleasepool { + if(selected == false) { + [[cocoaView content] deselectAll:nil]; + } + } +} + +void pListView::setSelection(unsigned row) { + @autoreleasepool { + [[cocoaView content] selectRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(row, 1)] byExtendingSelection:NO]; + } +} + +void pListView::constructor() { + @autoreleasepool { + cocoaView = cocoaListView = [[CocoaListView alloc] initWith:listView]; + setHeaderVisible(listView.state.headerVisible); + setHeaderText(listView.state.headerText); + } +} + +void pListView::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/list-view.hpp b/higan/phoenix/cocoa/widget/list-view.hpp new file mode 100644 index 00000000..5d794d3b --- /dev/null +++ b/higan/phoenix/cocoa/widget/list-view.hpp @@ -0,0 +1,62 @@ +@class CocoaListViewContent; + +@interface CocoaListView : NSScrollView { +@public + phoenix::ListView *listView; + CocoaListViewContent *content; + NSFont *font; +} +-(id) initWith :(phoenix::ListView&)listView; +-(void) dealloc; +-(CocoaListViewContent*) content; +-(NSFont*) font; +-(void) setFont :(NSFont*)font; +-(void) reloadColumns; +-(NSInteger) numberOfRowsInTableView :(NSTableView*)table; +-(id) tableView :(NSTableView*)table objectValueForTableColumn :(NSTableColumn*)tableColumn row:(NSInteger)row; +-(void) tableView :(NSTableView*)table setObjectValue:(id)object forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row; +-(void) tableView :(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row; +-(void) tableViewSelectionDidChange :(NSNotification*)notification; +-(IBAction) activate :(id)sender; +@end + +@interface CocoaListViewContent : NSTableView { +} +-(void) keyDown :(NSEvent*)event; +@end + +@interface CocoaListViewCell : NSTextFieldCell { +} +-(NSString*) stringValue; +-(void) drawWithFrame :(NSRect)frame inView:(NSView*)view; +@end + +namespace phoenix { + +struct pListView : public pWidget { + ListView &listView; + CocoaListView *cocoaListView; + + void append(const lstring &text); + void autoSizeColumns(); + bool checked(unsigned row); + void modify(unsigned row, const lstring &text); + void remove(unsigned row); + void reset(); + bool selected(); + unsigned selection(); + void setCheckable(bool checkable); + void setChecked(unsigned row, bool checked); + void setFont(const string &font); + void setHeaderText(const lstring &text); + void setHeaderVisible(bool visible); + void setImage(unsigned row, unsigned column, const image &image); + void setSelected(bool selected); + void setSelection(unsigned row); + + pListView(ListView &listView) : pWidget(listView), listView(listView) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/progress-bar.cpp b/higan/phoenix/cocoa/widget/progress-bar.cpp new file mode 100644 index 00000000..6a4cad1e --- /dev/null +++ b/higan/phoenix/cocoa/widget/progress-bar.cpp @@ -0,0 +1,37 @@ +@implementation CocoaProgressBar : NSProgressIndicator + +-(id) initWith :(phoenix::ProgressBar&)progressBarReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + progressBar = &progressBarReference; + + [self setIndeterminate:NO]; + [self setMinValue:0.0]; + [self setMaxValue:100.0]; + } + return self; +} + +@end + +namespace phoenix { + +void pProgressBar::setPosition(unsigned position) { + @autoreleasepool { + [cocoaView setDoubleValue:position]; + } +} + +void pProgressBar::constructor() { + @autoreleasepool { + cocoaView = cocoaProgressBar = [[CocoaProgressBar alloc] initWith:progressBar]; + setPosition(progressBar.state.position); + } +} + +void pProgressBar::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/progress-bar.hpp b/higan/phoenix/cocoa/widget/progress-bar.hpp new file mode 100644 index 00000000..7fd43079 --- /dev/null +++ b/higan/phoenix/cocoa/widget/progress-bar.hpp @@ -0,0 +1,21 @@ +@interface CocoaProgressBar : NSProgressIndicator { +@public + phoenix::ProgressBar *progressBar; +} +-(id) initWith :(phoenix::ProgressBar&)progressBar; +@end + +namespace phoenix { + +struct pProgressBar : public pWidget { + ProgressBar &progressBar; + CocoaProgressBar *cocoaProgressBar; + + void setPosition(unsigned position); + + pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/radio-button.cpp b/higan/phoenix/cocoa/widget/radio-button.cpp new file mode 100644 index 00000000..77ba67e0 --- /dev/null +++ b/higan/phoenix/cocoa/widget/radio-button.cpp @@ -0,0 +1,64 @@ +@implementation CocoaRadioButton : NSButton + +-(id) initWith :(phoenix::RadioButton&)radioButtonReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + radioButton = &radioButtonReference; + + [self setTarget:self]; + [self setAction:@selector(activate:)]; + [self setButtonType:NSRadioButton]; + } + return self; +} + +-(IBAction) activate :(id)sender { + radioButton->setChecked(); + if(radioButton->onActivate) radioButton->onActivate(); +} + +@end + +namespace phoenix { + +bool pRadioButton::checked() { + @autoreleasepool { + return [cocoaView state] != NSOffState; + } +} + +Size pRadioButton::minimumSize() { + Size size = Font::size(radioButton.font(), radioButton.state.text); + return {size.width + 24, size.height + 8}; +} + +void pRadioButton::setChecked() { + @autoreleasepool { + for(auto &button : radioButton.state.group) { + auto state = (&button == &radioButton) ? NSOnState : NSOffState; + [button.p.cocoaView setState:state]; + } + } +} + +void pRadioButton::setGroup(const set &group) { +} + +void pRadioButton::setText(const string &text) { + @autoreleasepool { + [cocoaView setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pRadioButton::constructor() { + @autoreleasepool { + cocoaView = cocoaRadioButton = [[CocoaRadioButton alloc] initWith:radioButton]; + } +} + +void pRadioButton::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/radio-button.hpp b/higan/phoenix/cocoa/widget/radio-button.hpp new file mode 100644 index 00000000..3c0a6658 --- /dev/null +++ b/higan/phoenix/cocoa/widget/radio-button.hpp @@ -0,0 +1,25 @@ +@interface CocoaRadioButton : NSButton { +@public + phoenix::RadioButton *radioButton; +} +-(id) initWith :(phoenix::RadioButton&)radioButton; +@end + +namespace phoenix { + +struct pRadioButton : public pWidget { + RadioButton &radioButton; + CocoaRadioButton *cocoaRadioButton; + + bool checked(); + Size minimumSize(); + void setChecked(); + void setGroup(const set &group); + void setText(const string &text); + + pRadioButton(RadioButton &radioButton) : pWidget(radioButton), radioButton(radioButton) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/sizable.hpp b/higan/phoenix/cocoa/widget/sizable.hpp new file mode 100644 index 00000000..b7c2f934 --- /dev/null +++ b/higan/phoenix/cocoa/widget/sizable.hpp @@ -0,0 +1,9 @@ +namespace phoenix { + +struct pSizable : public pObject { + Sizable &sizable; + + pSizable(Sizable &sizable) : pObject(sizable), sizable(sizable) {} +}; + +} diff --git a/higan/phoenix/cocoa/widget/text-edit.cpp b/higan/phoenix/cocoa/widget/text-edit.cpp new file mode 100644 index 00000000..36dde2a9 --- /dev/null +++ b/higan/phoenix/cocoa/widget/text-edit.cpp @@ -0,0 +1,101 @@ +@implementation CocoaTextEdit : NSScrollView + +-(id) initWith :(phoenix::TextEdit&)textEditReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) { + textEdit = &textEditReference; + + content = [[[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)] autorelease]; + [content setDelegate:self]; + [content setRichText:NO]; + + [self setBorderType:NSBezelBorder]; + [self setDocumentView:content]; + [self configure]; + } + return self; +} + +-(NSTextView*) content { + return content; +} + +-(void) configure { + [content setMinSize:NSMakeSize(0, 0)]; + [content setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; + + [[content textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)]; + [[content textContainer] setWidthTracksTextView:textEdit->wordWrap()]; + + [content setHorizontallyResizable:YES]; + [content setVerticallyResizable:YES]; + [content setAutoresizingMask:NSViewNotSizable]; + + [self setHasHorizontalScroller:!textEdit->wordWrap()]; + [self setHasVerticalScroller:YES]; +} + +-(void) textDidChange :(NSNotification*)notification { + textEdit->state.text = [[content string] UTF8String]; + if(textEdit->onChange) textEdit->onChange(); +} + +@end + +namespace phoenix { + +void pTextEdit::setCursorPosition(unsigned position) { + @autoreleasepool { + string text = [[[cocoaView content] string] UTF8String]; + position = min(position, text.length()); + [[cocoaView content] setSelectedRange:NSMakeRange(position, 0)]; + } +} + +void pTextEdit::setEditable(bool editable) { + @autoreleasepool { + [[cocoaView content] setEditable:editable]; + } +} + +void pTextEdit::setFont(const string &font) { + @autoreleasepool { + [[cocoaView content] setFont:pFont::cocoaFont(font)]; + } +} + +void pTextEdit::setText(const string &text) { + @autoreleasepool { + [[cocoaView content] setString:[NSString stringWithUTF8String:text]]; + } +} + +void pTextEdit::setWordWrap(bool wordWrap) { + @autoreleasepool { + [cocoaView configure]; + } +} + +string pTextEdit::text() { + @autoreleasepool { + return [[[cocoaView content] string] UTF8String]; + } +} + +void pTextEdit::constructor() { + @autoreleasepool { + cocoaView = cocoaTextEdit = [[CocoaTextEdit alloc] initWith:textEdit]; + setEditable(textEdit.state.editable); + setWordWrap(textEdit.state.wordWrap); + setFont(textEdit.font()); + setText(textEdit.state.text); + setCursorPosition(textEdit.state.cursorPosition); + } +} + +void pTextEdit::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/text-edit.hpp b/higan/phoenix/cocoa/widget/text-edit.hpp new file mode 100644 index 00000000..2b58f62a --- /dev/null +++ b/higan/phoenix/cocoa/widget/text-edit.hpp @@ -0,0 +1,30 @@ +@interface CocoaTextEdit : NSScrollView { +@public + phoenix::TextEdit *textEdit; + NSTextView *content; +} +-(id) initWith :(phoenix::TextEdit&)textEdit; +-(NSTextView*) content; +-(void) configure; +-(void) textDidChange :(NSNotification*)notification; +@end + +namespace phoenix { + +struct pTextEdit : public pWidget { + TextEdit &textEdit; + CocoaTextEdit *cocoaTextEdit; + + void setCursorPosition(unsigned position); + void setEditable(bool editable); + void setFont(const string &font); + void setText(const string &text); + void setWordWrap(bool wordWrap); + string text(); + + pTextEdit(TextEdit &textEdit) : pWidget(textEdit), textEdit(textEdit) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/vertical-scroller.cpp b/higan/phoenix/cocoa/widget/vertical-scroller.cpp new file mode 100644 index 00000000..830eb52b --- /dev/null +++ b/higan/phoenix/cocoa/widget/vertical-scroller.cpp @@ -0,0 +1,91 @@ +@implementation CocoaVerticalScroller : NSScroller + +-(id) initWith :(phoenix::VerticalScroller&)verticalScrollerReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 1)]) { + verticalScroller = &verticalScrollerReference; + + [self setTarget:self]; + [self setAction:@selector(scroll:)]; + + [self setControlSize:NSRegularControlSize]; + [self setScrollerStyle:NSScrollerStyleLegacy]; + [self setEnabled:YES]; + + [self update]; + } + return self; +} + +-(void) update { + double d = 1.0 / verticalScroller->state.length; + double f = d * verticalScroller->state.position; + + [self setDoubleValue:f]; + [self setKnobProportion:d]; +} + +-(IBAction) scroll :(id)sender { + auto &state = verticalScroller->state; + + switch([self hitPart]) { + case NSScrollerIncrementLine: + case NSScrollerIncrementPage: + if(state.position < state.length - 1) state.position++; + [self update]; + break; + + case NSScrollerDecrementLine: + case NSScrollerDecrementPage: + if(state.position) state.position--; + [self update]; + break; + + case NSScrollerKnob: + state.position = [self doubleValue] * state.length; + break; + } + + if(verticalScroller->onChange) verticalScroller->onChange(); +} + +@end + +namespace phoenix { + +Size pVerticalScroller::minimumSize() { + @autoreleasepool { + return {[NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy], 32}; + } +} + +unsigned pVerticalScroller::position() { + @autoreleasepool { + return [cocoaView doubleValue] * verticalScroller.state.length; + } +} + +void pVerticalScroller::setLength(unsigned length) { + @autoreleasepool { + [cocoaView update]; + } +} + +void pVerticalScroller::setPosition(unsigned position) { + @autoreleasepool { + [cocoaView update]; + } +} + +void pVerticalScroller::constructor() { + @autoreleasepool { + cocoaView = cocoaVerticalScroller = [[CocoaVerticalScroller alloc] initWith:verticalScroller]; + } +} + +void pVerticalScroller::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/vertical-scroller.hpp b/higan/phoenix/cocoa/widget/vertical-scroller.hpp new file mode 100644 index 00000000..ad2d87aa --- /dev/null +++ b/higan/phoenix/cocoa/widget/vertical-scroller.hpp @@ -0,0 +1,24 @@ +@interface CocoaVerticalScroller : NSScroller { +@public + phoenix::VerticalScroller *verticalScroller; +} +-(id) initWith :(phoenix::VerticalScroller&)verticalScroller; +@end + +namespace phoenix { + +struct pVerticalScroller : public pWidget { + VerticalScroller &verticalScroller; + CocoaVerticalScroller *cocoaVerticalScroller; + + Size minimumSize(); + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pVerticalScroller(VerticalScroller &verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/vertical-slider.cpp b/higan/phoenix/cocoa/widget/vertical-slider.cpp new file mode 100644 index 00000000..dadd07f9 --- /dev/null +++ b/higan/phoenix/cocoa/widget/vertical-slider.cpp @@ -0,0 +1,60 @@ +@implementation CocoaVerticalSlider : NSSlider + +-(id) initWith :(phoenix::VerticalSlider&)verticalSliderReference { + if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 1)]) { + verticalSlider = &verticalSliderReference; + + [self setTarget:self]; + [self setAction:@selector(activate:)]; + [self setMinValue:0]; + } + return self; +} + +-(IBAction) activate :(id)sender { + verticalSlider->state.position = [self doubleValue]; + if(verticalSlider->onChange) verticalSlider->onChange(); +} + +@end + +namespace phoenix { + +Size pVerticalSlider::minimumSize() { + return {24, 64}; +} + +unsigned pVerticalSlider::position() { + @autoreleasepool { + return [cocoaView doubleValue]; + } +} + +void pVerticalSlider::setLength(unsigned length) { + @autoreleasepool { + [cocoaView setMaxValue:length]; + } +} + +void pVerticalSlider::setPosition(unsigned position) { + @autoreleasepool { + [cocoaView setDoubleValue:position]; + } +} + +void pVerticalSlider::constructor() { + @autoreleasepool { + cocoaView = cocoaVerticalSlider = [[CocoaVerticalSlider alloc] initWith:verticalSlider]; + + setLength(verticalSlider.state.length); + setPosition(verticalSlider.state.position); + } +} + +void pVerticalSlider::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/vertical-slider.hpp b/higan/phoenix/cocoa/widget/vertical-slider.hpp new file mode 100644 index 00000000..dfcb8e69 --- /dev/null +++ b/higan/phoenix/cocoa/widget/vertical-slider.hpp @@ -0,0 +1,25 @@ +@interface CocoaVerticalSlider : NSSlider { +@public + phoenix::VerticalSlider *verticalSlider; +} +-(id) initWith :(phoenix::VerticalSlider&)verticalSlider; +-(IBAction) activate :(id)sender; +@end + +namespace phoenix { + +struct pVerticalSlider : public pWidget { + VerticalSlider &verticalSlider; + CocoaVerticalSlider *cocoaVerticalSlider; + + Size minimumSize(); + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pVerticalSlider(VerticalSlider &verticalSlider) : pWidget(verticalSlider), verticalSlider(verticalSlider) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/viewport.cpp b/higan/phoenix/cocoa/widget/viewport.cpp new file mode 100644 index 00000000..5d088e3d --- /dev/null +++ b/higan/phoenix/cocoa/widget/viewport.cpp @@ -0,0 +1,10 @@ +namespace phoenix { + +uintptr_t pViewport::handle() { + return 0; +} + +void pViewport::constructor() { +} + +} diff --git a/higan/phoenix/cocoa/widget/viewport.hpp b/higan/phoenix/cocoa/widget/viewport.hpp new file mode 100644 index 00000000..94a6eecb --- /dev/null +++ b/higan/phoenix/cocoa/widget/viewport.hpp @@ -0,0 +1,12 @@ +namespace phoenix { + +struct pViewport : public pWidget { + Viewport &viewport; + + uintptr_t handle(); + + pViewport(Viewport &viewport) : pWidget(viewport), viewport(viewport) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/cocoa/widget/widget.cpp b/higan/phoenix/cocoa/widget/widget.cpp new file mode 100644 index 00000000..6c1b75ee --- /dev/null +++ b/higan/phoenix/cocoa/widget/widget.cpp @@ -0,0 +1,76 @@ +namespace phoenix { + +bool pWidget::enabled() { + @autoreleasepool { + return [cocoaView respondsToSelector:@selector(enabled)] && [cocoaView enabled]; + } +} + +bool pWidget::focused() { + @autoreleasepool { + return cocoaView == [[cocoaView window] firstResponder]; + } +} + +Size pWidget::minimumSize() { + return {0, 0}; +} + +void pWidget::setEnabled(bool enabled) { + if(widget.state.abstract) enabled = false; + if(sizable.state.layout && sizable.state.layout->enabled() == false) enabled = false; + + @autoreleasepool { + if([cocoaView respondsToSelector:@selector(setEnabled:)]) { + [cocoaView setEnabled:enabled]; + } + } +} + +void pWidget::setFocused() { + @autoreleasepool { + [[cocoaView window] makeFirstResponder:cocoaView]; + } +} + +void pWidget::setFont(const string &font) { + @autoreleasepool { + if([cocoaView respondsToSelector:@selector(setFont:)]) { + [cocoaView setFont:pFont::cocoaFont(font)]; + } + } +} + +void pWidget::setGeometry(const Geometry &geometry) { + @autoreleasepool { + CGFloat windowHeight = [[cocoaView superview] frame].size.height; + [cocoaView setFrame:NSMakeRect(geometry.x, windowHeight - geometry.y - geometry.height, geometry.width, geometry.height)]; + [[cocoaView superview] setNeedsDisplay:YES]; + } +} + +void pWidget::setVisible(bool visible) { + if(widget.state.abstract) visible = false; + if(sizable.state.layout && sizable.state.layout->visible() == false) visible = false; + + @autoreleasepool { + [cocoaView setHidden:!visible]; + } +} + +void pWidget::constructor() { + if(!widget.state.abstract) return; + + @autoreleasepool { + cocoaView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)]; + [cocoaView setHidden:true]; + } +} + +void pWidget::destructor() { + @autoreleasepool { + [cocoaView release]; + } +} + +} diff --git a/higan/phoenix/cocoa/widget/widget.hpp b/higan/phoenix/cocoa/widget/widget.hpp new file mode 100644 index 00000000..d0dc99a2 --- /dev/null +++ b/higan/phoenix/cocoa/widget/widget.hpp @@ -0,0 +1,21 @@ +namespace phoenix { + +struct pWidget : public pSizable { + Widget &widget; + NSView *cocoaView; + + bool enabled(); + bool focused(); + virtual Size minimumSize(); + void setEnabled(bool enabled); + void setFocused(); + virtual void setFont(const string &font); + void setGeometry(const Geometry &geometry); + void setVisible(bool visible); + + pWidget(Widget &widget) : pSizable(widget), widget(widget) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/cocoa/window.cpp b/higan/phoenix/cocoa/window.cpp new file mode 100644 index 00000000..cb920b94 --- /dev/null +++ b/higan/phoenix/cocoa/window.cpp @@ -0,0 +1,326 @@ +@implementation CocoaWindow : NSWindow + +-(id) initWith :(phoenix::Window&)windowReference { + window = &windowReference; + + NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask; + if(window->state.resizable) style |= NSResizableWindowMask; + + if(self = [super initWithContentRect:NSMakeRect(0, 0, 640, 480) styleMask:style backing:NSBackingStoreBuffered defer:YES]) { + [self setDelegate:self]; + [self setReleasedWhenClosed:NO]; + [self setAcceptsMouseMovedEvents:YES]; + [self setLevel:NSFloatingWindowLevel]; //when launched from a terminal, this places the window above it + [self setTitle:@""]; + + menu = [[NSMenu alloc] init]; + [menu retain]; + + NSMenuItem *item; + string text; + + rootMenu = [[NSMenu alloc] init]; + item = [[[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""] autorelease]; + [item setSubmenu:rootMenu]; + [menu addItem:item]; + + text = {"About ", phoenix::applicationState.name, "..."}; + item = [[[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:text] action:@selector(menuAbout) keyEquivalent:@""] autorelease]; + [rootMenu addItem:item]; + [rootMenu addItem:[NSMenuItem separatorItem]]; + + item = [[[NSMenuItem alloc] initWithTitle:@"Preferences" action:@selector(menuPreferences) keyEquivalent:@""] autorelease]; + [rootMenu addItem:item]; + [rootMenu addItem:[NSMenuItem separatorItem]]; + + text = {"Quit ", phoenix::applicationState.name}; + item = [[[NSMenuItem alloc] initWithTitle:[NSString stringWithUTF8String:text] action:@selector(menuQuit) keyEquivalent:@""] autorelease]; + [rootMenu addItem:item]; + } + + return self; +} + +-(BOOL) canBecomeKeyWindow { + return YES; +} + +-(BOOL) canBecomeMainWindow { + return YES; +} + +-(void) windowDidBecomeMain :(NSNotification*)notification { + if(window->state.menu.size() > 0) { + [NSApp setMainMenu:menu]; + } +} + +-(void) windowDidMove :(NSNotification*)notification { + window->p.moveEvent(); +} + +-(void) windowDidResize :(NSNotification*)notification { + window->p.sizeEvent(); +} + +-(BOOL) windowShouldClose :(id)sender { + if(window->onClose) window->onClose(); + else window->setVisible(false); + if(window->state.modal && !window->visible()) window->setModal(false); + return NO; +} + +-(NSMenu*) menu { + return menu; +} + +-(void) menuAbout { + using phoenix::Application; + if(Application::Cocoa::onAbout) Application::Cocoa::onAbout(); +} + +-(void) menuPreferences { + using phoenix::Application; + if(Application::Cocoa::onPreferences) Application::Cocoa::onPreferences(); +} + +-(void) menuQuit { + using phoenix::Application; + if(Application::Cocoa::onQuit) Application::Cocoa::onQuit(); +} + +@end + +namespace phoenix { + +Window& pWindow::none() { + static Window *window = nullptr; + if(window == nullptr) window = new Window; + return *window; +} + +void pWindow::append(Layout &layout) { + Geometry geometry = window.state.geometry; + geometry.x = geometry.y = 0; + layout.setGeometry(geometry); +} + +void pWindow::append(Menu &menu) { + @autoreleasepool { + [[cocoaWindow menu] addItem:menu.p.cocoaAction]; + } +} + +void pWindow::append(Widget &widget) { + if(widget.font().empty() && !window.state.widgetFont.empty()) { + widget.setFont(window.state.widgetFont); + } + + @autoreleasepool { + [widget.p.cocoaView removeFromSuperview]; + [[cocoaWindow contentView] addSubview:widget.p.cocoaView positioned:NSWindowAbove relativeTo:nil]; + widget.p.setGeometry(widget.geometry()); + [[cocoaWindow contentView] setNeedsDisplay:YES]; + } +} + +Color pWindow::backgroundColor() { + @autoreleasepool { + NSColor *color = [[cocoaWindow backgroundColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + return { + uint8_t(255 * [color redComponent]), + uint8_t(255 * [color greenComponent]), + uint8_t(255 * [color blueComponent]), + uint8_t(255 * [color alphaComponent]) + }; + } +} + +bool pWindow::focused() { + @autoreleasepool { + return [cocoaWindow isMainWindow] == YES; + } +} + +Geometry pWindow::frameMargin() { + @autoreleasepool { + NSRect frame = [cocoaWindow frameRectForContentRect:NSMakeRect(0, 0, 640, 480)]; + return {abs(frame.origin.x), frame.size.height - 480, frame.size.width - 640, abs(frame.origin.y)}; + } +} + +Geometry pWindow::geometry() { + @autoreleasepool { + NSRect area = [cocoaWindow contentRectForFrameRect:[cocoaWindow frame]]; + return {area.origin.x, Desktop::size().height - area.origin.y - area.size.height, area.size.width, area.size.height}; + } +} + +void pWindow::remove(Layout &layout) { + @autoreleasepool { + [[cocoaWindow contentView] setNeedsDisplay:YES]; + } +} + +void pWindow::remove(Menu &menu) { + @autoreleasepool { + [[cocoaWindow menu] removeItem:menu.p.cocoaAction]; + } +} + +void pWindow::remove(Widget &widget) { + @autoreleasepool { + [widget.p.cocoaView removeFromSuperview]; + [[cocoaWindow contentView] setNeedsDisplay:YES]; + } +} + +void pWindow::setBackgroundColor(const Color &color) { + @autoreleasepool { + [cocoaWindow + setBackgroundColor:[NSColor + colorWithCalibratedRed:color.red / 255.0 + green:color.green / 255.0 + blue:color.blue / 255.0 + alpha:color.alpha / 255.0 + ] + ]; + } +} + +void pWindow::setFocused() { + @autoreleasepool { + [cocoaWindow makeKeyAndOrderFront:nil]; + } +} + +void pWindow::setFullScreen(bool fullScreen) { + @autoreleasepool { + [cocoaWindow setLevel:NSNormalWindowLevel]; + if(fullScreen == true) { + [NSApp setPresentationOptions:NSApplicationPresentationFullScreen]; + [cocoaWindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + [cocoaWindow toggleFullScreen:nil]; + } else { + [cocoaWindow toggleFullScreen:nil]; + [cocoaWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault]; + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + } + } +} + +void pWindow::setGeometry(const Geometry &geometry) { + locked = true; + + @autoreleasepool { + [cocoaWindow + setFrame:[cocoaWindow + frameRectForContentRect:NSMakeRect(geometry.x, Desktop::size().height - geometry.y - geometry.height, geometry.width, geometry.height) + ] + display:YES + ]; + + for(auto &layout : window.state.layout) { + Geometry geometry = this->geometry(); + geometry.x = geometry.y = 0; + layout.setGeometry(geometry); + } + } + + locked = false; +} + +void pWindow::setMenuFont(const string &font) { +} + +void pWindow::setMenuVisible(bool visible) { +} + +void pWindow::setModal(bool modal) { + @autoreleasepool { + if(modal == true) { + [NSApp runModalForWindow:cocoaWindow]; + } else { + [NSApp stopModal]; + NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0.0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]; + [NSApp postEvent:event atStart:true]; + } + } +} + +void pWindow::setResizable(bool resizable) { + @autoreleasepool { + NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask; + if(resizable) style |= NSResizableWindowMask; + [cocoaWindow setStyleMask:style]; + } +} + +void pWindow::setStatusFont(const string &font) { +} + +void pWindow::setStatusText(const string &text) { +} + +void pWindow::setStatusVisible(bool visible) { +} + +void pWindow::setTitle(const string &text) { + @autoreleasepool { + [cocoaWindow setTitle:[NSString stringWithUTF8String:text]]; + } +} + +void pWindow::setVisible(bool visible) { + @autoreleasepool { + if(visible) [cocoaWindow makeKeyAndOrderFront:nil]; + else [cocoaWindow orderOut:nil]; + } +} + +void pWindow::setWidgetFont(const string &font) { +} + +void pWindow::constructor() { + @autoreleasepool { + cocoaWindow = [[CocoaWindow alloc] initWith:window]; + } +} + +void pWindow::destructor() { + @autoreleasepool { + [cocoaWindow release]; + } +} + +void pWindow::moveEvent() { + if(locked == false && window.fullScreen() == false && window.visible() == true) { + Geometry geometry = this->geometry(); + window.state.geometry.x = geometry.x; + window.state.geometry.y = geometry.y; + } + + if(locked == false) { + if(window.onMove) window.onMove(); + } +} + +void pWindow::sizeEvent() { + if(locked == false && window.fullScreen() == false && window.visible() == true) { + Geometry geometry = this->geometry(); + window.state.geometry.width = geometry.width; + window.state.geometry.height = geometry.height; + } + + for(auto &layout : window.state.layout) { + Geometry geometry = this->geometry(); + geometry.x = geometry.y = 0; + layout.setGeometry(geometry); + } + + if(locked == false) { + if(window.onSize) window.onSize(); + } +} + +} diff --git a/higan/phoenix/cocoa/window.hpp b/higan/phoenix/cocoa/window.hpp new file mode 100644 index 00000000..79e9407e --- /dev/null +++ b/higan/phoenix/cocoa/window.hpp @@ -0,0 +1,60 @@ +@interface CocoaWindow : NSWindow { +@public + phoenix::Window *window; + NSMenu *menu; + NSMenu *rootMenu; +} +-(id) initWith :(phoenix::Window&)window; +-(BOOL) canBecomeKeyWindow; +-(BOOL) canBecomeMainWindow; +-(void) windowDidBecomeMain :(NSNotification*)notification; +-(void) windowDidMove :(NSNotification*)notification; +-(void) windowDidResize :(NSNotification*)notification; +-(BOOL) windowShouldClose :(id)sender; +-(NSMenu*) menu; +-(void) menuAbout; +-(void) menuPreferences; +-(void) menuQuit; +@end + +namespace phoenix { + +struct pWindow : public pObject { + Window &window; + CocoaWindow *cocoaWindow; + + static Window& none(); + + void append(Layout &layout); + void append(Menu &menu); + void append(Widget &widget); + Color backgroundColor(); + bool focused(); + Geometry frameMargin(); + Geometry geometry(); + void remove(Layout &layout); + void remove(Menu &menu); + void remove(Widget &widget); + void setBackgroundColor(const Color &color); + void setFocused(); + void setFullScreen(bool fullScreen); + void setGeometry(const Geometry &geometry); + void setMenuFont(const string &font); + void setMenuVisible(bool visible); + void setModal(bool modal); + void setResizable(bool resizable); + void setStatusFont(const string &font); + void setStatusText(const string &text); + void setStatusVisible(bool visible); + void setTitle(const string &text); + void setVisible(bool visible); + void setWidgetFont(const string &font); + + pWindow(Window &window) : pObject(window), window(window) {} + void constructor(); + void destructor(); + void moveEvent(); + void sizeEvent(); +}; + +} diff --git a/higan/phoenix/core/core.cpp b/higan/phoenix/core/core.cpp index a2588770..2bd5f4bd 100755 --- a/higan/phoenix/core/core.cpp +++ b/higan/phoenix/core/core.cpp @@ -1,7 +1,24 @@ -#include "state.hpp" -#include "layout/fixed-layout.cpp" -#include "layout/horizontal-layout.cpp" -#include "layout/vertical-layout.cpp" +#if defined(PHOENIX_WINDOWS) + #include "../windows/header.hpp" +#elif defined(PHOENIX_QT) + #include "../qt/header.hpp" +#elif defined(PHOENIX_GTK) + #include "../gtk/header.hpp" +#elif defined(PHOENIX_COCOA) + #include "../cocoa/header.hpp" +#elif defined(PHOENIX_REFERENCE) + #include "../reference/header.hpp" +#endif + +#include "core.hpp" +using namespace nall; + +namespace phoenix { + #include "state.hpp" + #include "layout/fixed-layout.cpp" + #include "layout/horizontal-layout.cpp" + #include "layout/vertical-layout.cpp" +} #if defined(PHOENIX_WINDOWS) #include "../windows/platform.cpp" @@ -9,11 +26,51 @@ #include "../qt/platform.cpp" #elif defined(PHOENIX_GTK) #include "../gtk/platform.cpp" +#elif defined(PHOENIX_COCOA) + #include "../cocoa/platform.cpp" #elif defined(PHOENIX_REFERENCE) #include "../reference/platform.cpp" #endif -static bool OS_quit = false; +namespace phoenix { + +//Application +//=========== + +nall::function Application::main; + +nall::function Application::Cocoa::onAbout; +nall::function Application::Cocoa::onPreferences; +nall::function Application::Cocoa::onQuit; + +void Application::run() { + return pApplication::run(); +} + +bool Application::pendingEvents() { + return pApplication::pendingEvents(); +} + +void Application::processEvents() { + return pApplication::processEvents(); +} + +void Application::quit() { + applicationState.quit = true; + return pApplication::quit(); +} + +void Application::setName(const string &name) { + applicationState.name = name; +} + +void Application::initialize() { + static bool initialized = false; + if(initialized == false) { + initialized = true; + return pApplication::initialize(); + } +} //Color //===== @@ -30,15 +87,15 @@ uint32_t Color::rgba() const { //======== Position Geometry::position() const { - return { x, y }; + return {x, y}; } Size Geometry::size() const { - return { width, height }; + return {width, height}; } string Geometry::text() const { - return { x, ",", y, ",", width, ",", height }; + return {x, ",", y, ",", width, ",", height}; } Geometry::Geometry(const string &text) { @@ -52,12 +109,20 @@ Geometry::Geometry(const string &text) { //Font //==== -Geometry Font::geometry(const string &text) { - return pFont::geometry(description, text); +string Font::serif(unsigned size, const string &style) { + return pFont::serif(size, style); } -Font::Font(const string &description): -description(description) { +string Font::sans(unsigned size, const string &style) { + return pFont::sans(size, style); +} + +string Font::monospace(unsigned size, const string &style) { + return pFont::monospace(size, style); +} + +Size Font::size(const string &font, const string &text) { + return pFont::size(font, text); } //Desktop @@ -144,7 +209,7 @@ MessageWindow::Response MessageWindow::critical(Window &parent, const string &te Object::Object(pObject &p): p(p) { - OS::initialize(); + Application::initialize(); p.constructor(); } @@ -153,38 +218,6 @@ Object::~Object() { delete &p; } -//OS -//== - -void OS::main() { - return pOS::main(); -} - -bool OS::pendingEvents() { - return pOS::pendingEvents(); -} - -void OS::processEvents() { - return pOS::processEvents(); -} - -void OS::quit() { - OS_quit = true; - return pOS::quit(); -} - -void OS::setName(const string &name) { - osState.name = name; -} - -void OS::initialize() { - static bool initialized = false; - if(initialized == false) { - initialized = true; - return pOS::initialize(); - } -} - //Timer //===== @@ -221,7 +254,7 @@ Window& Window::none() { void Window::append_(Layout &layout) { if(state.layout.append(layout)) { ((Sizable&)layout).state.window = this; - ((Sizable&)layout).state.layout = 0; + ((Sizable&)layout).state.layout = nullptr; p.append(layout); layout.synchronizeLayout(); } @@ -270,28 +303,24 @@ Geometry Window::geometry() { return p.geometry(); } -void Window::ignore() { - state.ignore = true; -} - void Window::remove_(Layout &layout) { if(state.layout.remove(layout)) { p.remove(layout); - ((Sizable&)layout).state.window = 0; + ((Sizable&)layout).state.window = nullptr; } } void Window::remove_(Menu &menu) { if(state.menu.remove(menu)) { p.remove(menu); - ((Action&)menu).state.window = 0; + ((Action&)menu).state.window = nullptr; } } void Window::remove_(Widget &widget) { if(state.widget.remove(widget)) { p.remove(widget); - ((Sizable&)widget).state.window = 0; + ((Sizable&)widget).state.window = nullptr; } } @@ -387,7 +416,7 @@ string Window::statusText() { } void Window::synchronizeLayout() { - if(visible() && OS_quit == false) setGeometry(geometry()); + if(visible() && applicationState.quit == false) setGeometry(geometry()); } bool Window::visible() { @@ -455,7 +484,7 @@ void Menu::append(const set &list) { void Menu::remove(const set &list) { for(auto &action : list) { if(state.action.remove(action)) { - action.state.menu = 0; + action.state.menu = nullptr; return p.remove(action); } } @@ -627,7 +656,7 @@ Sizable::~Sizable() { void Layout::append(Sizable &sizable) { sizable.state.layout = this; - sizable.state.window = 0; + sizable.state.window = nullptr; if(dynamic_cast(&sizable)) { Layout &layout = (Layout&)sizable; @@ -646,8 +675,8 @@ void Layout::remove(Sizable &sizable) { if(sizable.window()) sizable.window()->remove(widget); } - sizable.state.layout = 0; - sizable.state.window = 0; + sizable.state.layout = nullptr; + sizable.state.window = nullptr; } Layout::Layout(): @@ -690,8 +719,8 @@ Geometry Widget::geometry() { return state.geometry; } -Geometry Widget::minimumGeometry() { - return p.minimumGeometry(); +Size Widget::minimumSize() { + return p.minimumSize(); } void Widget::setEnabled(bool enabled) { @@ -818,88 +847,88 @@ Canvas::~Canvas() { delete &state; } -//CheckBox -//======== +//CheckButton +//=========== -bool CheckBox::checked() { +bool CheckButton::checked() { return p.checked(); } -void CheckBox::setChecked(bool checked) { +void CheckButton::setChecked(bool checked) { state.checked = checked; return p.setChecked(checked); } -void CheckBox::setText(const string &text) { +void CheckButton::setText(const string &text) { state.text = text; return p.setText(text); } -CheckBox::CheckBox(): +CheckButton::CheckButton(): state(*new State), -base_from_member(*new pCheckBox(*this)), -Widget(base_from_member::value), -p(base_from_member::value) { +base_from_member(*new pCheckButton(*this)), +Widget(base_from_member::value), +p(base_from_member::value) { p.constructor(); } -CheckBox::~CheckBox() { +CheckButton::~CheckButton() { p.destructor(); delete &state; } -//ComboBox -//======== +//ComboButton +//=========== -void ComboBox::append_(const lstring &list) { +void ComboButton::append_(const lstring &list) { for(auto &text : list) { state.text.append(text); p.append(text); } } -void ComboBox::modify(unsigned row, const string &text) { +void ComboButton::modify(unsigned row, const string &text) { state.text(row) = text; p.modify(row, text); } -void ComboBox::remove(unsigned row) { +void ComboButton::remove(unsigned row) { state.text.remove(row); p.remove(row); } -void ComboBox::reset() { +void ComboButton::reset() { state.selection = 0; state.text.reset(); return p.reset(); } -unsigned ComboBox::selection() { +unsigned ComboButton::selection() { return p.selection(); } -void ComboBox::setSelection(unsigned row) { +void ComboButton::setSelection(unsigned row) { state.selection = row; return p.setSelection(row); } -string ComboBox::text() { +string ComboButton::text() { return state.text(selection()); } -string ComboBox::text(unsigned row) { +string ComboButton::text(unsigned row) { return state.text(row); } -ComboBox::ComboBox(): +ComboButton::ComboButton(): state(*new State), -base_from_member(*new pComboBox(*this)), -Widget(base_from_member::value), -p(base_from_member::value) { +base_from_member(*new pComboButton(*this)), +Widget(base_from_member::value), +p(base_from_member::value) { p.constructor(); } -ComboBox::~ComboBox() { +ComboButton::~ComboButton() { p.destructor(); delete &state; } @@ -944,36 +973,36 @@ HexEdit::~HexEdit() { delete &state; } -//HorizontalScrollBar -//=================== +//HorizontalScroller +//================== -unsigned HorizontalScrollBar::length() { +unsigned HorizontalScroller::length() { return state.length; } -unsigned HorizontalScrollBar::position() { +unsigned HorizontalScroller::position() { return p.position(); } -void HorizontalScrollBar::setLength(unsigned length) { +void HorizontalScroller::setLength(unsigned length) { state.length = length; return p.setLength(length); } -void HorizontalScrollBar::setPosition(unsigned position) { +void HorizontalScroller::setPosition(unsigned position) { state.position = position; return p.setPosition(position); } -HorizontalScrollBar::HorizontalScrollBar(): +HorizontalScroller::HorizontalScroller(): state(*new State), -base_from_member(*new pHorizontalScrollBar(*this)), -Widget(base_from_member::value), -p(base_from_member::value) { +base_from_member(*new pHorizontalScroller(*this)), +Widget(base_from_member::value), +p(base_from_member::value) { p.constructor(); } -HorizontalScrollBar::~HorizontalScrollBar() { +HorizontalScroller::~HorizontalScroller() { p.destructor(); delete &state; } @@ -1176,38 +1205,38 @@ ProgressBar::~ProgressBar() { delete &state; } -//RadioBox -//======== +//RadioButton +//=========== -void RadioBox::group(const set &list) { +void RadioButton::group(const set &list) { for(auto &item : list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); } -bool RadioBox::checked() { +bool RadioButton::checked() { return p.checked(); } -void RadioBox::setChecked() { +void RadioButton::setChecked() { for(auto &item : state.group) item.state.checked = false; state.checked = true; return p.setChecked(); } -void RadioBox::setText(const string &text) { +void RadioButton::setText(const string &text) { state.text = text; return p.setText(text); } -RadioBox::RadioBox(): +RadioButton::RadioButton(): state(*new State), -base_from_member(*new pRadioBox(*this)), -Widget(base_from_member::value), -p(base_from_member::value) { +base_from_member(*new pRadioButton(*this)), +Widget(base_from_member::value), +p(base_from_member::value) { p.constructor(); } -RadioBox::~RadioBox() { +RadioButton::~RadioButton() { for(auto &item : state.group) { if(&item != this) item.state.group.remove(*this); } @@ -1242,6 +1271,10 @@ string TextEdit::text() { return p.text(); } +bool TextEdit::wordWrap() { + return state.wordWrap; +} + TextEdit::TextEdit(): state(*new State), base_from_member(*new pTextEdit(*this)), @@ -1255,36 +1288,36 @@ TextEdit::~TextEdit() { delete &state; } -//VerticalScrollBar -//================= +//VerticalScroller +//================ -unsigned VerticalScrollBar::length() { +unsigned VerticalScroller::length() { return state.length; } -unsigned VerticalScrollBar::position() { +unsigned VerticalScroller::position() { return p.position(); } -void VerticalScrollBar::setLength(unsigned length) { +void VerticalScroller::setLength(unsigned length) { state.length = length; return p.setLength(length); } -void VerticalScrollBar::setPosition(unsigned position) { +void VerticalScroller::setPosition(unsigned position) { state.position = position; return p.setPosition(position); } -VerticalScrollBar::VerticalScrollBar(): +VerticalScroller::VerticalScroller(): state(*new State), -base_from_member(*new pVerticalScrollBar(*this)), -Widget(base_from_member::value), -p(base_from_member::value) { +base_from_member(*new pVerticalScroller(*this)), +Widget(base_from_member::value), +p(base_from_member::value) { p.constructor(); } -VerticalScrollBar::~VerticalScrollBar() { +VerticalScroller::~VerticalScroller() { p.destructor(); delete &state; } @@ -1340,3 +1373,5 @@ p(base_from_member::value) { Viewport::~Viewport() { p.destructor(); } + +} diff --git a/higan/phoenix/core/core.hpp b/higan/phoenix/core/core.hpp index 1b329f85..f3c65f13 100755 --- a/higan/phoenix/core/core.hpp +++ b/higan/phoenix/core/core.hpp @@ -1,3 +1,17 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace phoenix { + +struct Application; struct Font; struct Window; struct Menu; @@ -5,9 +19,9 @@ struct Sizable; struct Layout; struct Widget; +struct pApplication; struct pFont; struct pObject; -struct pOS; struct pTimer; struct pWindow; struct pAction; @@ -21,21 +35,43 @@ struct pLayout; struct pWidget; struct pButton; struct pCanvas; -struct pCheckBox; -struct pComboBox; +struct pCheckButton; +struct pComboButton; struct pHexEdit; -struct pHorizontalScrollBar; +struct pHorizontalScroller; struct pHorizontalSlider; struct pLabel; struct pLineEdit; struct pListView; struct pProgressBar; -struct pRadioBox; +struct pRadioButton; struct pTextEdit; -struct pVerticalScrollBar; +struct pVerticalScroller; struct pVerticalSlider; struct pViewport; +struct Application { + static nall::function main; + + static void run(); + static bool pendingEvents(); + static void processEvents(); + static void quit(); + static void setName(const nall::string &name); + + Application() = delete; + struct State; + static void initialize(); + + struct Cocoa { + static nall::function onAbout; + static nall::function onPreferences; + static nall::function onQuit; + }; +}; + +typedef Application App; + enum : unsigned { MaximumSize = ~0u, MinimumSize = 0u, @@ -76,9 +112,11 @@ struct Geometry { enum class Orientation : unsigned { Horizontal, Vertical }; struct Font { - nall::string description; - Geometry geometry(const nall::string &text); - Font(const nall::string &description = ""); + static nall::string serif(unsigned size = 0, const nall::string &style = ""); + static nall::string sans(unsigned size = 0, const nall::string &style = ""); + static nall::string monospace(unsigned size = 0, const nall::string &style = ""); + static Size size(const nall::string &font, const nall::string &text); + Font() = delete; }; struct Desktop { @@ -119,6 +157,7 @@ struct MessageWindow { Ok, OkCancel, YesNo, + YesNoCancel, }; enum class Response : unsigned { @@ -143,19 +182,8 @@ struct Object { pObject &p; }; -struct OS { - static void main(); - static bool pendingEvents(); - static void processEvents(); - static void quit(); - static void setName(const nall::string &name); - - struct State; - static void initialize(); -}; - struct Timer : private nall::base_from_member, Object { - nall::function onTimeout; + nall::function onActivate; void setEnabled(bool enabled = true); void setInterval(unsigned milliseconds); @@ -190,7 +218,6 @@ struct Window : private nall::base_from_member, Object { bool focused(); bool fullScreen(); Geometry geometry(); - void ignore(); void remove_(Layout &layout); void remove_(Menu &menu); void remove_(Widget &widget); @@ -304,7 +331,7 @@ struct RadioItem : private nall::base_from_member, Action { struct Sizable : Object { virtual bool enabled() = 0; Layout* layout(); - virtual Geometry minimumGeometry() = 0; + virtual Size minimumSize() = 0; virtual void setEnabled(bool enabled = true) = 0; virtual void setGeometry(const Geometry &geometry) = 0; virtual void setVisible(bool visible = true) = 0; @@ -337,7 +364,7 @@ struct Widget : private nall::base_from_member, Sizable { bool focused(); nall::string font(); Geometry geometry(); - Geometry minimumGeometry(); + Size minimumSize(); void setEnabled(bool enabled = true); void setFocused(); void setFont(const nall::string &font); @@ -385,21 +412,21 @@ struct Canvas : private nall::base_from_member, Widget { pCanvas &p; }; -struct CheckBox : private nall::base_from_member, Widget { +struct CheckButton : private nall::base_from_member, Widget { nall::function onToggle; bool checked(); void setChecked(bool checked = true); void setText(const nall::string &text); - CheckBox(); - ~CheckBox(); + CheckButton(); + ~CheckButton(); struct State; State &state; - pCheckBox &p; + pCheckButton &p; }; -struct ComboBox : private nall::base_from_member, Widget { +struct ComboButton : private nall::base_from_member, Widget { nall::function onChange; template void append(const Args&... args) { append_({args...}); } @@ -413,11 +440,11 @@ struct ComboBox : private nall::base_from_member, Widget { nall::string text(); nall::string text(unsigned row); - ComboBox(); - ~ComboBox(); + ComboButton(); + ~ComboButton(); struct State; State &state; - pComboBox &p; + pComboButton &p; }; struct HexEdit : private nall::base_from_member, Widget { @@ -437,7 +464,7 @@ struct HexEdit : private nall::base_from_member, Widget { pHexEdit &p; }; -struct HorizontalScrollBar : private nall::base_from_member, Widget { +struct HorizontalScroller : private nall::base_from_member, Widget { nall::function onChange; unsigned length(); @@ -445,11 +472,11 @@ struct HorizontalScrollBar : private nall::base_from_member, Widget { @@ -534,9 +561,9 @@ struct ProgressBar : private nall::base_from_member, Widget { pProgressBar &p; }; -struct RadioBox : private nall::base_from_member, Widget { +struct RadioButton : private nall::base_from_member, Widget { template static void group(Args&... args) { group({args...}); } - static void group(const nall::set &list); + static void group(const nall::set &list); nall::function onActivate; @@ -544,11 +571,11 @@ struct RadioBox : private nall::base_from_member, Widget { void setChecked(); void setText(const nall::string &text); - RadioBox(); - ~RadioBox(); + RadioButton(); + ~RadioButton(); struct State; State &state; - pRadioBox &p; + pRadioButton &p; }; struct TextEdit : private nall::base_from_member, Widget { @@ -559,6 +586,7 @@ struct TextEdit : private nall::base_from_member, Widget { void setText(const nall::string &text); void setWordWrap(bool wordWrap = true); nall::string text(); + bool wordWrap(); TextEdit(); ~TextEdit(); @@ -567,7 +595,7 @@ struct TextEdit : private nall::base_from_member, Widget { pTextEdit &p; }; -struct VerticalScrollBar : private nall::base_from_member, Widget { +struct VerticalScroller : private nall::base_from_member, Widget { nall::function onChange; unsigned length(); @@ -575,11 +603,11 @@ struct VerticalScrollBar : private nall::base_from_member, void setLength(unsigned length); void setPosition(unsigned position); - VerticalScrollBar(); - ~VerticalScrollBar(); + VerticalScroller(); + ~VerticalScroller(); struct State; State &state; - pVerticalScrollBar &p; + pVerticalScroller &p; }; struct VerticalSlider : private nall::base_from_member, Widget { @@ -613,3 +641,5 @@ struct Viewport : private nall::base_from_member, Widget { #include "layout/fixed-layout.hpp" #include "layout/horizontal-layout.hpp" #include "layout/vertical-layout.hpp" + +} diff --git a/higan/phoenix/core/layout/fixed-layout.cpp b/higan/phoenix/core/layout/fixed-layout.cpp index 71ff3dac..7665123b 100755 --- a/higan/phoenix/core/layout/fixed-layout.cpp +++ b/higan/phoenix/core/layout/fixed-layout.cpp @@ -15,13 +15,13 @@ bool FixedLayout::enabled() { return state.enabled; } -Geometry FixedLayout::minimumGeometry() { +Size FixedLayout::minimumSize() { unsigned width = MinimumSize, height = MinimumSize; for(auto &child : children) { - width = max(width, child.sizable->minimumGeometry().width); - height = max(height, child.sizable->minimumGeometry().height); + width = max(width, child.sizable->minimumSize().width); + height = max(height, child.sizable->minimumSize().height); } - return { 0, 0, width, height }; + return {width, height}; } void FixedLayout::remove(Sizable &sizable) { diff --git a/higan/phoenix/core/layout/fixed-layout.hpp b/higan/phoenix/core/layout/fixed-layout.hpp index a67f2185..a8b3bab0 100755 --- a/higan/phoenix/core/layout/fixed-layout.hpp +++ b/higan/phoenix/core/layout/fixed-layout.hpp @@ -2,7 +2,7 @@ struct FixedLayout : Layout { void append(Sizable &sizable, const Geometry &geometry); void append(Sizable &sizable); bool enabled(); - Geometry minimumGeometry(); + Size minimumSize(); void remove(Sizable &sizable); void reset(); void setEnabled(bool enabled = true); diff --git a/higan/phoenix/core/layout/horizontal-layout.cpp b/higan/phoenix/core/layout/horizontal-layout.cpp index a1146038..67fdeaf2 100755 --- a/higan/phoenix/core/layout/horizontal-layout.cpp +++ b/higan/phoenix/core/layout/horizontal-layout.cpp @@ -1,6 +1,6 @@ void HorizontalLayout::append(Sizable &sizable, const Size &size, unsigned spacing) { for(auto &child : children) if(child.sizable == &sizable) return; - children.append({ &sizable, size.width, size.height, spacing }); + children.append({&sizable, size.width, size.height, spacing}); synchronizeLayout(); if(window()) window()->synchronizeLayout(); } @@ -16,13 +16,13 @@ bool HorizontalLayout::enabled() { return state.enabled; } -Geometry HorizontalLayout::minimumGeometry() { +Size HorizontalLayout::minimumSize() { unsigned width = 0, height = 0; for(auto &child : children) { width += child.spacing; if(child.width == MinimumSize || child.width == MaximumSize) { - width += child.sizable->minimumGeometry().width; + width += child.sizable->minimumSize().width; continue; } width += child.width; @@ -30,13 +30,13 @@ Geometry HorizontalLayout::minimumGeometry() { for(auto &child : children) { if(child.height == MinimumSize || child.height == MaximumSize) { - height = max(height, child.sizable->minimumGeometry().height); + height = max(height, child.sizable->minimumSize().height); continue; } height = max(height, child.height); } - return { 0, 0, state.margin * 2 + width, state.margin * 2 + height }; + return {state.margin * 2 + width, state.margin * 2 + height}; } void HorizontalLayout::remove(Sizable &sizable) { @@ -75,8 +75,8 @@ void HorizontalLayout::setEnabled(bool enabled) { void HorizontalLayout::setGeometry(const Geometry &containerGeometry) { auto children = this->children; for(auto &child : children) { - if(child.width == MinimumSize) child.width = child.sizable->minimumGeometry().width; - if(child.height == MinimumSize) child.height = child.sizable->minimumGeometry().height; + if(child.width == MinimumSize) child.width = child.sizable->minimumSize().width; + if(child.height == MinimumSize) child.height = child.sizable->minimumSize().height; } Geometry geometry = containerGeometry; @@ -102,7 +102,7 @@ void HorizontalLayout::setGeometry(const Geometry &containerGeometry) { for(auto &child : children) { unsigned pivot = (maximumHeight - child.height) * state.alignment; - Geometry childGeometry = { geometry.x, geometry.y + pivot, child.width, child.height }; + Geometry childGeometry = {geometry.x, geometry.y + pivot, child.width, child.height}; child.sizable->setGeometry(childGeometry); geometry.x += child.width + child.spacing; diff --git a/higan/phoenix/core/layout/horizontal-layout.hpp b/higan/phoenix/core/layout/horizontal-layout.hpp index 96d4f101..8a25f52f 100755 --- a/higan/phoenix/core/layout/horizontal-layout.hpp +++ b/higan/phoenix/core/layout/horizontal-layout.hpp @@ -2,7 +2,7 @@ struct HorizontalLayout : public Layout { void append(Sizable &sizable, const Size &size, unsigned spacing = 0); void append(Sizable &sizable); bool enabled(); - Geometry minimumGeometry(); + Size minimumSize(); void remove(Sizable &sizable); void reset(); void setAlignment(double alignment); diff --git a/higan/phoenix/core/layout/vertical-layout.cpp b/higan/phoenix/core/layout/vertical-layout.cpp index 4fd6315b..f1940965 100755 --- a/higan/phoenix/core/layout/vertical-layout.cpp +++ b/higan/phoenix/core/layout/vertical-layout.cpp @@ -1,6 +1,6 @@ void VerticalLayout::append(Sizable &sizable, const Size &size, unsigned spacing) { for(auto &child : children) if(child.sizable == &sizable) return; - children.append({ &sizable, size.width, size.height, spacing }); + children.append({&sizable, size.width, size.height, spacing}); synchronizeLayout(); if(window()) window()->synchronizeLayout(); } @@ -16,12 +16,12 @@ bool VerticalLayout::enabled() { return state.enabled; } -Geometry VerticalLayout::minimumGeometry() { +Size VerticalLayout::minimumSize() { unsigned width = 0, height = 0; for(auto &child : children) { if(child.width == MinimumSize || child.width == MaximumSize) { - width = max(width, child.sizable->minimumGeometry().width); + width = max(width, child.sizable->minimumSize().width); continue; } width = max(width, child.width); @@ -30,13 +30,13 @@ Geometry VerticalLayout::minimumGeometry() { for(auto &child : children) { height += child.spacing; if(child.height == MinimumSize || child.height == MaximumSize) { - height += child.sizable->minimumGeometry().height; + height += child.sizable->minimumSize().height; continue; } height += child.height; } - return { 0, 0, state.margin * 2 + width, state.margin * 2 + height }; + return {state.margin * 2 + width, state.margin * 2 + height}; } void VerticalLayout::remove(Sizable &sizable) { @@ -75,8 +75,8 @@ void VerticalLayout::setEnabled(bool enabled) { void VerticalLayout::setGeometry(const Geometry &containerGeometry) { auto children = this->children; for(auto &child : children) { - if(child.width == MinimumSize) child.width = child.sizable->minimumGeometry().width; - if(child.height == MinimumSize) child.height = child.sizable->minimumGeometry().height; + if(child.width == MinimumSize) child.width = child.sizable->minimumSize().width; + if(child.height == MinimumSize) child.height = child.sizable->minimumSize().height; } Geometry geometry = containerGeometry; @@ -102,7 +102,7 @@ void VerticalLayout::setGeometry(const Geometry &containerGeometry) { for(auto &child : children) { unsigned pivot = (maximumWidth - child.width) * state.alignment; - Geometry childGeometry = { geometry.x + pivot, geometry.y, child.width, child.height }; + Geometry childGeometry = {geometry.x + pivot, geometry.y, child.width, child.height}; child.sizable->setGeometry(childGeometry); geometry.y += child.height + child.spacing; diff --git a/higan/phoenix/core/layout/vertical-layout.hpp b/higan/phoenix/core/layout/vertical-layout.hpp index 8273dbe2..887bb24c 100755 --- a/higan/phoenix/core/layout/vertical-layout.hpp +++ b/higan/phoenix/core/layout/vertical-layout.hpp @@ -2,7 +2,7 @@ struct VerticalLayout : public Layout { void append(Sizable &sizable, const Size &size, unsigned spacing = 0); void append(Sizable &sizable); bool enabled(); - Geometry minimumGeometry(); + Size minimumSize(); void remove(Sizable &sizable); void reset(); void setAlignment(double alignment); diff --git a/higan/phoenix/core/state.hpp b/higan/phoenix/core/state.hpp index a4bff751..bbc259b4 100755 --- a/higan/phoenix/core/state.hpp +++ b/higan/phoenix/core/state.hpp @@ -1,205 +1,115 @@ -struct OS::State { +struct Application::State { string name; - - State() { - } -} osState; + bool quit = false; +} applicationState; struct Timer::State { - bool enabled; - unsigned milliseconds; - - State() { - enabled = false; - milliseconds = 0; - } + bool enabled = false; + unsigned milliseconds = 0; }; struct Window::State { - bool backgroundColorOverride; - Color backgroundColor; - bool fullScreen; - Geometry geometry; - bool ignore; + bool backgroundColorOverride = false; + Color backgroundColor = {0, 0, 0, 255}; + bool fullScreen = false; + Geometry geometry = {128, 128, 256, 256}; set layout; set menu; string menuFont; - bool menuVisible; - bool modal; - bool resizable; + bool menuVisible = false; + bool modal = false; + bool resizable = true; string statusFont; string statusText; - bool statusVisible; + bool statusVisible = false; string title; - bool visible; + bool visible = false; set widget; string widgetFont; - - State() { - backgroundColorOverride = false; - backgroundColor = {0, 0, 0, 255}; - fullScreen = false; - geometry = {128, 128, 256, 256}; - ignore = false; - menuVisible = false; - modal = false; - resizable = true; - statusVisible = false; - visible = false; - } }; struct Action::State { - bool enabled; - Menu *menu; - bool visible; - Window *window; - - State() { - enabled = true; - menu = 0; - visible = true; - window = 0; - } + bool enabled = true; + Menu *menu = nullptr; + bool visible = true; + Window *window = nullptr; }; struct Menu::State { set action; - nall::image image; + nall::image image = {0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0}; string text; - - State() : image(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0) { - } }; struct Item::State { - nall::image image; + nall::image image = {0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0}; string text; - - State() : image(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0) { - } }; struct CheckItem::State { - bool checked; + bool checked = false; string text; - - State() { - checked = false; - } }; struct RadioItem::State { - bool checked; + bool checked = true; set group; string text; - - State() { - checked = true; - } }; struct Sizable::State { - Layout *layout; - Window *window; - - State() { - layout = 0; - window = 0; - } + Layout *layout = nullptr; + Window *window = nullptr; }; struct Layout::State { - State() { - } }; struct Widget::State { - bool abstract; - bool enabled; + bool abstract = false; + bool enabled = true; string font; - Geometry geometry; - bool visible; - - State() { - abstract = false; - enabled = true; - geometry = {0, 0, 0, 0}; - visible = true; - } + Geometry geometry = {0, 0, 0, 0}; + bool visible = true; }; struct Button::State { - nall::image image; - Orientation orientation; + nall::image image = {0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0}; + Orientation orientation = Orientation::Horizontal; string text; - - State() : image(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0) { - } }; struct Canvas::State { - uint32_t *data; - unsigned width; - unsigned height; - - State() { - data = nullptr; - width = 256; - height = 256; - } + uint32_t *data = nullptr; + unsigned width = 256; + unsigned height = 256; }; -struct CheckBox::State { - bool checked; +struct CheckButton::State { + bool checked = false; string text; - - State() { - checked = false; - } }; -struct ComboBox::State { - unsigned selection; +struct ComboButton::State { + unsigned selection = 0; vector text; - - State() { - selection = 0; - } }; struct HexEdit::State { - unsigned columns; - unsigned length; - unsigned offset; - unsigned rows; - - State() { - columns = 16; - length = 0; - offset = 0; - rows = 16; - } + unsigned columns = 16; + unsigned length = 0; + unsigned offset = 0; + unsigned rows = 16; }; -struct HorizontalScrollBar::State { - unsigned length; - unsigned position; - - State() { - length = 101; - position = 0; - } +struct HorizontalScroller::State { + unsigned length = 101; + unsigned position = 0; }; struct HorizontalSlider::State { - unsigned length; - unsigned position; - - State() { - length = 101; - position = 0; - } + unsigned length = 101; + unsigned position = 0; }; struct Label::State { @@ -207,79 +117,44 @@ struct Label::State { }; struct LineEdit::State { - bool editable; + bool editable = true; string text; - - State() { - editable = true; - } }; struct ListView::State { - bool checkable; + bool checkable = false; vector checked; lstring headerText; - bool headerVisible; + bool headerVisible = false; vector> image; - bool selected; - unsigned selection; + bool selected = false; + unsigned selection = 0; vector text; - - State() { - checkable = false; - headerVisible = false; - selected = false; - selection = 0; - } }; struct ProgressBar::State { - unsigned position; - - State() { - position = 0; - } + unsigned position = 0; }; -struct RadioBox::State { - bool checked; - set group; +struct RadioButton::State { + bool checked = true; + set group; string text; - - State() { - checked = true; - } }; struct TextEdit::State { - unsigned cursorPosition; - bool editable; + unsigned cursorPosition = 0; + bool editable = true; string text; - bool wordWrap; - - State() { - cursorPosition = 0; - editable = true; - wordWrap = true; - } + bool wordWrap = true; }; -struct VerticalScrollBar::State { - unsigned length; - unsigned position; - - State() { - length = 101; - position = 0; - } +struct VerticalScroller::State { + unsigned length = 101; + unsigned position = 0; }; struct VerticalSlider::State { - unsigned length; - unsigned position; - - State() { - length = 101; - position = 0; - } + unsigned length = 101; + unsigned position = 0; }; diff --git a/higan/phoenix/gtk/action/action.cpp b/higan/phoenix/gtk/action/action.cpp index 950259de..a55af3de 100755 --- a/higan/phoenix/gtk/action/action.cpp +++ b/higan/phoenix/gtk/action/action.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pAction::setEnabled(bool enabled) { gtk_widget_set_sensitive(widget, enabled); } @@ -25,3 +27,5 @@ string pAction::mnemonic(string text) { void pAction::setFont(const string &font) { pFont::setFont(widget, font); } + +} diff --git a/higan/phoenix/gtk/action/check-item.cpp b/higan/phoenix/gtk/action/check-item.cpp index 2cc182a6..27a9c8ff 100755 --- a/higan/phoenix/gtk/action/check-item.cpp +++ b/higan/phoenix/gtk/action/check-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static void CheckItem_toggle(CheckItem *self) { if(self->p.locked == false && self->onToggle) self->onToggle(); } @@ -31,3 +33,5 @@ void pCheckItem::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/action/item.cpp b/higan/phoenix/gtk/action/item.cpp index afab955e..9379a3bc 100755 --- a/higan/phoenix/gtk/action/item.cpp +++ b/higan/phoenix/gtk/action/item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static void Item_activate(Item *self) { if(self->onActivate) self->onActivate(); } @@ -29,3 +31,5 @@ void pItem::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/action/menu.cpp b/higan/phoenix/gtk/action/menu.cpp index 92252085..d322f611 100755 --- a/higan/phoenix/gtk/action/menu.cpp +++ b/higan/phoenix/gtk/action/menu.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pMenu::append(Action &action) { action.state.window = this->action.state.window; @@ -10,7 +12,7 @@ void pMenu::append(Action &action) { void pMenu::remove(Action &action) { action.p.orphan(); - action.state.window = 0; + action.state.window = nullptr; } void pMenu::setImage(const image &image) { @@ -49,3 +51,5 @@ void pMenu::setFont(const string &font) { pAction::setFont(font); for(auto &item : menu.state.action) item.p.setFont(font); } + +} diff --git a/higan/phoenix/gtk/action/radio-item.cpp b/higan/phoenix/gtk/action/radio-item.cpp index a599d70b..a1b2bcfd 100755 --- a/higan/phoenix/gtk/action/radio-item.cpp +++ b/higan/phoenix/gtk/action/radio-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static void RadioItem_activate(RadioItem *self) { for(auto &item : self->state.group) item.state.checked = (&item == self); if(self->p.locked == false && self->checked() && self->onActivate) self->onActivate(); @@ -46,3 +48,5 @@ void pRadioItem::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/action/separator.cpp b/higan/phoenix/gtk/action/separator.cpp index 8b7a1a6b..0db95b2c 100755 --- a/higan/phoenix/gtk/action/separator.cpp +++ b/higan/phoenix/gtk/action/separator.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pSeparator::constructor() { widget = gtk_separator_menu_item_new(); } @@ -10,3 +12,5 @@ void pSeparator::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/application.cpp b/higan/phoenix/gtk/application.cpp new file mode 100644 index 00000000..c786816e --- /dev/null +++ b/higan/phoenix/gtk/application.cpp @@ -0,0 +1,62 @@ +namespace phoenix { + +XlibDisplay* pApplication::display = nullptr; + +void pApplication::run() { + if(Application::main) { + while(applicationState.quit == false) { + processEvents(); + Application::main(); + } + } else { + gtk_main(); + } +} + +bool pApplication::pendingEvents() { + return gtk_events_pending(); +} + +void pApplication::processEvents() { + while(pendingEvents()) gtk_main_iteration_do(false); +} + +void pApplication::quit() { + //if gtk_main() was invoked, call gtk_main_quit() + if(gtk_main_level()) gtk_main_quit(); +} + +void pApplication::initialize() { + display = XOpenDisplay(nullptr); + + settings = new Settings; + settings->load(); + + int argc = 1; + char *argv[2]; + argv[0] = new char[8]; + argv[1] = nullptr; + strcpy(argv[0], "phoenix"); + char **argvp = argv; + gtk_init(&argc, &argvp); + + GtkSettings *gtkSettings = gtk_settings_get_default(); + g_object_set(gtkSettings, "gtk-button-images", true, nullptr); + + gtk_rc_parse_string(R"( + style "phoenix-gtk" + { + GtkWindow::resize-grip-width = 0 + GtkWindow::resize-grip-height = 0 + GtkTreeView::vertical-separator = 0 + GtkComboBox::appears-as-list = 1 + } + class "GtkWindow" style "phoenix-gtk" + class "GtkTreeView" style "phoenix-gtk" + # class "GtkComboBox" style "phoenix-gtk" + )"); + + pKeyboard::initialize(); +} + +} diff --git a/higan/phoenix/gtk/desktop.cpp b/higan/phoenix/gtk/desktop.cpp index 2b1801ad..0c3f3625 100755 --- a/higan/phoenix/gtk/desktop.cpp +++ b/higan/phoenix/gtk/desktop.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + Size pDesktop::size() { return { gdk_screen_get_width(gdk_screen_get_default()), @@ -6,14 +8,14 @@ Size pDesktop::size() { } Geometry pDesktop::workspace() { - XlibDisplay *display = XOpenDisplay(0); + XlibDisplay *display = XOpenDisplay(nullptr); int screen = DefaultScreen(display); static Atom atom = XlibNone; if(atom == XlibNone) atom = XInternAtom(display, "_NET_WORKAREA", True); int format; - unsigned char *data = 0; + unsigned char *data = nullptr; unsigned long items, after; Atom returnAtom; @@ -34,3 +36,5 @@ Geometry pDesktop::workspace() { gdk_screen_get_height(gdk_screen_get_default()) }; } + +} diff --git a/higan/phoenix/gtk/dialog-window.cpp b/higan/phoenix/gtk/dialog-window.cpp index eb04bd64..abfb8b69 100755 --- a/higan/phoenix/gtk/dialog-window.cpp +++ b/higan/phoenix/gtk/dialog-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static string FileDialog(bool save, Window &parent, const string &path, const lstring &filter) { string name; @@ -67,3 +69,5 @@ string pDialogWindow::folderSelect(Window &parent, const string &path) { if(name.endswith("/") == false) name.append("/"); return name; } + +} diff --git a/higan/phoenix/gtk/font.cpp b/higan/phoenix/gtk/font.cpp index cb6889d1..2350c7c1 100755 --- a/higan/phoenix/gtk/font.cpp +++ b/higan/phoenix/gtk/font.cpp @@ -1,13 +1,32 @@ -Geometry pFont::geometry(const string &description, const string &text) { - PangoFontDescription *font = create(description); - Geometry geometry = pFont::geometry(font, text); - free(font); - return geometry; +namespace phoenix { + +string pFont::serif(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Serif, ", size, ", ", style}; +} + +string pFont::sans(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Sans, ", size, ", ", style}; +} + +string pFont::monospace(unsigned size, string style) { + if(size == 0) size = 8; + return {"Liberation Mono, ", size, ", ", style}; +} + +Size pFont::size(const string &font, const string &text) { + PangoFontDescription *description = create(font); + Size size = pFont::size(description, text); + free(description); + return size; } PangoFontDescription* pFont::create(const string &description) { lstring part; - part.split(",", description); + part.split<2>(",", description); for(auto &item : part) item.trim(" "); string family = "Sans"; @@ -32,7 +51,7 @@ void pFont::free(PangoFontDescription *font) { pango_font_description_free(font); } -Geometry pFont::geometry(PangoFontDescription *font, const string &text) { +Size pFont::size(PangoFontDescription *font, const string &text) { PangoContext *context = gdk_pango_context_get_for_screen(gdk_screen_get_default()); PangoLayout *layout = pango_layout_new(context); pango_layout_set_font_description(layout, font); @@ -40,7 +59,7 @@ Geometry pFont::geometry(PangoFontDescription *font, const string &text) { int width = 0, height = 0; pango_layout_get_pixel_size(layout, &width, &height); g_object_unref((gpointer)layout); - return { 0, 0, width, height }; + return {width, height}; } void pFont::setFont(GtkWidget *widget, const string &font) { @@ -50,9 +69,11 @@ void pFont::setFont(GtkWidget *widget, const string &font) { } void pFont::setFont(GtkWidget *widget, gpointer font) { - if(font == 0) return; + if(font == nullptr) return; gtk_widget_modify_font(widget, (PangoFontDescription*)font); if(GTK_IS_CONTAINER(widget)) { gtk_container_foreach(GTK_CONTAINER(widget), (GtkCallback)pFont::setFont, font); } } + +} diff --git a/higan/phoenix/gtk/header.hpp b/higan/phoenix/gtk/header.hpp new file mode 100644 index 00000000..036cabde --- /dev/null +++ b/higan/phoenix/gtk/header.hpp @@ -0,0 +1,8 @@ +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/higan/phoenix/gtk/keyboard.cpp b/higan/phoenix/gtk/keyboard.cpp index 5b346406..57df17f7 100755 --- a/higan/phoenix/gtk/keyboard.cpp +++ b/higan/phoenix/gtk/keyboard.cpp @@ -1,6 +1,8 @@ +namespace phoenix { + void pKeyboard::initialize() { auto append = [](Keyboard::Scancode scancode, unsigned keysym) { - settings->keymap.insert(scancode, XKeysymToKeycode(pOS::display, keysym)); + settings->keymap.insert(scancode, XKeysymToKeycode(pApplication::display, keysym)); }; append(Keyboard::Scancode::Escape, XK_Escape); @@ -120,7 +122,7 @@ void pKeyboard::initialize() { bool pKeyboard::pressed(Keyboard::Scancode scancode) { char state[256]; - XQueryKeymap(pOS::display, state); + XQueryKeymap(pApplication::display, state); unsigned id = settings->keymap.lhs[scancode]; return state[id >> 3] & (1 << (id & 7)); } @@ -131,7 +133,7 @@ vector pKeyboard::state() { for(auto &n : output) n = false; char state[256]; - XQueryKeymap(pOS::display, state); + XQueryKeymap(pApplication::display, state); for(auto &n : settings->keymap.rhs) { if(state[n.name >> 3] & (1 << (n.name & 7))) { output[(unsigned)n.data] = true; @@ -140,3 +142,5 @@ vector pKeyboard::state() { return output; } + +} diff --git a/higan/phoenix/gtk/message-window.cpp b/higan/phoenix/gtk/message-window.cpp index 7cd2172a..e1f30486 100755 --- a/higan/phoenix/gtk/message-window.cpp +++ b/higan/phoenix/gtk/message-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons buttons, gint response) { if(response == GTK_RESPONSE_OK) return MessageWindow::Response::Ok; if(response == GTK_RESPONSE_CANCEL) return MessageWindow::Response::Cancel; @@ -59,3 +61,5 @@ MessageWindow::Response pMessageWindow::critical(Window &parent, const string &t gtk_widget_destroy(dialog); return MessageWindow_response(buttons, response); } + +} diff --git a/higan/phoenix/gtk/mouse.cpp b/higan/phoenix/gtk/mouse.cpp index e00f7ff7..2e2a4021 100755 --- a/higan/phoenix/gtk/mouse.cpp +++ b/higan/phoenix/gtk/mouse.cpp @@ -1,16 +1,18 @@ +namespace phoenix { + Position pMouse::position() { XlibWindow root, child; int rootx, rooty, winx, winy; unsigned int mask; - XQueryPointer(pOS::display, DefaultRootWindow(pOS::display), &root, &child, &rootx, &rooty, &winx, &winy, &mask); - return { rootx, rooty }; + XQueryPointer(pApplication::display, DefaultRootWindow(pApplication::display), &root, &child, &rootx, &rooty, &winx, &winy, &mask); + return {rootx, rooty}; } bool pMouse::pressed(Mouse::Button button) { XlibWindow root, child; int rootx, rooty, winx, winy; unsigned int mask; - XQueryPointer(pOS::display, DefaultRootWindow(pOS::display), &root, &child, &rootx, &rooty, &winx, &winy, &mask); + XQueryPointer(pApplication::display, DefaultRootWindow(pApplication::display), &root, &child, &rootx, &rooty, &winx, &winy, &mask); switch(button) { case Mouse::Button::Left: return mask & Button1Mask; case Mouse::Button::Middle: return mask & Button2Mask; @@ -18,3 +20,5 @@ bool pMouse::pressed(Mouse::Button button) { } return false; } + +} diff --git a/higan/phoenix/gtk/platform.cpp b/higan/phoenix/gtk/platform.cpp index c6650dbb..72588750 100755 --- a/higan/phoenix/gtk/platform.cpp +++ b/higan/phoenix/gtk/platform.cpp @@ -1,4 +1,5 @@ #include "platform.hpp" + #include "utility.cpp" #include "settings.cpp" @@ -7,7 +8,6 @@ #include "mouse.cpp" #include "dialog-window.cpp" #include "message-window.cpp" - #include "font.cpp" #include "timer.cpp" #include "window.cpp" @@ -22,66 +22,19 @@ #include "widget/widget.cpp" #include "widget/button.cpp" #include "widget/canvas.cpp" -#include "widget/check-box.cpp" -#include "widget/combo-box.cpp" +#include "widget/check-button.cpp" +#include "widget/combo-button.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroll-bar.cpp" +#include "widget/horizontal-scroller.cpp" #include "widget/horizontal-slider.cpp" #include "widget/label.cpp" #include "widget/line-edit.cpp" #include "widget/list-view.cpp" #include "widget/progress-bar.cpp" -#include "widget/radio-box.cpp" +#include "widget/radio-button.cpp" #include "widget/text-edit.cpp" -#include "widget/vertical-scroll-bar.cpp" +#include "widget/vertical-scroller.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" -XlibDisplay* pOS::display = 0; -Font pOS::defaultFont; - -void pOS::main() { - gtk_main(); -} - -bool pOS::pendingEvents() { - return gtk_events_pending(); -} - -void pOS::processEvents() { - while(pendingEvents()) gtk_main_iteration_do(false); -} - -void pOS::quit() { - gtk_main_quit(); -} - -void pOS::initialize() { - display = XOpenDisplay(0); - - settings = new Settings; - settings->load(); - - int argc = 1; - char *argv[2]; - argv[0] = new char[8]; - argv[1] = 0; - strcpy(argv[0], "phoenix"); - char **argvp = argv; - gtk_init(&argc, &argvp); - - gtk_rc_parse_string(R"( - style "phoenix-gtk" - { - GtkWindow::resize-grip-width = 0 - GtkWindow::resize-grip-height = 0 - GtkTreeView::vertical-separator = 0 - GtkComboBox::appears-as-list = 1 - } - class "GtkWindow" style "phoenix-gtk" - class "GtkTreeView" style "phoenix-gtk" - # class "GtkComboBox" style "phoenix-gtk" - )"); - - pKeyboard::initialize(); -} +#include "application.cpp" diff --git a/higan/phoenix/gtk/platform.hpp b/higan/phoenix/gtk/platform.hpp index 01c4a223..98e8026a 100755 --- a/higan/phoenix/gtk/platform.hpp +++ b/higan/phoenix/gtk/platform.hpp @@ -1,3 +1,16 @@ +namespace phoenix { + +struct pApplication { + static XlibDisplay *display; + + static void run(); + static bool pendingEvents(); + static void processEvents(); + static void quit(); + + static void initialize(); +}; + struct Settings : public configuration { bidirectional_map keymap; @@ -20,11 +33,14 @@ struct pLayout; struct pWidget; struct pFont { - static Geometry geometry(const string &description, const string &text); + static string serif(unsigned size, string style); + static string sans(unsigned size, string style); + static string monospace(unsigned size, string style); + static Size size(const string &font, const string &text); static PangoFontDescription* create(const string &description); static void free(PangoFontDescription *font); - static Geometry geometry(PangoFontDescription *font, const string &text); + static Size size(PangoFontDescription *font, const string &text); static void setFont(GtkWidget *widget, const string &font); static void setFont(GtkWidget *widget, gpointer font); }; @@ -70,18 +86,6 @@ struct pObject { void destructor() {} }; -struct pOS : public pObject { - static XlibDisplay *display; - static Font defaultFont; - - static void main(); - static bool pendingEvents(); - static void processEvents(); - static void quit(); - - static void initialize(); -}; - struct pTimer : public pObject { Timer &timer; @@ -232,7 +236,7 @@ struct pWidget : public pSizable { bool enabled(); virtual bool focused(); - virtual Geometry minimumGeometry(); + virtual Size minimumSize(); void setEnabled(bool enabled); virtual void setFocused(); virtual void setFont(const string &font); @@ -248,7 +252,7 @@ struct pWidget : public pSizable { struct pButton : public pWidget { Button &button; - Geometry minimumGeometry(); + Size minimumSize(); void setImage(const image &image, Orientation orientation); void setText(const string &text); @@ -271,33 +275,33 @@ struct pCanvas : public pWidget { void orphan(); }; -struct pCheckBox : public pWidget { - CheckBox &checkBox; +struct pCheckButton : public pWidget { + CheckButton &checkButton; bool checked(); - Geometry minimumGeometry(); + Size minimumSize(); void setChecked(bool checked); void setText(const string &text); - pCheckBox(CheckBox &checkBox) : pWidget(checkBox), checkBox(checkBox) {} + pCheckButton(CheckButton &checkButton) : pWidget(checkButton), checkButton(checkButton) {} void constructor(); void destructor(); void orphan(); }; -struct pComboBox : public pWidget { - ComboBox &comboBox; +struct pComboButton : public pWidget { + ComboButton &comboButton; unsigned itemCounter; void append(const string &text); void modify(unsigned row, const string &text); void remove(unsigned row); - Geometry minimumGeometry(); + Size minimumSize(); void reset(); unsigned selection(); void setSelection(unsigned row); - pComboBox(ComboBox &comboBox) : pWidget(comboBox), comboBox(comboBox) {} + pComboButton(ComboButton &comboButton) : pWidget(comboButton), comboButton(comboButton) {} void constructor(); void destructor(); void orphan(); @@ -330,15 +334,15 @@ struct pHexEdit : public pWidget { void updateScroll(); }; -struct pHorizontalScrollBar : public pWidget { - HorizontalScrollBar &horizontalScrollBar; +struct pHorizontalScroller : public pWidget { + HorizontalScroller &horizontalScroller; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); - pHorizontalScrollBar(HorizontalScrollBar &horizontalScrollBar) : pWidget(horizontalScrollBar), horizontalScrollBar(horizontalScrollBar) {} + pHorizontalScroller(HorizontalScroller &horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {} void constructor(); void destructor(); void orphan(); @@ -347,7 +351,7 @@ struct pHorizontalScrollBar : public pWidget { struct pHorizontalSlider : public pWidget { HorizontalSlider &horizontalSlider; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -361,7 +365,7 @@ struct pHorizontalSlider : public pWidget { struct pLabel : public pWidget { Label &label; - Geometry minimumGeometry(); + Size minimumSize(); void setText(const string &text); pLabel(Label &label) : pWidget(label), label(label) {} @@ -373,7 +377,7 @@ struct pLabel : public pWidget { struct pLineEdit : public pWidget { LineEdit &lineEdit; - Geometry minimumGeometry(); + Size minimumSize(); void setEditable(bool editable); void setText(const string &text); string text(); @@ -390,7 +394,7 @@ struct pListView : public pWidget { GtkListStore *store; struct GtkColumn { GtkTreeViewColumn *column; - GtkCellRenderer *checkbox, *icon, *text; + GtkCellRenderer *checkbutton, *icon, *text; GtkWidget *label; }; vector column; @@ -423,7 +427,7 @@ struct pListView : public pWidget { struct pProgressBar : public pWidget { ProgressBar &progressBar; - Geometry minimumGeometry(); + Size minimumSize(); void setPosition(unsigned position); pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} @@ -432,16 +436,18 @@ struct pProgressBar : public pWidget { void orphan(); }; -struct pRadioBox : public pWidget { - RadioBox &radioBox; +struct pRadioButton : public pWidget { + RadioButton &radioButton; bool checked(); - Geometry minimumGeometry(); + Size minimumSize(); void setChecked(); - void setGroup(const set &group); + void setGroup(const set &group); void setText(const string &text); - pRadioBox(RadioBox &radioBox) : pWidget(radioBox), radioBox(radioBox) {} + pRadioButton(RadioButton &radioButton) : pWidget(radioButton), radioButton(radioButton) {} + void onActivate(); + pRadioButton& parent(); void constructor(); void destructor(); void orphan(); @@ -465,15 +471,15 @@ struct pTextEdit : public pWidget { void orphan(); }; -struct pVerticalScrollBar : public pWidget { - VerticalScrollBar &verticalScrollBar; +struct pVerticalScroller : public pWidget { + VerticalScroller &verticalScroller; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); - pVerticalScrollBar(VerticalScrollBar &verticalScrollBar) : pWidget(verticalScrollBar), verticalScrollBar(verticalScrollBar) {} + pVerticalScroller(VerticalScroller &verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {} void constructor(); void destructor(); void orphan(); @@ -482,7 +488,7 @@ struct pVerticalScrollBar : public pWidget { struct pVerticalSlider : public pWidget { VerticalSlider &verticalSlider; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -503,3 +509,5 @@ struct pViewport : public pWidget { void destructor(); void orphan(); }; + +} diff --git a/higan/phoenix/gtk/settings.cpp b/higan/phoenix/gtk/settings.cpp index aeb28bba..bd8950d5 100755 --- a/higan/phoenix/gtk/settings.cpp +++ b/higan/phoenix/gtk/settings.cpp @@ -1,7 +1,9 @@ +namespace phoenix { + static Settings *settings = nullptr; void Settings::load() { - string path = { userpath(), ".config/phoenix/gtk.cfg" }; + string path = {userpath(), ".config/phoenix/gtk.cfg"}; configuration::load(path); } @@ -23,3 +25,5 @@ Settings::Settings() { append(statusGeometryHeight = 20, "statusGeometryHeight"); append(windowBackgroundColor = 0xedeceb, "windowBackgroundColor"); } + +} diff --git a/higan/phoenix/gtk/timer.cpp b/higan/phoenix/gtk/timer.cpp index d04183f8..806910df 100755 --- a/higan/phoenix/gtk/timer.cpp +++ b/higan/phoenix/gtk/timer.cpp @@ -1,7 +1,9 @@ +namespace phoenix { + static guint Timer_trigger(pTimer *self) { //timer may have been disabled prior to triggering, so check state if(self->timer.state.enabled) { - if(self->timer.onTimeout) self->timer.onTimeout(); + if(self->timer.onActivate) self->timer.onActivate(); } //callback may have disabled timer, so check state again if(self->timer.state.enabled) { @@ -22,3 +24,5 @@ void pTimer::setInterval(unsigned milliseconds) { void pTimer::constructor() { } + +} diff --git a/higan/phoenix/gtk/utility.cpp b/higan/phoenix/gtk/utility.cpp index 29e87bb8..dbb5f688 100755 --- a/higan/phoenix/gtk/utility.cpp +++ b/higan/phoenix/gtk/utility.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static GdkPixbuf* CreatePixbuf(const nall::image &image, bool scale = false) { nall::image gdkImage = image; gdkImage.transform(0, 32, 255u << 24, 255u << 0, 255u << 8, 255u << 16); @@ -198,3 +200,5 @@ static Keyboard::Keycode Keysym(unsigned keysym) { } return Keyboard::Keycode::None; } + +} diff --git a/higan/phoenix/gtk/widget/button.cpp b/higan/phoenix/gtk/widget/button.cpp index 6f646a25..0dcc580e 100755 --- a/higan/phoenix/gtk/widget/button.cpp +++ b/higan/phoenix/gtk/widget/button.cpp @@ -1,21 +1,23 @@ +namespace phoenix { + static void Button_activate(Button *self) { if(self->onActivate) self->onActivate(); } -Geometry pButton::minimumGeometry() { - Geometry geometry = pFont::geometry(widget.state.font, button.state.text); +Size pButton::minimumSize() { + Size size = pFont::size(widget.state.font, button.state.text); if(button.state.orientation == Orientation::Horizontal) { - geometry.width += button.state.image.width; - geometry.height = max(button.state.image.height, geometry.height); + size.width += button.state.image.width; + size.height = max(button.state.image.height, size.height); } if(button.state.orientation == Orientation::Vertical) { - geometry.width = max(button.state.image.width, geometry.width); - geometry.height += button.state.image.height; + size.width = max(button.state.image.width, size.width); + size.height += button.state.image.height; } - return { 0, 0, geometry.width + 24, geometry.height + 12 }; + return {size.width + 24, size.height + 12}; } void pButton::setImage(const image &image, Orientation orientation) { @@ -51,3 +53,5 @@ void pButton::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/canvas.cpp b/higan/phoenix/gtk/widget/canvas.cpp index 9d17dc82..75c6aaf0 100755 --- a/higan/phoenix/gtk/widget/canvas.cpp +++ b/higan/phoenix/gtk/widget/canvas.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static gboolean Canvas_expose(GtkWidget *widget, GdkEvent *event, pCanvas *self) { cairo_t *context = gdk_cairo_create(gtk_widget_get_window(widget)); cairo_set_source_surface(context, self->surface, 0, 0); @@ -42,7 +44,7 @@ void pCanvas::setSize(const Size &size) { void pCanvas::update() { memcpy(cairo_image_surface_get_data(surface), canvas.state.data, canvas.state.width * canvas.state.height * sizeof(uint32_t)); if(gtk_widget_get_realized(gtkWidget) == false) return; - gdk_window_invalidate_rect(gtk_widget_get_window(gtkWidget), 0, true); + gdk_window_invalidate_rect(gtk_widget_get_window(gtkWidget), nullptr, true); } void pCanvas::constructor() { @@ -68,3 +70,5 @@ void pCanvas::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/check-box.cpp b/higan/phoenix/gtk/widget/check-box.cpp deleted file mode 100755 index b6493f32..00000000 --- a/higan/phoenix/gtk/widget/check-box.cpp +++ /dev/null @@ -1,40 +0,0 @@ -static void CheckBox_toggle(CheckBox *self) { - self->state.checked = self->checked(); - if(self->p.locked == false && self->onToggle) self->onToggle(); -} - -bool pCheckBox::checked() { - return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget)); -} - -Geometry pCheckBox::minimumGeometry() { - Geometry geometry = pFont::geometry(widget.state.font, checkBox.state.text); - return { 0, 0, geometry.width + 28, geometry.height + 4 }; -} - -void pCheckBox::setChecked(bool checked) { - locked = true; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), checked); - locked = false; -} - -void pCheckBox::setText(const string &text) { - gtk_button_set_label(GTK_BUTTON(gtkWidget), text); -} - -void pCheckBox::constructor() { - gtkWidget = gtk_check_button_new_with_label(""); - g_signal_connect_swapped(G_OBJECT(gtkWidget), "toggled", G_CALLBACK(CheckBox_toggle), (gpointer)&checkBox); - - setChecked(checkBox.state.checked); - setText(checkBox.state.text); -} - -void pCheckBox::destructor() { - gtk_widget_destroy(gtkWidget); -} - -void pCheckBox::orphan() { - destructor(); - constructor(); -} diff --git a/higan/phoenix/gtk/widget/check-button.cpp b/higan/phoenix/gtk/widget/check-button.cpp new file mode 100644 index 00000000..e67f2405 --- /dev/null +++ b/higan/phoenix/gtk/widget/check-button.cpp @@ -0,0 +1,44 @@ +namespace phoenix { + +static void CheckButton_toggle(CheckButton *self) { + self->state.checked = self->checked(); + if(self->p.locked == false && self->onToggle) self->onToggle(); +} + +bool pCheckButton::checked() { + return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget)); +} + +Size pCheckButton::minimumSize() { + Size size = pFont::size(widget.state.font, checkButton.state.text); + return {size.width + 28, size.height + 4}; +} + +void pCheckButton::setChecked(bool checked) { + locked = true; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), checked); + locked = false; +} + +void pCheckButton::setText(const string &text) { + gtk_button_set_label(GTK_BUTTON(gtkWidget), text); +} + +void pCheckButton::constructor() { + gtkWidget = gtk_check_button_new_with_label(""); + g_signal_connect_swapped(G_OBJECT(gtkWidget), "toggled", G_CALLBACK(CheckButton_toggle), (gpointer)&checkButton); + + setChecked(checkButton.state.checked); + setText(checkButton.state.text); +} + +void pCheckButton::destructor() { + gtk_widget_destroy(gtkWidget); +} + +void pCheckButton::orphan() { + destructor(); + constructor(); +} + +} diff --git a/higan/phoenix/gtk/widget/combo-box.cpp b/higan/phoenix/gtk/widget/combo-button.cpp old mode 100755 new mode 100644 similarity index 60% rename from higan/phoenix/gtk/widget/combo-box.cpp rename to higan/phoenix/gtk/widget/combo-button.cpp index 648d587f..b6263551 --- a/higan/phoenix/gtk/widget/combo-box.cpp +++ b/higan/phoenix/gtk/widget/combo-button.cpp @@ -1,24 +1,26 @@ -static void ComboBox_change(ComboBox *self) { +namespace phoenix { + +static void ComboButton_change(ComboButton *self) { if(self->p.locked == false) { self->state.selection = self->selection(); if(self->onChange) self->onChange(); } } -void pComboBox::append(const string &text) { +void pComboButton::append(const string &text) { gtk_combo_box_append_text(GTK_COMBO_BOX(gtkWidget), text); if(itemCounter++ == 0) setSelection(0); } -Geometry pComboBox::minimumGeometry() { +Size pComboButton::minimumSize() { unsigned maximumWidth = 0; - for(auto &item : comboBox.state.text) maximumWidth = max(maximumWidth, pFont::geometry(widget.state.font, item).width); + for(auto &item : comboButton.state.text) maximumWidth = max(maximumWidth, pFont::size(widget.state.font, item).width); - Geometry geometry = pFont::geometry(widget.state.font, " "); - return { 0, 0, maximumWidth + 44, geometry.height + 12 }; + Size size = pFont::size(widget.state.font, " "); + return {maximumWidth + 44, size.height + 12}; } -void pComboBox::modify(unsigned row, const string &text) { +void pComboButton::modify(unsigned row, const string &text) { locked = true; unsigned position = selection(); gtk_combo_box_remove_text(GTK_COMBO_BOX(gtkWidget), row); @@ -27,7 +29,7 @@ void pComboBox::modify(unsigned row, const string &text) { locked = false; } -void pComboBox::remove(unsigned row) { +void pComboButton::remove(unsigned row) { locked = true; unsigned position = selection(); gtk_combo_box_remove_text(GTK_COMBO_BOX(gtkWidget), row); @@ -35,39 +37,41 @@ void pComboBox::remove(unsigned row) { locked = false; } -void pComboBox::reset() { +void pComboButton::reset() { locked = true; gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(gtkWidget)))); itemCounter = 0; locked = false; } -unsigned pComboBox::selection() { +unsigned pComboButton::selection() { return gtk_combo_box_get_active(GTK_COMBO_BOX(gtkWidget)); } -void pComboBox::setSelection(unsigned row) { +void pComboButton::setSelection(unsigned row) { locked = true; gtk_combo_box_set_active(GTK_COMBO_BOX(gtkWidget), row); locked = false; } -void pComboBox::constructor() { +void pComboButton::constructor() { itemCounter = 0; gtkWidget = gtk_combo_box_new_text(); - g_signal_connect_swapped(G_OBJECT(gtkWidget), "changed", G_CALLBACK(ComboBox_change), (gpointer)&comboBox); + g_signal_connect_swapped(G_OBJECT(gtkWidget), "changed", G_CALLBACK(ComboButton_change), (gpointer)&comboButton); locked = true; - for(auto &text : comboBox.state.text) append(text); + for(auto &text : comboButton.state.text) append(text); locked = false; - setSelection(comboBox.state.selection); + setSelection(comboButton.state.selection); } -void pComboBox::destructor() { +void pComboButton::destructor() { gtk_widget_destroy(gtkWidget); } -void pComboBox::orphan() { +void pComboButton::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/hex-edit.cpp b/higan/phoenix/gtk/widget/hex-edit.cpp index ec10cd7c..1941ffba 100755 --- a/higan/phoenix/gtk/widget/hex-edit.cpp +++ b/higan/phoenix/gtk/widget/hex-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static bool HexEdit_keyPress(GtkWidget *widget, GdkEventKey *event, HexEdit *self) { return self->p.keyPress(event->keyval); } @@ -266,3 +268,5 @@ void pHexEdit::updateScroll() { unsigned row = hexEdit.state.offset / hexEdit.state.columns; gtk_range_set_value(GTK_RANGE(scrollBar), row); } + +} diff --git a/higan/phoenix/gtk/widget/horizontal-scroll-bar.cpp b/higan/phoenix/gtk/widget/horizontal-scroller.cpp old mode 100755 new mode 100644 similarity index 52% rename from higan/phoenix/gtk/widget/horizontal-scroll-bar.cpp rename to higan/phoenix/gtk/widget/horizontal-scroller.cpp index 0d765e92..e8280a33 --- a/higan/phoenix/gtk/widget/horizontal-scroll-bar.cpp +++ b/higan/phoenix/gtk/widget/horizontal-scroller.cpp @@ -1,18 +1,20 @@ -static void HorizontalScrollBar_change(HorizontalScrollBar *self) { +namespace phoenix { + +static void HorizontalScroller_change(HorizontalScroller *self) { if(self->state.position == self->position()) return; self->state.position = self->position(); if(self->p.locked == false && self->onChange) self->onChange(); } -Geometry pHorizontalScrollBar::minimumGeometry() { - return { 0, 0, 0, 20 }; +Size pHorizontalScroller::minimumSize() { + return {0, 20}; } -unsigned pHorizontalScrollBar::position() { +unsigned pHorizontalScroller::position() { return (unsigned)gtk_range_get_value(GTK_RANGE(gtkWidget)); } -void pHorizontalScrollBar::setLength(unsigned length) { +void pHorizontalScroller::setLength(unsigned length) { locked = true; length += length == 0; gtk_range_set_range(GTK_RANGE(gtkWidget), 0, max(1u, length - 1)); @@ -20,23 +22,25 @@ void pHorizontalScrollBar::setLength(unsigned length) { locked = false; } -void pHorizontalScrollBar::setPosition(unsigned position) { +void pHorizontalScroller::setPosition(unsigned position) { gtk_range_set_value(GTK_RANGE(gtkWidget), position); } -void pHorizontalScrollBar::constructor() { +void pHorizontalScroller::constructor() { gtkWidget = gtk_hscrollbar_new(0); - g_signal_connect_swapped(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(HorizontalScrollBar_change), (gpointer)&horizontalScrollBar); + g_signal_connect_swapped(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(HorizontalScroller_change), (gpointer)&horizontalScroller); - setLength(horizontalScrollBar.state.length); - setPosition(horizontalScrollBar.state.position); + setLength(horizontalScroller.state.length); + setPosition(horizontalScroller.state.position); } -void pHorizontalScrollBar::destructor() { +void pHorizontalScroller::destructor() { gtk_widget_destroy(gtkWidget); } -void pHorizontalScrollBar::orphan() { +void pHorizontalScroller::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/horizontal-slider.cpp b/higan/phoenix/gtk/widget/horizontal-slider.cpp index 2d19bae6..3c3bc9fe 100755 --- a/higan/phoenix/gtk/widget/horizontal-slider.cpp +++ b/higan/phoenix/gtk/widget/horizontal-slider.cpp @@ -1,11 +1,13 @@ +namespace phoenix { + static void HorizontalSlider_change(HorizontalSlider *self) { if(self->state.position == self->position()) return; self->state.position = self->position(); if(self->onChange) self->onChange(); } -Geometry pHorizontalSlider::minimumGeometry() { - return { 0, 0, 0, 20 }; +Size pHorizontalSlider::minimumSize() { + return {0, 20}; } unsigned pHorizontalSlider::position() { @@ -39,3 +41,5 @@ void pHorizontalSlider::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/label.cpp b/higan/phoenix/gtk/widget/label.cpp index 8b5cec4f..325ee749 100755 --- a/higan/phoenix/gtk/widget/label.cpp +++ b/higan/phoenix/gtk/widget/label.cpp @@ -1,6 +1,8 @@ -Geometry pLabel::minimumGeometry() { - Geometry geometry = pFont::geometry(widget.state.font, label.state.text); - return { 0, 0, geometry.width, geometry.height }; +namespace phoenix { + +Size pLabel::minimumSize() { + Size size = pFont::size(widget.state.font, label.state.text); + return {size.width, size.height}; } void pLabel::setText(const string &text) { @@ -22,3 +24,5 @@ void pLabel::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/line-edit.cpp b/higan/phoenix/gtk/widget/line-edit.cpp index 8dbe9ef4..c7db7980 100755 --- a/higan/phoenix/gtk/widget/line-edit.cpp +++ b/higan/phoenix/gtk/widget/line-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static void LineEdit_activate(LineEdit *self) { if(self->onActivate) self->onActivate(); } @@ -7,9 +9,9 @@ static void LineEdit_change(LineEdit *self) { if(self->p.locked == false && self->onChange) self->onChange(); } -Geometry pLineEdit::minimumGeometry() { - Geometry geometry = pFont::geometry(widget.state.font, lineEdit.state.text); - return { 0, 0, geometry.width + 10, geometry.height + 10 }; +Size pLineEdit::minimumSize() { + Size size = pFont::size(widget.state.font, lineEdit.state.text); + return {size.width + 10, size.height + 10}; } void pLineEdit::setEditable(bool editable) { @@ -43,3 +45,5 @@ void pLineEdit::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/list-view.cpp b/higan/phoenix/gtk/widget/list-view.cpp index 10e1d439..499c59f4 100755 --- a/higan/phoenix/gtk/widget/list-view.cpp +++ b/higan/phoenix/gtk/widget/list-view.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static void ListView_activate(ListView *self) { if(self->onActivate) self->onActivate(); } @@ -80,7 +82,7 @@ unsigned pListView::selection() { } void pListView::setCheckable(bool checkable) { - gtk_cell_renderer_set_visible(column(0).checkbox, checkable); + gtk_cell_renderer_set_visible(column(0).checkbutton, checkable); } void pListView::setChecked(unsigned row, bool checked) { @@ -153,12 +155,12 @@ void pListView::constructor() { gtk_tree_view_column_set_resizable(cell.column, true); gtk_tree_view_column_set_title(cell.column, ""); - if(column.size() == 0) { //first column checkbox - cell.checkbox = gtk_cell_renderer_toggle_new(); - gtk_tree_view_column_pack_start(cell.column, cell.checkbox, false); - gtk_tree_view_column_set_attributes(cell.column, cell.checkbox, "active", gtype.size(), nullptr); + if(column.size() == 0) { //first column checkbutton + cell.checkbutton = gtk_cell_renderer_toggle_new(); + gtk_tree_view_column_pack_start(cell.column, cell.checkbutton, false); + gtk_tree_view_column_set_attributes(cell.column, cell.checkbutton, "active", gtype.size(), nullptr); gtype.append(G_TYPE_BOOLEAN); - g_signal_connect(cell.checkbox, "toggled", G_CALLBACK(ListView_toggle), (gpointer)&listView); + g_signal_connect(cell.checkbutton, "toggled", G_CALLBACK(ListView_toggle), (gpointer)&listView); } cell.icon = gtk_cell_renderer_pixbuf_new(); @@ -185,7 +187,7 @@ void pListView::constructor() { gtk_widget_show(cell.label); } - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(subWidget), headerText.size() >= 2); //two or more columns + checkbox column + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(subWidget), headerText.size() >= 2); //two or more columns + checkbutton column gtk_tree_view_set_search_column(GTK_TREE_VIEW(subWidget), 2); g_signal_connect_swapped(G_OBJECT(subWidget), "cursor-changed", G_CALLBACK(ListView_change), (gpointer)&listView); @@ -219,3 +221,5 @@ void pListView::setFont(const string &font) { pFont::setFont(gtkWidget, font); for(auto &cell : column) pFont::setFont(cell.label, font); } + +} diff --git a/higan/phoenix/gtk/widget/progress-bar.cpp b/higan/phoenix/gtk/widget/progress-bar.cpp index 972170b8..7f4545a2 100755 --- a/higan/phoenix/gtk/widget/progress-bar.cpp +++ b/higan/phoenix/gtk/widget/progress-bar.cpp @@ -1,5 +1,7 @@ -Geometry pProgressBar::minimumGeometry() { - return { 0, 0, 0, 25 }; +namespace phoenix { + +Size pProgressBar::minimumSize() { + return {0, 25}; } void pProgressBar::setPosition(unsigned position) { @@ -21,3 +23,5 @@ void pProgressBar::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/radio-box.cpp b/higan/phoenix/gtk/widget/radio-box.cpp deleted file mode 100755 index 36aff3fa..00000000 --- a/higan/phoenix/gtk/widget/radio-box.cpp +++ /dev/null @@ -1,50 +0,0 @@ -static void RadioBox_activate(RadioBox *self) { - if(self->p.locked == false && self->checked() && self->onActivate) self->onActivate(); -} - -bool pRadioBox::checked() { - return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget)); -} - -Geometry pRadioBox::minimumGeometry() { - Geometry geometry = pFont::geometry(widget.state.font, radioBox.state.text); -//Font &font = pWidget::font(); -//Geometry geometry = font.geometry(radioBox.state.text); - return { 0, 0, geometry.width + 28, geometry.height + 4 }; -} - -void pRadioBox::setChecked() { - locked = true; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), true); - locked = false; -} - -void pRadioBox::setGroup(const set &group) { - for(unsigned n = 0; n < group.size(); n++) { - if(n == 0) continue; - GSList *currentGroup = gtk_radio_button_get_group(GTK_RADIO_BUTTON(group[0].p.gtkWidget)); - if(currentGroup != gtk_radio_button_get_group(GTK_RADIO_BUTTON(gtkWidget))) { - gtk_radio_button_set_group(GTK_RADIO_BUTTON(gtkWidget), currentGroup); - } - } -} - -void pRadioBox::setText(const string &text) { - gtk_button_set_label(GTK_BUTTON(gtkWidget), text); -} - -void pRadioBox::constructor() { - gtkWidget = gtk_radio_button_new_with_label(0, ""); - g_signal_connect_swapped(G_OBJECT(gtkWidget), "toggled", G_CALLBACK(RadioBox_activate), (gpointer)&radioBox); - - setText(radioBox.state.text); -} - -void pRadioBox::destructor() { - gtk_widget_destroy(gtkWidget); -} - -void pRadioBox::orphan() { - destructor(); - constructor(); -} diff --git a/higan/phoenix/gtk/widget/radio-button.cpp b/higan/phoenix/gtk/widget/radio-button.cpp new file mode 100644 index 00000000..cdcddcc6 --- /dev/null +++ b/higan/phoenix/gtk/widget/radio-button.cpp @@ -0,0 +1,75 @@ +namespace phoenix { + +static void RadioButton_activate(RadioButton *self) { + self->p.onActivate(); +} + +bool pRadioButton::checked() { + return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget)); +} + +Size pRadioButton::minimumSize() { + Size size = pFont::size(widget.state.font, radioButton.state.text); + return {size.width + 28, size.height + 4}; +} + +void pRadioButton::setChecked() { + parent().locked = true; + for(auto &item : radioButton.state.group) item.state.checked = false; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), radioButton.state.checked = true); + parent().locked = false; +} + +void pRadioButton::setGroup(const set &group) { + parent().locked = true; + if(radioButton.state.group.size() == 0 || &radioButton.state.group[0].p == this) return; + gtk_radio_button_set_group( + GTK_RADIO_BUTTON(gtkWidget), + gtk_radio_button_get_group(GTK_RADIO_BUTTON(radioButton.state.group[0].p.gtkWidget)) + ); + for(auto &item : radioButton.state.group) { + if(item.state.checked) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item.p.gtkWidget), true); + break; + } + } + parent().locked = false; +} + +void pRadioButton::setText(const string &text) { + gtk_button_set_label(GTK_BUTTON(gtkWidget), text); +} + +void pRadioButton::onActivate() { + if(parent().locked == false) { + bool wasChecked = radioButton.state.checked; + setChecked(); + if(wasChecked == false) { + if(radioButton.onActivate) radioButton.onActivate(); + } + } +} + +pRadioButton& pRadioButton::parent() { + if(radioButton.state.group.size()) return radioButton.state.group[0].p; + return *this; +} + +void pRadioButton::constructor() { + gtkWidget = gtk_radio_button_new_with_label(nullptr, ""); + g_signal_connect_swapped(G_OBJECT(gtkWidget), "toggled", G_CALLBACK(RadioButton_activate), (gpointer)&radioButton); + + setGroup(radioButton.state.group); + setText(radioButton.state.text); +} + +void pRadioButton::destructor() { + gtk_widget_destroy(gtkWidget); +} + +void pRadioButton::orphan() { + destructor(); + constructor(); +} + +} diff --git a/higan/phoenix/gtk/widget/text-edit.cpp b/higan/phoenix/gtk/widget/text-edit.cpp index 2d2b740b..2a62ea17 100755 --- a/higan/phoenix/gtk/widget/text-edit.cpp +++ b/higan/phoenix/gtk/widget/text-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static void TextEdit_change(TextEdit *self) { self->state.text = self->text(); if(self->p.locked == false && self->onChange) self->onChange(); @@ -68,3 +70,5 @@ void pTextEdit::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/vertical-scroll-bar.cpp b/higan/phoenix/gtk/widget/vertical-scroller.cpp old mode 100755 new mode 100644 similarity index 53% rename from higan/phoenix/gtk/widget/vertical-scroll-bar.cpp rename to higan/phoenix/gtk/widget/vertical-scroller.cpp index e3bde589..35002283 --- a/higan/phoenix/gtk/widget/vertical-scroll-bar.cpp +++ b/higan/phoenix/gtk/widget/vertical-scroller.cpp @@ -1,18 +1,20 @@ -static void VerticalScrollBar_change(VerticalScrollBar *self) { +namespace phoenix { + +static void VerticalScroller_change(VerticalScroller *self) { if(self->state.position == self->position()) return; self->state.position = self->position(); if(self->p.locked == false && self->onChange) self->onChange(); } -Geometry pVerticalScrollBar::minimumGeometry() { - return { 0, 0, 20, 0 }; +Size pVerticalScroller::minimumSize() { + return {20, 0}; } -unsigned pVerticalScrollBar::position() { +unsigned pVerticalScroller::position() { return (unsigned)gtk_range_get_value(GTK_RANGE(gtkWidget)); } -void pVerticalScrollBar::setLength(unsigned length) { +void pVerticalScroller::setLength(unsigned length) { locked = true; length += length == 0; gtk_range_set_range(GTK_RANGE(gtkWidget), 0, max(1u, length - 1)); @@ -20,23 +22,25 @@ void pVerticalScrollBar::setLength(unsigned length) { locked = false; } -void pVerticalScrollBar::setPosition(unsigned position) { +void pVerticalScroller::setPosition(unsigned position) { gtk_range_set_value(GTK_RANGE(gtkWidget), position); } -void pVerticalScrollBar::constructor() { +void pVerticalScroller::constructor() { gtkWidget = gtk_vscrollbar_new(0); - g_signal_connect_swapped(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(VerticalScrollBar_change), (gpointer)&verticalScrollBar); + g_signal_connect_swapped(G_OBJECT(gtkWidget), "value-changed", G_CALLBACK(VerticalScroller_change), (gpointer)&verticalScroller); - setLength(verticalScrollBar.state.length); - setPosition(verticalScrollBar.state.position); + setLength(verticalScroller.state.length); + setPosition(verticalScroller.state.position); } -void pVerticalScrollBar::destructor() { +void pVerticalScroller::destructor() { gtk_widget_destroy(gtkWidget); } -void pVerticalScrollBar::orphan() { +void pVerticalScroller::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/vertical-slider.cpp b/higan/phoenix/gtk/widget/vertical-slider.cpp index 3c68489e..5325b090 100755 --- a/higan/phoenix/gtk/widget/vertical-slider.cpp +++ b/higan/phoenix/gtk/widget/vertical-slider.cpp @@ -1,11 +1,13 @@ +namespace phoenix { + static void VerticalSlider_change(VerticalSlider *self) { if(self->state.position == self->position()) return; self->state.position = self->position(); if(self->onChange) self->onChange(); } -Geometry pVerticalSlider::minimumGeometry() { - return { 0, 0, 20, 0 }; +Size pVerticalSlider::minimumSize() { + return {20, 0}; } unsigned pVerticalSlider::position() { @@ -39,3 +41,5 @@ void pVerticalSlider::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/viewport.cpp b/higan/phoenix/gtk/widget/viewport.cpp index e842a2e5..f93521ee 100755 --- a/higan/phoenix/gtk/widget/viewport.cpp +++ b/higan/phoenix/gtk/widget/viewport.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static gboolean Viewport_mouseLeave(GtkWidget *widget, GdkEventButton *event, pViewport *self) { if(self->viewport.onMouseLeave) self->viewport.onMouseLeave(); return true; @@ -56,3 +58,5 @@ void pViewport::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/widget/widget.cpp b/higan/phoenix/gtk/widget/widget.cpp index aa4eacfa..55fe3458 100755 --- a/higan/phoenix/gtk/widget/widget.cpp +++ b/higan/phoenix/gtk/widget/widget.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pWidget::enabled() { return gtk_widget_get_sensitive(gtkWidget); } @@ -6,8 +8,8 @@ bool pWidget::focused() { return GTK_WIDGET_HAS_FOCUS(gtkWidget); } -Geometry pWidget::minimumGeometry() { - return {0, 0, 0, 0}; +Size pWidget::minimumSize() { + return {0, 0}; } void pWidget::setEnabled(bool enabled) { @@ -49,3 +51,5 @@ void pWidget::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/gtk/window.cpp b/higan/phoenix/gtk/window.cpp index 4518c38a..be190fdf 100755 --- a/higan/phoenix/gtk/window.cpp +++ b/higan/phoenix/gtk/window.cpp @@ -1,7 +1,9 @@ +namespace phoenix { + static gint Window_close(GtkWidget *widget, GdkEvent *event, Window *window) { - window->state.ignore = false; if(window->onClose) window->onClose(); - if(window->state.ignore == false) window->setVisible(false); + else window->setVisible(false); + if(window->state.modal && !window->visible()) window->setModal(false); return true; } @@ -35,7 +37,7 @@ static gboolean Window_configure(GtkWidget *widget, GdkEvent *event, Window *win GdkRectangle border, client; gdk_window_get_frame_extents(gdkWindow, &border); - gdk_window_get_geometry(gdkWindow, 0, 0, &client.width, &client.height, 0); + gdk_window_get_geometry(gdkWindow, nullptr, nullptr, &client.width, &client.height, nullptr); gdk_window_get_origin(gdkWindow, &client.x, &client.y); if(window->state.fullScreen == false) { @@ -137,6 +139,10 @@ void pWindow::append(Menu &menu) { } void pWindow::append(Widget &widget) { + if(widget.font().empty() && !window.state.widgetFont.empty()) { + widget.setFont(window.state.widgetFont); + } + ((Sizable&)widget).state.window = &window; gtk_fixed_put(GTK_FIXED(formContainer), widget.p.gtkWidget, 0, 0); if(widget.state.font != "") widget.p.setFont(widget.state.font); @@ -230,6 +236,12 @@ void pWindow::setGeometry(const Geometry &geometry) { //gtk_window_set_policy(GTK_WINDOW(widget), true, true, false); gtk_widget_set_size_request(formContainer, geometry.width, geometry.height); gtk_window_resize(GTK_WINDOW(widget), geometry.width, geometry.height + menuHeight() + statusHeight()); + + for(auto &layout : window.state.layout) { + Geometry layoutGeometry = geometry; + layoutGeometry.x = layoutGeometry.y = 0; + layout.setGeometry(layoutGeometry); + } } void pWindow::setMenuFont(const string &font) { @@ -241,7 +253,14 @@ void pWindow::setMenuVisible(bool visible) { } void pWindow::setModal(bool modal) { - gtk_window_set_modal(GTK_WINDOW(widget), modal); + if(modal == true) { + gtk_window_set_modal(GTK_WINDOW(widget), true); + while(window.state.modal) { + Application::processEvents(); + usleep(20 * 1000); + } + gtk_window_set_modal(GTK_WINDOW(widget), false); + } } void pWindow::setResizable(bool resizable) { @@ -284,9 +303,6 @@ void pWindow::setVisible(bool visible) { } void pWindow::setWidgetFont(const string &font) { - for(auto &item : window.state.widget) { - if(item.state.font == "") item.setFont(font); - } } void pWindow::constructor() { @@ -297,11 +313,11 @@ void pWindow::constructor() { widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); //if program was given a name, try and set the window taskbar icon from one of the pixmaps folders - if(osState.name.empty() == false) { - if(file::exists({"/usr/share/pixmaps/", osState.name, ".png"})) { - gtk_window_set_icon_from_file(GTK_WINDOW(widget), string{"/usr/share/pixmaps/", osState.name, ".png"}, nullptr); - } else if(file::exists({"/usr/local/share/pixmaps/", osState.name, ".png"})) { - gtk_window_set_icon_from_file(GTK_WINDOW(widget), string{"/usr/local/share/pixmaps/", osState.name, ".png"}, nullptr); + if(applicationState.name.empty() == false) { + if(file::exists({"/usr/share/pixmaps/", applicationState.name, ".png"})) { + gtk_window_set_icon_from_file(GTK_WINDOW(widget), string{"/usr/share/pixmaps/", applicationState.name, ".png"}, nullptr); + } else if(file::exists({"/usr/local/share/pixmaps/", applicationState.name, ".png"})) { + gtk_window_set_icon_from_file(GTK_WINDOW(widget), string{"/usr/local/share/pixmaps/", applicationState.name, ".png"}, nullptr); } } @@ -360,3 +376,5 @@ unsigned pWindow::menuHeight() { unsigned pWindow::statusHeight() { return window.state.statusVisible ? settings->statusGeometryHeight : 0; } + +} diff --git a/higan/phoenix/phoenix.cpp b/higan/phoenix/phoenix.cpp index eaa66b97..63041289 100755 --- a/higan/phoenix/phoenix.cpp +++ b/higan/phoenix/phoenix.cpp @@ -1,52 +1,6 @@ #ifndef PHOENIX_CPP #define PHOENIX_CPP -#if defined(PHOENIX_WINDOWS) - #define UNICODE - #define WINVER 0x0501 - #define _WIN32_WINNT 0x0501 - #define _WIN32_IE 0x0600 - #define __MSVCRT_VERSION__ 0x0601 - #define NOMINMAX - - #include - #include - #include - #include - #include - #include - #include - #include -#elif defined(PHOENIX_QT) - #include - #include - #include - #define XK_MISCELLANY - #define XK_LATIN1 - #include - #include - #undef XK_MISCELLANY - #undef XK_LATIN1 - #include -#elif defined(PHOENIX_GTK) - #include - #include - #include - #include - #include - #include - #include - #include -#elif defined(PHOENIX_REFERENCE) -#else - #error "phoenix: unrecognized target" -#endif - -#include "phoenix.hpp" -using namespace nall; - -namespace phoenix { - #include "core/core.cpp" -} +#include "core/core.cpp" #endif diff --git a/higan/phoenix/phoenix.hpp b/higan/phoenix/phoenix.hpp index 8a6129c4..21e85af6 100755 --- a/higan/phoenix/phoenix.hpp +++ b/higan/phoenix/phoenix.hpp @@ -1,19 +1,6 @@ #ifndef PHOENIX_HPP #define PHOENIX_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace phoenix { - #include "core/core.hpp" -} +#include "core/core.hpp" #endif diff --git a/higan/phoenix/qt/action/action.cpp b/higan/phoenix/qt/action/action.cpp index 62efaa2a..af1e29ec 100755 --- a/higan/phoenix/qt/action/action.cpp +++ b/higan/phoenix/qt/action/action.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pAction::setEnabled(bool enabled) { if(dynamic_cast(&action)) { ((Menu&)action).p.qtMenu->setEnabled(enabled); @@ -47,3 +49,5 @@ void pAction::constructor() { void pAction::destructor() { } + +} diff --git a/higan/phoenix/qt/action/check-item.cpp b/higan/phoenix/qt/action/check-item.cpp index ef451e73..0018b737 100755 --- a/higan/phoenix/qt/action/check-item.cpp +++ b/higan/phoenix/qt/action/check-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pCheckItem::checked() { return qtAction->isChecked(); } @@ -25,3 +27,5 @@ void pCheckItem::onToggle() { checkItem.state.checked = checked(); if(checkItem.onToggle) checkItem.onToggle(); } + +} diff --git a/higan/phoenix/qt/action/item.cpp b/higan/phoenix/qt/action/item.cpp index 7f142289..09e31978 100755 --- a/higan/phoenix/qt/action/item.cpp +++ b/higan/phoenix/qt/action/item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pItem::setImage(const image &image) { qtAction->setIcon(CreateIcon(image)); } @@ -19,3 +21,5 @@ void pItem::destructor() { void pItem::onActivate() { if(item.onActivate) item.onActivate(); } + +} diff --git a/higan/phoenix/qt/action/menu.cpp b/higan/phoenix/qt/action/menu.cpp index 43d89a1e..019ae637 100755 --- a/higan/phoenix/qt/action/menu.cpp +++ b/higan/phoenix/qt/action/menu.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pMenu::append(Action &action) { if(dynamic_cast(&action)) { qtMenu->addMenu(((Menu&)action).p.qtMenu); @@ -49,3 +51,5 @@ void pMenu::destructor() { if(action.state.menu) action.state.menu->remove(menu); delete qtMenu; } + +} diff --git a/higan/phoenix/qt/action/radio-item.cpp b/higan/phoenix/qt/action/radio-item.cpp index 66cf6c6a..535be71e 100755 --- a/higan/phoenix/qt/action/radio-item.cpp +++ b/higan/phoenix/qt/action/radio-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pRadioItem::checked() { return qtAction->isChecked(); } @@ -39,3 +41,5 @@ void pRadioItem::onActivate() { if(locked == false && radioItem.onActivate) radioItem.onActivate(); } } + +} diff --git a/higan/phoenix/qt/action/separator.cpp b/higan/phoenix/qt/action/separator.cpp index 95e66b6c..7b1f2ad1 100755 --- a/higan/phoenix/qt/action/separator.cpp +++ b/higan/phoenix/qt/action/separator.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pSeparator::constructor() { qtAction = new QAction(0); qtAction->setSeparator(true); @@ -7,3 +9,5 @@ void pSeparator::destructor() { if(action.state.menu) action.state.menu->remove(separator); delete qtAction; } + +} diff --git a/higan/phoenix/qt/application.cpp b/higan/phoenix/qt/application.cpp new file mode 100644 index 00000000..1bfa81e3 --- /dev/null +++ b/higan/phoenix/qt/application.cpp @@ -0,0 +1,56 @@ +namespace phoenix { + +XlibDisplay* pApplication::display = nullptr; + +void pApplication::run() { + if(Application::main) { + while(applicationState.quit == false) { + processEvents(); + Application::main(); + } + } else { + QApplication::exec(); + } +} + +bool pApplication::pendingEvents() { + return QApplication::hasPendingEvents(); +} + +void pApplication::processEvents() { + while(pendingEvents()) QApplication::processEvents(); +} + +void pApplication::quit() { + QApplication::quit(); + //note: QApplication cannot be deleted; or libQtGui will crash + qtApplication = nullptr; +} + +void pApplication::syncX() { + for(unsigned n = 0; n < 8; n++) { + QApplication::syncX(); + Application::processEvents(); + usleep(2000); + } +} + +void pApplication::initialize() { + display = XOpenDisplay(0); + + settings = new Settings; + settings->load(); + + static int argc = 1; + static char *argv[2]; + argv[0] = new char[8]; + argv[1] = 0; + strcpy(argv[0], "phoenix"); + char **argvp = argv; + + qtApplication = new QApplication(argc, argvp); + + pKeyboard::initialize(); +} + +} diff --git a/higan/phoenix/qt/desktop.cpp b/higan/phoenix/qt/desktop.cpp index 554106b5..f8e51dbe 100755 --- a/higan/phoenix/qt/desktop.cpp +++ b/higan/phoenix/qt/desktop.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + Size pDesktop::size() { QRect rect = QApplication::desktop()->screenGeometry(); return { rect.width(), rect.height() }; @@ -7,3 +9,5 @@ Geometry pDesktop::workspace() { QRect rect = QApplication::desktop()->availableGeometry(); return { rect.x(), rect.y(), rect.width(), rect.height() }; } + +} diff --git a/higan/phoenix/qt/dialog-window.cpp b/higan/phoenix/qt/dialog-window.cpp index 680a6e2e..86e73f6e 100755 --- a/higan/phoenix/qt/dialog-window.cpp +++ b/higan/phoenix/qt/dialog-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + string pDialogWindow::fileOpen(Window &parent, const string &path, const lstring &filter) { string filterList; for(auto &item : filter) { @@ -55,3 +57,5 @@ string pDialogWindow::folderSelect(Window &parent, const string &path) { if(name != "" && name.endswith("/") == false) name.append("/"); return name; } + +} diff --git a/higan/phoenix/qt/font.cpp b/higan/phoenix/qt/font.cpp index bb3261cd..f3874199 100755 --- a/higan/phoenix/qt/font.cpp +++ b/higan/phoenix/qt/font.cpp @@ -1,10 +1,30 @@ -Geometry pFont::geometry(const string &description, const string &text) { - return pFont::geometry(pFont::create(description), text); +namespace phoenix { + +string pFont::serif(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Serif, ", size, ", ", style}; +} + +string pFont::sans(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Sans, ", size, ", ", style}; +} + +string pFont::monospace(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Liberation Mono, ", size, ", ", style}; +} + +Size pFont::size(const string &font, const string &text) { + return pFont::size(pFont::create(font), text); } QFont pFont::create(const string &description) { lstring part; - part.split(",", description); + part.split<2>(",", description); for(auto &item : part) item.trim(" "); string family = "Sans"; @@ -25,7 +45,7 @@ QFont pFont::create(const string &description) { return qtFont; } -Geometry pFont::geometry(const QFont &qtFont, const string &text) { +Size pFont::size(const QFont &qtFont, const string &text) { QFontMetrics metrics(qtFont); lstring lines; @@ -36,5 +56,7 @@ Geometry pFont::geometry(const QFont &qtFont, const string &text) { maxWidth = max(maxWidth, metrics.width(line)); } - return { 0, 0, maxWidth, metrics.height() * lines.size() }; + return {maxWidth, metrics.height() * lines.size()}; +} + } diff --git a/higan/phoenix/qt/header.hpp b/higan/phoenix/qt/header.hpp new file mode 100644 index 00000000..03c4a0c2 --- /dev/null +++ b/higan/phoenix/qt/header.hpp @@ -0,0 +1,16 @@ +#include +#include +#include +#define XK_MISCELLANY +#define XK_LATIN1 +#include +#include +#undef XK_MISCELLANY +#undef XK_LATIN1 +#include + +//Qt 4.8.0 and earlier improperly define the QLOCATION macro +//in C++11, it is detected as a malformed user-defined literal +//below is a workaround to fix compilation errors caused by this +#undef QLOCATION +#define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__) diff --git a/higan/phoenix/qt/keyboard.cpp b/higan/phoenix/qt/keyboard.cpp index 5b346406..57df17f7 100755 --- a/higan/phoenix/qt/keyboard.cpp +++ b/higan/phoenix/qt/keyboard.cpp @@ -1,6 +1,8 @@ +namespace phoenix { + void pKeyboard::initialize() { auto append = [](Keyboard::Scancode scancode, unsigned keysym) { - settings->keymap.insert(scancode, XKeysymToKeycode(pOS::display, keysym)); + settings->keymap.insert(scancode, XKeysymToKeycode(pApplication::display, keysym)); }; append(Keyboard::Scancode::Escape, XK_Escape); @@ -120,7 +122,7 @@ void pKeyboard::initialize() { bool pKeyboard::pressed(Keyboard::Scancode scancode) { char state[256]; - XQueryKeymap(pOS::display, state); + XQueryKeymap(pApplication::display, state); unsigned id = settings->keymap.lhs[scancode]; return state[id >> 3] & (1 << (id & 7)); } @@ -131,7 +133,7 @@ vector pKeyboard::state() { for(auto &n : output) n = false; char state[256]; - XQueryKeymap(pOS::display, state); + XQueryKeymap(pApplication::display, state); for(auto &n : settings->keymap.rhs) { if(state[n.name >> 3] & (1 << (n.name & 7))) { output[(unsigned)n.data] = true; @@ -140,3 +142,5 @@ vector pKeyboard::state() { return output; } + +} diff --git a/higan/phoenix/qt/message-window.cpp b/higan/phoenix/qt/message-window.cpp index 7bceba0f..e8003cb6 100755 --- a/higan/phoenix/qt/message-window.cpp +++ b/higan/phoenix/qt/message-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static QMessageBox::StandardButtons MessageWindow_buttons(MessageWindow::Buttons buttons) { QMessageBox::StandardButtons standardButtons = QMessageBox::NoButton; if(buttons == MessageWindow::Buttons::Ok) standardButtons = QMessageBox::Ok; @@ -45,3 +47,5 @@ MessageWindow::Response pMessageWindow::critical(Window &parent, const string &t QString::fromUtf8(text), MessageWindow_buttons(buttons)) ); } + +} diff --git a/higan/phoenix/qt/mouse.cpp b/higan/phoenix/qt/mouse.cpp index 4ea06cc9..169b5111 100755 --- a/higan/phoenix/qt/mouse.cpp +++ b/higan/phoenix/qt/mouse.cpp @@ -1,6 +1,8 @@ +namespace phoenix { + Position pMouse::position() { QPoint point = QCursor::pos(); - return { point.x(), point.y() }; + return {point.x(), point.y()}; } bool pMouse::pressed(Mouse::Button button) { @@ -12,3 +14,5 @@ bool pMouse::pressed(Mouse::Button button) { } return false; } + +} diff --git a/higan/phoenix/qt/platform.cpp b/higan/phoenix/qt/platform.cpp index 86f659c8..1e9a318a 100755 --- a/higan/phoenix/qt/platform.cpp +++ b/higan/phoenix/qt/platform.cpp @@ -1,11 +1,6 @@ -//Qt 4.8.0 and earlier improperly define the QLOCATION macro -//in C++11, it is detected as a malformed user-defined literal -//below is a workaround to fix compilation errors caused by this -#undef QLOCATION -#define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__) - #include "platform.moc.hpp" #include "platform.moc" + #include "utility.cpp" #include "settings.cpp" @@ -14,7 +9,6 @@ #include "mouse.cpp" #include "dialog-window.cpp" #include "message-window.cpp" - #include "font.cpp" #include "timer.cpp" #include "window.cpp" @@ -29,63 +23,19 @@ #include "widget/widget.cpp" #include "widget/button.cpp" #include "widget/canvas.cpp" -#include "widget/check-box.cpp" -#include "widget/combo-box.cpp" +#include "widget/check-button.cpp" +#include "widget/combo-button.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroll-bar.cpp" +#include "widget/horizontal-scroller.cpp" #include "widget/horizontal-slider.cpp" #include "widget/label.cpp" #include "widget/line-edit.cpp" #include "widget/list-view.cpp" #include "widget/progress-bar.cpp" -#include "widget/radio-box.cpp" +#include "widget/radio-button.cpp" #include "widget/text-edit.cpp" -#include "widget/vertical-scroll-bar.cpp" +#include "widget/vertical-scroller.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" -XlibDisplay* pOS::display = 0; - -void pOS::main() { - QApplication::exec(); -} - -bool pOS::pendingEvents() { - return QApplication::hasPendingEvents(); -} - -void pOS::processEvents() { - while(pendingEvents()) QApplication::processEvents(); -} - -void pOS::quit() { - QApplication::quit(); - //note: QApplication cannot be deleted; or libQtGui will crash - qtApplication = 0; -} - -void pOS::syncX() { - for(unsigned n = 0; n < 8; n++) { - QApplication::syncX(); - OS::processEvents(); - usleep(2000); - } -} - -void pOS::initialize() { - display = XOpenDisplay(0); - - settings = new Settings; - settings->load(); - - static int argc = 1; - static char *argv[2]; - argv[0] = new char[8]; - argv[1] = 0; - strcpy(argv[0], "phoenix"); - char **argvp = argv; - - qtApplication = new QApplication(argc, argvp); - - pKeyboard::initialize(); -} +#include "application.cpp" diff --git a/higan/phoenix/qt/platform.moc b/higan/phoenix/qt/platform.moc index 2a53a326..1ccf4d6c 100755 --- a/higan/phoenix/qt/platform.moc +++ b/higan/phoenix/qt/platform.moc @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'platform.moc.hpp' ** -** Created: Wed Dec 26 00:12:14 2012 +** Created: Thu Mar 14 08:12:31 2013 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.3) ** ** WARNING! All changes made in this file will be lost! @@ -16,1032 +16,7 @@ #endif QT_BEGIN_MOC_NAMESPACE -static const uint qt_meta_data_pTimer[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 8, 7, 7, 7, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pTimer[] = { - "pTimer\0\0onTimeout()\0" -}; - -const QMetaObject pTimer::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pTimer, - qt_meta_data_pTimer, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pTimer::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pTimer::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pTimer::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pTimer)) - return static_cast(const_cast< pTimer*>(this)); - if (!strcmp(_clname, "pObject")) - return static_cast< pObject*>(const_cast< pTimer*>(this)); - return QObject::qt_metacast(_clname); -} - -int pTimer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onTimeout(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pWindow[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 0, 0, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - 0 // eod -}; - -static const char qt_meta_stringdata_pWindow[] = { - "pWindow\0" -}; - -const QMetaObject pWindow::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pWindow, - qt_meta_data_pWindow, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pWindow::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pWindow::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pWindow::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pWindow)) - return static_cast(const_cast< pWindow*>(this)); - if (!strcmp(_clname, "pObject")) - return static_cast< pObject*>(const_cast< pWindow*>(this)); - return QObject::qt_metacast(_clname); -} - -int pWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - return _id; -} -static const uint qt_meta_data_pItem[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 7, 6, 6, 6, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pItem[] = { - "pItem\0\0onActivate()\0" -}; - -const QMetaObject pItem::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pItem, - qt_meta_data_pItem, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pItem::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pItem::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pItem::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pItem)) - return static_cast(const_cast< pItem*>(this)); - if (!strcmp(_clname, "pAction")) - return static_cast< pAction*>(const_cast< pItem*>(this)); - return QObject::qt_metacast(_clname); -} - -int pItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onActivate(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pCheckItem[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 12, 11, 11, 11, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pCheckItem[] = { - "pCheckItem\0\0onToggle()\0" -}; - -const QMetaObject pCheckItem::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pCheckItem, - qt_meta_data_pCheckItem, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pCheckItem::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pCheckItem::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pCheckItem::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pCheckItem)) - return static_cast(const_cast< pCheckItem*>(this)); - if (!strcmp(_clname, "pAction")) - return static_cast< pAction*>(const_cast< pCheckItem*>(this)); - return QObject::qt_metacast(_clname); -} - -int pCheckItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onToggle(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pRadioItem[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 12, 11, 11, 11, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pRadioItem[] = { - "pRadioItem\0\0onActivate()\0" -}; - -const QMetaObject pRadioItem::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pRadioItem, - qt_meta_data_pRadioItem, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pRadioItem::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pRadioItem::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pRadioItem::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pRadioItem)) - return static_cast(const_cast< pRadioItem*>(this)); - if (!strcmp(_clname, "pAction")) - return static_cast< pAction*>(const_cast< pRadioItem*>(this)); - return QObject::qt_metacast(_clname); -} - -int pRadioItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onActivate(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pButton[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 9, 8, 8, 8, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pButton[] = { - "pButton\0\0onActivate()\0" -}; - -const QMetaObject pButton::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pButton, - qt_meta_data_pButton, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pButton::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pButton::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pButton::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pButton)) - return static_cast(const_cast< pButton*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pButton*>(this)); - return QObject::qt_metacast(_clname); -} - -int pButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onActivate(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pCanvas[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 0, 0, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - 0 // eod -}; - -static const char qt_meta_stringdata_pCanvas[] = { - "pCanvas\0" -}; - -const QMetaObject pCanvas::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pCanvas, - qt_meta_data_pCanvas, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pCanvas::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pCanvas::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pCanvas::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pCanvas)) - return static_cast(const_cast< pCanvas*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pCanvas*>(this)); - return QObject::qt_metacast(_clname); -} - -int pCanvas::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - return _id; -} -static const uint qt_meta_data_pCheckBox[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 11, 10, 10, 10, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pCheckBox[] = { - "pCheckBox\0\0onToggle()\0" -}; - -const QMetaObject pCheckBox::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pCheckBox, - qt_meta_data_pCheckBox, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pCheckBox::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pCheckBox::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pCheckBox::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pCheckBox)) - return static_cast(const_cast< pCheckBox*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pCheckBox*>(this)); - return QObject::qt_metacast(_clname); -} - -int pCheckBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onToggle(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pComboBox[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 11, 10, 10, 10, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pComboBox[] = { - "pComboBox\0\0onChange()\0" -}; - -const QMetaObject pComboBox::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pComboBox, - qt_meta_data_pComboBox, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pComboBox::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pComboBox::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pComboBox::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pComboBox)) - return static_cast(const_cast< pComboBox*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pComboBox*>(this)); - return QObject::qt_metacast(_clname); -} - -int pComboBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onChange(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pHexEdit[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 10, 9, 9, 9, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pHexEdit[] = { - "pHexEdit\0\0onScroll()\0" -}; - -const QMetaObject pHexEdit::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pHexEdit, - qt_meta_data_pHexEdit, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pHexEdit::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pHexEdit::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pHexEdit::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pHexEdit)) - return static_cast(const_cast< pHexEdit*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pHexEdit*>(this)); - return QObject::qt_metacast(_clname); -} - -int pHexEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onScroll(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pHorizontalScrollBar[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 22, 21, 21, 21, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pHorizontalScrollBar[] = { - "pHorizontalScrollBar\0\0onChange()\0" -}; - -const QMetaObject pHorizontalScrollBar::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pHorizontalScrollBar, - qt_meta_data_pHorizontalScrollBar, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pHorizontalScrollBar::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pHorizontalScrollBar::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pHorizontalScrollBar::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pHorizontalScrollBar)) - return static_cast(const_cast< pHorizontalScrollBar*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pHorizontalScrollBar*>(this)); - return QObject::qt_metacast(_clname); -} - -int pHorizontalScrollBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onChange(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pHorizontalSlider[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 19, 18, 18, 18, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pHorizontalSlider[] = { - "pHorizontalSlider\0\0onChange()\0" -}; - -const QMetaObject pHorizontalSlider::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pHorizontalSlider, - qt_meta_data_pHorizontalSlider, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pHorizontalSlider::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pHorizontalSlider::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pHorizontalSlider::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pHorizontalSlider)) - return static_cast(const_cast< pHorizontalSlider*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pHorizontalSlider*>(this)); - return QObject::qt_metacast(_clname); -} - -int pHorizontalSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onChange(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pLineEdit[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 2, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 11, 10, 10, 10, 0x0a, - 24, 10, 10, 10, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pLineEdit[] = { - "pLineEdit\0\0onActivate()\0onChange()\0" -}; - -const QMetaObject pLineEdit::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pLineEdit, - qt_meta_data_pLineEdit, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pLineEdit::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pLineEdit::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pLineEdit::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pLineEdit)) - return static_cast(const_cast< pLineEdit*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pLineEdit*>(this)); - return QObject::qt_metacast(_clname); -} - -int pLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onActivate(); break; - case 1: onChange(); break; - default: ; - } - _id -= 2; - } - return _id; -} -static const uint qt_meta_data_pListView[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 3, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 11, 10, 10, 10, 0x0a, - 29, 24, 10, 10, 0x0a, - 56, 24, 10, 10, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pListView[] = { - "pListView\0\0onActivate()\0item\0" - "onChange(QTreeWidgetItem*)\0" - "onToggle(QTreeWidgetItem*)\0" -}; - -const QMetaObject pListView::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pListView, - qt_meta_data_pListView, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pListView::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pListView::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pListView::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pListView)) - return static_cast(const_cast< pListView*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pListView*>(this)); - return QObject::qt_metacast(_clname); -} - -int pListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onActivate(); break; - case 1: onChange((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; - case 2: onToggle((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; - default: ; - } - _id -= 3; - } - return _id; -} -static const uint qt_meta_data_pRadioBox[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 11, 10, 10, 10, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pRadioBox[] = { - "pRadioBox\0\0onActivate()\0" -}; - -const QMetaObject pRadioBox::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pRadioBox, - qt_meta_data_pRadioBox, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pRadioBox::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pRadioBox::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pRadioBox::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pRadioBox)) - return static_cast(const_cast< pRadioBox*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pRadioBox*>(this)); - return QObject::qt_metacast(_clname); -} - -int pRadioBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onActivate(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pTextEdit[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 11, 10, 10, 10, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pTextEdit[] = { - "pTextEdit\0\0onChange()\0" -}; - -const QMetaObject pTextEdit::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pTextEdit, - qt_meta_data_pTextEdit, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pTextEdit::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pTextEdit::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pTextEdit::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pTextEdit)) - return static_cast(const_cast< pTextEdit*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pTextEdit*>(this)); - return QObject::qt_metacast(_clname); -} - -int pTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onChange(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pVerticalScrollBar[] = { - - // content: - 4, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 20, 19, 19, 19, 0x0a, - - 0 // eod -}; - -static const char qt_meta_stringdata_pVerticalScrollBar[] = { - "pVerticalScrollBar\0\0onChange()\0" -}; - -const QMetaObject pVerticalScrollBar::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pVerticalScrollBar, - qt_meta_data_pVerticalScrollBar, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pVerticalScrollBar::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *pVerticalScrollBar::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *pVerticalScrollBar::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pVerticalScrollBar)) - return static_cast(const_cast< pVerticalScrollBar*>(this)); - if (!strcmp(_clname, "pWidget")) - return static_cast< pWidget*>(const_cast< pVerticalScrollBar*>(this)); - return QObject::qt_metacast(_clname); -} - -int pVerticalScrollBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: onChange(); break; - default: ; - } - _id -= 1; - } - return _id; -} -static const uint qt_meta_data_pVerticalSlider[] = { +static const uint qt_meta_data_phoenix__pTimer[] = { // content: 4, // revision @@ -1060,35 +35,1061 @@ static const uint qt_meta_data_pVerticalSlider[] = { 0 // eod }; -static const char qt_meta_stringdata_pVerticalSlider[] = { - "pVerticalSlider\0\0onChange()\0" +static const char qt_meta_stringdata_phoenix__pTimer[] = { + "phoenix::pTimer\0\0onActivate()\0" }; -const QMetaObject pVerticalSlider::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_pVerticalSlider, - qt_meta_data_pVerticalSlider, 0 } +const QMetaObject phoenix::pTimer::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pTimer, + qt_meta_data_phoenix__pTimer, 0 } }; #ifdef Q_NO_DATA_RELOCATION -const QMetaObject &pVerticalSlider::getStaticMetaObject() { return staticMetaObject; } +const QMetaObject &phoenix::pTimer::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION -const QMetaObject *pVerticalSlider::metaObject() const +const QMetaObject *phoenix::pTimer::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } -void *pVerticalSlider::qt_metacast(const char *_clname) +void *phoenix::pTimer::qt_metacast(const char *_clname) { if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_pVerticalSlider)) + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pTimer)) + return static_cast(const_cast< pTimer*>(this)); + if (!strcmp(_clname, "pObject")) + return static_cast< pObject*>(const_cast< pTimer*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pTimer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pWindow[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pWindow[] = { + "phoenix::pWindow\0" +}; + +const QMetaObject phoenix::pWindow::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pWindow, + qt_meta_data_phoenix__pWindow, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pWindow::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pWindow::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pWindow::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pWindow)) + return static_cast(const_cast< pWindow*>(this)); + if (!strcmp(_clname, "pObject")) + return static_cast< pObject*>(const_cast< pWindow*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} +static const uint qt_meta_data_phoenix__pItem[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 16, 15, 15, 15, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pItem[] = { + "phoenix::pItem\0\0onActivate()\0" +}; + +const QMetaObject phoenix::pItem::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pItem, + qt_meta_data_phoenix__pItem, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pItem::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pItem::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pItem::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pItem)) + return static_cast(const_cast< pItem*>(this)); + if (!strcmp(_clname, "pAction")) + return static_cast< pAction*>(const_cast< pItem*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pCheckItem[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 21, 20, 20, 20, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pCheckItem[] = { + "phoenix::pCheckItem\0\0onToggle()\0" +}; + +const QMetaObject phoenix::pCheckItem::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pCheckItem, + qt_meta_data_phoenix__pCheckItem, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pCheckItem::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pCheckItem::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pCheckItem::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pCheckItem)) + return static_cast(const_cast< pCheckItem*>(this)); + if (!strcmp(_clname, "pAction")) + return static_cast< pAction*>(const_cast< pCheckItem*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pCheckItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onToggle(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pRadioItem[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 21, 20, 20, 20, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pRadioItem[] = { + "phoenix::pRadioItem\0\0onActivate()\0" +}; + +const QMetaObject phoenix::pRadioItem::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pRadioItem, + qt_meta_data_phoenix__pRadioItem, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pRadioItem::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pRadioItem::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pRadioItem::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pRadioItem)) + return static_cast(const_cast< pRadioItem*>(this)); + if (!strcmp(_clname, "pAction")) + return static_cast< pAction*>(const_cast< pRadioItem*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pRadioItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pButton[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 18, 17, 17, 17, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pButton[] = { + "phoenix::pButton\0\0onActivate()\0" +}; + +const QMetaObject phoenix::pButton::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pButton, + qt_meta_data_phoenix__pButton, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pButton::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pButton::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pButton::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pButton)) + return static_cast(const_cast< pButton*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pButton*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pCanvas[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pCanvas[] = { + "phoenix::pCanvas\0" +}; + +const QMetaObject phoenix::pCanvas::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pCanvas, + qt_meta_data_phoenix__pCanvas, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pCanvas::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pCanvas::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pCanvas::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pCanvas)) + return static_cast(const_cast< pCanvas*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pCanvas*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pCanvas::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} +static const uint qt_meta_data_phoenix__pCheckButton[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 23, 22, 22, 22, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pCheckButton[] = { + "phoenix::pCheckButton\0\0onToggle()\0" +}; + +const QMetaObject phoenix::pCheckButton::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pCheckButton, + qt_meta_data_phoenix__pCheckButton, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pCheckButton::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pCheckButton::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pCheckButton::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pCheckButton)) + return static_cast(const_cast< pCheckButton*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pCheckButton*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pCheckButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onToggle(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pComboButton[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 23, 22, 22, 22, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pComboButton[] = { + "phoenix::pComboButton\0\0onChange()\0" +}; + +const QMetaObject phoenix::pComboButton::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pComboButton, + qt_meta_data_phoenix__pComboButton, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pComboButton::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pComboButton::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pComboButton::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pComboButton)) + return static_cast(const_cast< pComboButton*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pComboButton*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pComboButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onChange(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pHexEdit[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 19, 18, 18, 18, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pHexEdit[] = { + "phoenix::pHexEdit\0\0onScroll()\0" +}; + +const QMetaObject phoenix::pHexEdit::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pHexEdit, + qt_meta_data_phoenix__pHexEdit, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pHexEdit::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pHexEdit::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pHexEdit::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pHexEdit)) + return static_cast(const_cast< pHexEdit*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pHexEdit*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pHexEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onScroll(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pHorizontalScroller[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 30, 29, 29, 29, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pHorizontalScroller[] = { + "phoenix::pHorizontalScroller\0\0onChange()\0" +}; + +const QMetaObject phoenix::pHorizontalScroller::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pHorizontalScroller, + qt_meta_data_phoenix__pHorizontalScroller, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pHorizontalScroller::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pHorizontalScroller::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pHorizontalScroller::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pHorizontalScroller)) + return static_cast(const_cast< pHorizontalScroller*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pHorizontalScroller*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pHorizontalScroller::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onChange(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pHorizontalSlider[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 28, 27, 27, 27, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pHorizontalSlider[] = { + "phoenix::pHorizontalSlider\0\0onChange()\0" +}; + +const QMetaObject phoenix::pHorizontalSlider::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pHorizontalSlider, + qt_meta_data_phoenix__pHorizontalSlider, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pHorizontalSlider::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pHorizontalSlider::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pHorizontalSlider::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pHorizontalSlider)) + return static_cast(const_cast< pHorizontalSlider*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pHorizontalSlider*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pHorizontalSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onChange(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pLineEdit[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 2, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 20, 19, 19, 19, 0x0a, + 33, 19, 19, 19, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pLineEdit[] = { + "phoenix::pLineEdit\0\0onActivate()\0" + "onChange()\0" +}; + +const QMetaObject phoenix::pLineEdit::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pLineEdit, + qt_meta_data_phoenix__pLineEdit, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pLineEdit::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pLineEdit::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pLineEdit::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pLineEdit)) + return static_cast(const_cast< pLineEdit*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pLineEdit*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + case 1: onChange(); break; + default: ; + } + _id -= 2; + } + return _id; +} +static const uint qt_meta_data_phoenix__pListView[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 3, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 20, 19, 19, 19, 0x0a, + 38, 33, 19, 19, 0x0a, + 65, 33, 19, 19, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pListView[] = { + "phoenix::pListView\0\0onActivate()\0item\0" + "onChange(QTreeWidgetItem*)\0" + "onToggle(QTreeWidgetItem*)\0" +}; + +const QMetaObject phoenix::pListView::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pListView, + qt_meta_data_phoenix__pListView, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pListView::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pListView::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pListView::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pListView)) + return static_cast(const_cast< pListView*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pListView*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + case 1: onChange((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; + case 2: onToggle((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; + default: ; + } + _id -= 3; + } + return _id; +} +static const uint qt_meta_data_phoenix__pRadioButton[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 23, 22, 22, 22, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pRadioButton[] = { + "phoenix::pRadioButton\0\0onActivate()\0" +}; + +const QMetaObject phoenix::pRadioButton::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pRadioButton, + qt_meta_data_phoenix__pRadioButton, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pRadioButton::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pRadioButton::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pRadioButton::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pRadioButton)) + return static_cast(const_cast< pRadioButton*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pRadioButton*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pRadioButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onActivate(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pTextEdit[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 20, 19, 19, 19, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pTextEdit[] = { + "phoenix::pTextEdit\0\0onChange()\0" +}; + +const QMetaObject phoenix::pTextEdit::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pTextEdit, + qt_meta_data_phoenix__pTextEdit, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pTextEdit::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pTextEdit::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pTextEdit::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pTextEdit)) + return static_cast(const_cast< pTextEdit*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pTextEdit*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onChange(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pVerticalScroller[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 28, 27, 27, 27, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pVerticalScroller[] = { + "phoenix::pVerticalScroller\0\0onChange()\0" +}; + +const QMetaObject phoenix::pVerticalScroller::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pVerticalScroller, + qt_meta_data_phoenix__pVerticalScroller, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pVerticalScroller::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pVerticalScroller::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pVerticalScroller::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pVerticalScroller)) + return static_cast(const_cast< pVerticalScroller*>(this)); + if (!strcmp(_clname, "pWidget")) + return static_cast< pWidget*>(const_cast< pVerticalScroller*>(this)); + return QObject::qt_metacast(_clname); +} + +int phoenix::pVerticalScroller::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + switch (_id) { + case 0: onChange(); break; + default: ; + } + _id -= 1; + } + return _id; +} +static const uint qt_meta_data_phoenix__pVerticalSlider[] = { + + // content: + 4, // revision + 0, // classname + 0, 0, // classinfo + 1, 14, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + // slots: signature, parameters, type, tag, flags + 26, 25, 25, 25, 0x0a, + + 0 // eod +}; + +static const char qt_meta_stringdata_phoenix__pVerticalSlider[] = { + "phoenix::pVerticalSlider\0\0onChange()\0" +}; + +const QMetaObject phoenix::pVerticalSlider::staticMetaObject = { + { &QObject::staticMetaObject, qt_meta_stringdata_phoenix__pVerticalSlider, + qt_meta_data_phoenix__pVerticalSlider, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &phoenix::pVerticalSlider::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *phoenix::pVerticalSlider::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *phoenix::pVerticalSlider::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_phoenix__pVerticalSlider)) return static_cast(const_cast< pVerticalSlider*>(this)); if (!strcmp(_clname, "pWidget")) return static_cast< pWidget*>(const_cast< pVerticalSlider*>(this)); return QObject::qt_metacast(_clname); } -int pVerticalSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +int phoenix::pVerticalSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) diff --git a/higan/phoenix/qt/platform.moc.hpp b/higan/phoenix/qt/platform.moc.hpp index 6a3909bf..ea7e4e61 100755 --- a/higan/phoenix/qt/platform.moc.hpp +++ b/higan/phoenix/qt/platform.moc.hpp @@ -1,3 +1,17 @@ +namespace phoenix { + +struct pApplication { + static XlibDisplay *display; + + static void run(); + static bool pendingEvents(); + static void processEvents(); + static void quit(); + + static void initialize(); + static void syncX(); +}; + static QApplication *qtApplication = nullptr; struct Settings : public configuration { @@ -21,10 +35,13 @@ struct pLayout; struct pWidget; struct pFont { - static Geometry geometry(const string &description, const string &text); + static string serif(unsigned size, string style); + static string sans(unsigned size, string style); + static string monospace(unsigned size, string style); + static Size size(const string &font, const string &text); static QFont create(const string &description); - static Geometry geometry(const QFont &qtFont, const string &text); + static Size size(const QFont &qtFont, const string &text); }; struct pDesktop { @@ -67,18 +84,6 @@ struct pObject { void destructor() {} }; -struct pOS : public pObject { - static XlibDisplay *display; - - static void main(); - static bool pendingEvents(); - static void processEvents(); - static void quit(); - - static void initialize(); - static void syncX(); -}; - struct pTimer : public QObject, public pObject { Q_OBJECT @@ -94,7 +99,7 @@ public: void destructor(); public slots: - void onTimeout(); + void onActivate(); }; struct pWindow : public QObject, public pObject { @@ -267,7 +272,7 @@ struct pWidget : public pSizable { QWidget *qtWidget; bool focused(); - virtual Geometry minimumGeometry(); + virtual Size minimumSize(); void setEnabled(bool enabled); void setFocused(); void setFont(const string &font); @@ -288,7 +293,7 @@ public: Button &button; QToolButton *qtButton; - Geometry minimumGeometry(); + Size minimumSize(); void setImage(const image &image, Orientation orientation); void setText(const string &text); @@ -328,19 +333,19 @@ public: public slots: }; -struct pCheckBox : public QObject, public pWidget { +struct pCheckButton : public QObject, public pWidget { Q_OBJECT public: - CheckBox &checkBox; - QCheckBox *qtCheckBox; + CheckButton &checkButton; + QCheckBox *qtCheckButton; bool checked(); - Geometry minimumGeometry(); + Size minimumSize(); void setChecked(bool checked); void setText(const string &text); - pCheckBox(CheckBox &checkBox) : pWidget(checkBox), checkBox(checkBox) {} + pCheckButton(CheckButton &checkButton) : pWidget(checkButton), checkButton(checkButton) {} void constructor(); void destructor(); void orphan(); @@ -349,22 +354,22 @@ public slots: void onToggle(); }; -struct pComboBox : public QObject, public pWidget { +struct pComboButton : public QObject, public pWidget { Q_OBJECT public: - ComboBox &comboBox; - QComboBox *qtComboBox; + ComboButton &comboButton; + QComboBox *qtComboButton; void append(const string &text); void modify(unsigned row, const string &text); void remove(unsigned row); - Geometry minimumGeometry(); + Size minimumSize(); void reset(); unsigned selection(); void setSelection(unsigned row); - pComboBox(ComboBox &comboBox) : pWidget(comboBox), comboBox(comboBox) {} + pComboButton(ComboButton &comboButton) : pWidget(comboButton), comboButton(comboButton) {} void constructor(); void destructor(); void orphan(); @@ -403,19 +408,19 @@ public slots: void onScroll(); }; -struct pHorizontalScrollBar : public QObject, public pWidget { +struct pHorizontalScroller : public QObject, public pWidget { Q_OBJECT public: - HorizontalScrollBar &horizontalScrollBar; - QScrollBar *qtScrollBar; + HorizontalScroller &horizontalScroller; + QScrollBar *qtScroller; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); - pHorizontalScrollBar(HorizontalScrollBar &horizontalScrollBar) : pWidget(horizontalScrollBar), horizontalScrollBar(horizontalScrollBar) {} + pHorizontalScroller(HorizontalScroller &horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {} void constructor(); void destructor(); void orphan(); @@ -431,7 +436,7 @@ public: HorizontalSlider &horizontalSlider; QSlider *qtSlider; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -449,7 +454,7 @@ struct pLabel : public pWidget { Label &label; QLabel *qtLabel; - Geometry minimumGeometry(); + Size minimumSize(); void setText(const string &text); pLabel(Label &label) : pWidget(label), label(label) {} @@ -465,7 +470,7 @@ public: LineEdit &lineEdit; QLineEdit *qtLineEdit; - Geometry minimumGeometry(); + Size minimumSize(); void setEditable(bool editable); void setText(const string &text); string text(); @@ -518,7 +523,7 @@ struct pProgressBar : public pWidget { ProgressBar &progressBar; QProgressBar *qtProgressBar; - Geometry minimumGeometry(); + Size minimumSize(); void setPosition(unsigned position); pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} @@ -527,21 +532,21 @@ struct pProgressBar : public pWidget { void orphan(); }; -struct pRadioBox : public QObject, public pWidget { +struct pRadioButton : public QObject, public pWidget { Q_OBJECT public: - RadioBox &radioBox; - QRadioButton *qtRadioBox; - QButtonGroup *qtGroup; + RadioButton &radioButton; + QRadioButton *qtRadioButton; bool checked(); - Geometry minimumGeometry(); + Size minimumSize(); void setChecked(); - void setGroup(const set &group); + void setGroup(const set &group); void setText(const string &text); - pRadioBox(RadioBox &radioBox) : pWidget(radioBox), radioBox(radioBox) {} + pRadioButton(RadioButton &radioButton) : pWidget(radioButton), radioButton(radioButton) {} + pRadioButton& parent(); void constructor(); void destructor(); void orphan(); @@ -572,19 +577,19 @@ public slots: void onChange(); }; -struct pVerticalScrollBar : public QObject, public pWidget { +struct pVerticalScroller : public QObject, public pWidget { Q_OBJECT public: - VerticalScrollBar &verticalScrollBar; - QScrollBar *qtScrollBar; + VerticalScroller &verticalScroller; + QScrollBar *qtScroller; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); - pVerticalScrollBar(VerticalScrollBar &verticalScrollBar) : pWidget(verticalScrollBar), verticalScrollBar(verticalScrollBar) {} + pVerticalScroller(VerticalScroller &verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {} void constructor(); void destructor(); void orphan(); @@ -600,7 +605,7 @@ public: VerticalSlider &verticalSlider; QSlider *qtSlider; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -632,3 +637,5 @@ struct pViewport : public pWidget { void destructor(); void orphan(); }; + +} diff --git a/higan/phoenix/qt/settings.cpp b/higan/phoenix/qt/settings.cpp index 90d3a76e..dcaf9faf 100755 --- a/higan/phoenix/qt/settings.cpp +++ b/higan/phoenix/qt/settings.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static Settings *settings = nullptr; void Settings::load() { @@ -22,3 +24,5 @@ Settings::Settings() { append(menuGeometryHeight = 20, "menuGeometryHeight"); append(statusGeometryHeight = 20, "statusGeometryHeight"); } + +} diff --git a/higan/phoenix/qt/timer.cpp b/higan/phoenix/qt/timer.cpp index 61f00ba8..db6bc52b 100755 --- a/higan/phoenix/qt/timer.cpp +++ b/higan/phoenix/qt/timer.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pTimer::setEnabled(bool enabled) { if(enabled) { qtTimer->start(); @@ -13,13 +15,15 @@ void pTimer::setInterval(unsigned milliseconds) { void pTimer::constructor() { qtTimer = new QTimer; qtTimer->setInterval(0); - connect(qtTimer, SIGNAL(timeout()), SLOT(onTimeout())); + connect(qtTimer, SIGNAL(timeout()), SLOT(onActivate())); } void pTimer::destructor() { delete qtTimer; } -void pTimer::onTimeout() { - if(timer.onTimeout) timer.onTimeout(); +void pTimer::onActivate() { + if(timer.onActivate) timer.onActivate(); +} + } diff --git a/higan/phoenix/qt/utility.cpp b/higan/phoenix/qt/utility.cpp index 400df0a2..2ac2701f 100755 --- a/higan/phoenix/qt/utility.cpp +++ b/higan/phoenix/qt/utility.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static QIcon CreateIcon(const nall::image &image, bool scale = false) { nall::image qtBuffer = image; qtBuffer.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0); @@ -188,3 +190,5 @@ static Keyboard::Keycode Keysym(int keysym) { } return Keyboard::Keycode::None; } + +} diff --git a/higan/phoenix/qt/widget/button.cpp b/higan/phoenix/qt/widget/button.cpp index 0e1522b3..ffe83fa9 100755 --- a/higan/phoenix/qt/widget/button.cpp +++ b/higan/phoenix/qt/widget/button.cpp @@ -1,17 +1,19 @@ -Geometry pButton::minimumGeometry() { - Geometry geometry = pFont::geometry(qtWidget->font(), button.state.text); +namespace phoenix { + +Size pButton::minimumSize() { + Size size = pFont::size(qtWidget->font(), button.state.text); if(button.state.orientation == Orientation::Horizontal) { - geometry.width += button.state.image.width; - geometry.height = max(button.state.image.height, geometry.height); + size.width += button.state.image.width; + size.height = max(button.state.image.height, size.height); } if(button.state.orientation == Orientation::Vertical) { - geometry.width = max(button.state.image.width, geometry.width); - geometry.height += button.state.image.height; + size.width = max(button.state.image.width, size.width); + size.height += button.state.image.height; } - return { 0, 0, geometry.width + 20, geometry.height + 12 }; + return {size.width + 20, size.height + 12}; } void pButton::setImage(const image &image, Orientation orientation) { @@ -50,3 +52,5 @@ void pButton::orphan() { void pButton::onActivate() { if(button.onActivate) button.onActivate(); } + +} diff --git a/higan/phoenix/qt/widget/canvas.cpp b/higan/phoenix/qt/widget/canvas.cpp index 245c1e9f..4029d237 100755 --- a/higan/phoenix/qt/widget/canvas.cpp +++ b/higan/phoenix/qt/widget/canvas.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pCanvas::setSize(const Size &size) { delete qtImage; qtImage = new QImage(size.width, size.height, QImage::Format_ARGB32); @@ -22,8 +24,8 @@ void pCanvas::constructor() { void pCanvas::destructor() { delete qtCanvas; delete qtImage; - qtWidget = qtCanvas = 0; - qtImage = 0; + qtWidget = qtCanvas = nullptr; + qtImage = nullptr; } void pCanvas::orphan() { @@ -36,11 +38,11 @@ void pCanvas::QtCanvas::leaveEvent(QEvent *event) { } void pCanvas::QtCanvas::mouseMoveEvent(QMouseEvent *event) { - if(self.canvas.onMouseMove) self.canvas.onMouseMove({ event->pos().x(), event->pos().y() }); + if(self.canvas.onMouseMove) self.canvas.onMouseMove({event->pos().x(), event->pos().y()}); } void pCanvas::QtCanvas::mousePressEvent(QMouseEvent *event) { - if(self.canvas.onMousePress == false) return; + if(!self.canvas.onMousePress) return; switch(event->button()) { case Qt::LeftButton: self.canvas.onMousePress(Mouse::Button::Left); break; case Qt::MidButton: self.canvas.onMousePress(Mouse::Button::Middle); break; @@ -49,7 +51,7 @@ void pCanvas::QtCanvas::mousePressEvent(QMouseEvent *event) { } void pCanvas::QtCanvas::mouseReleaseEvent(QMouseEvent *event) { - if(self.canvas.onMouseRelease == false) return; + if(!self.canvas.onMouseRelease) return; switch(event->button()) { case Qt::LeftButton: self.canvas.onMouseRelease(Mouse::Button::Left); break; case Qt::MidButton: self.canvas.onMouseRelease(Mouse::Button::Middle); break; @@ -71,3 +73,5 @@ void pCanvas::QtCanvas::paintEvent(QPaintEvent *event) { pCanvas::QtCanvas::QtCanvas(pCanvas &self) : self(self) { } + +} diff --git a/higan/phoenix/qt/widget/check-box.cpp b/higan/phoenix/qt/widget/check-box.cpp deleted file mode 100755 index c45bb326..00000000 --- a/higan/phoenix/qt/widget/check-box.cpp +++ /dev/null @@ -1,42 +0,0 @@ -bool pCheckBox::checked() { - return qtCheckBox->isChecked(); -} - -Geometry pCheckBox::minimumGeometry() { - Geometry geometry = pFont::geometry(qtWidget->font(), checkBox.state.text); - return { 0, 0, geometry.width + 26, geometry.height + 6 }; -} - -void pCheckBox::setChecked(bool checked) { - locked = true; - qtCheckBox->setChecked(checked); - locked = false; -} - -void pCheckBox::setText(const string &text) { - qtCheckBox->setText(QString::fromUtf8(text)); -} - -void pCheckBox::constructor() { - qtWidget = qtCheckBox = new QCheckBox; - connect(qtCheckBox, SIGNAL(stateChanged(int)), SLOT(onToggle())); - - pWidget::synchronizeState(); - setChecked(checkBox.state.checked); - setText(checkBox.state.text); -} - -void pCheckBox::destructor() { - delete qtCheckBox; - qtWidget = qtCheckBox = 0; -} - -void pCheckBox::orphan() { - destructor(); - constructor(); -} - -void pCheckBox::onToggle() { - checkBox.state.checked = checked(); - if(locked == false && checkBox.onToggle) checkBox.onToggle(); -} diff --git a/higan/phoenix/qt/widget/check-button.cpp b/higan/phoenix/qt/widget/check-button.cpp new file mode 100644 index 00000000..bcf850bf --- /dev/null +++ b/higan/phoenix/qt/widget/check-button.cpp @@ -0,0 +1,46 @@ +namespace phoenix { + +bool pCheckButton::checked() { + return qtCheckButton->isChecked(); +} + +Size pCheckButton::minimumSize() { + Size size = pFont::size(qtWidget->font(), checkButton.state.text); + return {size.width + 26, size.height + 6}; +} + +void pCheckButton::setChecked(bool checked) { + locked = true; + qtCheckButton->setChecked(checked); + locked = false; +} + +void pCheckButton::setText(const string &text) { + qtCheckButton->setText(QString::fromUtf8(text)); +} + +void pCheckButton::constructor() { + qtWidget = qtCheckButton = new QCheckBox; + connect(qtCheckButton, SIGNAL(stateChanged(int)), SLOT(onToggle())); + + pWidget::synchronizeState(); + setChecked(checkButton.state.checked); + setText(checkButton.state.text); +} + +void pCheckButton::destructor() { + delete qtCheckButton; + qtWidget = qtCheckButton = nullptr; +} + +void pCheckButton::orphan() { + destructor(); + constructor(); +} + +void pCheckButton::onToggle() { + checkButton.state.checked = checked(); + if(locked == false && checkButton.onToggle) checkButton.onToggle(); +} + +} diff --git a/higan/phoenix/qt/widget/combo-box.cpp b/higan/phoenix/qt/widget/combo-box.cpp deleted file mode 100755 index 1dfa609d..00000000 --- a/higan/phoenix/qt/widget/combo-box.cpp +++ /dev/null @@ -1,68 +0,0 @@ -void pComboBox::append(const string &text) { - locked = true; - qtComboBox->addItem(QString::fromUtf8(text)); - locked = false; -} - -Geometry pComboBox::minimumGeometry() { - unsigned maximumWidth = 0; - for(auto &text : comboBox.state.text) maximumWidth = max(maximumWidth, pFont::geometry(qtWidget->font(), text).width); - Geometry geometry = pFont::geometry(qtWidget->font(), " "); - return { 0, 0, maximumWidth + 32, geometry.height + 12 }; -} - -void pComboBox::modify(unsigned row, const string &text) { - qtComboBox->setItemText(row, text); -} - -void pComboBox::remove(unsigned row) { - locked = true; - unsigned position = selection(); - qtComboBox->removeItem(row); - if(position == row) qtComboBox->setCurrentIndex(0); - locked = false; -} - -void pComboBox::reset() { - locked = true; - while(qtComboBox->count()) qtComboBox->removeItem(0); - locked = false; -} - -unsigned pComboBox::selection() { - signed index = qtComboBox->currentIndex(); - return index >= 0 ? index : 0; -} - -void pComboBox::setSelection(unsigned row) { - locked = true; - qtComboBox->setCurrentIndex(row); - locked = false; -} - -void pComboBox::constructor() { - qtWidget = qtComboBox = new QComboBox; - connect(qtComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onChange())); - - pWidget::synchronizeState(); - unsigned selection = comboBox.state.selection; - locked = true; - for(auto &text : comboBox.state.text) append(text); - locked = false; - setSelection(selection); -} - -void pComboBox::destructor() { - delete qtComboBox; - qtWidget = qtComboBox = 0; -} - -void pComboBox::orphan() { - destructor(); - constructor(); -} - -void pComboBox::onChange() { - comboBox.state.selection = selection(); - if(locked == false && comboBox.onChange) comboBox.onChange(); -} diff --git a/higan/phoenix/qt/widget/combo-button.cpp b/higan/phoenix/qt/widget/combo-button.cpp new file mode 100644 index 00000000..ae90bfc1 --- /dev/null +++ b/higan/phoenix/qt/widget/combo-button.cpp @@ -0,0 +1,72 @@ +namespace phoenix { + +void pComboButton::append(const string &text) { + locked = true; + qtComboButton->addItem(QString::fromUtf8(text)); + locked = false; +} + +Size pComboButton::minimumSize() { + unsigned maximumWidth = 0; + for(auto &text : comboButton.state.text) maximumWidth = max(maximumWidth, pFont::size(qtWidget->font(), text).width); + Size size = pFont::size(qtWidget->font(), " "); + return {maximumWidth + 32, size.height + 12}; +} + +void pComboButton::modify(unsigned row, const string &text) { + qtComboButton->setItemText(row, text); +} + +void pComboButton::remove(unsigned row) { + locked = true; + unsigned position = selection(); + qtComboButton->removeItem(row); + if(position == row) qtComboButton->setCurrentIndex(0); + locked = false; +} + +void pComboButton::reset() { + locked = true; + while(qtComboButton->count()) qtComboButton->removeItem(0); + locked = false; +} + +unsigned pComboButton::selection() { + signed index = qtComboButton->currentIndex(); + return index >= 0 ? index : 0; +} + +void pComboButton::setSelection(unsigned row) { + locked = true; + qtComboButton->setCurrentIndex(row); + locked = false; +} + +void pComboButton::constructor() { + qtWidget = qtComboButton = new QComboBox; + connect(qtComboButton, SIGNAL(currentIndexChanged(int)), SLOT(onChange())); + + pWidget::synchronizeState(); + unsigned selection = comboButton.state.selection; + locked = true; + for(auto &text : comboButton.state.text) append(text); + locked = false; + setSelection(selection); +} + +void pComboButton::destructor() { + delete qtComboButton; + qtWidget = qtComboButton = nullptr; +} + +void pComboButton::orphan() { + destructor(); + constructor(); +} + +void pComboButton::onChange() { + comboButton.state.selection = selection(); + if(locked == false && comboButton.onChange) comboButton.onChange(); +} + +} diff --git a/higan/phoenix/qt/widget/hex-edit.cpp b/higan/phoenix/qt/widget/hex-edit.cpp index fdeebe4a..922da71a 100755 --- a/higan/phoenix/qt/widget/hex-edit.cpp +++ b/higan/phoenix/qt/widget/hex-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pHexEdit::setColumns(unsigned columns) { update(); } @@ -189,3 +191,5 @@ void pHexEdit::QtHexEdit::keyPressEvent(QKeyEvent *event) { void pHexEdit::QtHexEdit::keyPressEventAcknowledge(QKeyEvent *event) { QTextEdit::keyPressEvent(event); } + +} diff --git a/higan/phoenix/qt/widget/horizontal-scroll-bar.cpp b/higan/phoenix/qt/widget/horizontal-scroll-bar.cpp deleted file mode 100755 index 6127c301..00000000 --- a/higan/phoenix/qt/widget/horizontal-scroll-bar.cpp +++ /dev/null @@ -1,43 +0,0 @@ -Geometry pHorizontalScrollBar::minimumGeometry() { - return { 0, 0, 0, 15 }; -} - -unsigned pHorizontalScrollBar::position() { - return qtScrollBar->value(); -} - -void pHorizontalScrollBar::setLength(unsigned length) { - length += length == 0; - qtScrollBar->setRange(0, length - 1); - qtScrollBar->setPageStep(length >> 3); -} - -void pHorizontalScrollBar::setPosition(unsigned position) { - qtScrollBar->setValue(position); -} - -void pHorizontalScrollBar::constructor() { - qtWidget = qtScrollBar = new QScrollBar(Qt::Horizontal); - qtScrollBar->setRange(0, 100); - qtScrollBar->setPageStep(101 >> 3); - connect(qtScrollBar, SIGNAL(valueChanged(int)), SLOT(onChange())); - - pWidget::synchronizeState(); - setLength(horizontalScrollBar.state.length); - setPosition(horizontalScrollBar.state.position); -} - -void pHorizontalScrollBar::destructor() { - delete qtScrollBar; - qtWidget = qtScrollBar = 0; -} - -void pHorizontalScrollBar::orphan() { - destructor(); - constructor(); -} - -void pHorizontalScrollBar::onChange() { - horizontalScrollBar.state.position = position(); - if(horizontalScrollBar.onChange) horizontalScrollBar.onChange(); -} diff --git a/higan/phoenix/qt/widget/horizontal-scroller.cpp b/higan/phoenix/qt/widget/horizontal-scroller.cpp new file mode 100644 index 00000000..b60182ac --- /dev/null +++ b/higan/phoenix/qt/widget/horizontal-scroller.cpp @@ -0,0 +1,47 @@ +namespace phoenix { + +Size pHorizontalScroller::minimumSize() { + return {0, 15}; +} + +unsigned pHorizontalScroller::position() { + return qtScroller->value(); +} + +void pHorizontalScroller::setLength(unsigned length) { + length += length == 0; + qtScroller->setRange(0, length - 1); + qtScroller->setPageStep(length >> 3); +} + +void pHorizontalScroller::setPosition(unsigned position) { + qtScroller->setValue(position); +} + +void pHorizontalScroller::constructor() { + qtWidget = qtScroller = new QScrollBar(Qt::Horizontal); + qtScroller->setRange(0, 100); + qtScroller->setPageStep(101 >> 3); + connect(qtScroller, SIGNAL(valueChanged(int)), SLOT(onChange())); + + pWidget::synchronizeState(); + setLength(horizontalScroller.state.length); + setPosition(horizontalScroller.state.position); +} + +void pHorizontalScroller::destructor() { + delete qtScroller; + qtWidget = qtScroller = nullptr; +} + +void pHorizontalScroller::orphan() { + destructor(); + constructor(); +} + +void pHorizontalScroller::onChange() { + horizontalScroller.state.position = position(); + if(horizontalScroller.onChange) horizontalScroller.onChange(); +} + +} diff --git a/higan/phoenix/qt/widget/horizontal-slider.cpp b/higan/phoenix/qt/widget/horizontal-slider.cpp index 5401aae1..074a14b9 100755 --- a/higan/phoenix/qt/widget/horizontal-slider.cpp +++ b/higan/phoenix/qt/widget/horizontal-slider.cpp @@ -1,5 +1,7 @@ -Geometry pHorizontalSlider::minimumGeometry() { - return { 0, 0, 0, 20 }; +namespace phoenix { + +Size pHorizontalSlider::minimumSize() { + return {0, 20}; } unsigned pHorizontalSlider::position() { @@ -41,3 +43,5 @@ void pHorizontalSlider::onChange() { horizontalSlider.state.position = position(); if(horizontalSlider.onChange) horizontalSlider.onChange(); } + +} diff --git a/higan/phoenix/qt/widget/label.cpp b/higan/phoenix/qt/widget/label.cpp index 8dd86eb6..95a1230b 100755 --- a/higan/phoenix/qt/widget/label.cpp +++ b/higan/phoenix/qt/widget/label.cpp @@ -1,6 +1,8 @@ -Geometry pLabel::minimumGeometry() { - Geometry geometry = pFont::geometry(qtWidget->font(), label.state.text); - return { 0, 0, geometry.width, geometry.height }; +namespace phoenix { + +Size pLabel::minimumSize() { + Size size = pFont::size(qtWidget->font(), label.state.text); + return {size.width, size.height}; } void pLabel::setText(const string &text) { @@ -23,3 +25,5 @@ void pLabel::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/qt/widget/line-edit.cpp b/higan/phoenix/qt/widget/line-edit.cpp index a13f3b81..20f294f5 100755 --- a/higan/phoenix/qt/widget/line-edit.cpp +++ b/higan/phoenix/qt/widget/line-edit.cpp @@ -1,6 +1,8 @@ -Geometry pLineEdit::minimumGeometry() { - Geometry geometry = pFont::geometry(qtWidget->font(), lineEdit.state.text); - return { 0, 0, geometry.width + 12, geometry.height + 12 }; +namespace phoenix { + +Size pLineEdit::minimumSize() { + Size size = pFont::size(qtWidget->font(), lineEdit.state.text); + return {size.width + 12, size.height + 12}; } void pLineEdit::setEditable(bool editable) { @@ -43,3 +45,5 @@ void pLineEdit::onChange() { lineEdit.state.text = text(); if(lineEdit.onChange) lineEdit.onChange(); } + +} diff --git a/higan/phoenix/qt/widget/list-view.cpp b/higan/phoenix/qt/widget/list-view.cpp index a81c092d..0a81cc62 100755 --- a/higan/phoenix/qt/widget/list-view.cpp +++ b/higan/phoenix/qt/widget/list-view.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pListView::append(const lstring &text) { locked = true; auto items = qtListView->findItems("", Qt::MatchContains); @@ -162,3 +164,5 @@ void pListView::onToggle(QTreeWidgetItem *item) { listView.state.checked[row] = checkState; if(locked == false && listView.onToggle) listView.onToggle(row); } + +} diff --git a/higan/phoenix/qt/widget/progress-bar.cpp b/higan/phoenix/qt/widget/progress-bar.cpp index 8178bb66..e72dbb96 100755 --- a/higan/phoenix/qt/widget/progress-bar.cpp +++ b/higan/phoenix/qt/widget/progress-bar.cpp @@ -1,5 +1,7 @@ -Geometry pProgressBar::minimumGeometry() { - return { 0, 0, 0, 25 }; +namespace phoenix { + +Size pProgressBar::minimumSize() { + return {0, 25}; } void pProgressBar::setPosition(unsigned position) { @@ -24,3 +26,5 @@ void pProgressBar::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/qt/widget/radio-box.cpp b/higan/phoenix/qt/widget/radio-box.cpp deleted file mode 100755 index bf640fd2..00000000 --- a/higan/phoenix/qt/widget/radio-box.cpp +++ /dev/null @@ -1,64 +0,0 @@ -bool pRadioBox::checked() { - return qtRadioBox->isChecked(); -} - -Geometry pRadioBox::minimumGeometry() { - Geometry geometry = pFont::geometry(qtWidget->font(), radioBox.state.text); - return { 0, 0, geometry.width + 26, geometry.height + 6 }; -} - -void pRadioBox::setChecked() { - locked = true; - for(auto &item : radioBox.state.group) { - bool checkState = item.p.qtRadioBox == qtRadioBox; - item.state.checked = checkState; - item.p.qtRadioBox->setChecked(checkState); - } - locked = false; -} - -void pRadioBox::setGroup(const set &group) { - locked = true; - if(qtGroup) { - delete qtGroup; - qtGroup = 0; - } - if(group.size() > 0 && qtRadioBox == group[0].p.qtRadioBox) { - qtGroup = new QButtonGroup; - for(auto &item : group) qtGroup->addButton(item.p.qtRadioBox); - setChecked(); - } - locked = false; -} - -void pRadioBox::setText(const string &text) { - qtRadioBox->setText(QString::fromUtf8(text)); -} - -void pRadioBox::constructor() { - qtWidget = qtRadioBox = new QRadioButton; - qtGroup = new QButtonGroup; - qtGroup->addButton(qtRadioBox); - qtRadioBox->setChecked(true); - connect(qtRadioBox, SIGNAL(toggled(bool)), SLOT(onActivate())); - - pWidget::synchronizeState(); - setGroup(radioBox.state.group); - setText(radioBox.state.text); -} - -void pRadioBox::destructor() { - delete qtGroup; - delete qtRadioBox; - qtWidget = qtRadioBox = 0; - qtGroup = 0; -} - -void pRadioBox::orphan() { - destructor(); - constructor(); -} - -void pRadioBox::onActivate() { - if(locked == false && checked() && radioBox.onActivate) radioBox.onActivate(); -} diff --git a/higan/phoenix/qt/widget/radio-button.cpp b/higan/phoenix/qt/widget/radio-button.cpp new file mode 100644 index 00000000..3f8a58e2 --- /dev/null +++ b/higan/phoenix/qt/widget/radio-button.cpp @@ -0,0 +1,68 @@ +namespace phoenix { + +bool pRadioButton::checked() { + return qtRadioButton->isChecked(); +} + +Size pRadioButton::minimumSize() { + Size size = pFont::size(qtWidget->font(), radioButton.state.text); + return {size.width + 26, size.height + 6}; +} + +void pRadioButton::setChecked() { + parent().locked = true; + for(auto &item : radioButton.state.group) { + item.p.qtRadioButton->setChecked(item.state.checked = false); + } + qtRadioButton->setChecked(radioButton.state.checked = true); + parent().locked = false; +} + +void pRadioButton::setGroup(const set &group) { + parent().locked = true; + for(auto &item : radioButton.state.group) { + item.p.qtRadioButton->setChecked(item.state.checked); + } + parent().locked = false; +} + +void pRadioButton::setText(const string &text) { + qtRadioButton->setText(QString::fromUtf8(text)); +} + +pRadioButton& pRadioButton::parent() { + if(radioButton.state.group.size()) return radioButton.state.group[0].p; + return *this; +} + +void pRadioButton::constructor() { + qtWidget = qtRadioButton = new QRadioButton; + qtRadioButton->setAutoExclusive(false); + connect(qtRadioButton, SIGNAL(toggled(bool)), SLOT(onActivate())); + + pWidget::synchronizeState(); + setGroup(radioButton.state.group); + setText(radioButton.state.text); +} + +void pRadioButton::destructor() { + if(qtRadioButton) delete qtRadioButton; + qtWidget = qtRadioButton = nullptr; +} + +void pRadioButton::orphan() { + destructor(); + constructor(); +} + +void pRadioButton::onActivate() { + if(parent().locked == false) { + bool wasChecked = radioButton.state.checked; + setChecked(); + if(wasChecked == false) { + if(radioButton.onActivate) radioButton.onActivate(); + } + } +} + +} diff --git a/higan/phoenix/qt/widget/text-edit.cpp b/higan/phoenix/qt/widget/text-edit.cpp index 8cdbe573..4ef881bf 100755 --- a/higan/phoenix/qt/widget/text-edit.cpp +++ b/higan/phoenix/qt/widget/text-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pTextEdit::setCursorPosition(unsigned position) { QTextCursor cursor = qtTextEdit->textCursor(); unsigned lastCharacter = strlen(qtTextEdit->toPlainText().toUtf8().constData()); @@ -48,3 +50,5 @@ void pTextEdit::onChange() { textEdit.state.text = text(); if(textEdit.onChange) textEdit.onChange(); } + +} diff --git a/higan/phoenix/qt/widget/vertical-scroll-bar.cpp b/higan/phoenix/qt/widget/vertical-scroll-bar.cpp deleted file mode 100755 index 74d68ca6..00000000 --- a/higan/phoenix/qt/widget/vertical-scroll-bar.cpp +++ /dev/null @@ -1,43 +0,0 @@ -Geometry pVerticalScrollBar::minimumGeometry() { - return { 0, 0, 15, 0 }; -} - -unsigned pVerticalScrollBar::position() { - return qtScrollBar->value(); -} - -void pVerticalScrollBar::setLength(unsigned length) { - length += length == 0; - qtScrollBar->setRange(0, length - 1); - qtScrollBar->setPageStep(length >> 3); -} - -void pVerticalScrollBar::setPosition(unsigned position) { - qtScrollBar->setValue(position); -} - -void pVerticalScrollBar::constructor() { - qtWidget = qtScrollBar = new QScrollBar(Qt::Vertical); - qtScrollBar->setRange(0, 100); - qtScrollBar->setPageStep(101 >> 3); - connect(qtScrollBar, SIGNAL(valueChanged(int)), SLOT(onChange())); - - pWidget::synchronizeState(); - setLength(verticalScrollBar.state.length); - setPosition(verticalScrollBar.state.position); -} - -void pVerticalScrollBar::destructor() { - delete qtScrollBar; - qtWidget = qtScrollBar = 0; -} - -void pVerticalScrollBar::orphan() { - destructor(); - constructor(); -} - -void pVerticalScrollBar::onChange() { - verticalScrollBar.state.position = position(); - if(verticalScrollBar.onChange) verticalScrollBar.onChange(); -} diff --git a/higan/phoenix/qt/widget/vertical-scroller.cpp b/higan/phoenix/qt/widget/vertical-scroller.cpp new file mode 100644 index 00000000..3e11a8f7 --- /dev/null +++ b/higan/phoenix/qt/widget/vertical-scroller.cpp @@ -0,0 +1,47 @@ +namespace phoenix { + +Size pVerticalScroller::minimumSize() { + return {15, 0}; +} + +unsigned pVerticalScroller::position() { + return qtScroller->value(); +} + +void pVerticalScroller::setLength(unsigned length) { + length += length == 0; + qtScroller->setRange(0, length - 1); + qtScroller->setPageStep(length >> 3); +} + +void pVerticalScroller::setPosition(unsigned position) { + qtScroller->setValue(position); +} + +void pVerticalScroller::constructor() { + qtWidget = qtScroller = new QScrollBar(Qt::Vertical); + qtScroller->setRange(0, 100); + qtScroller->setPageStep(101 >> 3); + connect(qtScroller, SIGNAL(valueChanged(int)), SLOT(onChange())); + + pWidget::synchronizeState(); + setLength(verticalScroller.state.length); + setPosition(verticalScroller.state.position); +} + +void pVerticalScroller::destructor() { + delete qtScroller; + qtWidget = qtScroller = nullptr; +} + +void pVerticalScroller::orphan() { + destructor(); + constructor(); +} + +void pVerticalScroller::onChange() { + verticalScroller.state.position = position(); + if(verticalScroller.onChange) verticalScroller.onChange(); +} + +} diff --git a/higan/phoenix/qt/widget/vertical-slider.cpp b/higan/phoenix/qt/widget/vertical-slider.cpp index 500adb07..005f0a5b 100755 --- a/higan/phoenix/qt/widget/vertical-slider.cpp +++ b/higan/phoenix/qt/widget/vertical-slider.cpp @@ -1,5 +1,7 @@ -Geometry pVerticalSlider::minimumGeometry() { - return { 0, 0, 20, 0 }; +namespace phoenix { + +Size pVerticalSlider::minimumSize() { + return {20, 0}; } unsigned pVerticalSlider::position() { @@ -41,3 +43,5 @@ void pVerticalSlider::onChange() { verticalSlider.state.position = position(); if(verticalSlider.onChange) verticalSlider.onChange(); } + +} diff --git a/higan/phoenix/qt/widget/viewport.cpp b/higan/phoenix/qt/widget/viewport.cpp index 1b67d776..385372bf 100755 --- a/higan/phoenix/qt/widget/viewport.cpp +++ b/higan/phoenix/qt/widget/viewport.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + uintptr_t pViewport::handle() { return (uintptr_t)qtViewport->winId(); } @@ -30,7 +32,7 @@ void pViewport::QtViewport::mouseMoveEvent(QMouseEvent *event) { } void pViewport::QtViewport::mousePressEvent(QMouseEvent *event) { - if(self.viewport.onMousePress == false) return; + if(!self.viewport.onMousePress) return; switch(event->button()) { case Qt::LeftButton: self.viewport.onMousePress(Mouse::Button::Left); break; case Qt::MidButton: self.viewport.onMousePress(Mouse::Button::Middle); break; @@ -39,7 +41,7 @@ void pViewport::QtViewport::mousePressEvent(QMouseEvent *event) { } void pViewport::QtViewport::mouseReleaseEvent(QMouseEvent *event) { - if(self.viewport.onMouseRelease == false) return; + if(!self.viewport.onMouseRelease) return; switch(event->button()) { case Qt::LeftButton: self.viewport.onMouseRelease(Mouse::Button::Left); break; case Qt::MidButton: self.viewport.onMouseRelease(Mouse::Button::Middle); break; @@ -49,3 +51,5 @@ void pViewport::QtViewport::mouseReleaseEvent(QMouseEvent *event) { pViewport::QtViewport::QtViewport(pViewport &self) : self(self) { } + +} diff --git a/higan/phoenix/qt/widget/widget.cpp b/higan/phoenix/qt/widget/widget.cpp index 27d23354..ae86a7e9 100755 --- a/higan/phoenix/qt/widget/widget.cpp +++ b/higan/phoenix/qt/widget/widget.cpp @@ -1,9 +1,11 @@ +namespace phoenix { + bool pWidget::focused() { return qtWidget->hasFocus(); } -Geometry pWidget::minimumGeometry() { - return {0, 0, 0, 0}; +Size pWidget::minimumSize() { + return {0, 0}; } void pWidget::setEnabled(bool enabled) { @@ -54,3 +56,5 @@ void pWidget::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/qt/window.cpp b/higan/phoenix/qt/window.cpp index dac311ee..cbc57cd6 100755 --- a/higan/phoenix/qt/window.cpp +++ b/higan/phoenix/qt/window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + Window& pWindow::none() { static Window *window = nullptr; if(window == nullptr) window = new Window; @@ -17,10 +19,10 @@ void pWindow::append(Menu &menu) { } void pWindow::append(Widget &widget) { - if(widget.state.font == "") { - if(window.state.widgetFont != "") widget.p.setFont(window.state.widgetFont); - else widget.p.setFont("Sans, 8"); + if(widget.font().empty() && !window.state.widgetFont.empty()) { + widget.setFont(window.state.widgetFont); } + if(widget.font().empty()) widget.p.setFont("Sans, 8"); widget.p.qtWidget->setParent(qtContainer); widget.setVisible(widget.visible()); } @@ -28,7 +30,7 @@ void pWindow::append(Widget &widget) { Color pWindow::backgroundColor() { if(window.state.backgroundColorOverride) return window.state.backgroundColor; QColor color = qtWindow->palette().color(QPalette::ColorRole::Window); - return { (uint8_t)color.red(), (uint8_t)color.green(), (uint8_t)color.blue(), (uint8_t)color.alpha() }; + return {(uint8_t)color.red(), (uint8_t)color.green(), (uint8_t)color.blue(), (uint8_t)color.alpha()}; } Geometry pWindow::frameMargin() { @@ -66,7 +68,7 @@ void pWindow::remove(Menu &menu) { } void pWindow::remove(Widget &widget) { - //bugfix: orphan() destroys and recreates widgets (to disassociate them from their parent); + //orphan() destroys and recreates widgets (to disassociate them from their parent); //attempting to create widget again after QApplication::quit() crashes libQtGui if(qtApplication) widget.p.orphan(); } @@ -98,7 +100,7 @@ void pWindow::setFullScreen(bool fullScreen) { void pWindow::setGeometry(const Geometry &geometry_) { locked = true; - OS::processEvents(); + Application::processEvents(); QApplication::syncX(); Geometry geometry = geometry_, margin = frameMargin(); @@ -106,8 +108,11 @@ void pWindow::setGeometry(const Geometry &geometry_) { qtWindow->move(geometry.x - frameMargin().x, geometry.y - frameMargin().y); //qtWindow->adjustSize() fails if larger than 2/3rds screen size qtWindow->resize(qtWindow->sizeHint()); - qtWindow->setMinimumSize(1, 1); - qtContainer->setMinimumSize(1, 1); + if(window.state.resizable) { + //required to allow shrinking window from default size + qtWindow->setMinimumSize(1, 1); + qtContainer->setMinimumSize(1, 1); + } for(auto &layout : window.state.layout) { geometry = geometry_; @@ -128,7 +133,17 @@ void pWindow::setMenuVisible(bool visible) { } void pWindow::setModal(bool modal) { - qtWindow->setWindowModality(modal ? Qt::ApplicationModal : Qt::NonModal); + if(modal == true) { + //windowModality can only be enabled while window is invisible + setVisible(false); + qtWindow->setWindowModality(Qt::ApplicationModal); + setVisible(true); + while(window.state.modal) { + Application::processEvents(); + usleep(20 * 1000); + } + qtWindow->setWindowModality(Qt::NonModal); + } } void pWindow::setResizable(bool resizable) { @@ -170,9 +185,6 @@ void pWindow::setVisible(bool visible) { } void pWindow::setWidgetFont(const string &font) { - for(auto &item : window.state.widget) { - if(!item.state.font) item.setFont(font); - } } void pWindow::constructor() { @@ -180,11 +192,11 @@ void pWindow::constructor() { qtWindow->setWindowTitle(" "); //if program was given a name, try and set the window taskbar icon to a matching pixmap image - if(osState.name.empty() == false) { - if(file::exists({"/usr/share/pixmaps/", osState.name, ".png"})) { - qtWindow->setWindowIcon(QIcon(string{"/usr/share/pixmaps/", osState.name, ".png"})); - } else if(file::exists({"/usr/local/share/pixmaps/", osState.name, ".png"})) { - qtWindow->setWindowIcon(QIcon(string{"/usr/local/share/pixmaps/", osState.name, ".png"})); + if(applicationState.name.empty() == false) { + if(file::exists({"/usr/share/pixmaps/", applicationState.name, ".png"})) { + qtWindow->setWindowIcon(QIcon(string{"/usr/share/pixmaps/", applicationState.name, ".png"})); + } else if(file::exists({"/usr/local/share/pixmaps/", applicationState.name, ".png"})) { + qtWindow->setWindowIcon(QIcon(string{"/usr/local/share/pixmaps/", applicationState.name, ".png"})); } } @@ -221,7 +233,7 @@ void pWindow::destructor() { } void pWindow::updateFrameGeometry() { - pOS::syncX(); + pApplication::syncX(); QRect border = qtWindow->frameGeometry(); QRect client = qtWindow->geometry(); @@ -231,12 +243,12 @@ void pWindow::updateFrameGeometry() { settings->frameGeometryHeight = border.height() - client.height(); if(window.state.menuVisible) { - pOS::syncX(); + pApplication::syncX(); settings->menuGeometryHeight = qtMenu->height(); } if(window.state.statusVisible) { - pOS::syncX(); + pApplication::syncX(); settings->statusGeometryHeight = qtStatus->height(); } @@ -244,10 +256,10 @@ void pWindow::updateFrameGeometry() { } void pWindow::QtWindow::closeEvent(QCloseEvent *event) { - self.window.state.ignore = false; event->ignore(); if(self.window.onClose) self.window.onClose(); - if(self.window.state.ignore == false) hide(); + else self.window.setVisible(false); + if(self.window.state.modal && !self.window.visible()) self.window.setModal(false); } void pWindow::QtWindow::moveEvent(QMoveEvent *event) { @@ -295,3 +307,5 @@ QSize pWindow::QtWindow::sizeHint() const { if(self.window.state.statusVisible) height += settings->statusGeometryHeight; return QSize(width, height); } + +} diff --git a/higan/phoenix/reference/action/action.cpp b/higan/phoenix/reference/action/action.cpp index 0bc6bc3f..87320a55 100755 --- a/higan/phoenix/reference/action/action.cpp +++ b/higan/phoenix/reference/action/action.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pAction::setEnabled(bool enabled) { } @@ -6,3 +8,5 @@ void pAction::setVisible(bool visible) { void pAction::constructor() { } + +} diff --git a/higan/phoenix/reference/action/action.hpp b/higan/phoenix/reference/action/action.hpp new file mode 100644 index 00000000..936afae0 --- /dev/null +++ b/higan/phoenix/reference/action/action.hpp @@ -0,0 +1,13 @@ +namespace phoenix { + +struct pAction : public pObject { + Action &action; + + void setEnabled(bool enabled); + void setVisible(bool visible); + + pAction(Action &action) : pObject(action), action(action) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/action/check-item.cpp b/higan/phoenix/reference/action/check-item.cpp index 26970fc8..74f3ac27 100755 --- a/higan/phoenix/reference/action/check-item.cpp +++ b/higan/phoenix/reference/action/check-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pCheckItem::checked() { return false; } @@ -13,3 +15,5 @@ void pCheckItem::constructor() { void pCheckItem::destructor() { } + +} diff --git a/higan/phoenix/reference/action/check-item.hpp b/higan/phoenix/reference/action/check-item.hpp new file mode 100644 index 00000000..e7c3828c --- /dev/null +++ b/higan/phoenix/reference/action/check-item.hpp @@ -0,0 +1,15 @@ +namespace phoenix { + +struct pCheckItem : public pAction { + CheckItem &checkItem; + + bool checked(); + void setChecked(bool checked); + void setText(const string &text); + + pCheckItem(CheckItem &checkItem) : pAction(checkItem), checkItem(checkItem) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/reference/action/item.cpp b/higan/phoenix/reference/action/item.cpp index 438ed32f..e151b27c 100755 --- a/higan/phoenix/reference/action/item.cpp +++ b/higan/phoenix/reference/action/item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pItem::setImage(const image &image) { } @@ -9,3 +11,5 @@ void pItem::constructor() { void pItem::destructor() { } + +} diff --git a/higan/phoenix/reference/action/item.hpp b/higan/phoenix/reference/action/item.hpp new file mode 100644 index 00000000..35bf5324 --- /dev/null +++ b/higan/phoenix/reference/action/item.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pItem : public pAction { + Item &item; + + void setImage(const image &image); + void setText(const string &text); + + pItem(Item &item) : pAction(item), item(item) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/reference/action/menu.cpp b/higan/phoenix/reference/action/menu.cpp index 4f0a65a8..32f7be8c 100755 --- a/higan/phoenix/reference/action/menu.cpp +++ b/higan/phoenix/reference/action/menu.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pMenu::append(Action &action) { } @@ -15,3 +17,5 @@ void pMenu::constructor() { void pMenu::destructor() { } + +} diff --git a/higan/phoenix/reference/action/menu.hpp b/higan/phoenix/reference/action/menu.hpp new file mode 100644 index 00000000..b07114aa --- /dev/null +++ b/higan/phoenix/reference/action/menu.hpp @@ -0,0 +1,16 @@ +namespace phoenix { + +struct pMenu : public pAction { + Menu &menu; + + void append(Action &action); + void remove(Action &action); + void setImage(const image &image); + void setText(const string &text); + + pMenu(Menu &menu) : pAction(menu), menu(menu) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/reference/action/radio-item.cpp b/higan/phoenix/reference/action/radio-item.cpp index e87a4deb..2bc64520 100755 --- a/higan/phoenix/reference/action/radio-item.cpp +++ b/higan/phoenix/reference/action/radio-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pRadioItem::checked() { return false; } @@ -16,3 +18,5 @@ void pRadioItem::constructor() { void pRadioItem::destructor() { } + +} diff --git a/higan/phoenix/reference/action/radio-item.hpp b/higan/phoenix/reference/action/radio-item.hpp new file mode 100644 index 00000000..a8e245f8 --- /dev/null +++ b/higan/phoenix/reference/action/radio-item.hpp @@ -0,0 +1,16 @@ +namespace phoenix { + +struct pRadioItem : public pAction { + RadioItem &radioItem; + + bool checked(); + void setChecked(); + void setGroup(const set &group); + void setText(const string &text); + + pRadioItem(RadioItem &radioItem) : pAction(radioItem), radioItem(radioItem) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/reference/action/separator.cpp b/higan/phoenix/reference/action/separator.cpp index 24a45c04..64e21197 100755 --- a/higan/phoenix/reference/action/separator.cpp +++ b/higan/phoenix/reference/action/separator.cpp @@ -1,5 +1,9 @@ +namespace phoenix { + void pSeparator::constructor() { } void pSeparator::destructor() { } + +} diff --git a/higan/phoenix/reference/action/separator.hpp b/higan/phoenix/reference/action/separator.hpp new file mode 100644 index 00000000..722c9714 --- /dev/null +++ b/higan/phoenix/reference/action/separator.hpp @@ -0,0 +1,11 @@ +namespace phoenix { + +struct pSeparator : public pAction { + Separator &separator; + + pSeparator(Separator &separator) : pAction(separator), separator(separator) {} + void constructor(); + void destructor(); +}; + +} diff --git a/higan/phoenix/reference/application.cpp b/higan/phoenix/reference/application.cpp new file mode 100644 index 00000000..a05d1c3f --- /dev/null +++ b/higan/phoenix/reference/application.cpp @@ -0,0 +1,19 @@ +namespace phoenix { + +void pApplication::run() { +} + +bool pApplication::pendingEvents() { + return false; +} + +void pApplication::processEvents() { +} + +void pApplication::quit() { +} + +void pApplication::initialize() { +} + +} diff --git a/higan/phoenix/reference/application.hpp b/higan/phoenix/reference/application.hpp new file mode 100644 index 00000000..effab50b --- /dev/null +++ b/higan/phoenix/reference/application.hpp @@ -0,0 +1,12 @@ +namespace phoenix { + +struct pApplication { + static void run(); + static bool pendingEvents(); + static void processEvents(); + static void quit(); + + static void initialize(); +}; + +} diff --git a/higan/phoenix/reference/desktop.cpp b/higan/phoenix/reference/desktop.cpp index a96eb1f0..ba385d9e 100755 --- a/higan/phoenix/reference/desktop.cpp +++ b/higan/phoenix/reference/desktop.cpp @@ -1,8 +1,11 @@ +namespace phoenix { + Size pDesktop::size() { - return { 0, 0 }; + return {0, 0}; } Geometry pDesktop::workspace() { - return { 0, 0, 0, 0 }; + return {0, 0, 0, 0}; } +} diff --git a/higan/phoenix/reference/desktop.hpp b/higan/phoenix/reference/desktop.hpp new file mode 100644 index 00000000..fed9ab6a --- /dev/null +++ b/higan/phoenix/reference/desktop.hpp @@ -0,0 +1,8 @@ +namespace phoenix { + +struct pDesktop { + static Size size(); + static Geometry workspace(); +}; + +} diff --git a/higan/phoenix/reference/dialog-window.cpp b/higan/phoenix/reference/dialog-window.cpp index c7d089ae..6821f74c 100755 --- a/higan/phoenix/reference/dialog-window.cpp +++ b/higan/phoenix/reference/dialog-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + string pDialogWindow::fileOpen(Window &parent, const string &path, const lstring &filter) { return ""; } @@ -9,3 +11,5 @@ string pDialogWindow::fileSave(Window &parent, const string &path, const lstring string pDialogWindow::folderSelect(Window &parent, const string &path) { return ""; } + +} diff --git a/higan/phoenix/reference/dialog-window.hpp b/higan/phoenix/reference/dialog-window.hpp new file mode 100644 index 00000000..758ba2f5 --- /dev/null +++ b/higan/phoenix/reference/dialog-window.hpp @@ -0,0 +1,9 @@ +namespace phoenix { + +struct pDialogWindow { + static string fileOpen(Window &parent, const string &path, const lstring &filter); + static string fileSave(Window &parent, const string &path, const lstring &filter); + static string folderSelect(Window &parent, const string &path); +}; + +} diff --git a/higan/phoenix/reference/font.cpp b/higan/phoenix/reference/font.cpp index bfda5c06..8bee7676 100755 --- a/higan/phoenix/reference/font.cpp +++ b/higan/phoenix/reference/font.cpp @@ -1,3 +1,19 @@ -Geometry pFont::geometry(const string &description, const string &text) { - return { 0, 0, 0, 0 }; +namespace phoenix { + +string pFont::serif(unsigned size, string style) { + return ""; +} + +string pFont::sans(unsigned size, string style) { + return ""; +} + +string pFont::monospace(unsigned size, string style) { + return ""; +} + +Size pFont::size(const string &font, const string &text) { + return {0, 0}; +} + } diff --git a/higan/phoenix/reference/font.hpp b/higan/phoenix/reference/font.hpp new file mode 100644 index 00000000..abe56d56 --- /dev/null +++ b/higan/phoenix/reference/font.hpp @@ -0,0 +1,10 @@ +namespace phoenix { + +struct pFont { + static string serif(unsigned size, string style); + static string sans(unsigned size, string style); + static string monospace(unsigned size, string style); + static Size size(const string &font, const string &text); +}; + +} diff --git a/higan/phoenix/reference/header.hpp b/higan/phoenix/reference/header.hpp new file mode 100644 index 00000000..e69de29b diff --git a/higan/phoenix/reference/keyboard.cpp b/higan/phoenix/reference/keyboard.cpp index 40b3a1a7..adc28c87 100755 --- a/higan/phoenix/reference/keyboard.cpp +++ b/higan/phoenix/reference/keyboard.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pKeyboard::pressed(Keyboard::Scancode scancode) { return false; } @@ -8,3 +10,5 @@ vector pKeyboard::state() { for(auto &n : output) n = false; return output; } + +} diff --git a/higan/phoenix/reference/keyboard.hpp b/higan/phoenix/reference/keyboard.hpp new file mode 100644 index 00000000..2c0a42ae --- /dev/null +++ b/higan/phoenix/reference/keyboard.hpp @@ -0,0 +1,8 @@ +namespace phoenix { + +struct pKeyboard { + static bool pressed(Keyboard::Scancode scancode); + static vector state(); +}; + +} diff --git a/higan/phoenix/reference/message-window.cpp b/higan/phoenix/reference/message-window.cpp index 84a287f5..f4d9d187 100755 --- a/higan/phoenix/reference/message-window.cpp +++ b/higan/phoenix/reference/message-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + MessageWindow::Response pMessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) { return MessageWindow::Response::Ok; } @@ -13,3 +15,5 @@ MessageWindow::Response pMessageWindow::warning(Window &parent, const string &te MessageWindow::Response pMessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) { return MessageWindow::Response::Ok; } + +} diff --git a/higan/phoenix/reference/message-window.hpp b/higan/phoenix/reference/message-window.hpp new file mode 100644 index 00000000..b44c9420 --- /dev/null +++ b/higan/phoenix/reference/message-window.hpp @@ -0,0 +1,10 @@ +namespace phoenix { + +struct pMessageWindow { + static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons); + static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons); + static MessageWindow::Response warning(Window &parent, const string &text, MessageWindow::Buttons buttons); + static MessageWindow::Response critical(Window &parent, const string &text, MessageWindow::Buttons buttons); +}; + +} diff --git a/higan/phoenix/reference/mouse.cpp b/higan/phoenix/reference/mouse.cpp index f103a15a..ca5e8556 100755 --- a/higan/phoenix/reference/mouse.cpp +++ b/higan/phoenix/reference/mouse.cpp @@ -1,7 +1,11 @@ +namespace phoenix { + Position pMouse::position() { - return { 0, 0 }; + return {0, 0}; } bool pMouse::pressed(Mouse::Button button) { return false; } + +} diff --git a/higan/phoenix/reference/mouse.hpp b/higan/phoenix/reference/mouse.hpp new file mode 100644 index 00000000..7e21f2ea --- /dev/null +++ b/higan/phoenix/reference/mouse.hpp @@ -0,0 +1,8 @@ +namespace phoenix { + +struct pMouse { + static Position position(); + static bool pressed(Mouse::Button button); +}; + +} diff --git a/higan/phoenix/reference/object.hpp b/higan/phoenix/reference/object.hpp new file mode 100644 index 00000000..6958a5fb --- /dev/null +++ b/higan/phoenix/reference/object.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pObject { + Object &object; + bool locked; + + pObject(Object &object) : object(object), locked(locked) {} + virtual ~pObject() {} + + void constructor() {} + void destructor() {} +}; + +} diff --git a/higan/phoenix/reference/platform.cpp b/higan/phoenix/reference/platform.cpp index e64f7eab..da266935 100755 --- a/higan/phoenix/reference/platform.cpp +++ b/higan/phoenix/reference/platform.cpp @@ -5,7 +5,6 @@ #include "mouse.cpp" #include "dialog-window.cpp" #include "message-window.cpp" - #include "font.cpp" #include "timer.cpp" #include "window.cpp" @@ -20,33 +19,19 @@ #include "widget/widget.cpp" #include "widget/button.cpp" #include "widget/canvas.cpp" -#include "widget/check-box.cpp" -#include "widget/combo-box.cpp" +#include "widget/check-button.cpp" +#include "widget/combo-button.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroll-bar.cpp" +#include "widget/horizontal-scroller.cpp" #include "widget/horizontal-slider.cpp" #include "widget/label.cpp" #include "widget/line-edit.cpp" #include "widget/list-view.cpp" #include "widget/progress-bar.cpp" -#include "widget/radio-box.cpp" +#include "widget/radio-button.cpp" #include "widget/text-edit.cpp" -#include "widget/vertical-scroll-bar.cpp" +#include "widget/vertical-scroller.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" -void pOS::main() { -} - -bool pOS::pendingEvents() { - return false; -} - -void pOS::processEvents() { -} - -void pOS::quit() { -} - -void pOS::initialize() { -} +#include "application.cpp" diff --git a/higan/phoenix/reference/platform.hpp b/higan/phoenix/reference/platform.hpp index cd9e4152..fab4a5c6 100755 --- a/higan/phoenix/reference/platform.hpp +++ b/higan/phoenix/reference/platform.hpp @@ -1,384 +1,46 @@ -struct pFont; -struct pWindow; -struct pMenu; -struct pLayout; -struct pWidget; - -struct pFont { - static Geometry geometry(const string &description, const string &text); -}; - -struct pDesktop { - static Size size(); - static Geometry workspace(); -}; - -struct pKeyboard { - static bool pressed(Keyboard::Scancode scancode); - static vector state(); -}; - -struct pMouse { - static Position position(); - static bool pressed(Mouse::Button button); -}; - -struct pDialogWindow { - static string fileOpen(Window &parent, const string &path, const lstring &filter); - static string fileSave(Window &parent, const string &path, const lstring &filter); - static string folderSelect(Window &parent, const string &path); -}; - -struct pMessageWindow { - static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons); - static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons); - static MessageWindow::Response warning(Window &parent, const string &text, MessageWindow::Buttons buttons); - static MessageWindow::Response critical(Window &parent, const string &text, MessageWindow::Buttons buttons); -}; - -struct pObject { - Object &object; - bool locked; - - pObject(Object &object) : object(object), locked(locked) {} - virtual ~pObject() {} - - void constructor() {} - void destructor() {} -}; - -struct pOS : public pObject { - static void main(); - static bool pendingEvents(); - static void processEvents(); - static void quit(); - - static void initialize(); -}; - -struct pTimer : public pObject { - Timer &timer; - - void setEnabled(bool enabled); - void setInterval(unsigned milliseconds); - - pTimer(Timer &timer) : pObject(timer), timer(timer) {} - void constructor(); -}; - -struct pWindow : public pObject { - Window &window; - - static Window& none(); - - void append(Layout &layout); - void append(Menu &menu); - void append(Widget &widget); - Color backgroundColor(); - bool focused(); - Geometry frameMargin(); - Geometry geometry(); - void remove(Layout &layout); - void remove(Menu &menu); - void remove(Widget &widget); - void setBackgroundColor(const Color &color); - void setFocused(); - void setFullScreen(bool fullScreen); - void setGeometry(const Geometry &geometry); - void setMenuFont(const string &font); - void setMenuVisible(bool visible); - void setModal(bool modal); - void setResizable(bool resizable); - void setStatusFont(const string &font); - void setStatusText(const string &text); - void setStatusVisible(bool visible); - void setTitle(const string &text); - void setVisible(bool visible); - void setWidgetFont(const string &font); - - pWindow(Window &window) : pObject(window), window(window) {} - void constructor(); -}; - -struct pAction : public pObject { - Action &action; - - void setEnabled(bool enabled); - void setVisible(bool visible); - - pAction(Action &action) : pObject(action), action(action) {} - void constructor(); -}; - -struct pMenu : public pAction { - Menu &menu; - - void append(Action &action); - void remove(Action &action); - void setImage(const image &image); - void setText(const string &text); - - pMenu(Menu &menu) : pAction(menu), menu(menu) {} - void constructor(); - void destructor(); -}; - -struct pSeparator : public pAction { - Separator &separator; - - pSeparator(Separator &separator) : pAction(separator), separator(separator) {} - void constructor(); - void destructor(); -}; - -struct pItem : public pAction { - Item &item; - - void setImage(const image &image); - void setText(const string &text); - - pItem(Item &item) : pAction(item), item(item) {} - void constructor(); - void destructor(); -}; - -struct pCheckItem : public pAction { - CheckItem &checkItem; - - bool checked(); - void setChecked(bool checked); - void setText(const string &text); - - pCheckItem(CheckItem &checkItem) : pAction(checkItem), checkItem(checkItem) {} - void constructor(); - void destructor(); -}; - -struct pRadioItem : public pAction { - RadioItem &radioItem; - - bool checked(); - void setChecked(); - void setGroup(const set &group); - void setText(const string &text); - - pRadioItem(RadioItem &radioItem) : pAction(radioItem), radioItem(radioItem) {} - void constructor(); - void destructor(); -}; - -struct pSizable : public pObject { - Sizable &sizable; - - pSizable(Sizable &sizable) : pObject(sizable), sizable(sizable) {} -}; - -struct pLayout : public pSizable { - Layout &layout; - - pLayout(Layout &layout) : pSizable(layout), layout(layout) {} -}; - -struct pWidget : public pSizable { - Widget &widget; - - bool enabled(); - bool focused(); - Geometry minimumGeometry(); - void setEnabled(bool enabled); - void setFocused(); - void setFont(const string &font); - void setGeometry(const Geometry &geometry); - void setVisible(bool visible); - - pWidget(Widget &widget) : pSizable(widget), widget(widget) {} - void constructor(); -}; - -struct pButton : public pWidget { - Button &button; - - void setImage(const image &image, Orientation orientation); - void setText(const string &text); - - pButton(Button &button) : pWidget(button), button(button) {} - void constructor(); -}; - -struct pCanvas : public pWidget { - Canvas &canvas; - - void setSize(const Size &size); - void update(); - - pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {} - void constructor(); -}; - -struct pCheckBox : public pWidget { - CheckBox &checkBox; - - bool checked(); - void setChecked(bool checked); - void setText(const string &text); - - pCheckBox(CheckBox &checkBox) : pWidget(checkBox), checkBox(checkBox) {} - void constructor(); -}; - -struct pComboBox : public pWidget { - ComboBox &comboBox; - - void append(const string &text); - void modify(unsigned row, const string &text); - void remove(unsigned row); - void reset(); - unsigned selection(); - void setSelection(unsigned row); - - pComboBox(ComboBox &comboBox) : pWidget(comboBox), comboBox(comboBox) {} - void constructor(); -}; - -struct pHexEdit : public pWidget { - HexEdit &hexEdit; - - void setColumns(unsigned columns); - void setLength(unsigned length); - void setOffset(unsigned offset); - void setRows(unsigned rows); - void update(); - - pHexEdit(HexEdit &hexEdit) : pWidget(hexEdit), hexEdit(hexEdit) {} - void constructor(); -}; - -struct pHorizontalScrollBar : public pWidget { - HorizontalScrollBar &horizontalScrollBar; - - unsigned position(); - void setLength(unsigned length); - void setPosition(unsigned position); - - pHorizontalScrollBar(HorizontalScrollBar &horizontalScrollBar) : pWidget(horizontalScrollBar), horizontalScrollBar(horizontalScrollBar) {} - void constructor(); -}; - -struct pHorizontalSlider : public pWidget { - HorizontalSlider &horizontalSlider; - - unsigned position(); - void setLength(unsigned length); - void setPosition(unsigned position); - - pHorizontalSlider(HorizontalSlider &horizontalSlider) : pWidget(horizontalSlider), horizontalSlider(horizontalSlider) {} - void constructor(); -}; - -struct pLabel : public pWidget { - Label &label; - - void setText(const string &text); - - pLabel(Label &label) : pWidget(label), label(label) {} - void constructor(); -}; - -struct pLineEdit : public pWidget { - LineEdit &lineEdit; - - void setEditable(bool editable); - void setText(const string &text); - string text(); - - pLineEdit(LineEdit &lineEdit) : pWidget(lineEdit), lineEdit(lineEdit) {} - void constructor(); -}; - -struct pListView : public pWidget { - ListView &listView; - - void append(const lstring &text); - void autoSizeColumns(); - bool checked(unsigned row); - void modify(unsigned row, const lstring &text); - void remove(unsigned row); - void reset(); - bool selected(); - unsigned selection(); - void setCheckable(bool checkable); - void setChecked(unsigned row, bool checked); - void setHeaderText(const lstring &text); - void setHeaderVisible(bool visible); - void setImage(unsigned row, unsigned column, const image &image); - void setSelected(bool selected); - void setSelection(unsigned row); - - pListView(ListView &listView) : pWidget(listView), listView(listView) {} - void constructor(); -}; - -struct pProgressBar : public pWidget { - ProgressBar &progressBar; - - void setPosition(unsigned position); - - pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} - void constructor(); -}; - -struct pRadioBox : public pWidget { - RadioBox &radioBox; - - bool checked(); - void setChecked(); - void setGroup(const set &group); - void setText(const string &text); - - pRadioBox(RadioBox &radioBox) : pWidget(radioBox), radioBox(radioBox) {} - void constructor(); -}; - -struct pTextEdit : public pWidget { - TextEdit &textEdit; - - void setCursorPosition(unsigned position); - void setEditable(bool editable); - void setText(const string &text); - void setWordWrap(bool wordWrap); - string text(); - - pTextEdit(TextEdit &textEdit) : pWidget(textEdit), textEdit(textEdit) {} - void constructor(); -}; - -struct pVerticalScrollBar : public pWidget { - VerticalScrollBar &verticalScrollBar; - - unsigned position(); - void setLength(unsigned length); - void setPosition(unsigned position); - - pVerticalScrollBar(VerticalScrollBar &verticalScrollBar) : pWidget(verticalScrollBar), verticalScrollBar(verticalScrollBar) {} - void constructor(); -}; - -struct pVerticalSlider : public pWidget { - VerticalSlider &verticalSlider; - - unsigned position(); - void setLength(unsigned length); - void setPosition(unsigned position); - - pVerticalSlider(VerticalSlider &verticalSlider) : pWidget(verticalSlider), verticalSlider(verticalSlider) {} - void constructor(); -}; - -struct pViewport : public pWidget { - Viewport &viewport; - - uintptr_t handle(); - - pViewport(Viewport &viewport) : pWidget(viewport), viewport(viewport) {} - void constructor(); -}; +namespace phoenix { + struct pFont; + struct pWindow; + struct pMenu; + struct pLayout; + struct pWidget; +} + +#include "font.hpp" +#include "desktop.hpp" +#include "keyboard.hpp" +#include "mouse.hpp" +#include "dialog-window.hpp" +#include "message-window.hpp" +#include "object.hpp" +#include "timer.hpp" +#include "window.hpp" + +#include "action/action.hpp" +#include "action/menu.hpp" +#include "action/separator.hpp" +#include "action/item.hpp" +#include "action/check-item.hpp" +#include "action/radio-item.hpp" + +#include "widget/sizable.hpp" +#include "widget/layout.hpp" +#include "widget/widget.hpp" +#include "widget/button.hpp" +#include "widget/canvas.hpp" +#include "widget/check-button.hpp" +#include "widget/combo-button.hpp" +#include "widget/hex-edit.hpp" +#include "widget/horizontal-scroller.hpp" +#include "widget/horizontal-slider.hpp" +#include "widget/label.hpp" +#include "widget/line-edit.hpp" +#include "widget/list-view.hpp" +#include "widget/progress-bar.hpp" +#include "widget/radio-button.hpp" +#include "widget/text-edit.hpp" +#include "widget/vertical-scroller.hpp" +#include "widget/vertical-slider.hpp" +#include "widget/viewport.hpp" + +#include "application.hpp" diff --git a/higan/phoenix/reference/timer.cpp b/higan/phoenix/reference/timer.cpp index 6cbe571a..66681688 100755 --- a/higan/phoenix/reference/timer.cpp +++ b/higan/phoenix/reference/timer.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pTimer::setEnabled(bool enabled) { } @@ -6,3 +8,5 @@ void pTimer::setInterval(unsigned milliseconds) { void pTimer::constructor() { } + +} diff --git a/higan/phoenix/reference/timer.hpp b/higan/phoenix/reference/timer.hpp new file mode 100644 index 00000000..b4c296bc --- /dev/null +++ b/higan/phoenix/reference/timer.hpp @@ -0,0 +1,13 @@ +namespace phoenix { + +struct pTimer : public pObject { + Timer &timer; + + void setEnabled(bool enabled); + void setInterval(unsigned milliseconds); + + pTimer(Timer &timer) : pObject(timer), timer(timer) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/button.cpp b/higan/phoenix/reference/widget/button.cpp index fc06c371..1a9cdc08 100755 --- a/higan/phoenix/reference/widget/button.cpp +++ b/higan/phoenix/reference/widget/button.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pButton::setImage(const image &image, Orientation orientation) { } @@ -6,3 +8,5 @@ void pButton::setText(const string &text) { void pButton::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/button.hpp b/higan/phoenix/reference/widget/button.hpp new file mode 100644 index 00000000..a3ad3277 --- /dev/null +++ b/higan/phoenix/reference/widget/button.hpp @@ -0,0 +1,13 @@ +namespace phoenix { + +struct pButton : public pWidget { + Button &button; + + void setImage(const image &image, Orientation orientation); + void setText(const string &text); + + pButton(Button &button) : pWidget(button), button(button) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/canvas.cpp b/higan/phoenix/reference/widget/canvas.cpp index 953cfa77..82b81b7a 100755 --- a/higan/phoenix/reference/widget/canvas.cpp +++ b/higan/phoenix/reference/widget/canvas.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pCanvas::setSize(const Size &size) { } @@ -6,3 +8,5 @@ void pCanvas::update() { void pCanvas::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/canvas.hpp b/higan/phoenix/reference/widget/canvas.hpp new file mode 100644 index 00000000..d8f14cc9 --- /dev/null +++ b/higan/phoenix/reference/widget/canvas.hpp @@ -0,0 +1,13 @@ +namespace phoenix { + +struct pCanvas : public pWidget { + Canvas &canvas; + + void setSize(const Size &size); + void update(); + + pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/check-box.cpp b/higan/phoenix/reference/widget/check-box.cpp deleted file mode 100755 index c5aec216..00000000 --- a/higan/phoenix/reference/widget/check-box.cpp +++ /dev/null @@ -1,12 +0,0 @@ -bool pCheckBox::checked() { - return false; -} - -void pCheckBox::setChecked(bool checked) { -} - -void pCheckBox::setText(const string &text) { -} - -void pCheckBox::constructor() { -} diff --git a/higan/phoenix/reference/widget/check-button.cpp b/higan/phoenix/reference/widget/check-button.cpp new file mode 100644 index 00000000..37564725 --- /dev/null +++ b/higan/phoenix/reference/widget/check-button.cpp @@ -0,0 +1,16 @@ +namespace phoenix { + +bool pCheckButton::checked() { + return false; +} + +void pCheckButton::setChecked(bool checked) { +} + +void pCheckButton::setText(const string &text) { +} + +void pCheckButton::constructor() { +} + +} diff --git a/higan/phoenix/reference/widget/check-button.hpp b/higan/phoenix/reference/widget/check-button.hpp new file mode 100644 index 00000000..17cd5d71 --- /dev/null +++ b/higan/phoenix/reference/widget/check-button.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pCheckButton : public pWidget { + CheckButton &checkButton; + + bool checked(); + void setChecked(bool checked); + void setText(const string &text); + + pCheckButton(CheckButton &checkButton) : pWidget(checkButton), checkButton(checkButton) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/combo-box.cpp b/higan/phoenix/reference/widget/combo-box.cpp deleted file mode 100755 index 297d7369..00000000 --- a/higan/phoenix/reference/widget/combo-box.cpp +++ /dev/null @@ -1,21 +0,0 @@ -void pComboBox::append(const string &text) { -} - -void pComboBox::modify(unsigned row, const string &text) { -} - -void pComboBox::remove(unsigned row) { -} - -void pComboBox::reset() { -} - -unsigned pComboBox::selection() { - return 0; -} - -void pComboBox::setSelection(unsigned row) { -} - -void pComboBox::constructor() { -} diff --git a/higan/phoenix/reference/widget/combo-button.cpp b/higan/phoenix/reference/widget/combo-button.cpp new file mode 100644 index 00000000..13787999 --- /dev/null +++ b/higan/phoenix/reference/widget/combo-button.cpp @@ -0,0 +1,25 @@ +namespace phoenix { + +void pComboButton::append(const string &text) { +} + +void pComboButton::modify(unsigned row, const string &text) { +} + +void pComboButton::remove(unsigned row) { +} + +void pComboButton::reset() { +} + +unsigned pComboButton::selection() { + return 0; +} + +void pComboButton::setSelection(unsigned row) { +} + +void pComboButton::constructor() { +} + +} diff --git a/higan/phoenix/reference/widget/combo-button.hpp b/higan/phoenix/reference/widget/combo-button.hpp new file mode 100644 index 00000000..84cc0372 --- /dev/null +++ b/higan/phoenix/reference/widget/combo-button.hpp @@ -0,0 +1,17 @@ +namespace phoenix { + +struct pComboButton : public pWidget { + ComboButton &comboButton; + + void append(const string &text); + void modify(unsigned row, const string &text); + void remove(unsigned row); + void reset(); + unsigned selection(); + void setSelection(unsigned row); + + pComboButton(ComboButton &comboButton) : pWidget(comboButton), comboButton(comboButton) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/hex-edit.cpp b/higan/phoenix/reference/widget/hex-edit.cpp index 40bf9f5d..95d8b72a 100755 --- a/higan/phoenix/reference/widget/hex-edit.cpp +++ b/higan/phoenix/reference/widget/hex-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pHexEdit::setColumns(unsigned columns) { } @@ -15,3 +17,5 @@ void pHexEdit::update() { void pHexEdit::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/hex-edit.hpp b/higan/phoenix/reference/widget/hex-edit.hpp new file mode 100644 index 00000000..5819ee4d --- /dev/null +++ b/higan/phoenix/reference/widget/hex-edit.hpp @@ -0,0 +1,16 @@ +namespace phoenix { + +struct pHexEdit : public pWidget { + HexEdit &hexEdit; + + void setColumns(unsigned columns); + void setLength(unsigned length); + void setOffset(unsigned offset); + void setRows(unsigned rows); + void update(); + + pHexEdit(HexEdit &hexEdit) : pWidget(hexEdit), hexEdit(hexEdit) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/horizontal-scroll-bar.cpp b/higan/phoenix/reference/widget/horizontal-scroll-bar.cpp deleted file mode 100755 index 352b3393..00000000 --- a/higan/phoenix/reference/widget/horizontal-scroll-bar.cpp +++ /dev/null @@ -1,12 +0,0 @@ -unsigned pHorizontalScrollBar::position() { - return 0; -} - -void pHorizontalScrollBar::setLength(unsigned length) { -} - -void pHorizontalScrollBar::setPosition(unsigned position) { -} - -void pHorizontalScrollBar::constructor() { -} diff --git a/higan/phoenix/reference/widget/horizontal-scroller.cpp b/higan/phoenix/reference/widget/horizontal-scroller.cpp new file mode 100644 index 00000000..ef66115a --- /dev/null +++ b/higan/phoenix/reference/widget/horizontal-scroller.cpp @@ -0,0 +1,16 @@ +namespace phoenix { + +unsigned pHorizontalScroller::position() { + return 0; +} + +void pHorizontalScroller::setLength(unsigned length) { +} + +void pHorizontalScroller::setPosition(unsigned position) { +} + +void pHorizontalScroller::constructor() { +} + +} diff --git a/higan/phoenix/reference/widget/horizontal-scroller.hpp b/higan/phoenix/reference/widget/horizontal-scroller.hpp new file mode 100644 index 00000000..ea915b59 --- /dev/null +++ b/higan/phoenix/reference/widget/horizontal-scroller.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pHorizontalScroller : public pWidget { + HorizontalScroller &horizontalScroller; + + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pHorizontalScroller(HorizontalScroller &horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/horizontal-slider.cpp b/higan/phoenix/reference/widget/horizontal-slider.cpp index 0a4a8392..2bc97bab 100755 --- a/higan/phoenix/reference/widget/horizontal-slider.cpp +++ b/higan/phoenix/reference/widget/horizontal-slider.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + unsigned pHorizontalSlider::position() { return 0; } @@ -10,3 +12,5 @@ void pHorizontalSlider::setPosition(unsigned position) { void pHorizontalSlider::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/horizontal-slider.hpp b/higan/phoenix/reference/widget/horizontal-slider.hpp new file mode 100644 index 00000000..3caac46a --- /dev/null +++ b/higan/phoenix/reference/widget/horizontal-slider.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pHorizontalSlider : public pWidget { + HorizontalSlider &horizontalSlider; + + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pHorizontalSlider(HorizontalSlider &horizontalSlider) : pWidget(horizontalSlider), horizontalSlider(horizontalSlider) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/label.cpp b/higan/phoenix/reference/widget/label.cpp index 25600d2a..30f0ea63 100755 --- a/higan/phoenix/reference/widget/label.cpp +++ b/higan/phoenix/reference/widget/label.cpp @@ -1,5 +1,9 @@ +namespace phoenix { + void pLabel::setText(const string &text) { } void pLabel::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/label.hpp b/higan/phoenix/reference/widget/label.hpp new file mode 100644 index 00000000..aca53cef --- /dev/null +++ b/higan/phoenix/reference/widget/label.hpp @@ -0,0 +1,12 @@ +namespace phoenix { + +struct pLabel : public pWidget { + Label &label; + + void setText(const string &text); + + pLabel(Label &label) : pWidget(label), label(label) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/layout.hpp b/higan/phoenix/reference/widget/layout.hpp new file mode 100644 index 00000000..100b7463 --- /dev/null +++ b/higan/phoenix/reference/widget/layout.hpp @@ -0,0 +1,9 @@ +namespace phoenix { + +struct pLayout : public pSizable { + Layout &layout; + + pLayout(Layout &layout) : pSizable(layout), layout(layout) {} +}; + +} diff --git a/higan/phoenix/reference/widget/line-edit.cpp b/higan/phoenix/reference/widget/line-edit.cpp index 96b9ac6c..6fd26dfe 100755 --- a/higan/phoenix/reference/widget/line-edit.cpp +++ b/higan/phoenix/reference/widget/line-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pLineEdit::setEditable(bool editable) { } @@ -9,3 +11,5 @@ string pLineEdit::text() { void pLineEdit::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/line-edit.hpp b/higan/phoenix/reference/widget/line-edit.hpp new file mode 100644 index 00000000..1ca8b0ab --- /dev/null +++ b/higan/phoenix/reference/widget/line-edit.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pLineEdit : public pWidget { + LineEdit &lineEdit; + + void setEditable(bool editable); + void setText(const string &text); + string text(); + + pLineEdit(LineEdit &lineEdit) : pWidget(lineEdit), lineEdit(lineEdit) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/list-view.cpp b/higan/phoenix/reference/widget/list-view.cpp index 6e90e0a3..c1cb54cf 100755 --- a/higan/phoenix/reference/widget/list-view.cpp +++ b/higan/phoenix/reference/widget/list-view.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pListView::append(const lstring &text) { } @@ -47,3 +49,5 @@ void pListView::setSelection(unsigned row) { void pListView::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/list-view.hpp b/higan/phoenix/reference/widget/list-view.hpp new file mode 100644 index 00000000..8f0695c3 --- /dev/null +++ b/higan/phoenix/reference/widget/list-view.hpp @@ -0,0 +1,26 @@ +namespace phoenix { + +struct pListView : public pWidget { + ListView &listView; + + void append(const lstring &text); + void autoSizeColumns(); + bool checked(unsigned row); + void modify(unsigned row, const lstring &text); + void remove(unsigned row); + void reset(); + bool selected(); + unsigned selection(); + void setCheckable(bool checkable); + void setChecked(unsigned row, bool checked); + void setHeaderText(const lstring &text); + void setHeaderVisible(bool visible); + void setImage(unsigned row, unsigned column, const image &image); + void setSelected(bool selected); + void setSelection(unsigned row); + + pListView(ListView &listView) : pWidget(listView), listView(listView) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/progress-bar.cpp b/higan/phoenix/reference/widget/progress-bar.cpp index b4905a85..87144b3d 100755 --- a/higan/phoenix/reference/widget/progress-bar.cpp +++ b/higan/phoenix/reference/widget/progress-bar.cpp @@ -1,5 +1,9 @@ +namespace phoenix { + void pProgressBar::setPosition(unsigned position) { } void pProgressBar::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/progress-bar.hpp b/higan/phoenix/reference/widget/progress-bar.hpp new file mode 100644 index 00000000..06d745c0 --- /dev/null +++ b/higan/phoenix/reference/widget/progress-bar.hpp @@ -0,0 +1,12 @@ +namespace phoenix { + +struct pProgressBar : public pWidget { + ProgressBar &progressBar; + + void setPosition(unsigned position); + + pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/radio-box.cpp b/higan/phoenix/reference/widget/radio-box.cpp deleted file mode 100755 index f6aebcbe..00000000 --- a/higan/phoenix/reference/widget/radio-box.cpp +++ /dev/null @@ -1,15 +0,0 @@ -bool pRadioBox::checked() { - return false; -} - -void pRadioBox::setChecked() { -} - -void pRadioBox::setGroup(const set &group) { -} - -void pRadioBox::setText(const string &text) { -} - -void pRadioBox::constructor() { -} diff --git a/higan/phoenix/reference/widget/radio-button.cpp b/higan/phoenix/reference/widget/radio-button.cpp new file mode 100644 index 00000000..34c82bc6 --- /dev/null +++ b/higan/phoenix/reference/widget/radio-button.cpp @@ -0,0 +1,19 @@ +namespace phoenix { + +bool pRadioButton::checked() { + return false; +} + +void pRadioButton::setChecked() { +} + +void pRadioButton::setGroup(const set &group) { +} + +void pRadioButton::setText(const string &text) { +} + +void pRadioButton::constructor() { +} + +} diff --git a/higan/phoenix/reference/widget/radio-button.hpp b/higan/phoenix/reference/widget/radio-button.hpp new file mode 100644 index 00000000..6c92b52e --- /dev/null +++ b/higan/phoenix/reference/widget/radio-button.hpp @@ -0,0 +1,15 @@ +namespace phoenix { + +struct pRadioButton : public pWidget { + RadioButton &radioButton; + + bool checked(); + void setChecked(); + void setGroup(const set &group); + void setText(const string &text); + + pRadioButton(RadioButton &radioButton) : pWidget(radioButton), radioButton(radioButton) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/sizable.hpp b/higan/phoenix/reference/widget/sizable.hpp new file mode 100644 index 00000000..b7c2f934 --- /dev/null +++ b/higan/phoenix/reference/widget/sizable.hpp @@ -0,0 +1,9 @@ +namespace phoenix { + +struct pSizable : public pObject { + Sizable &sizable; + + pSizable(Sizable &sizable) : pObject(sizable), sizable(sizable) {} +}; + +} diff --git a/higan/phoenix/reference/widget/text-edit.cpp b/higan/phoenix/reference/widget/text-edit.cpp index 74121b2d..20f02df6 100755 --- a/higan/phoenix/reference/widget/text-edit.cpp +++ b/higan/phoenix/reference/widget/text-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pTextEdit::setCursorPosition(unsigned position) { } @@ -15,3 +17,5 @@ string pTextEdit::text() { void pTextEdit::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/text-edit.hpp b/higan/phoenix/reference/widget/text-edit.hpp new file mode 100644 index 00000000..46e1a93e --- /dev/null +++ b/higan/phoenix/reference/widget/text-edit.hpp @@ -0,0 +1,16 @@ +namespace phoenix { + +struct pTextEdit : public pWidget { + TextEdit &textEdit; + + void setCursorPosition(unsigned position); + void setEditable(bool editable); + void setText(const string &text); + void setWordWrap(bool wordWrap); + string text(); + + pTextEdit(TextEdit &textEdit) : pWidget(textEdit), textEdit(textEdit) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/vertical-scroll-bar.cpp b/higan/phoenix/reference/widget/vertical-scroll-bar.cpp deleted file mode 100755 index 26795248..00000000 --- a/higan/phoenix/reference/widget/vertical-scroll-bar.cpp +++ /dev/null @@ -1,12 +0,0 @@ -unsigned pVerticalScrollBar::position() { - return 0; -} - -void pVerticalScrollBar::setLength(unsigned length) { -} - -void pVerticalScrollBar::setPosition(unsigned position) { -} - -void pVerticalScrollBar::constructor() { -} diff --git a/higan/phoenix/reference/widget/vertical-scroller.cpp b/higan/phoenix/reference/widget/vertical-scroller.cpp new file mode 100644 index 00000000..6b03f2fa --- /dev/null +++ b/higan/phoenix/reference/widget/vertical-scroller.cpp @@ -0,0 +1,16 @@ +namespace phoenix { + +unsigned pVerticalScroller::position() { + return 0; +} + +void pVerticalScroller::setLength(unsigned length) { +} + +void pVerticalScroller::setPosition(unsigned position) { +} + +void pVerticalScroller::constructor() { +} + +} diff --git a/higan/phoenix/reference/widget/vertical-scroller.hpp b/higan/phoenix/reference/widget/vertical-scroller.hpp new file mode 100644 index 00000000..d1efe1c3 --- /dev/null +++ b/higan/phoenix/reference/widget/vertical-scroller.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pVerticalScroller : public pWidget { + VerticalScroller &verticalScroller; + + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pVerticalScroller(VerticalScroller &verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/vertical-slider.cpp b/higan/phoenix/reference/widget/vertical-slider.cpp index a6d8ae00..6f48f80a 100755 --- a/higan/phoenix/reference/widget/vertical-slider.cpp +++ b/higan/phoenix/reference/widget/vertical-slider.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + unsigned pVerticalSlider::position() { return 0; } @@ -10,3 +12,5 @@ void pVerticalSlider::setPosition(unsigned position) { void pVerticalSlider::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/vertical-slider.hpp b/higan/phoenix/reference/widget/vertical-slider.hpp new file mode 100644 index 00000000..bad27451 --- /dev/null +++ b/higan/phoenix/reference/widget/vertical-slider.hpp @@ -0,0 +1,14 @@ +namespace phoenix { + +struct pVerticalSlider : public pWidget { + VerticalSlider &verticalSlider; + + unsigned position(); + void setLength(unsigned length); + void setPosition(unsigned position); + + pVerticalSlider(VerticalSlider &verticalSlider) : pWidget(verticalSlider), verticalSlider(verticalSlider) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/viewport.cpp b/higan/phoenix/reference/widget/viewport.cpp index 9d398438..5d088e3d 100755 --- a/higan/phoenix/reference/widget/viewport.cpp +++ b/higan/phoenix/reference/widget/viewport.cpp @@ -1,6 +1,10 @@ +namespace phoenix { + uintptr_t pViewport::handle() { return 0; } void pViewport::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/viewport.hpp b/higan/phoenix/reference/widget/viewport.hpp new file mode 100644 index 00000000..94a6eecb --- /dev/null +++ b/higan/phoenix/reference/widget/viewport.hpp @@ -0,0 +1,12 @@ +namespace phoenix { + +struct pViewport : public pWidget { + Viewport &viewport; + + uintptr_t handle(); + + pViewport(Viewport &viewport) : pWidget(viewport), viewport(viewport) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/widget/widget.cpp b/higan/phoenix/reference/widget/widget.cpp index d9c86478..6533ac62 100755 --- a/higan/phoenix/reference/widget/widget.cpp +++ b/higan/phoenix/reference/widget/widget.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pWidget::enabled() { return false; } @@ -6,8 +8,8 @@ bool pWidget::focused() { return false; } -Geometry pWidget::minimumGeometry() { - return {0, 0, 0, 0}; +Size pWidget::minimumSize() { + return {0, 0}; } void pWidget::setEnabled(bool enabled) { @@ -27,3 +29,5 @@ void pWidget::setVisible(bool visible) { void pWidget::constructor() { } + +} diff --git a/higan/phoenix/reference/widget/widget.hpp b/higan/phoenix/reference/widget/widget.hpp new file mode 100644 index 00000000..797fda05 --- /dev/null +++ b/higan/phoenix/reference/widget/widget.hpp @@ -0,0 +1,19 @@ +namespace phoenix { + +struct pWidget : public pSizable { + Widget &widget; + + bool enabled(); + bool focused(); + Size minimumSize(); + void setEnabled(bool enabled); + void setFocused(); + void setFont(const string &font); + void setGeometry(const Geometry &geometry); + void setVisible(bool visible); + + pWidget(Widget &widget) : pSizable(widget), widget(widget) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/reference/window.cpp b/higan/phoenix/reference/window.cpp index aca2cc2d..aa6c4adb 100755 --- a/higan/phoenix/reference/window.cpp +++ b/higan/phoenix/reference/window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + Window& pWindow::none() { static Window *window = nullptr; if(window == nullptr) window = new Window; @@ -82,3 +84,5 @@ void pWindow::setWidgetFont(const string &font) { void pWindow::constructor() { } + +} diff --git a/higan/phoenix/reference/window.hpp b/higan/phoenix/reference/window.hpp new file mode 100644 index 00000000..12fc6a03 --- /dev/null +++ b/higan/phoenix/reference/window.hpp @@ -0,0 +1,37 @@ +namespace phoenix { + +struct pWindow : public pObject { + Window &window; + + static Window& none(); + + void append(Layout &layout); + void append(Menu &menu); + void append(Widget &widget); + Color backgroundColor(); + bool focused(); + Geometry frameMargin(); + Geometry geometry(); + void remove(Layout &layout); + void remove(Menu &menu); + void remove(Widget &widget); + void setBackgroundColor(const Color &color); + void setFocused(); + void setFullScreen(bool fullScreen); + void setGeometry(const Geometry &geometry); + void setMenuFont(const string &font); + void setMenuVisible(bool visible); + void setModal(bool modal); + void setResizable(bool resizable); + void setStatusFont(const string &font); + void setStatusText(const string &text); + void setStatusVisible(bool visible); + void setTitle(const string &text); + void setVisible(bool visible); + void setWidgetFont(const string &font); + + pWindow(Window &window) : pObject(window), window(window) {} + void constructor(); +}; + +} diff --git a/higan/phoenix/windows/action/action.cpp b/higan/phoenix/windows/action/action.cpp index b80208d1..8a39da11 100755 --- a/higan/phoenix/windows/action/action.cpp +++ b/higan/phoenix/windows/action/action.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pAction::setEnabled(bool enabled) { if(parentWindow) parentWindow->p.updateMenu(); } @@ -10,3 +12,5 @@ void pAction::constructor() { parentMenu = 0; parentWindow = 0; } + +} diff --git a/higan/phoenix/windows/action/check-item.cpp b/higan/phoenix/windows/action/check-item.cpp index 195deabd..0b2d3dd9 100755 --- a/higan/phoenix/windows/action/check-item.cpp +++ b/higan/phoenix/windows/action/check-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pCheckItem::checked() { return checkItem.state.checked; } @@ -16,3 +18,5 @@ void pCheckItem::constructor() { void pCheckItem::destructor() { if(parentMenu) parentMenu->remove(checkItem); } + +} diff --git a/higan/phoenix/windows/action/item.cpp b/higan/phoenix/windows/action/item.cpp index 2804bfcb..13e8835b 100755 --- a/higan/phoenix/windows/action/item.cpp +++ b/higan/phoenix/windows/action/item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pItem::setImage(const image &image) { createBitmap(); if(parentWindow) parentWindow->p.updateMenu(); @@ -27,3 +29,5 @@ void pItem::createBitmap() { hbitmap = CreateBitmap(nallImage); } } + +} diff --git a/higan/phoenix/windows/action/menu.cpp b/higan/phoenix/windows/action/menu.cpp index 5d9da04e..3a26cae7 100755 --- a/higan/phoenix/windows/action/menu.cpp +++ b/higan/phoenix/windows/action/menu.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pMenu::append(Action &action) { action.p.parentMenu = &menu; if(parentWindow) parentWindow->p.updateMenu(); @@ -107,3 +109,5 @@ void pMenu::update(Window &parentWindow, Menu *parentMenu) { } } } + +} diff --git a/higan/phoenix/windows/action/radio-item.cpp b/higan/phoenix/windows/action/radio-item.cpp index 6b4f3a31..e43332bf 100755 --- a/higan/phoenix/windows/action/radio-item.cpp +++ b/higan/phoenix/windows/action/radio-item.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pRadioItem::checked() { return radioItem.state.checked; } @@ -24,3 +26,5 @@ void pRadioItem::constructor() { void pRadioItem::destructor() { if(parentMenu) parentMenu->remove(radioItem); } + +} diff --git a/higan/phoenix/windows/action/separator.cpp b/higan/phoenix/windows/action/separator.cpp index fac38eca..c3be0e15 100755 --- a/higan/phoenix/windows/action/separator.cpp +++ b/higan/phoenix/windows/action/separator.cpp @@ -1,6 +1,10 @@ +namespace phoenix { + void pSeparator::constructor() { } void pSeparator::destructor() { if(parentMenu) parentMenu->remove(separator); } + +} diff --git a/higan/phoenix/windows/application.cpp b/higan/phoenix/windows/application.cpp new file mode 100644 index 00000000..35d48a3b --- /dev/null +++ b/higan/phoenix/windows/application.cpp @@ -0,0 +1,447 @@ +namespace phoenix { + +static bool Application_keyboardProc(HWND, UINT, WPARAM, LPARAM); +static void Application_processDialogMessage(MSG&); +static LRESULT CALLBACK Application_windowProc(HWND, UINT, WPARAM, LPARAM); + +void pApplication::run() { + MSG msg; + if(Application::main) { + while(applicationState.quit == false) { + Application::main(); + processEvents(); + } + } else { + MSG msg; + while(GetMessage(&msg, 0, 0, 0)) { + Application_processDialogMessage(msg); + } + } +} + +bool pApplication::pendingEvents() { + MSG msg; + return PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE); +} + +void pApplication::processEvents() { + while(pendingEvents()) { + MSG msg; + if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + Application_processDialogMessage(msg); + } + } +} + +void Application_processDialogMessage(MSG &msg) { + if(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP + || msg.message == WM_SYSKEYDOWN || msg.message == WM_SYSKEYUP) { + if(Application_keyboardProc(msg.hwnd, msg.message, msg.wParam, msg.lParam)) { + DispatchMessage(&msg); + return; + } + } + + if(!IsDialogMessage(GetForegroundWindow(), &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + +void pApplication::quit() { + PostQuitMessage(0); +} + +void pApplication::initialize() { + CoInitialize(0); + InitCommonControls(); + + WNDCLASS wc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hIcon = LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(2)); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = Application_windowProc; + wc.lpszClassName = L"phoenix_window"; + wc.lpszMenuName = 0; + wc.style = CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hIcon = LoadIcon(0, IDI_APPLICATION); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = Canvas_windowProc; + wc.lpszClassName = L"phoenix_canvas"; + wc.lpszMenuName = 0; + wc.style = CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hIcon = LoadIcon(0, IDI_APPLICATION); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = Label_windowProc; + wc.lpszClassName = L"phoenix_label"; + wc.lpszMenuName = 0; + wc.style = CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hIcon = LoadIcon(0, IDI_APPLICATION); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = Viewport_windowProc; + wc.lpszClassName = L"phoenix_viewport"; + wc.lpszMenuName = 0; + wc.style = CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + + settings = new Settings; + pKeyboard::initialize(); +} + +static bool Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + if(msg != WM_KEYDOWN && msg != WM_SYSKEYDOWN && msg != WM_KEYUP && msg != WM_SYSKEYUP) return false; + + GUITHREADINFO info; + memset(&info, 0, sizeof(GUITHREADINFO)); + info.cbSize = sizeof(GUITHREADINFO); + GetGUIThreadInfo(GetCurrentThreadId(), &info); + Object *object = (Object*)GetWindowLongPtr(info.hwndFocus, GWLP_USERDATA); + if(object == nullptr) return false; + + if(dynamic_cast(object)) { + Window &window = (Window&)*object; + if(pWindow::modal.size() > 0 && !pWindow::modal.find(&window.p)) return false; + Keyboard::Keycode keysym = Keysym(wparam, lparam); + if(keysym != Keyboard::Keycode::None) { + if((msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) && window.onKeyPress) window.onKeyPress(keysym); + if((msg == WM_KEYUP || msg == WM_SYSKEYUP) && window.onKeyRelease) window.onKeyRelease(keysym); + } + return false; + } + + if(msg == WM_KEYDOWN) { + if(dynamic_cast(object)) { + ListView &listView = (ListView&)*object; + if(wparam == VK_RETURN) { + if(listView.onActivate) listView.onActivate(); + } + } else if(dynamic_cast(object)) { + LineEdit &lineEdit = (LineEdit&)*object; + if(wparam == VK_RETURN) { + if(lineEdit.onActivate) lineEdit.onActivate(); + } + } else if(dynamic_cast(object)) { + TextEdit &textEdit = (TextEdit&)*object; + if(wparam == 'A' && GetKeyState(VK_CONTROL) < 0) { + //Ctrl+A = select all text + //note: this is not a standard accelerator on Windows + Edit_SetSel(textEdit.p.hwnd, 0, ~0); + return true; + } else if(wparam == 'V' && GetKeyState(VK_CONTROL) < 0) { + //Ctrl+V = paste text + //note: this formats Unix (LF) and OS9 (CR) line-endings to Windows (CR+LF) line-endings + //this is necessary as the EDIT control only supports Windows line-endings + OpenClipboard(hwnd); + HANDLE handle = GetClipboardData(CF_UNICODETEXT); + if(handle) { + wchar_t *text = (wchar_t*)GlobalLock(handle); + if(text) { + string data = (const char*)utf8_t(text); + data.replace("\r\n", "\n"); + data.replace("\r", "\n"); + data.replace("\n", "\r\n"); + GlobalUnlock(handle); + utf16_t output(data); + HGLOBAL resource = GlobalAlloc(GMEM_MOVEABLE, (wcslen(output) + 1) * sizeof(wchar_t)); + if(resource) { + wchar_t *write = (wchar_t*)GlobalLock(resource); + if(write) { + wcscpy(write, output); + GlobalUnlock(write); + if(SetClipboardData(CF_UNICODETEXT, resource) == FALSE) { + GlobalFree(resource); + } + } + } + } + } + CloseClipboard(); + return false; + } + } + } + + return false; +} + +static LRESULT CALLBACK Application_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + Object *object = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if(!object || !dynamic_cast(object)) return DefWindowProc(hwnd, msg, wparam, lparam); + Window &window = (Window&)*object; + + bool process = true; + if(pWindow::modal.size() > 0 && !pWindow::modal.find(&window.p)) process = false; + if(applicationState.quit) process = false; + + if(process) switch(msg) { + case WM_CLOSE: { + if(window.onClose) window.onClose(); + else window.setVisible(false); + if(window.state.modal && !window.visible()) window.setModal(false); + return TRUE; + } + + case WM_MOVE: { + if(window.p.locked) break; + + Geometry geometry = window.geometry(); + window.state.geometry.x = geometry.x; + window.state.geometry.y = geometry.y; + + if(window.onMove) window.onMove(); + break; + } + + case WM_SIZE: { + if(window.p.locked) break; + SetWindowPos(window.p.hstatus, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_FRAMECHANGED); + + Geometry geometry = window.geometry(); + window.state.geometry.width = geometry.width; + window.state.geometry.height = geometry.height; + + for(auto &layout : window.state.layout) { + Geometry geom = window.geometry(); + geom.x = geom.y = 0; + layout.setGeometry(geom); + } + + if(window.onSize) window.onSize(); + break; + } + + case WM_GETMINMAXINFO: { + MINMAXINFO *mmi = (MINMAXINFO*)lparam; + //mmi->ptMinTrackSize.x = 256 + window.p.frameMargin().width; + //mmi->ptMinTrackSize.y = 256 + window.p.frameMargin().height; + //return TRUE; + break; + } + + case WM_ERASEBKGND: { + if(window.p.brush == 0) break; + RECT rc; + GetClientRect(window.p.hwnd, &rc); + PAINTSTRUCT ps; + BeginPaint(window.p.hwnd, &ps); + FillRect(ps.hdc, &rc, window.p.brush); + EndPaint(window.p.hwnd, &ps); + return TRUE; + } + + case WM_CTLCOLORBTN: + case WM_CTLCOLORSTATIC: { + Object *object = (Object*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA); + if(object && window.p.brush) { + HDC hdc = (HDC)wparam; + SetBkColor((HDC)wparam, window.p.brushColor); + return (INT_PTR)window.p.brush; + } + break; + } + + case WM_COMMAND: { + unsigned id = LOWORD(wparam); + HWND control = GetDlgItem(window.p.hwnd, id); + if(control == 0) { + pObject *object = (pObject*)pObject::find(id); + if(!object) break; + if(dynamic_cast(object)) { + Item &item = ((pItem*)object)->item; + if(item.onActivate) item.onActivate(); + } else if(dynamic_cast(object)) { + CheckItem &checkItem = ((pCheckItem*)object)->checkItem; + checkItem.setChecked(!checkItem.state.checked); + if(checkItem.onToggle) checkItem.onToggle(); + } else if(dynamic_cast(object)) { + RadioItem &radioItem = ((pRadioItem*)object)->radioItem; + if(radioItem.state.checked == false) { + radioItem.setChecked(); + if(radioItem.onActivate) radioItem.onActivate(); + } + } + } else { + Object *object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA); + if(!object) break; + if(dynamic_cast(object)) { + Button &button = (Button&)*object; + if(button.onActivate) button.onActivate(); + } else if(dynamic_cast(object)) { + CheckButton &checkButton = (CheckButton&)*object; + checkButton.setChecked(!checkButton.state.checked); + if(checkButton.onToggle) checkButton.onToggle(); + } else if(dynamic_cast(object)) { + ComboButton &comboButton = (ComboButton&)*object; + if(HIWORD(wparam) == CBN_SELCHANGE) { + if(comboButton.state.selection != comboButton.selection()) { + comboButton.state.selection = comboButton.selection(); + if(comboButton.onChange) comboButton.onChange(); + } + } + } else if(dynamic_cast(object)) { + LineEdit &lineEdit = (LineEdit&)*object; + if(HIWORD(wparam) == EN_CHANGE) { + if(lineEdit.p.locked == false && lineEdit.onChange) lineEdit.onChange(); + } + } else if(dynamic_cast(object)) { + RadioButton &radioButton = (RadioButton&)*object; + if(radioButton.state.checked == false) { + radioButton.setChecked(); + if(radioButton.onActivate) radioButton.onActivate(); + } + } else if(dynamic_cast(object)) { + TextEdit &textEdit = (TextEdit&)*object; + if(HIWORD(wparam) == EN_CHANGE) { + if(textEdit.p.locked == false && textEdit.onChange) textEdit.onChange(); + } + } + } + break; + } + + case WM_NOTIFY: { + unsigned id = LOWORD(wparam); + HWND control = GetDlgItem(window.p.hwnd, id); + if(control == 0) break; + Object *object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA); + if(object == 0) break; + if(dynamic_cast(object)) { + ListView &listView = (ListView&)*object; + LPNMHDR nmhdr = (LPNMHDR)lparam; + LPNMLISTVIEW nmlistview = (LPNMLISTVIEW)lparam; + + if(nmhdr->code == LVN_ITEMCHANGED && (nmlistview->uChanged & LVIF_STATE)) { + unsigned imagemask = ((nmlistview->uNewState & LVIS_STATEIMAGEMASK) >> 12) - 1; + if(imagemask == 0 || imagemask == 1) { + if(listView.p.locked == false && listView.onToggle) listView.onToggle(nmlistview->iItem); + } else if((nmlistview->uOldState & LVIS_FOCUSED) && !(nmlistview->uNewState & LVIS_FOCUSED)) { + listView.p.lostFocus = true; + } else if(!(nmlistview->uOldState & LVIS_SELECTED) && (nmlistview->uNewState & LVIS_SELECTED)) { + listView.p.lostFocus = false; + listView.state.selected = true; + listView.state.selection = listView.selection(); + if(listView.p.locked == false && listView.onChange) listView.onChange(); + } else if(listView.p.lostFocus == false && listView.selected() == false) { + listView.p.lostFocus = false; + listView.state.selected = false; + listView.state.selection = 0; + if(listView.p.locked == false && listView.onChange) listView.onChange(); + } + } else if(nmhdr->code == LVN_ITEMACTIVATE) { + if(listView.onActivate) listView.onActivate(); + } else if(nmhdr->code == NM_CUSTOMDRAW) { + LPNMLVCUSTOMDRAW lvcd = (LPNMLVCUSTOMDRAW)nmhdr; + switch(lvcd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + return CDRF_NOTIFYITEMDRAW; + case CDDS_ITEMPREPAINT: + if(listView.state.headerText.size() >= 2) { + //draw alternating row colors of there are two or more columns + if(lvcd->nmcd.dwItemSpec % 2) lvcd->clrTextBk = GetSysColor(COLOR_WINDOW) ^ 0x070707; + } + return CDRF_DODEFAULT; + default: + return CDRF_DODEFAULT; + } + } + } + break; + } + + case WM_HSCROLL: + case WM_VSCROLL: { + Object *object = 0; + if(lparam) { + object = (Object*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA); + } else { + unsigned id = LOWORD(wparam); + HWND control = GetDlgItem(window.p.hwnd, id); + if(control == 0) break; + object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA); + } + if(object == 0) break; + + if(dynamic_cast(object) + || dynamic_cast(object)) { + SCROLLINFO info; + memset(&info, 0, sizeof(SCROLLINFO)); + info.cbSize = sizeof(SCROLLINFO); + info.fMask = SIF_ALL; + GetScrollInfo((HWND)lparam, SB_CTL, &info); + + switch(LOWORD(wparam)) { + case SB_LEFT: info.nPos = info.nMin; break; + case SB_RIGHT: info.nPos = info.nMax; break; + case SB_LINELEFT: info.nPos--; break; + case SB_LINERIGHT: info.nPos++; break; + case SB_PAGELEFT: info.nPos -= info.nMax >> 3; break; + case SB_PAGERIGHT: info.nPos += info.nMax >> 3; break; + case SB_THUMBTRACK: info.nPos = info.nTrackPos; break; + } + + info.fMask = SIF_POS; + SetScrollInfo((HWND)lparam, SB_CTL, &info, TRUE); + + //Windows may clamp position to scroller range + GetScrollInfo((HWND)lparam, SB_CTL, &info); + + if(dynamic_cast(object)) { + HorizontalScroller &horizontalScroller = (HorizontalScroller&)*object; + if(horizontalScroller.state.position != info.nPos) { + horizontalScroller.state.position = info.nPos; + if(horizontalScroller.onChange) horizontalScroller.onChange(); + } + } else { + VerticalScroller &verticalScroller = (VerticalScroller&)*object; + if(verticalScroller.state.position != info.nPos) { + verticalScroller.state.position = info.nPos; + if(verticalScroller.onChange) verticalScroller.onChange(); + } + } + + return TRUE; + } + + if(dynamic_cast(object)) { + HorizontalSlider &horizontalSlider = (HorizontalSlider&)*object; + if(horizontalSlider.state.position != horizontalSlider.position()) { + horizontalSlider.state.position = horizontalSlider.position(); + if(horizontalSlider.onChange) horizontalSlider.onChange(); + } + } else if(dynamic_cast(object)) { + VerticalSlider &verticalSlider = (VerticalSlider&)*object; + if(verticalSlider.state.position != verticalSlider.position()) { + verticalSlider.state.position = verticalSlider.position(); + if(verticalSlider.onChange) verticalSlider.onChange(); + } + } + + break; + } + } + + return DefWindowProc(hwnd, msg, wparam, lparam); +} + +} diff --git a/higan/phoenix/windows/desktop.cpp b/higan/phoenix/windows/desktop.cpp index 956ba521..dd6e27fb 100755 --- a/higan/phoenix/windows/desktop.cpp +++ b/higan/phoenix/windows/desktop.cpp @@ -1,9 +1,13 @@ +namespace phoenix { + Size pDesktop::size() { - return { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) }; + return {GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)}; } Geometry pDesktop::workspace() { RECT rc; SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); - return { rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top }; + return {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top}; +} + } diff --git a/higan/phoenix/windows/dialog-window.cpp b/higan/phoenix/windows/dialog-window.cpp index 5ef21153..219151ba 100755 --- a/higan/phoenix/windows/dialog-window.cpp +++ b/higan/phoenix/windows/dialog-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static string FileDialog(bool save, Window &parent, const string &path, const lstring &filter) { string dir = path; dir.replace("/", "\\"); @@ -95,4 +97,6 @@ string pDialogWindow::folderSelect(Window &parent, const string &path) { name.transform("\\", "/"); if(name.endswith("/") == false) name.append("/"); return name; -} \ No newline at end of file +} + +} diff --git a/higan/phoenix/windows/font.cpp b/higan/phoenix/windows/font.cpp index de42f24d..635f5a61 100755 --- a/higan/phoenix/windows/font.cpp +++ b/higan/phoenix/windows/font.cpp @@ -1,8 +1,28 @@ -Geometry pFont::geometry(const string &description, const string &text) { - HFONT hfont = pFont::create(description); - Geometry geometry = pFont::geometry(hfont, text); +namespace phoenix { + +string pFont::serif(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Georgia, ", size, ", ", style}; +} + +string pFont::sans(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Tahoma, ", size, ", ", style}; +} + +string pFont::monospace(unsigned size, string style) { + if(size == 0) size = 8; + if(style == "") style = "Normal"; + return {"Lucida Console, ", size, ", ", style}; +} + +Size pFont::size(const string &font, const string &text) { + HFONT hfont = pFont::create(font); + Size size = pFont::size(hfont, text); pFont::free(hfont); - return geometry; + return size; } HFONT pFont::create(const string &description) { @@ -31,14 +51,16 @@ void pFont::free(HFONT hfont) { DeleteObject(hfont); } -Geometry pFont::geometry(HFONT hfont, const string &text_) { +Size pFont::size(HFONT hfont, const string &text_) { //temporary fix: empty text string returns height of zero; bad for eg Button height string text = (text_ == "" ? " " : text_); HDC hdc = GetDC(0); SelectObject(hdc, hfont); - RECT rc = { 0, 0, 0, 0 }; + RECT rc = {0, 0, 0, 0}; DrawText(hdc, utf16_t(text), -1, &rc, DT_CALCRECT); ReleaseDC(0, hdc); - return { 0, 0, rc.right, rc.bottom }; + return {rc.right, rc.bottom}; +} + } diff --git a/higan/phoenix/windows/header.hpp b/higan/phoenix/windows/header.hpp new file mode 100644 index 00000000..fb15f5d9 --- /dev/null +++ b/higan/phoenix/windows/header.hpp @@ -0,0 +1,15 @@ +#define UNICODE +#define WINVER 0x0501 +#define _WIN32_WINNT 0x0501 +#define _WIN32_IE 0x0600 +#define __MSVCRT_VERSION__ 0x0601 +#define NOMINMAX + +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/higan/phoenix/windows/keyboard.cpp b/higan/phoenix/windows/keyboard.cpp index 1edffcb3..02177b4e 100755 --- a/higan/phoenix/windows/keyboard.cpp +++ b/higan/phoenix/windows/keyboard.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pKeyboard::initialize() { auto append = [](Keyboard::Scancode scancode, unsigned keysym) { settings->keymap.insert(scancode, keysym); @@ -135,3 +137,5 @@ vector pKeyboard::state() { return output; } + +} diff --git a/higan/phoenix/windows/message-window.cpp b/higan/phoenix/windows/message-window.cpp index fca126f4..7aaa6192 100755 --- a/higan/phoenix/windows/message-window.cpp +++ b/higan/phoenix/windows/message-window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons buttons, UINT response) { if(response == IDOK) return MessageWindow::Response::Ok; if(response == IDCANCEL) return MessageWindow::Response::Cancel; @@ -39,3 +41,5 @@ MessageWindow::Response pMessageWindow::critical(Window &parent, const string &t if(buttons == MessageWindow::Buttons::YesNo) flags |= MB_YESNO; return MessageWindow_response(buttons, MessageBox(&parent != &Window::none() ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); } + +} diff --git a/higan/phoenix/windows/mouse.cpp b/higan/phoenix/windows/mouse.cpp index e5004645..ee3a0f06 100755 --- a/higan/phoenix/windows/mouse.cpp +++ b/higan/phoenix/windows/mouse.cpp @@ -1,7 +1,9 @@ +namespace phoenix { + Position pMouse::position() { - POINT point = { 0 }; + POINT point = {0}; GetCursorPos(&point); - return { point.x, point.y }; + return {point.x, point.y}; } bool pMouse::pressed(Mouse::Button button) { @@ -11,4 +13,6 @@ bool pMouse::pressed(Mouse::Button button) { case Mouse::Button::Right: return GetAsyncKeyState(VK_RBUTTON) & 0x8000; } return false; -} \ No newline at end of file +} + +} diff --git a/higan/phoenix/windows/object.cpp b/higan/phoenix/windows/object.cpp index 78811d79..cf829e08 100755 --- a/higan/phoenix/windows/object.cpp +++ b/higan/phoenix/windows/object.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + vector pObject::objects; pObject::pObject(Object &object) : object(object) { @@ -11,3 +13,5 @@ pObject* pObject::find(unsigned id) { for(auto &item : objects) if(item->id == id) return item; return 0; } + +} diff --git a/higan/phoenix/windows/platform.cpp b/higan/phoenix/windows/platform.cpp index 1214f2c2..bcf4b30a 100755 --- a/higan/phoenix/windows/platform.cpp +++ b/higan/phoenix/windows/platform.cpp @@ -1,4 +1,5 @@ #include "platform.hpp" + #include "utility.cpp" #include "settings.cpp" @@ -7,7 +8,6 @@ #include "mouse.cpp" #include "dialog-window.cpp" #include "message-window.cpp" - #include "object.cpp" #include "font.cpp" #include "timer.cpp" @@ -23,457 +23,19 @@ #include "widget/widget.cpp" #include "widget/button.cpp" #include "widget/canvas.cpp" -#include "widget/check-box.cpp" -#include "widget/combo-box.cpp" +#include "widget/check-button.cpp" +#include "widget/combo-button.cpp" #include "widget/hex-edit.cpp" -#include "widget/horizontal-scroll-bar.cpp" +#include "widget/horizontal-scroller.cpp" #include "widget/horizontal-slider.cpp" #include "widget/label.cpp" #include "widget/line-edit.cpp" #include "widget/list-view.cpp" #include "widget/progress-bar.cpp" -#include "widget/radio-box.cpp" +#include "widget/radio-button.cpp" #include "widget/text-edit.cpp" -#include "widget/vertical-scroll-bar.cpp" +#include "widget/vertical-scroller.cpp" #include "widget/vertical-slider.cpp" #include "widget/viewport.cpp" -static bool OS_keyboardProc(HWND, UINT, WPARAM, LPARAM); -static void OS_processDialogMessage(MSG&); -static LRESULT CALLBACK OS_windowProc(HWND, UINT, WPARAM, LPARAM); - -void pOS::main() { - MSG msg; - while(GetMessage(&msg, 0, 0, 0)) { - OS_processDialogMessage(msg); - } -} - -bool pOS::pendingEvents() { - MSG msg; - return PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE); -} - -void pOS::processEvents() { - while(pendingEvents()) { - MSG msg; - if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { - OS_processDialogMessage(msg); - } - } -} - -void OS_processDialogMessage(MSG &msg) { - if(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP - || msg.message == WM_SYSKEYDOWN || msg.message == WM_SYSKEYUP) { - if(OS_keyboardProc(msg.hwnd, msg.message, msg.wParam, msg.lParam)) { - DispatchMessage(&msg); - return; - } - } - - if(!IsDialogMessage(GetForegroundWindow(), &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - -void pOS::quit() { - osQuit = true; - PostQuitMessage(0); -} - -void pOS::initialize() { - CoInitialize(0); - InitCommonControls(); - - WNDCLASS wc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); - wc.hCursor = LoadCursor(0, IDC_ARROW); - wc.hIcon = LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(2)); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = OS_windowProc; - wc.lpszClassName = L"phoenix_window"; - wc.lpszMenuName = 0; - wc.style = CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); - wc.hCursor = LoadCursor(0, IDC_ARROW); - wc.hIcon = LoadIcon(0, IDI_APPLICATION); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = Canvas_windowProc; - wc.lpszClassName = L"phoenix_canvas"; - wc.lpszMenuName = 0; - wc.style = CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); - wc.hCursor = LoadCursor(0, IDC_ARROW); - wc.hIcon = LoadIcon(0, IDI_APPLICATION); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = Label_windowProc; - wc.lpszClassName = L"phoenix_label"; - wc.lpszMenuName = 0; - wc.style = CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); - wc.hCursor = LoadCursor(0, IDC_ARROW); - wc.hIcon = LoadIcon(0, IDI_APPLICATION); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = Viewport_windowProc; - wc.lpszClassName = L"phoenix_viewport"; - wc.lpszMenuName = 0; - wc.style = CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - settings = new Settings; - pKeyboard::initialize(); -} - -static bool OS_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - if(msg != WM_KEYDOWN && msg != WM_SYSKEYDOWN && msg != WM_KEYUP && msg != WM_SYSKEYUP) return false; - - GUITHREADINFO info; - memset(&info, 0, sizeof(GUITHREADINFO)); - info.cbSize = sizeof(GUITHREADINFO); - GetGUIThreadInfo(GetCurrentThreadId(), &info); - Object *object = (Object*)GetWindowLongPtr(info.hwndFocus, GWLP_USERDATA); - if(object == nullptr) return false; - - if(dynamic_cast(object)) { - Window &window = (Window&)*object; - if(pWindow::modal.size() > 0 && !pWindow::modal.find(&window.p)) return false; - Keyboard::Keycode keysym = Keysym(wparam, lparam); - if(keysym != Keyboard::Keycode::None) { - if((msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) && window.onKeyPress) window.onKeyPress(keysym); - if((msg == WM_KEYUP || msg == WM_SYSKEYUP) && window.onKeyRelease) window.onKeyRelease(keysym); - } - return false; - } - - if(msg == WM_KEYDOWN) { - if(dynamic_cast(object)) { - ListView &listView = (ListView&)*object; - if(wparam == VK_RETURN) { - if(listView.onActivate) listView.onActivate(); - } - } else if(dynamic_cast(object)) { - LineEdit &lineEdit = (LineEdit&)*object; - if(wparam == VK_RETURN) { - if(lineEdit.onActivate) lineEdit.onActivate(); - } - } else if(dynamic_cast(object)) { - TextEdit &textEdit = (TextEdit&)*object; - if(wparam == 'A' && GetKeyState(VK_CONTROL) < 0) { - //Ctrl+A = select all text - //note: this is not a standard accelerator on Windows - Edit_SetSel(textEdit.p.hwnd, 0, ~0); - return true; - } else if(wparam == 'V' && GetKeyState(VK_CONTROL) < 0) { - //Ctrl+V = paste text - //note: this formats Unix (LF) and OS9 (CR) line-endings to Windows (CR+LF) line-endings - //this is necessary as the EDIT control only supports Windows line-endings - OpenClipboard(hwnd); - HANDLE handle = GetClipboardData(CF_UNICODETEXT); - if(handle) { - wchar_t *text = (wchar_t*)GlobalLock(handle); - if(text) { - string data = (const char*)utf8_t(text); - data.replace("\r\n", "\n"); - data.replace("\r", "\n"); - data.replace("\n", "\r\n"); - GlobalUnlock(handle); - utf16_t output(data); - HGLOBAL resource = GlobalAlloc(GMEM_MOVEABLE, (wcslen(output) + 1) * sizeof(wchar_t)); - if(resource) { - wchar_t *write = (wchar_t*)GlobalLock(resource); - if(write) { - wcscpy(write, output); - GlobalUnlock(write); - if(SetClipboardData(CF_UNICODETEXT, resource) == FALSE) { - GlobalFree(resource); - } - } - } - } - } - CloseClipboard(); - return false; - } - } - } - - return false; -} - -static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - Object *object = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if(!object || !dynamic_cast(object)) return DefWindowProc(hwnd, msg, wparam, lparam); - Window &window = (Window&)*object; - - bool process = true; - if(pWindow::modal.size() > 0 && !pWindow::modal.find(&window.p)) process = false; - if(osQuit) process = false; - - if(process) switch(msg) { - case WM_CLOSE: { - window.state.ignore = false; - if(window.onClose) window.onClose(); - if(window.state.ignore == false) { - window.setVisible(false); - window.setModal(false); - } - return TRUE; - } - - case WM_MOVE: { - if(window.p.locked) break; - - Geometry geometry = window.geometry(); - window.state.geometry.x = geometry.x; - window.state.geometry.y = geometry.y; - - if(window.onMove) window.onMove(); - break; - } - - case WM_SIZE: { - if(window.p.locked) break; - SetWindowPos(window.p.hstatus, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_FRAMECHANGED); - - Geometry geometry = window.geometry(); - window.state.geometry.width = geometry.width; - window.state.geometry.height = geometry.height; - - for(auto &layout : window.state.layout) { - Geometry geom = window.geometry(); - geom.x = geom.y = 0; - layout.setGeometry(geom); - } - - if(window.onSize) window.onSize(); - break; - } - - case WM_GETMINMAXINFO: { - MINMAXINFO *mmi = (MINMAXINFO*)lparam; - //mmi->ptMinTrackSize.x = 256 + window.p.frameMargin().width; - //mmi->ptMinTrackSize.y = 256 + window.p.frameMargin().height; - //return TRUE; - break; - } - - case WM_ERASEBKGND: { - if(window.p.brush == 0) break; - RECT rc; - GetClientRect(window.p.hwnd, &rc); - PAINTSTRUCT ps; - BeginPaint(window.p.hwnd, &ps); - FillRect(ps.hdc, &rc, window.p.brush); - EndPaint(window.p.hwnd, &ps); - return TRUE; - } - - case WM_CTLCOLORBTN: - case WM_CTLCOLORSTATIC: { - Object *object = (Object*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA); - if(object && window.p.brush) { - HDC hdc = (HDC)wparam; - SetBkColor((HDC)wparam, window.p.brushColor); - return (INT_PTR)window.p.brush; - } - break; - } - - case WM_COMMAND: { - unsigned id = LOWORD(wparam); - HWND control = GetDlgItem(window.p.hwnd, id); - if(control == 0) { - pObject *object = (pObject*)pObject::find(id); - if(!object) break; - if(dynamic_cast(object)) { - Item &item = ((pItem*)object)->item; - if(item.onActivate) item.onActivate(); - } else if(dynamic_cast(object)) { - CheckItem &checkItem = ((pCheckItem*)object)->checkItem; - checkItem.setChecked(!checkItem.state.checked); - if(checkItem.onToggle) checkItem.onToggle(); - } else if(dynamic_cast(object)) { - RadioItem &radioItem = ((pRadioItem*)object)->radioItem; - if(radioItem.state.checked == false) { - radioItem.setChecked(); - if(radioItem.onActivate) radioItem.onActivate(); - } - } - } else { - Object *object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA); - if(!object) break; - if(dynamic_cast(object)) { - Button &button = (Button&)*object; - if(button.onActivate) button.onActivate(); - } else if(dynamic_cast(object)) { - CheckBox &checkBox = (CheckBox&)*object; - checkBox.setChecked(!checkBox.state.checked); - if(checkBox.onToggle) checkBox.onToggle(); - } else if(dynamic_cast(object)) { - ComboBox &comboBox = (ComboBox&)*object; - if(HIWORD(wparam) == CBN_SELCHANGE) { - if(comboBox.state.selection != comboBox.selection()) { - comboBox.state.selection = comboBox.selection(); - if(comboBox.onChange) comboBox.onChange(); - } - } - } else if(dynamic_cast(object)) { - LineEdit &lineEdit = (LineEdit&)*object; - if(HIWORD(wparam) == EN_CHANGE) { - if(lineEdit.p.locked == false && lineEdit.onChange) lineEdit.onChange(); - } - } else if(dynamic_cast(object)) { - RadioBox &radioBox = (RadioBox&)*object; - if(radioBox.state.checked == false) { - radioBox.setChecked(); - if(radioBox.onActivate) radioBox.onActivate(); - } - } else if(dynamic_cast(object)) { - TextEdit &textEdit = (TextEdit&)*object; - if(HIWORD(wparam) == EN_CHANGE) { - if(textEdit.p.locked == false && textEdit.onChange) textEdit.onChange(); - } - } - } - break; - } - - case WM_NOTIFY: { - unsigned id = LOWORD(wparam); - HWND control = GetDlgItem(window.p.hwnd, id); - if(control == 0) break; - Object *object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA); - if(object == 0) break; - if(dynamic_cast(object)) { - ListView &listView = (ListView&)*object; - LPNMHDR nmhdr = (LPNMHDR)lparam; - LPNMLISTVIEW nmlistview = (LPNMLISTVIEW)lparam; - - if(nmhdr->code == LVN_ITEMCHANGED && (nmlistview->uChanged & LVIF_STATE)) { - unsigned imagemask = ((nmlistview->uNewState & LVIS_STATEIMAGEMASK) >> 12) - 1; - if(imagemask == 0 || imagemask == 1) { - if(listView.p.locked == false && listView.onToggle) listView.onToggle(nmlistview->iItem); - } else if((nmlistview->uOldState & LVIS_FOCUSED) && !(nmlistview->uNewState & LVIS_FOCUSED)) { - listView.p.lostFocus = true; - } else if(!(nmlistview->uOldState & LVIS_SELECTED) && (nmlistview->uNewState & LVIS_SELECTED)) { - listView.p.lostFocus = false; - listView.state.selected = true; - listView.state.selection = listView.selection(); - if(listView.p.locked == false && listView.onChange) listView.onChange(); - } else if(listView.p.lostFocus == false && listView.selected() == false) { - listView.p.lostFocus = false; - listView.state.selected = false; - listView.state.selection = 0; - if(listView.p.locked == false && listView.onChange) listView.onChange(); - } - } else if(nmhdr->code == LVN_ITEMACTIVATE) { - if(listView.onActivate) listView.onActivate(); - } else if(nmhdr->code == NM_CUSTOMDRAW) { - LPNMLVCUSTOMDRAW lvcd = (LPNMLVCUSTOMDRAW)nmhdr; - switch(lvcd->nmcd.dwDrawStage) { - case CDDS_PREPAINT: - return CDRF_NOTIFYITEMDRAW; - case CDDS_ITEMPREPAINT: - if(listView.state.headerText.size() >= 2) { - //draw alternating row colors of there are two or more columns - if(lvcd->nmcd.dwItemSpec % 2) lvcd->clrTextBk = GetSysColor(COLOR_WINDOW) ^ 0x070707; - } - return CDRF_DODEFAULT; - default: - return CDRF_DODEFAULT; - } - } - } - break; - } - - case WM_HSCROLL: - case WM_VSCROLL: { - Object *object = 0; - if(lparam) { - object = (Object*)GetWindowLongPtr((HWND)lparam, GWLP_USERDATA); - } else { - unsigned id = LOWORD(wparam); - HWND control = GetDlgItem(window.p.hwnd, id); - if(control == 0) break; - object = (Object*)GetWindowLongPtr(control, GWLP_USERDATA); - } - if(object == 0) break; - - if(dynamic_cast(object) - || dynamic_cast(object)) { - SCROLLINFO info; - memset(&info, 0, sizeof(SCROLLINFO)); - info.cbSize = sizeof(SCROLLINFO); - info.fMask = SIF_ALL; - GetScrollInfo((HWND)lparam, SB_CTL, &info); - - switch(LOWORD(wparam)) { - case SB_LEFT: info.nPos = info.nMin; break; - case SB_RIGHT: info.nPos = info.nMax; break; - case SB_LINELEFT: info.nPos--; break; - case SB_LINERIGHT: info.nPos++; break; - case SB_PAGELEFT: info.nPos -= info.nMax >> 3; break; - case SB_PAGERIGHT: info.nPos += info.nMax >> 3; break; - case SB_THUMBTRACK: info.nPos = info.nTrackPos; break; - } - - info.fMask = SIF_POS; - SetScrollInfo((HWND)lparam, SB_CTL, &info, TRUE); - - //Windows may clamp position to scrollbar range - GetScrollInfo((HWND)lparam, SB_CTL, &info); - - if(dynamic_cast(object)) { - HorizontalScrollBar &horizontalScrollBar = (HorizontalScrollBar&)*object; - if(horizontalScrollBar.state.position != info.nPos) { - horizontalScrollBar.state.position = info.nPos; - if(horizontalScrollBar.onChange) horizontalScrollBar.onChange(); - } - } else { - VerticalScrollBar &verticalScrollBar = (VerticalScrollBar&)*object; - if(verticalScrollBar.state.position != info.nPos) { - verticalScrollBar.state.position = info.nPos; - if(verticalScrollBar.onChange) verticalScrollBar.onChange(); - } - } - - return TRUE; - } - - if(dynamic_cast(object)) { - HorizontalSlider &horizontalSlider = (HorizontalSlider&)*object; - if(horizontalSlider.state.position != horizontalSlider.position()) { - horizontalSlider.state.position = horizontalSlider.position(); - if(horizontalSlider.onChange) horizontalSlider.onChange(); - } - } else if(dynamic_cast(object)) { - VerticalSlider &verticalSlider = (VerticalSlider&)*object; - if(verticalSlider.state.position != verticalSlider.position()) { - verticalSlider.state.position = verticalSlider.position(); - if(verticalSlider.onChange) verticalSlider.onChange(); - } - } - - break; - } - } - - return DefWindowProc(hwnd, msg, wparam, lparam); -} +#include "application.cpp" diff --git a/higan/phoenix/windows/platform.hpp b/higan/phoenix/windows/platform.hpp index d14685b2..f4aa0169 100755 --- a/higan/phoenix/windows/platform.hpp +++ b/higan/phoenix/windows/platform.hpp @@ -1,3 +1,14 @@ +namespace phoenix { + +struct pApplication { + static void run(); + static bool pendingEvents(); + static void processEvents(); + static void quit(); + + static void initialize(); +}; + struct Settings { bidirectional_map keymap; }; @@ -9,14 +20,15 @@ struct pMenu; struct pLayout; struct pWidget; -static bool osQuit = false; - struct pFont { - static Geometry geometry(const string &description, const string &text); + static string serif(unsigned size, string style); + static string sans(unsigned size, string style); + static string monospace(unsigned size, string style); + static Size size(const string &font, const string &text); static HFONT create(const string &description); static void free(HFONT hfont); - static Geometry geometry(HFONT hfont, const string &text); + static Size size(HFONT hfont, const string &text); }; struct pDesktop { @@ -64,15 +76,6 @@ struct pObject { void destructor() {} }; -struct pOS : public pObject { - static void main(); - static bool pendingEvents(); - static void processEvents(); - static void quit(); - - static void initialize(); -}; - struct pTimer : public pObject { Timer &timer; UINT_PTR htimer; @@ -224,7 +227,7 @@ struct pWidget : public pSizable { bool enabled(); bool focused(); - virtual Geometry minimumGeometry(); + virtual Size minimumSize(); void setEnabled(bool enabled); void setFocused(); void setFont(const string &font); @@ -244,7 +247,7 @@ struct pButton : public pWidget { HBITMAP hbitmap; HIMAGELIST himagelist; - Geometry minimumGeometry(); + Size minimumSize(); void setImage(const image &image, Orientation orientation); void setText(const string &text); @@ -268,32 +271,32 @@ struct pCanvas : public pWidget { void paint(); }; -struct pCheckBox : public pWidget { - CheckBox &checkBox; +struct pCheckButton : public pWidget { + CheckButton &checkButton; bool checked(); - Geometry minimumGeometry(); + Size minimumSize(); void setChecked(bool checked); void setText(const string &text); - pCheckBox(CheckBox &checkBox) : pWidget(checkBox), checkBox(checkBox) {} + pCheckButton(CheckButton &checkButton) : pWidget(checkButton), checkButton(checkButton) {} void constructor(); void destructor(); void orphan(); }; -struct pComboBox : public pWidget { - ComboBox &comboBox; +struct pComboButton : public pWidget { + ComboButton &comboButton; void append(const string &text); void modify(unsigned row, const string &text); void remove(unsigned row); - Geometry minimumGeometry(); + Size minimumSize(); void reset(); unsigned selection(); void setSelection(unsigned row); - pComboBox(ComboBox &comboBox) : pWidget(comboBox), comboBox(comboBox) {} + pComboButton(ComboButton &comboButton) : pWidget(comboButton), comboButton(comboButton) {} void constructor(); void destructor(); void orphan(); @@ -317,15 +320,15 @@ struct pHexEdit : public pWidget { bool keyPress(unsigned key); }; -struct pHorizontalScrollBar : public pWidget { - HorizontalScrollBar &horizontalScrollBar; +struct pHorizontalScroller : public pWidget { + HorizontalScroller &horizontalScroller; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); - pHorizontalScrollBar(HorizontalScrollBar &horizontalScrollBar) : pWidget(horizontalScrollBar), horizontalScrollBar(horizontalScrollBar) {} + pHorizontalScroller(HorizontalScroller &horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {} void constructor(); void destructor(); void orphan(); @@ -334,7 +337,7 @@ struct pHorizontalScrollBar : public pWidget { struct pHorizontalSlider : public pWidget { HorizontalSlider &horizontalSlider; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -348,7 +351,7 @@ struct pHorizontalSlider : public pWidget { struct pLabel : public pWidget { Label &label; - Geometry minimumGeometry(); + Size minimumSize(); void setText(const string &text); pLabel(Label &label) : pWidget(label), label(label) {} @@ -360,7 +363,7 @@ struct pLabel : public pWidget { struct pLineEdit : public pWidget { LineEdit &lineEdit; - Geometry minimumGeometry(); + Size minimumSize(); void setEditable(bool editable); void setText(const string &text); string text(); @@ -405,7 +408,7 @@ struct pListView : public pWidget { struct pProgressBar : public pWidget { ProgressBar &progressBar; - Geometry minimumGeometry(); + Size minimumSize(); void setPosition(unsigned position); pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {} @@ -414,16 +417,16 @@ struct pProgressBar : public pWidget { void orphan(); }; -struct pRadioBox : public pWidget { - RadioBox &radioBox; +struct pRadioButton : public pWidget { + RadioButton &radioButton; bool checked(); - Geometry minimumGeometry(); + Size minimumSize(); void setChecked(); - void setGroup(const set &group); + void setGroup(const set &group); void setText(const string &text); - pRadioBox(RadioBox &radioBox) : pWidget(radioBox), radioBox(radioBox) {} + pRadioButton(RadioButton &radioButton) : pWidget(radioButton), radioButton(radioButton) {} void constructor(); void destructor(); void orphan(); @@ -444,15 +447,15 @@ struct pTextEdit : public pWidget { void orphan(); }; -struct pVerticalScrollBar : public pWidget { - VerticalScrollBar &verticalScrollBar; +struct pVerticalScroller : public pWidget { + VerticalScroller &verticalScroller; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); - pVerticalScrollBar(VerticalScrollBar &verticalScrollBar) : pWidget(verticalScrollBar), verticalScrollBar(verticalScrollBar) {} + pVerticalScroller(VerticalScroller &verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {} void constructor(); void destructor(); void orphan(); @@ -461,7 +464,7 @@ struct pVerticalScrollBar : public pWidget { struct pVerticalSlider : public pWidget { VerticalSlider &verticalSlider; - Geometry minimumGeometry(); + Size minimumSize(); unsigned position(); void setLength(unsigned length); void setPosition(unsigned position); @@ -482,3 +485,5 @@ struct pViewport : public pWidget { void destructor(); void orphan(); }; + +} diff --git a/higan/phoenix/windows/settings.cpp b/higan/phoenix/windows/settings.cpp index 343fc9fb..153c9b91 100755 --- a/higan/phoenix/windows/settings.cpp +++ b/higan/phoenix/windows/settings.cpp @@ -1 +1,5 @@ -static Settings *settings = nullptr; \ No newline at end of file +namespace phoenix { + +static Settings *settings = nullptr; + +} diff --git a/higan/phoenix/windows/timer.cpp b/higan/phoenix/windows/timer.cpp index 99fb5c00..08234c2c 100755 --- a/higan/phoenix/windows/timer.cpp +++ b/higan/phoenix/windows/timer.cpp @@ -1,9 +1,11 @@ +namespace phoenix { + static vector timers; static void CALLBACK Timer_timeoutProc(HWND hwnd, UINT msg, UINT_PTR timerID, DWORD time) { for(auto &timer : timers) { if(timer->htimer == timerID) { - if(timer->timer.onTimeout) timer->timer.onTimeout(); + if(timer->timer.onActivate) timer->timer.onActivate(); return; } } @@ -29,3 +31,5 @@ void pTimer::constructor() { timers.append(this); htimer = 0; } + +} diff --git a/higan/phoenix/windows/utility.cpp b/higan/phoenix/windows/utility.cpp index c247d5cc..0e7ddb62 100755 --- a/higan/phoenix/windows/utility.cpp +++ b/higan/phoenix/windows/utility.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static const unsigned Windows2000 = 0x0500; static const unsigned WindowsXP = 0x0501; static const unsigned WindowsVista = 0x0600; @@ -148,3 +150,5 @@ static Keyboard::Keycode Keysym(unsigned keysym, unsigned keyflags) { #undef shifted #undef extended } + +} diff --git a/higan/phoenix/windows/widget/button.cpp b/higan/phoenix/windows/widget/button.cpp index 12cacbe5..55e4cc9d 100755 --- a/higan/phoenix/windows/widget/button.cpp +++ b/higan/phoenix/windows/widget/button.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + #ifndef Button_SetImageList //MinGW/32-bit has painfully outdated platform headers ... typedef struct { @@ -17,20 +19,20 @@ #define Button_SetImageList(hwnd, pbuttonImagelist) (WINBOOL)SNDMSG((hwnd),BCM_SETIMAGELIST,0,(LPARAM)(pbuttonImagelist)) #endif -Geometry pButton::minimumGeometry() { - Geometry geometry = pFont::geometry(hfont, button.state.text); +Size pButton::minimumSize() { + Size size = pFont::size(hfont, button.state.text); if(button.state.orientation == Orientation::Horizontal) { - geometry.width += button.state.image.width; - geometry.height = max(button.state.image.height, geometry.height); + size.width += button.state.image.width; + size.height = max(button.state.image.height, size.height); } if(button.state.orientation == Orientation::Vertical) { - geometry.width = max(button.state.image.width, geometry.width); - geometry.height += button.state.image.height; + size.width = max(button.state.image.width, size.width); + size.height += button.state.image.height; } - return { 0, 0, geometry.width + 20, geometry.height + 10 }; + return {size.width + 20, size.height + 10}; } void pButton::setImage(const image &image, Orientation orientation) { @@ -103,3 +105,5 @@ void pButton::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/windows/widget/canvas.cpp b/higan/phoenix/windows/widget/canvas.cpp index f2be9e38..b34f22e5 100755 --- a/higan/phoenix/windows/widget/canvas.cpp +++ b/higan/phoenix/windows/widget/canvas.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static LRESULT CALLBACK Canvas_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { Object *object = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if(object == nullptr) return DefWindowProc(hwnd, msg, wparam, lparam); @@ -90,3 +92,5 @@ void pCanvas::paint() { SetDIBitsToDevice(ps.hdc, 0, 0, width, height, 0, 0, 0, height, (void*)data, &bmi, DIB_RGB_COLORS); EndPaint(hwnd, &ps); } + +} diff --git a/higan/phoenix/windows/widget/check-box.cpp b/higan/phoenix/windows/widget/check-box.cpp deleted file mode 100755 index 8f0d2eb8..00000000 --- a/higan/phoenix/windows/widget/check-box.cpp +++ /dev/null @@ -1,39 +0,0 @@ -bool pCheckBox::checked() { - return SendMessage(hwnd, BM_GETCHECK, 0, 0); -} - -Geometry pCheckBox::minimumGeometry() { - Geometry geometry = pFont::geometry(hfont, checkBox.state.text); - return { 0, 0, geometry.width + 20, geometry.height + 4 }; -} - -void pCheckBox::setChecked(bool checked) { - SendMessage(hwnd, BM_SETCHECK, (WPARAM)checked, 0); -} - -void pCheckBox::setText(const string &text) { - SetWindowText(hwnd, utf16_t(text)); -} - -void pCheckBox::constructor() { - hwnd = CreateWindow( - L"BUTTON", L"", - WS_CHILD | WS_TABSTOP | BS_CHECKBOX, - 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 - ); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&checkBox); - setDefaultFont(); - if(checkBox.state.checked) setChecked(true); - setText(checkBox.state.text); - synchronize(); - -} - -void pCheckBox::destructor() { - DestroyWindow(hwnd); -} - -void pCheckBox::orphan() { - destructor(); - constructor(); -} diff --git a/higan/phoenix/windows/widget/check-button.cpp b/higan/phoenix/windows/widget/check-button.cpp new file mode 100644 index 00000000..a7a13a1b --- /dev/null +++ b/higan/phoenix/windows/widget/check-button.cpp @@ -0,0 +1,43 @@ +namespace phoenix { + +bool pCheckButton::checked() { + return SendMessage(hwnd, BM_GETCHECK, 0, 0); +} + +Size pCheckButton::minimumSize() { + Size size = pFont::size(hfont, checkButton.state.text); + return {size.width + 20, size.height + 4}; +} + +void pCheckButton::setChecked(bool checked) { + SendMessage(hwnd, BM_SETCHECK, (WPARAM)checked, 0); +} + +void pCheckButton::setText(const string &text) { + SetWindowText(hwnd, utf16_t(text)); +} + +void pCheckButton::constructor() { + hwnd = CreateWindow( + L"BUTTON", L"", + WS_CHILD | WS_TABSTOP | BS_CHECKBOX, + 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 + ); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&checkButton); + setDefaultFont(); + if(checkButton.state.checked) setChecked(true); + setText(checkButton.state.text); + synchronize(); + +} + +void pCheckButton::destructor() { + DestroyWindow(hwnd); +} + +void pCheckButton::orphan() { + destructor(); + constructor(); +} + +} diff --git a/higan/phoenix/windows/widget/combo-box.cpp b/higan/phoenix/windows/widget/combo-button.cpp old mode 100755 new mode 100644 similarity index 61% rename from higan/phoenix/windows/widget/combo-box.cpp rename to higan/phoenix/windows/widget/combo-button.cpp index bff1170d..0d81f46e --- a/higan/phoenix/windows/widget/combo-box.cpp +++ b/higan/phoenix/windows/widget/combo-button.cpp @@ -1,15 +1,17 @@ -void pComboBox::append(const string &text) { +namespace phoenix { + +void pComboButton::append(const string &text) { SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(wchar_t*)utf16_t(text)); if(SendMessage(hwnd, CB_GETCOUNT, 0, 0) == 1) setSelection(0); } -Geometry pComboBox::minimumGeometry() { +Size pComboButton::minimumSize() { unsigned maximumWidth = 0; - for(auto &text : comboBox.state.text) maximumWidth = max(maximumWidth, pFont::geometry(hfont, text).width); - return { 0, 0, maximumWidth + 24, pFont::geometry(hfont, " ").height + 10 }; + for(auto &text : comboButton.state.text) maximumWidth = max(maximumWidth, pFont::size(hfont, text).width); + return {maximumWidth + 24, pFont::size(hfont, " ").height + 10}; } -void pComboBox::modify(unsigned row, const string &text) { +void pComboButton::modify(unsigned row, const string &text) { locked = true; unsigned position = selection(); SendMessage(hwnd, CB_DELETESTRING, row, 0); @@ -18,7 +20,7 @@ void pComboBox::modify(unsigned row, const string &text) { locked = false; } -void pComboBox::remove(unsigned row) { +void pComboButton::remove(unsigned row) { locked = true; unsigned position = selection(); SendMessage(hwnd, CB_DELETESTRING, row, 0); @@ -26,45 +28,47 @@ void pComboBox::remove(unsigned row) { locked = false; } -void pComboBox::reset() { +void pComboButton::reset() { SendMessage(hwnd, CB_RESETCONTENT, 0, 0); } -unsigned pComboBox::selection() { +unsigned pComboButton::selection() { return SendMessage(hwnd, CB_GETCURSEL, 0, 0); } -void pComboBox::setSelection(unsigned row) { +void pComboButton::setSelection(unsigned row) { SendMessage(hwnd, CB_SETCURSEL, row, 0); } -void pComboBox::constructor() { +void pComboButton::constructor() { hwnd = CreateWindow( L"COMBOBOX", L"", WS_CHILD | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_HASSTRINGS, 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 ); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&comboBox); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&comboButton); setDefaultFont(); - for(auto &text : comboBox.state.text) append(text); - setSelection(comboBox.state.selection); + for(auto &text : comboButton.state.text) append(text); + setSelection(comboButton.state.selection); synchronize(); } -void pComboBox::destructor() { +void pComboButton::destructor() { DestroyWindow(hwnd); } -void pComboBox::orphan() { +void pComboButton::orphan() { destructor(); constructor(); } -void pComboBox::setGeometry(const Geometry &geometry) { +void pComboButton::setGeometry(const Geometry &geometry) { SetWindowPos(hwnd, NULL, geometry.x, geometry.y, geometry.width, 1, SWP_NOZORDER); RECT rc; GetWindowRect(hwnd, &rc); unsigned adjustedHeight = geometry.height - ((rc.bottom - rc.top) - SendMessage(hwnd, CB_GETITEMHEIGHT, (WPARAM)-1, 0)); SendMessage(hwnd, CB_SETITEMHEIGHT, (WPARAM)-1, adjustedHeight); } + +} diff --git a/higan/phoenix/windows/widget/hex-edit.cpp b/higan/phoenix/windows/widget/hex-edit.cpp index 789f4faf..5909e63f 100755 --- a/higan/phoenix/windows/widget/hex-edit.cpp +++ b/higan/phoenix/windows/widget/hex-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static LRESULT CALLBACK HexEdit_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { HexEdit &hexEdit = *(HexEdit*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if(msg == WM_CHAR) { @@ -134,3 +136,5 @@ bool pHexEdit::keyPress(unsigned scancode) { return true; } + +} diff --git a/higan/phoenix/windows/widget/horizontal-scroll-bar.cpp b/higan/phoenix/windows/widget/horizontal-scroll-bar.cpp deleted file mode 100755 index 250ac247..00000000 --- a/higan/phoenix/windows/widget/horizontal-scroll-bar.cpp +++ /dev/null @@ -1,38 +0,0 @@ -Geometry pHorizontalScrollBar::minimumGeometry() { - return { 0, 0, 0, 18 }; -} - -unsigned pHorizontalScrollBar::position() { - return GetScrollPos(hwnd, SB_CTL); -} - -void pHorizontalScrollBar::setLength(unsigned length) { - length += (length == 0); - SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE); - horizontalScrollBar.setPosition(0); -} - -void pHorizontalScrollBar::setPosition(unsigned position) { - SetScrollPos(hwnd, SB_CTL, position, TRUE); -} - -void pHorizontalScrollBar::constructor() { - hwnd = CreateWindow( - L"SCROLLBAR", L"", WS_CHILD | WS_TABSTOP | SBS_HORZ, - 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 - ); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&horizontalScrollBar); - unsigned position = horizontalScrollBar.state.position; - setLength(horizontalScrollBar.state.length); - horizontalScrollBar.setPosition(position); - synchronize(); -} - -void pHorizontalScrollBar::destructor() { - DestroyWindow(hwnd); -} - -void pHorizontalScrollBar::orphan() { - destructor(); - constructor(); -} diff --git a/higan/phoenix/windows/widget/horizontal-scroller.cpp b/higan/phoenix/windows/widget/horizontal-scroller.cpp new file mode 100644 index 00000000..8fe3c3d9 --- /dev/null +++ b/higan/phoenix/windows/widget/horizontal-scroller.cpp @@ -0,0 +1,42 @@ +namespace phoenix { + +Size pHorizontalScroller::minimumSize() { + return {0, 18}; +} + +unsigned pHorizontalScroller::position() { + return GetScrollPos(hwnd, SB_CTL); +} + +void pHorizontalScroller::setLength(unsigned length) { + length += (length == 0); + SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE); + horizontalScroller.setPosition(0); +} + +void pHorizontalScroller::setPosition(unsigned position) { + SetScrollPos(hwnd, SB_CTL, position, TRUE); +} + +void pHorizontalScroller::constructor() { + hwnd = CreateWindow( + L"SCROLLBAR", L"", WS_CHILD | WS_TABSTOP | SBS_HORZ, + 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 + ); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&horizontalScroller); + unsigned position = horizontalScroller.state.position; + setLength(horizontalScroller.state.length); + horizontalScroller.setPosition(position); + synchronize(); +} + +void pHorizontalScroller::destructor() { + DestroyWindow(hwnd); +} + +void pHorizontalScroller::orphan() { + destructor(); + constructor(); +} + +} diff --git a/higan/phoenix/windows/widget/horizontal-slider.cpp b/higan/phoenix/windows/widget/horizontal-slider.cpp index 807086ae..b4e1bbd4 100755 --- a/higan/phoenix/windows/widget/horizontal-slider.cpp +++ b/higan/phoenix/windows/widget/horizontal-slider.cpp @@ -1,5 +1,7 @@ -Geometry pHorizontalSlider::minimumGeometry() { - return { 0, 0, 0, 25 }; +namespace phoenix { + +Size pHorizontalSlider::minimumSize() { + return {0, 25}; } unsigned pHorizontalSlider::position() { @@ -37,3 +39,5 @@ void pHorizontalSlider::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/windows/widget/label.cpp b/higan/phoenix/windows/widget/label.cpp index 56f0d433..772cd8b3 100755 --- a/higan/phoenix/windows/widget/label.cpp +++ b/higan/phoenix/windows/widget/label.cpp @@ -1,6 +1,8 @@ -Geometry pLabel::minimumGeometry() { - Geometry geometry = pFont::geometry(hfont, label.state.text); - return { 0, 0, geometry.width, geometry.height }; +namespace phoenix { + +Size pLabel::minimumSize() { + Size size = pFont::size(hfont, label.state.text); + return {size.width, size.height}; } void pLabel::setText(const string &text) { @@ -62,3 +64,5 @@ static LRESULT CALLBACK Label_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPA return DefWindowProc(hwnd, msg, wparam, lparam); } + +} diff --git a/higan/phoenix/windows/widget/line-edit.cpp b/higan/phoenix/windows/widget/line-edit.cpp index eb6a8fb7..464865cd 100755 --- a/higan/phoenix/windows/widget/line-edit.cpp +++ b/higan/phoenix/windows/widget/line-edit.cpp @@ -1,6 +1,8 @@ -Geometry pLineEdit::minimumGeometry() { - Geometry geometry = pFont::geometry(hfont, lineEdit.state.text); - return { 0, 0, geometry.width + 12, geometry.height + 10 }; +namespace phoenix { + +Size pLineEdit::minimumSize() { + Size size = pFont::size(hfont, lineEdit.state.text); + return {size.width + 12, size.height + 10}; } void pLineEdit::setEditable(bool editable) { @@ -43,3 +45,5 @@ void pLineEdit::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/windows/widget/list-view.cpp b/higan/phoenix/windows/widget/list-view.cpp index 675691e6..9a13d135 100755 --- a/higan/phoenix/windows/widget/list-view.cpp +++ b/higan/phoenix/windows/widget/list-view.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + unsigned ListView_GetColumnCount(HWND hwnd) { unsigned count = 0; LVCOLUMN column; @@ -241,3 +243,5 @@ void pListView::buildImageList() { } } } + +} diff --git a/higan/phoenix/windows/widget/progress-bar.cpp b/higan/phoenix/windows/widget/progress-bar.cpp index f4703f1e..4b438e8b 100755 --- a/higan/phoenix/windows/widget/progress-bar.cpp +++ b/higan/phoenix/windows/widget/progress-bar.cpp @@ -1,5 +1,7 @@ -Geometry pProgressBar::minimumGeometry() { - return { 0, 0, 0, 23 }; +namespace phoenix { + +Size pProgressBar::minimumSize() { + return {0, 23}; } void pProgressBar::setPosition(unsigned position) { @@ -23,3 +25,5 @@ void pProgressBar::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/windows/widget/radio-box.cpp b/higan/phoenix/windows/widget/radio-box.cpp deleted file mode 100755 index ebcb1edc..00000000 --- a/higan/phoenix/windows/widget/radio-box.cpp +++ /dev/null @@ -1,43 +0,0 @@ -bool pRadioBox::checked() { - return SendMessage(hwnd, BM_GETCHECK, 0, 0); -} - -Geometry pRadioBox::minimumGeometry() { - Geometry geometry = pFont::geometry(hfont, radioBox.state.text); - return { 0, 0, geometry.width + 20, geometry.height + 4 }; -} - -void pRadioBox::setChecked() { - for(auto &item : radioBox.state.group) { - SendMessage(item.p.hwnd, BM_SETCHECK, (WPARAM)(&item == &radioBox), 0); - } -} - -void pRadioBox::setGroup(const set &group) { -} - -void pRadioBox::setText(const string &text) { - SetWindowText(hwnd, utf16_t(text)); -} - -void pRadioBox::constructor() { - hwnd = CreateWindow( - L"BUTTON", L"", - WS_CHILD | WS_TABSTOP | BS_RADIOBUTTON, - 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 - ); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&radioBox); - setDefaultFont(); - if(radioBox.state.checked) setChecked(); - setText(radioBox.state.text); - synchronize(); -} - -void pRadioBox::destructor() { - DestroyWindow(hwnd); -} - -void pRadioBox::orphan() { - destructor(); - constructor(); -} diff --git a/higan/phoenix/windows/widget/radio-button.cpp b/higan/phoenix/windows/widget/radio-button.cpp new file mode 100644 index 00000000..9ddf8d2d --- /dev/null +++ b/higan/phoenix/windows/widget/radio-button.cpp @@ -0,0 +1,47 @@ +namespace phoenix { + +bool pRadioButton::checked() { + return SendMessage(hwnd, BM_GETCHECK, 0, 0); +} + +Size pRadioButton::minimumSize() { + Size size = pFont::size(hfont, radioButton.state.text); + return {size.width + 20, size.height + 4}; +} + +void pRadioButton::setChecked() { + for(auto &item : radioButton.state.group) { + SendMessage(item.p.hwnd, BM_SETCHECK, (WPARAM)(&item == &radioButton), 0); + } +} + +void pRadioButton::setGroup(const set &group) { +} + +void pRadioButton::setText(const string &text) { + SetWindowText(hwnd, utf16_t(text)); +} + +void pRadioButton::constructor() { + hwnd = CreateWindow( + L"BUTTON", L"", + WS_CHILD | WS_TABSTOP | BS_RADIOBUTTON, + 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 + ); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&radioButton); + setDefaultFont(); + if(radioButton.state.checked) setChecked(); + setText(radioButton.state.text); + synchronize(); +} + +void pRadioButton::destructor() { + DestroyWindow(hwnd); +} + +void pRadioButton::orphan() { + destructor(); + constructor(); +} + +} diff --git a/higan/phoenix/windows/widget/text-edit.cpp b/higan/phoenix/windows/widget/text-edit.cpp index 8e1df517..e788fd49 100755 --- a/higan/phoenix/windows/widget/text-edit.cpp +++ b/higan/phoenix/windows/widget/text-edit.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + void pTextEdit::setCursorPosition(unsigned position) { if(position == ~0) position >>= 1; //Edit_SetSel takes signed type Edit_SetSel(hwnd, position, position); @@ -56,3 +58,5 @@ void pTextEdit::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/windows/widget/vertical-scroll-bar.cpp b/higan/phoenix/windows/widget/vertical-scroll-bar.cpp deleted file mode 100755 index dcc281f2..00000000 --- a/higan/phoenix/windows/widget/vertical-scroll-bar.cpp +++ /dev/null @@ -1,38 +0,0 @@ -Geometry pVerticalScrollBar::minimumGeometry() { - return { 0, 0, 18, 0 }; -} - -unsigned pVerticalScrollBar::position() { - return GetScrollPos(hwnd, SB_CTL); -} - -void pVerticalScrollBar::setLength(unsigned length) { - length += (length == 0); - SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE); - verticalScrollBar.setPosition(0); -} - -void pVerticalScrollBar::setPosition(unsigned position) { - SetScrollPos(hwnd, SB_CTL, position, TRUE); -} - -void pVerticalScrollBar::constructor() { - hwnd = CreateWindow( - L"SCROLLBAR", L"", WS_CHILD | SBS_VERT, - 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 - ); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&verticalScrollBar); - unsigned position = verticalScrollBar.state.position; - setLength(verticalScrollBar.state.length); - verticalScrollBar.setPosition(position); - synchronize(); -} - -void pVerticalScrollBar::destructor() { - DestroyWindow(hwnd); -} - -void pVerticalScrollBar::orphan() { - destructor(); - constructor(); -} diff --git a/higan/phoenix/windows/widget/vertical-scroller.cpp b/higan/phoenix/windows/widget/vertical-scroller.cpp new file mode 100644 index 00000000..84a3b74c --- /dev/null +++ b/higan/phoenix/windows/widget/vertical-scroller.cpp @@ -0,0 +1,42 @@ +namespace phoenix { + +Size pVerticalScroller::minimumSize() { + return {18, 0}; +} + +unsigned pVerticalScroller::position() { + return GetScrollPos(hwnd, SB_CTL); +} + +void pVerticalScroller::setLength(unsigned length) { + length += (length == 0); + SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE); + verticalScroller.setPosition(0); +} + +void pVerticalScroller::setPosition(unsigned position) { + SetScrollPos(hwnd, SB_CTL, position, TRUE); +} + +void pVerticalScroller::constructor() { + hwnd = CreateWindow( + L"SCROLLBAR", L"", WS_CHILD | SBS_VERT, + 0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0 + ); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&verticalScroller); + unsigned position = verticalScroller.state.position; + setLength(verticalScroller.state.length); + verticalScroller.setPosition(position); + synchronize(); +} + +void pVerticalScroller::destructor() { + DestroyWindow(hwnd); +} + +void pVerticalScroller::orphan() { + destructor(); + constructor(); +} + +} diff --git a/higan/phoenix/windows/widget/vertical-slider.cpp b/higan/phoenix/windows/widget/vertical-slider.cpp index ac5cb1ce..c4924557 100755 --- a/higan/phoenix/windows/widget/vertical-slider.cpp +++ b/higan/phoenix/windows/widget/vertical-slider.cpp @@ -1,5 +1,7 @@ -Geometry pVerticalSlider::minimumGeometry() { - return { 0, 0, 0, 25 }; +namespace phoenix { + +Size pVerticalSlider::minimumSize() { + return {0, 25}; } unsigned pVerticalSlider::position() { @@ -37,3 +39,5 @@ void pVerticalSlider::orphan() { destructor(); constructor(); } + +} diff --git a/higan/phoenix/windows/widget/viewport.cpp b/higan/phoenix/windows/widget/viewport.cpp index c0b13b69..72a4a143 100755 --- a/higan/phoenix/windows/widget/viewport.cpp +++ b/higan/phoenix/windows/widget/viewport.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + static LRESULT CALLBACK Viewport_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { Object *object = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if(object == nullptr) return DefWindowProc(hwnd, msg, wparam, lparam); @@ -54,4 +56,6 @@ void pViewport::destructor() { void pViewport::orphan() { destructor(); constructor(); -} \ No newline at end of file +} + +} diff --git a/higan/phoenix/windows/widget/widget.cpp b/higan/phoenix/windows/widget/widget.cpp index d8c25c9b..1c6abd69 100755 --- a/higan/phoenix/windows/widget/widget.cpp +++ b/higan/phoenix/windows/widget/widget.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + bool pWidget::enabled() { return IsWindowEnabled(hwnd); } @@ -6,8 +8,8 @@ bool pWidget::focused() { return GetFocus() == hwnd; } -Geometry pWidget::minimumGeometry() { - return {0, 0, 0, 0}; +Size pWidget::minimumSize() { + return {0, 0}; } void pWidget::setEnabled(bool enabled) { @@ -57,7 +59,7 @@ void pWidget::orphan() { void pWidget::setDefaultFont() { string description = widget.state.font; - if(description == "") description = "Tahoma, 8"; + if(description.empty()) description = "Tahoma, 8"; hfont = pFont::create(description); SendMessage(hwnd, WM_SETFONT, (WPARAM)hfont, 0); } @@ -68,3 +70,5 @@ void pWidget::synchronize() { widget.setEnabled(widget.enabled()); widget.setVisible(widget.visible()); } + +} diff --git a/higan/phoenix/windows/window.cpp b/higan/phoenix/windows/window.cpp index dc8aea28..515effec 100755 --- a/higan/phoenix/windows/window.cpp +++ b/higan/phoenix/windows/window.cpp @@ -1,3 +1,5 @@ +namespace phoenix { + vector pWindow::modal; void pWindow::updateModality() { @@ -32,9 +34,10 @@ void pWindow::append(Menu &menu) { void pWindow::append(Widget &widget) { widget.p.parentWindow = &window; widget.p.orphan(); - if(widget.state.font != "") widget.p.setFont(widget.state.font); - else if(window.state.widgetFont != "") widget.p.setFont(window.state.widgetFont); - else widget.p.setFont("Tahoma, 8"); + + if(widget.font().empty() && !window.state.widgetFont.empty()) { + widget.setFont(window.state.widgetFont); + } } Color pWindow::backgroundColor() { @@ -146,12 +149,16 @@ void pWindow::setMenuVisible(bool visible) { } void pWindow::setModal(bool modality) { - if(modality == false) { - if(auto position = modal.find(this)) modal.remove(position()); - } else { + if(modality == true) { modal.appendonce(this); + updateModality(); + while(window.state.modal) { + Application::processEvents(); + usleep(20 * 1000); + } + if(auto position = modal.find(this)) modal.remove(position()); + updateModality(); } - updateModality(); } void pWindow::setResizable(bool resizable) { @@ -186,9 +193,6 @@ void pWindow::setVisible(bool visible) { } void pWindow::setWidgetFont(const string &font) { - for(auto &widget : window.state.widget) { - if(widget.state.font == "") widget.setFont(font); - } } void pWindow::constructor() { @@ -227,3 +231,5 @@ void pWindow::updateMenu() { SetMenu(hwnd, window.state.menuVisible ? hmenu : 0); } + +} diff --git a/higan/sfc/controller/usart/usart.cpp b/higan/sfc/controller/usart/usart.cpp index 54879d57..f66f6b03 100755 --- a/higan/sfc/controller/usart/usart.cpp +++ b/higan/sfc/controller/usart/usart.cpp @@ -131,7 +131,7 @@ USART::USART(bool port) : Controller(port) { } USART::~USART() { - if(opened()) close(); + if(open()) close(); } #endif diff --git a/higan/target-ethos/bootstrap.cpp b/higan/target-ethos/bootstrap.cpp index 4be57460..49649660 100755 --- a/higan/target-ethos/bootstrap.cpp +++ b/higan/target-ethos/bootstrap.cpp @@ -4,7 +4,7 @@ #include //#include -void Application::bootstrap() { +void Program::bootstrap() { interface = new Interface; emulator.append(new Famicom::Interface); diff --git a/higan/target-ethos/configuration/configuration.cpp b/higan/target-ethos/configuration/configuration.cpp index 5024772e..5b24f2e2 100755 --- a/higan/target-ethos/configuration/configuration.cpp +++ b/higan/target-ethos/configuration/configuration.cpp @@ -33,10 +33,10 @@ Configuration::Configuration() { } void Configuration::load() { - configuration::load(application->path("settings.cfg")); + configuration::load(program->path("settings.cfg")); save(); //creates file if it does not exist } void Configuration::save() { - configuration::save(application->path("settings.cfg")); + configuration::save(program->path("settings.cfg")); } diff --git a/higan/target-ethos/ethos.cpp b/higan/target-ethos/ethos.cpp index 4c7ba66d..d9049a2c 100755 --- a/higan/target-ethos/ethos.cpp +++ b/higan/target-ethos/ethos.cpp @@ -2,26 +2,28 @@ #include "bootstrap.cpp" #include "resource/resource.cpp" -Application *application = nullptr; +Program *program = nullptr; DSP dspaudio; Emulator::Interface& system() { - if(application->active == nullptr) throw; - return *application->active; + if(program->active == nullptr) throw; + return *program->active; } -bool Application::focused() { +bool Program::focused() { return config->input.focusAllow || presentation->focused(); } -string Application::path(const string &filename) { +//look for file in executable path; if not found, use user path instead +//this allows configuration files to be placed in either location +string Program::path(const string &filename) { string path = {basepath, filename}; if(file::exists(path)) return path; if(directory::exists(path)) return path; return {userpath, filename}; } -void Application::run() { +void Program::main() { inputManager->poll(); utility->updateStatus(); autopause = config->input.focusPause && presentation->focused() == false; @@ -35,11 +37,10 @@ void Application::run() { system().run(); } -Application::Application(int argc, char **argv) { +Program::Program(int argc, char **argv) { ananke.open("ananke"); - application = this; - quit = false; + program = this; pause = false; autopause = false; @@ -50,16 +51,16 @@ Application::Application(int argc, char **argv) { bootstrap(); active = nullptr; - if(Intrinsics::platform() == Intrinsics::Platform::Windows) { - normalFont = "Tahoma, 8"; - boldFont = "Tahoma, 8, Bold"; - titleFont = "Tahoma, 16, Bold"; - monospaceFont = "Lucida Console, 8"; + if(Intrinsics::platform() == Intrinsics::Platform::OSX) { + normalFont = Font::sans(12); + boldFont = Font::sans(12, "Bold"); + titleFont = Font::sans(24, "Bold"); + monospaceFont = Font::monospace(8); } else { - normalFont = "Sans, 8"; - boldFont = "Sans, 8, Bold"; - titleFont = "Sans, 16, Bold"; - monospaceFont = "Liberation Mono, 8"; + normalFont = Font::sans(8); + boldFont = Font::sans(8, "Bold"); + titleFont = Font::sans(16, "Bold"); + monospaceFont = Font::monospace(8); } config = new Configuration; @@ -107,14 +108,12 @@ Application::Application(int argc, char **argv) { utility->updateShader(); if(config->video.startFullScreen && argc >= 2) utility->toggleFullScreen(); - OS::processEvents(); + Application::processEvents(); if(argc >= 2) utility->loadMedia(argv[1]); - while(quit == false) { - OS::processEvents(); - run(); - } + Application::main = {&Program::main, this}; + Application::run(); utility->unload(); config->save(); @@ -125,16 +124,14 @@ Application::Application(int argc, char **argv) { ananke.close(); } -Application::~Application() { -} - int main(int argc, char **argv) { #if defined(PLATFORM_WINDOWS) utf8_args(argc, argv); #endif - OS::setName("higan"); - new Application(argc, argv); - delete application; + Application::setName("higan"); + Application::Cocoa::onQuit = &Application::quit; + new Program(argc, argv); + delete program; return 0; } diff --git a/higan/target-ethos/ethos.hpp b/higan/target-ethos/ethos.hpp index 91aa7a64..aeea395f 100755 --- a/higan/target-ethos/ethos.hpp +++ b/higan/target-ethos/ethos.hpp @@ -30,15 +30,14 @@ using namespace ruby; Emulator::Interface& system(); -struct Application { +struct Program { vector emulator; - Emulator::Interface *active; + Emulator::Interface *active = nullptr; library ananke; - bool quit; bool pause; bool autopause; - unsigned depth; + unsigned depth; //color depth; 24(bpp) or 30(bpp) string basepath; string userpath; @@ -50,11 +49,10 @@ struct Application { bool focused(); string path(const string &filename); - void run(); + void main(); void bootstrap(); - Application(int argc, char **argv); - ~Application(); + Program(int argc, char **argv); }; -extern Application *application; +extern Program *program; extern DSP dspaudio; diff --git a/higan/target-ethos/general/browser.cpp b/higan/target-ethos/general/browser.cpp index e84bb832..d514bd5f 100755 --- a/higan/target-ethos/general/browser.cpp +++ b/higan/target-ethos/general/browser.cpp @@ -40,7 +40,11 @@ Browser::Browser() { fileList.onChange = {&Browser::synchronize, this}; fileList.onActivate = openButton.onActivate = {&Browser::fileListActivate, this}; - onClose = [&] { dialogActive = false; }; + + onClose = [&] { + setModal(false); + setVisible(false); + }; synchronize(); } @@ -57,11 +61,11 @@ void Browser::synchronize() { } void Browser::saveConfiguration() { - config.save(application->path("paths.cfg")); + config.save(program->path("paths.cfg")); } void Browser::bootstrap() { - for(auto &emulator : application->emulator) { + for(auto &emulator : program->emulator) { for(auto &media : emulator->media) { bool found = false; for(auto &folder : folderList) { @@ -85,8 +89,8 @@ void Browser::bootstrap() { config.append(folder.selection, string{folder.extension, "::selection"}); } - config.load(application->path("paths.cfg")); - config.save(application->path("paths.cfg")); + config.load(program->path("paths.cfg")); + config.save(program->path("paths.cfg")); } string Browser::select(const string &title, const string &extension) { @@ -101,38 +105,18 @@ string Browser::select(const string &title, const string &extension) { break; } } - if(path.empty()) path = application->basepath; + if(path.empty()) path = program->basepath; setPath(path, selection); filterLabel.setText({"Filter: *.", extension}); audio.clear(); setTitle(title); - setModal(true); setVisible(true); fileList.setFocused(); outputFilename = ""; - dialogActive = true; - bool backspace = false; - using phoenix::Keyboard; - - while(dialogActive) { - OS::processEvents(); - if(Keyboard::pressed(Keyboard::Scancode::Escape)) onClose(); - if(Keyboard::pressed(Keyboard::Scancode::Backspace)) { - if(backspace == false) { - backspace = true; - if(fileList.focused()) upButton.onActivate(); - } - } else { - backspace = false; - } - usleep(20 * 1000); - } - - setModal(false); - setVisible(false); + setModal(); return outputFilename; } @@ -187,6 +171,6 @@ void Browser::fileListActivate() { string filename = filenameList[selection]; if(string{filename}.rtrim<1>("/").endswith(this->extension) == false) return setPath({path, filename}); - dialogActive = false; outputFilename = {path, filename}; + onClose(); } diff --git a/higan/target-ethos/general/browser.hpp b/higan/target-ethos/general/browser.hpp index d3beea4e..c116fd46 100755 --- a/higan/target-ethos/general/browser.hpp +++ b/higan/target-ethos/general/browser.hpp @@ -24,7 +24,6 @@ private: }; vector folderList; - bool dialogActive; string outputFilename; string extension; diff --git a/higan/target-ethos/general/dip-switches.cpp b/higan/target-ethos/general/dip-switches.cpp index c257936f..ebef54de 100755 --- a/higan/target-ethos/general/dip-switches.cpp +++ b/higan/target-ethos/general/dip-switches.cpp @@ -16,16 +16,15 @@ DipSwitches::DipSwitches() { controlLayout.append(spacer, {~0, 0}); controlLayout.append(accept, {80, 0}); - setGeometry({128, 128, 250, layout.minimumGeometry().height}); + setGeometry({128, 128, 250, layout.minimumSize().height}); - onClose = accept.onActivate = [&] { quit = true; }; + onClose = accept.onActivate = [&] { + setModal(false); + setVisible(false); + }; } unsigned DipSwitches::run(const Markup::Node &node) { - audio.clear(); - setModal(true); - quit = false; - for(auto &dipItem : dip) { dipItem.name.setEnabled(false); dipItem.name.setText("(empty)"); @@ -52,12 +51,8 @@ unsigned DipSwitches::run(const Markup::Node &node) { setVisible(); accept.setFocused(); - while(quit == false) { - OS::processEvents(); - } - - setModal(false); - setVisible(false); + audio.clear(); + setModal(); unsigned result = 0; for(auto &dipItem : dip) { diff --git a/higan/target-ethos/general/dip-switches.hpp b/higan/target-ethos/general/dip-switches.hpp index 5c7f2d91..92b55c83 100755 --- a/higan/target-ethos/general/dip-switches.hpp +++ b/higan/target-ethos/general/dip-switches.hpp @@ -1,6 +1,6 @@ struct DipSwitch : HorizontalLayout { Label name; - ComboBox value; + ComboButton value; vector values; DipSwitch(); @@ -17,9 +17,6 @@ struct DipSwitches : Window { unsigned run(const Markup::Node &node); DipSwitches(); - -private: - bool quit; }; extern DipSwitches *dipSwitches; diff --git a/higan/target-ethos/general/presentation.cpp b/higan/target-ethos/general/presentation.cpp index 956aa975..fca73e03 100755 --- a/higan/target-ethos/general/presentation.cpp +++ b/higan/target-ethos/general/presentation.cpp @@ -3,7 +3,7 @@ Presentation *presentation = nullptr; void Presentation::synchronize() { for(auto &emulator : emulatorList) emulator->menu.setVisible(false); for(auto &emulator : emulatorList) { - if(emulator->interface == application->active) { + if(emulator->interface == program->active) { active = emulator; emulator->menu.setVisible(true); } @@ -29,7 +29,7 @@ void Presentation::synchronize() { synchronizeAudio.setChecked(config->audio.synchronize); muteAudio.setChecked(config->audio.mute); - if(application->active == nullptr) { + if(program->active == nullptr) { toolsMenu.setVisible(false); } else { toolsMenu.setVisible(true); @@ -87,7 +87,7 @@ Presentation::Presentation() : active(nullptr) { append(loadMenu); for(auto &item : loadListSystem) loadMenu.append(*item); - if(application->ananke.opened()) loadMenu.append(loadSeparator, loadImport); + if(program->ananke.open()) loadMenu.append(loadSeparator, loadImport); for(auto &systemItem : emulatorList) append(systemItem->menu); append(settingsMenu); settingsMenu.append(videoMenu); @@ -111,13 +111,19 @@ Presentation::Presentation() : active(nullptr) { append(layout); layout.append(viewport, {0, 0, 720, 480}); - onSize = [&] { utility->resize(); }; - onClose = [&] { application->quit = true; }; + onSize = [&] { + utility->resize(); + }; + + onClose = [&] { + setVisible(false); + Application::quit(); + }; loadImport.onActivate = [&] { - if(application->ananke.opened() == false) return; - function browse = application->ananke.sym("ananke_browse"); - if(browse == false) return; + if(program->ananke.open() == false) return; + function browse = program->ananke.sym("ananke_browse"); + if(!browse) return; string pathname = browse(); if(pathname.empty()) return; utility->loadMedia(pathname); @@ -145,7 +151,7 @@ Presentation::Presentation() : active(nullptr) { } void Presentation::bootstrap() { - for(auto &emulator : application->emulator) { + for(auto &emulator : program->emulator) { auto iEmulator = new Emulator; iEmulator->interface = emulator; @@ -206,7 +212,7 @@ void Presentation::bootstrap() { } void Presentation::loadShaders() { - string pathname = application->path("Video Shaders/"); + string pathname = program->path("Video Shaders/"); lstring files = directory::files(pathname); for(auto &filename : files) { lstring name = string{filename}.split("."); diff --git a/higan/target-ethos/input/hotkeys.cpp b/higan/target-ethos/input/hotkeys.cpp index 978d5dfc..60f70887 100755 --- a/higan/target-ethos/input/hotkeys.cpp +++ b/higan/target-ethos/input/hotkeys.cpp @@ -25,7 +25,7 @@ void InputManager::appendHotkeys() { hotkey->mapping = "KB0::P"; hotkey->press = [] { - application->pause = !application->pause; + program->pause = !program->pause; }; } @@ -115,7 +115,7 @@ void InputManager::appendHotkeys() { hotkey->mapping = "None"; hotkey->press = [] { - application->quit = true; + Application::quit(); }; } @@ -135,7 +135,7 @@ void InputManager::appendHotkeys() { hotkey->mapping = "None"; hotkey->press = [&] { - if(application->active == nullptr) return; + if(program->active == nullptr) return; system().exportMemory(); utility->showMessage("Memory exported"); }; diff --git a/higan/target-ethos/input/input.cpp b/higan/target-ethos/input/input.cpp index 98806576..0c2ab8f3 100755 --- a/higan/target-ethos/input/input.cpp +++ b/higan/target-ethos/input/input.cpp @@ -78,7 +78,7 @@ bool DigitalInput::bind(unsigned scancode, int16_t value) { } int16_t DigitalInput::poll() { - if(application->focused() == false) return 0; + if(program->focused() == false) return 0; bool result = logic; for(auto &item : inputList) { @@ -122,7 +122,7 @@ bool RelativeInput::bind(unsigned scancode, int16_t value) { } int16_t RelativeInput::poll() { - if(application->focused() == false) return 0; + if(program->focused() == false) return 0; int16_t result = 0; for(auto &item : inputList) { @@ -162,7 +162,7 @@ bool AbsoluteInput::bind(unsigned scancode, int16_t value) { } int16_t AbsoluteInput::poll() { - if(application->focused() == false) return -32768; + if(program->focused() == false) return -32768; int16_t result = -32768; //offscreen value using nall::Mouse; @@ -245,7 +245,7 @@ int16_t InputManager::poll(unsigned scancode) { } void InputManager::saveConfiguration() { - config.save(application->path("input.cfg")); + config.save(program->path("input.cfg")); } InputManager::InputManager() { @@ -256,7 +256,7 @@ InputManager::InputManager() { void InputManager::bootstrap() { unsigned guid = 0; - for(auto &emulator : application->emulator) { + for(auto &emulator : program->emulator) { for(auto &port : emulator->port) { for(auto &device : port.device) { for(auto &number : device.order) { @@ -286,8 +286,8 @@ void InputManager::bootstrap() { appendHotkeys(); - config.load(application->path("input.cfg")); - config.save(application->path("input.cfg")); + config.load(program->path("input.cfg")); + config.save(program->path("input.cfg")); bind(); } diff --git a/higan/target-ethos/interface/interface.cpp b/higan/target-ethos/interface/interface.cpp index b6d4e940..69184447 100755 --- a/higan/target-ethos/interface/interface.cpp +++ b/higan/target-ethos/interface/interface.cpp @@ -38,12 +38,12 @@ uint32_t Interface::videoColor(unsigned source, uint16_t r, uint16_t g, uint16_t b = b * luminance; } - if(application->depth == 30) { + if(program->depth == 30) { r >>= 6, g >>= 6, b >>= 6; return r << 20 | g << 10 | b << 0; } - if(application->depth == 24) { + if(program->depth == 24) { r >>= 8, g >>= 8, b >>= 8; return r << 16 | g << 8 | b << 0; } diff --git a/higan/target-ethos/settings/advanced.cpp b/higan/target-ethos/settings/advanced.cpp index 3d3973f9..394aa49c 100644 --- a/higan/target-ethos/settings/advanced.cpp +++ b/higan/target-ethos/settings/advanced.cpp @@ -1,12 +1,12 @@ AdvancedSettings *advancedSettings = nullptr; AdvancedSettings::AdvancedSettings() { - driverTitle.setFont(application->titleFont); + driverTitle.setFont(program->titleFont); driverTitle.setText("Driver Selection"); videoLabel.setText("Video:"); audioLabel.setText("Audio:"); inputLabel.setText("Input:"); - libraryTitle.setFont(application->titleFont); + libraryTitle.setFont(program->titleFont); libraryTitle.setText("Game Library Path"); libraryLabel.setText("Path:"); libraryPath.setEditable(false); @@ -15,7 +15,7 @@ AdvancedSettings::AdvancedSettings() { if(path.endswith("/") == false) path.append("/"); libraryPath.setText(path); libraryBrowse.setText("Browse ..."); - infoLabel.setFont(application->boldFont); + infoLabel.setFont(program->boldFont); string profile; #if defined(PROFILE_ACCURACY) profile = "Accuracy"; diff --git a/higan/target-ethos/settings/advanced.hpp b/higan/target-ethos/settings/advanced.hpp index c6d86c0d..5099b067 100644 --- a/higan/target-ethos/settings/advanced.hpp +++ b/higan/target-ethos/settings/advanced.hpp @@ -2,11 +2,11 @@ struct AdvancedSettings : SettingsLayout { Label driverTitle; HorizontalLayout driverLayout; Label videoLabel; - ComboBox videoDriver; + ComboButton videoDriver; Label audioLabel; - ComboBox audioDriver; + ComboButton audioDriver; Label inputLabel; - ComboBox inputDriver; + ComboButton inputDriver; Label libraryTitle; HorizontalLayout libraryLayout; diff --git a/higan/target-ethos/settings/audio.cpp b/higan/target-ethos/settings/audio.cpp index 9aae9e69..35cff8c3 100755 --- a/higan/target-ethos/settings/audio.cpp +++ b/higan/target-ethos/settings/audio.cpp @@ -7,7 +7,7 @@ AudioSlider::AudioSlider() { } AudioSettings::AudioSettings() { - title.setFont(application->titleFont); + title.setFont(program->titleFont); title.setText("Audio Settings"); frequencyLabel.setText("Frequency:"); frequency.append("32000hz", "44100hz", "48000hz", "96000hz"); diff --git a/higan/target-ethos/settings/audio.hpp b/higan/target-ethos/settings/audio.hpp index 22a2386f..11d8e7c4 100755 --- a/higan/target-ethos/settings/audio.hpp +++ b/higan/target-ethos/settings/audio.hpp @@ -10,11 +10,11 @@ struct AudioSettings : SettingsLayout { Label title; HorizontalLayout controlLayout; Label frequencyLabel; - ComboBox frequency; + ComboButton frequency; Label latencyLabel; - ComboBox latency; + ComboButton latency; Label resamplerLabel; - ComboBox resampler; + ComboButton resampler; AudioSlider volume; void synchronize(); diff --git a/higan/target-ethos/settings/hotkey.cpp b/higan/target-ethos/settings/hotkey.cpp index c73d6068..c12f6ea1 100755 --- a/higan/target-ethos/settings/hotkey.cpp +++ b/higan/target-ethos/settings/hotkey.cpp @@ -1,7 +1,7 @@ HotkeySettings *hotkeySettings = nullptr; HotkeySettings::HotkeySettings() : activeInput(nullptr) { - title.setFont(application->titleFont); + title.setFont(program->titleFont); title.setText("Hotkey Bindings"); inputList.setHeaderText("Name", "Mapping"); diff --git a/higan/target-ethos/settings/input.cpp b/higan/target-ethos/settings/input.cpp index 9ccb155b..8d36ab91 100755 --- a/higan/target-ethos/settings/input.cpp +++ b/higan/target-ethos/settings/input.cpp @@ -1,7 +1,7 @@ InputSettings *inputSettings = nullptr; InputSettings::InputSettings() : activeInput(nullptr) { - title.setFont(application->titleFont); + title.setFont(program->titleFont); title.setText("Input Settings"); focusLabel.setText("When Focus is Lost:"); focusPause.setText("Pause Emulation"); @@ -29,7 +29,7 @@ InputSettings::InputSettings() : activeInput(nullptr) { controlLayout.append(resetButton, {80, 0}, 5); controlLayout.append(eraseButton, {80, 0}); - for(auto &emulator : application->emulator) { + for(auto &emulator : program->emulator) { systemList.append(emulator->information.name); } @@ -86,7 +86,7 @@ void InputSettings::synchronize() { } Emulator::Interface& InputSettings::activeSystem() { - return *application->emulator[systemList.selection()]; + return *program->emulator[systemList.selection()]; } Emulator::Interface::Port& InputSettings::activePort() { diff --git a/higan/target-ethos/settings/input.hpp b/higan/target-ethos/settings/input.hpp index db5460b7..c1d330bc 100755 --- a/higan/target-ethos/settings/input.hpp +++ b/higan/target-ethos/settings/input.hpp @@ -2,12 +2,12 @@ struct InputSettings : SettingsLayout { Label title; HorizontalLayout focusLayout; Label focusLabel; - CheckBox focusPause; - CheckBox focusAllow; + CheckButton focusPause; + CheckButton focusAllow; HorizontalLayout selectionLayout; - ComboBox systemList; - ComboBox portList; - ComboBox deviceList; + ComboButton systemList; + ComboButton portList; + ComboButton deviceList; ListView inputList; HorizontalLayout controlLayout; Button assign[3]; diff --git a/higan/target-ethos/settings/server.cpp b/higan/target-ethos/settings/server.cpp index 4728f7f5..c6310ec1 100644 --- a/higan/target-ethos/settings/server.cpp +++ b/higan/target-ethos/settings/server.cpp @@ -1,15 +1,15 @@ ServerSettings *serverSettings = nullptr; ServerSettings::ServerSettings() { - title.setFont(application->titleFont); + title.setFont(program->titleFont); title.setText("Server Settings"); hostLabel.setText("Hostname:"); userLabel.setText("Username:"); passLabel.setText("Password:"); unsigned width = min( - Font(application->normalFont).geometry("Hostname:").width, - Font(application->normalFont).geometry("Username:").width + Font::size(program->normalFont, "Hostname:").width, + Font::size(program->normalFont, "Username:").width ); append(title, {~0, 0}, 5); diff --git a/higan/target-ethos/settings/settings.cpp b/higan/target-ethos/settings/settings.cpp index d2e7578f..e7cdd555 100755 --- a/higan/target-ethos/settings/settings.cpp +++ b/higan/target-ethos/settings/settings.cpp @@ -26,7 +26,7 @@ Settings::Settings() { setStatusVisible(); layout.setMargin(5); - panelList.setFont(application->boldFont); + panelList.setFont(program->boldFont); panelList.append("Video"); panelList.append("Audio"); panelList.append("Input"); @@ -47,6 +47,7 @@ Settings::Settings() { onClose = [&] { timingSettings->analysis.stop = true; + setVisible(false); }; panelList.onChange = {&Settings::panelChanged, this}; diff --git a/higan/target-ethos/settings/timing.cpp b/higan/target-ethos/settings/timing.cpp index a1b1fbc1..27fc47a8 100755 --- a/higan/target-ethos/settings/timing.cpp +++ b/higan/target-ethos/settings/timing.cpp @@ -16,7 +16,7 @@ TimingAdjustment::TimingAdjustment() { } TimingSettings::TimingSettings() { - title.setFont(application->titleFont); + title.setFont(program->titleFont); title.setText("Audiovisual Synchronization"); videoAdjust.name.setText("Video:"); videoAdjust.value.setText({config->timing.video}); @@ -77,12 +77,12 @@ void TimingSettings::analyzeAudioFrequency() { void TimingSettings::analyzeStart() { audio.clear(); - settings->setModal(true); + settings->panelList.setEnabled(false); videoAdjust.analyze.setEnabled(false); audioAdjust.analyze.setEnabled(false); settings->setStatusText("Initializing ..."); - OS::processEvents(); + Application::processEvents(); analysis.stop = false; analysis.seconds = 0; @@ -97,7 +97,7 @@ bool TimingSettings::analyzeTick(const string &type) { time_t systemTime = time(0); if(systemTime > analysis.systemTime) { analysis.systemTime = systemTime; - OS::processEvents(); + Application::processEvents(); if(analysis.seconds < 3) { analysis.seconds++; @@ -126,5 +126,4 @@ void TimingSettings::analyzeStop() { audioAdjust.analyze.setEnabled(true); videoAdjust.stop.setEnabled(false); audioAdjust.stop.setEnabled(false); - settings->setModal(false); } diff --git a/higan/target-ethos/settings/video.cpp b/higan/target-ethos/settings/video.cpp index f741fb73..3f190ee8 100755 --- a/higan/target-ethos/settings/video.cpp +++ b/higan/target-ethos/settings/video.cpp @@ -7,9 +7,9 @@ VideoSlider::VideoSlider() { } VideoSettings::VideoSettings() { - title.setFont(application->titleFont); + title.setFont(program->titleFont); title.setText("Video Settings"); - colorAdjustment.setFont(application->boldFont); + colorAdjustment.setFont(program->boldFont); colorAdjustment.setText("Color adjustment:"); saturation.name.setText("Saturation:"); saturation.slider.setLength(201); @@ -17,7 +17,7 @@ VideoSettings::VideoSettings() { gamma.slider.setLength(101); luminance.name.setText("Luminance:"); luminance.slider.setLength(101); - overscanAdjustment.setFont(application->boldFont); + overscanAdjustment.setFont(program->boldFont); overscanAdjustment.setText("Overscan mask:"); overscanHorizontal.name.setText("Horizontal:"); overscanHorizontal.slider.setLength(17); @@ -59,5 +59,5 @@ void VideoSettings::synchronize() { overscanHorizontal.value.setText({config->video.maskOverscanHorizontal, "px"}); overscanVertical.value.setText({config->video.maskOverscanVertical, "px"}); - if(application->active) system().paletteUpdate(); + if(program->active) system().paletteUpdate(); } diff --git a/higan/target-ethos/tools/cheat-database.cpp b/higan/target-ethos/tools/cheat-database.cpp index 83026fc7..c5d8caf6 100755 --- a/higan/target-ethos/tools/cheat-database.cpp +++ b/higan/target-ethos/tools/cheat-database.cpp @@ -34,7 +34,7 @@ void CheatDatabase::findCodes() { cheatList.reset(); cheat.reset(); - auto document = Markup::Document(string::read(application->path("cheats.bml"))); + auto document = Markup::Document(string::read(program->path("cheats.bml"))); for(auto &node : document) { if(node.name != "cartridge") continue; if(node["sha256"].text() != sha256) continue; diff --git a/higan/target-ethos/tools/cheat-editor.cpp b/higan/target-ethos/tools/cheat-editor.cpp index 682244df..eeb62276 100755 --- a/higan/target-ethos/tools/cheat-editor.cpp +++ b/higan/target-ethos/tools/cheat-editor.cpp @@ -16,8 +16,8 @@ CheatEditor::CheatEditor() { resetButton.setText("Reset"); eraseButton.setText("Erase"); unsigned width = max( - Font(application->normalFont).geometry("Codes(s)" ).width, - Font(application->normalFont).geometry("Description:").width + Font::size(program->normalFont, "Codes(s)" ).width, + Font::size(program->normalFont, "Description:").width ); append(layout); @@ -50,7 +50,7 @@ CheatEditor::CheatEditor() { } void CheatEditor::synchronize() { - layout.setEnabled(application->active); + layout.setEnabled(program->active); if(cheatList.selected()) { unsigned n = cheatList.selection(); diff --git a/higan/target-ethos/tools/state-manager.cpp b/higan/target-ethos/tools/state-manager.cpp index 23bd39b5..e3935eca 100755 --- a/higan/target-ethos/tools/state-manager.cpp +++ b/higan/target-ethos/tools/state-manager.cpp @@ -44,7 +44,7 @@ StateManager::StateManager() { } void StateManager::synchronize() { - layout.setEnabled(application->active); + layout.setEnabled(program->active); descEdit.setText(""); descEdit.setEnabled(false); diff --git a/higan/target-ethos/utility/utility.cpp b/higan/target-ethos/utility/utility.cpp index 5cc9a3f0..d25a3725 100755 --- a/higan/target-ethos/utility/utility.cpp +++ b/higan/target-ethos/utility/utility.cpp @@ -3,7 +3,7 @@ Utility *utility = nullptr; void Utility::setInterface(Emulator::Interface *emulator) { - application->active = emulator; + program->active = emulator; presentation->synchronize(); } @@ -14,9 +14,9 @@ void Utility::loadMedia(string pathname) { //if a filename was provided: convert to game folder and then load if(!directory::exists(pathname) && file::exists(pathname)) { - if(application->ananke.opened() == false) return; - function open = application->ananke.sym("ananke_open"); - if(open == false) return; + if(program->ananke.open() == false) return; + function open = program->ananke.sym("ananke_open"); + if(!open) return; string name = open(pathname); if(name.empty()) return; return loadMedia(name); @@ -26,7 +26,7 @@ void Utility::loadMedia(string pathname) { string type = extension(pathname); //determine type by comparing extension against all emulation cores - for(auto &emulator : application->emulator) { + for(auto &emulator : program->emulator) { for(auto &media : emulator->media) { if(media.bootable == false) continue; if(type != media.type) continue; @@ -48,7 +48,7 @@ void Utility::loadMedia(Emulator::Interface *emulator, Emulator::Interface::Medi void Utility::loadMedia(Emulator::Interface *emulator, Emulator::Interface::Media &media, const string &pathname) { unload(); setInterface(emulator); - path(0) = application->path({media.name, ".sys/"}); + path(0) = program->path({media.name, ".sys/"}); path(media.id) = pathname; this->pathname.append(pathname); @@ -85,17 +85,17 @@ void Utility::saveRequest(unsigned id, const string &path) { } void Utility::connect(unsigned port, unsigned device) { - if(application->active == nullptr) return; + if(program->active == nullptr) return; system().connect(port, device); } void Utility::power() { - if(application->active == nullptr) return; + if(program->active == nullptr) return; system().power(); } void Utility::reset() { - if(application->active == nullptr) return; + if(program->active == nullptr) return; system().reset(); } @@ -114,7 +114,7 @@ void Utility::load() { } void Utility::unload() { - if(application->active == nullptr) return; + if(program->active == nullptr) return; if(tracerEnable) tracerToggle(); cheatEditor->save({pathname[0], "cheats.bml"}); @@ -136,7 +136,7 @@ void Utility::unload() { } void Utility::saveState(unsigned slot) { - if(application->active == nullptr) return; + if(program->active == nullptr) return; serializer s = system().serialize(); if(s.size() == 0) return; directory::create({pathname[0], "bsnes/"}); @@ -145,7 +145,7 @@ void Utility::saveState(unsigned slot) { } void Utility::loadState(unsigned slot) { - if(application->active == nullptr) return; + if(program->active == nullptr) return; auto memory = file::read({pathname[0], "bsnes/state-", slot, ".bsa"}); if(memory.size() == 0) return showMessage({"Unable to locate slot ", slot, " state"}); serializer s(memory.data(), memory.size()); @@ -154,7 +154,7 @@ void Utility::loadState(unsigned slot) { } void Utility::tracerToggle() { - if(application->active == nullptr) return; + if(program->active == nullptr) return; tracerEnable = !tracerEnable; bool result = system().tracerEnable(tracerEnable); if( tracerEnable && result) return utility->showMessage("Tracer activated"); @@ -164,7 +164,7 @@ void Utility::tracerToggle() { } void Utility::synchronizeDSP() { - if(application->active == nullptr) return; + if(program->active == nullptr) return; if(config->video.synchronize == false) { return dspaudio.setFrequency(system().audioFrequency()); @@ -210,7 +210,7 @@ void Utility::updateShader() { } void Utility::resize(bool resizeWindow) { - if(application->active == nullptr) return; + if(program->active == nullptr) return; Geometry geometry = presentation->geometry(); unsigned width = system().information.width; unsigned height = system().information.height; @@ -278,9 +278,9 @@ void Utility::updateStatus() { string text; if((currentTime - statusTime) <= 2) { text = statusMessage; - } else if(application->active == nullptr) { + } else if(program->active == nullptr) { text = "No cartridge loaded"; - } else if(application->pause || application->autopause) { + } else if(program->pause || program->autopause) { text = "Paused"; } else { text = statusText; diff --git a/higan/target-ethos/window/window.cpp b/higan/target-ethos/window/window.cpp index f663b056..afe70a1a 100755 --- a/higan/target-ethos/window/window.cpp +++ b/higan/target-ethos/window/window.cpp @@ -2,9 +2,9 @@ WindowManager *windowManager = nullptr; void WindowManager::append(Window *window, const string &name) { - window->setMenuFont(application->normalFont); - window->setWidgetFont(application->normalFont); - window->setStatusFont(application->boldFont); + window->setMenuFont(program->normalFont); + window->setWidgetFont(program->normalFont); + window->setStatusFont(program->boldFont); windowList.append({window, name, window->geometry().text()}); } @@ -12,8 +12,8 @@ void WindowManager::loadGeometry() { for(auto &window : windowList) { config.append(window.geometry, window.name); } - config.load(application->path("geometry.cfg")); - config.save(application->path("geometry.cfg")); + config.load(program->path("geometry.cfg")); + config.save(program->path("geometry.cfg")); for(auto &window : windowList) { window.window->setGeometry(window.geometry); } @@ -23,7 +23,7 @@ void WindowManager::saveGeometry() { for(auto &window : windowList) { window.geometry = window.window->geometry().text(); } - config.save(application->path("geometry.cfg")); + config.save(program->path("geometry.cfg")); } void WindowManager::hideAll() {