diff --git a/apps/sample-gui/gui-main-win.cpp b/apps/sample-gui/gui-main-win.cpp index ef4beb6..697c017 100644 --- a/apps/sample-gui/gui-main-win.cpp +++ b/apps/sample-gui/gui-main-win.cpp @@ -31,7 +31,7 @@ void initializeCommandLineArgs(CommandLineArgs* args) } LocalFree(szArglist); - args->Process(windowsArgs); + args->process(windowsArgs); } int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) @@ -39,9 +39,9 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine std::ofstream out("out.txt"); std::cout.rdbuf(out.rdbuf()); - auto args = CommandLineArgs::CreateUnique(); + auto args = CommandLineArgs::Create(); initializeCommandLineArgs(args.get()); - args->RecordLaunchPath(); + args->recordLaunchPath(); // Start the main app auto main_app = MainApplication::Create(); @@ -50,18 +50,18 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine applicationContext->hInstance = reinterpret_cast(hInstance); applicationContext->nCmdShow = nCmdShow; - main_app->Initialize(std::move(args), std::move(applicationContext)); + main_app->initialize(std::move(args), std::move(applicationContext)); MLOG_INFO("Creating GUI Application"); // Start the gui application auto gui_app = GuiApplication(); - gui_app.SetMainApplication(main_app); + //gui_app.setMainApplication(main_app); MLOG_INFO("Running GUI Application"); - gui_app.Run(); + gui_app.run(); - main_app->ShutDown(); + main_app->shutDown(); return 0; } diff --git a/src/compression/Lz77Encoder.cpp b/src/compression/Lz77Encoder.cpp index b247e45..ff3ff85 100644 --- a/src/compression/Lz77Encoder.cpp +++ b/src/compression/Lz77Encoder.cpp @@ -48,7 +48,7 @@ void Lz77Encoder::populateSearchBuffer(const Hit& hit) int difference = int(length) - distance; if (difference > 0) { - for(unsigned idx=0; idx(pow(2, compression_info + 8)); } } diff --git a/src/compression/deflate/DeflateEncoder.cpp b/src/compression/deflate/DeflateEncoder.cpp index 704c399..60ffdeb 100644 --- a/src/compression/deflate/DeflateEncoder.cpp +++ b/src/compression/deflate/DeflateEncoder.cpp @@ -25,7 +25,6 @@ bool DeflateEncoder::encode() std::unique_ptr working_block = std::make_unique(&stream, mOutputStream); working_block->setCompressionMethod(mCompressionMethod); - AbstractChecksumCalculator* checksum_calc; if (mChecksumCalculators.size() > 0) { //std::cout << "Setting checksum calculator " << std::endl; diff --git a/src/compression/huffman/HuffmanStream.cpp b/src/compression/huffman/HuffmanStream.cpp index 38275a0..e03e304 100644 --- a/src/compression/huffman/HuffmanStream.cpp +++ b/src/compression/huffman/HuffmanStream.cpp @@ -120,7 +120,7 @@ void HuffmanStream::readCodeLengths() mInputStream->readNextNBits(2, num_reps); //std::cout << "Got val 16 doing " << 3 + num_reps << std::endl; - for(unsigned idx=0; idx< 3 + num_reps; idx++) + for(unsigned char idx=0; idx< 3 + num_reps; idx++) { addValue(last_value, count, last_value, literal_lengths, mNumLiterals, distance_lengths); } @@ -131,7 +131,7 @@ void HuffmanStream::readCodeLengths() mInputStream->readNextNBits(3, num_reps); //std::cout << "Got val 17 doing " << 3 + num_reps << std::endl; - for(unsigned idx=0; idx< 3 + num_reps; idx++) + for(unsigned char idx=0; idx< 3 + num_reps; idx++) { addValue(0, count, last_value, literal_lengths, mNumLiterals, distance_lengths); } @@ -142,7 +142,7 @@ void HuffmanStream::readCodeLengths() mInputStream->readNextNBits(7, num_reps); //std::cout << "Got val 18 doing " << 11 + num_reps << std::endl; - for(unsigned idx=0; idx< 11 + num_reps; idx++) + for(unsigned idx=0; idx< 11 + unsigned(num_reps); idx++) { addValue(0, count, last_value, literal_lengths, mNumLiterals, distance_lengths); } @@ -172,7 +172,7 @@ void HuffmanStream::readCodeLengths() void HuffmanStream::copyFromBuffer(unsigned length, unsigned distance) { - unsigned offset = mBuffer.size() - 1 - distance; + std::size_t offset = mBuffer.size() - 1 - distance; for(unsigned idx=0; idxreadNextNBits(4, h_clen); - auto num_code_lengths = h_clen + 4; + unsigned num_code_lengths = h_clen + 4; //std::cout << "Got HCLEN " << num_code_lengths << std::endl; auto sequence = std::vector(num_code_lengths, 0); diff --git a/src/core/ByteUtils.cpp b/src/core/ByteUtils.cpp index 20126a6..2c03981 100644 --- a/src/core/ByteUtils.cpp +++ b/src/core/ByteUtils.cpp @@ -18,7 +18,7 @@ ByteUtils::Word ByteUtils::GetWordLastByte(const Word word) unsigned char ByteUtils::getHigherNBits(unsigned char input, unsigned num) { - return input >> 8 - num; + return input >> (8 - num); } unsigned char ByteUtils::getByteN(uint32_t input, unsigned n) diff --git a/src/core/streams/BitStream.cpp b/src/core/streams/BitStream.cpp index 9a5c7c9..010a0c5 100644 --- a/src/core/streams/BitStream.cpp +++ b/src/core/streams/BitStream.cpp @@ -78,7 +78,7 @@ void BitStream::writeNBits(uint32_t data, unsigned length) writeByte(mCurrentByte, false); - auto num_bytes = overshoot / 8; + unsigned num_bytes = overshoot / 8; for (unsigned idx=0; idx< num_bytes; idx++) { mCurrentByte = ByteUtils::getMBitsAtN(data, overshoot, idx*8 + num_left); diff --git a/src/core/streams/BufferBitStream.h b/src/core/streams/BufferBitStream.h index a5a0520..b239d06 100644 --- a/src/core/streams/BufferBitStream.h +++ b/src/core/streams/BufferBitStream.h @@ -3,6 +3,7 @@ #include "BitStream.h" #include +#include class BufferBitStream : public BitStream { diff --git a/src/graphics/CMakeLists.txt b/src/graphics/CMakeLists.txt index b52041a..968a3e7 100644 --- a/src/graphics/CMakeLists.txt +++ b/src/graphics/CMakeLists.txt @@ -20,7 +20,7 @@ list(APPEND graphics_HEADERS RasterPainter.h PainterFactory.h ) - +if(UNIX) set(OpenGL_GL_PREFERENCE "GLVND") find_package(OpenGL QUIET) if (OpenGL_FOUND) @@ -42,6 +42,7 @@ if (OpenGL_FOUND) else() message(STATUS "OpenGL not found - skipping support") endif() +endif() add_library(${MODULE_NAME} SHARED ${graphics_LIB_INCLUDES} diff --git a/src/image/png/PngWriter.cpp b/src/image/png/PngWriter.cpp index dec427f..2b1e638 100644 --- a/src/image/png/PngWriter.cpp +++ b/src/image/png/PngWriter.cpp @@ -120,9 +120,9 @@ void PngWriter::writeDataChunks(const BufferBitStream& buffer) auto num_bytes = buffer.getBuffer().size(); auto max_bytes{32000}; - unsigned num_dat_chunks = num_bytes/max_bytes + 1; + auto num_dat_chunks = num_bytes/max_bytes + 1; unsigned offset = 0; - for(unsigned idx=0;idx #include diff --git a/src/network/NetworkManager.cpp b/src/network/NetworkManager.cpp index 700542d..5b47f34 100644 --- a/src/network/NetworkManager.cpp +++ b/src/network/NetworkManager.cpp @@ -49,6 +49,11 @@ void NetworkManager::RunHttpClient() Initialize(); } + if (!mSocketInterface) + { + return; + } + auto socket = Socket::Create(); mSocketInterface->InitializeSocket(socket, "127.0.0.1"); mSocketInterface->Write(socket, "Hello Friend"); diff --git a/src/ui_elements/widgets/TextBox.cpp b/src/ui_elements/widgets/TextBox.cpp index 66cec27..3c99290 100644 --- a/src/ui_elements/widgets/TextBox.cpp +++ b/src/ui_elements/widgets/TextBox.cpp @@ -40,7 +40,7 @@ void TextBox::appendContent(const std::string& text) bool TextBox::onMyKeyboardEvent(const KeyboardEvent* event) { - if(!event or !mVisible) return false; + if(!event || !mVisible) return false; if(event->isFunctionKey()) { diff --git a/src/windows/CMakeLists.txt b/src/windows/CMakeLists.txt index 8a3c08e..a127447 100644 --- a/src/windows/CMakeLists.txt +++ b/src/windows/CMakeLists.txt @@ -82,7 +82,9 @@ target_include_directories(windows PUBLIC ) target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES}) +if(UNIX) target_compile_options(${MODULE_NAME} PRIVATE -Wno-attributes) # From xdg shell autogen code +endif() target_link_libraries(${MODULE_NAME} PUBLIC ${platform_LIBS} core geometry graphics ui_elements) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src) diff --git a/src/windows/ui_interfaces/UiInterfaceFactory.cpp b/src/windows/ui_interfaces/UiInterfaceFactory.cpp index f0f2350..bf13e42 100644 --- a/src/windows/ui_interfaces/UiInterfaceFactory.cpp +++ b/src/windows/ui_interfaces/UiInterfaceFactory.cpp @@ -44,6 +44,6 @@ std::unique_ptr UiInterfaceFactory::create(DesktopManager* #endif } #else - return std::make_unique(); + return std::make_unique(desktopManager, std::move(fonts_manager)); #endif } diff --git a/src/windows/ui_interfaces/win32/Win32UIInterface.cpp b/src/windows/ui_interfaces/win32/Win32UIInterface.cpp index d44b354..9dd2d30 100644 --- a/src/windows/ui_interfaces/win32/Win32UIInterface.cpp +++ b/src/windows/ui_interfaces/win32/Win32UIInterface.cpp @@ -2,18 +2,19 @@ #include -Win32UIInterface::Win32UIInterface() - : mWindowInterface(std::make_unique()) +Win32UIInterface::Win32UIInterface(DesktopManager* desktopManager, std::unique_ptr fontsManager, bool useHardware) + : AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware), + mWindowInterface(std::make_unique()) { } -void Win32UIInterface::Initialize(DesktopManager* desktopManager) +void Win32UIInterface::initialize() { } -void Win32UIInterface::Loop(DesktopManager* desktopManager) +void Win32UIInterface::loop() { // Run the message loop. MSG msg = { }; @@ -24,17 +25,17 @@ void Win32UIInterface::Loop(DesktopManager* desktopManager) } } -void Win32UIInterface::ShutDown() +void Win32UIInterface::shutDown() { } -void Win32UIInterface::ShowWindow(mt::Window* window) +void Win32UIInterface::showWindow(mt::Window* window) { mWindowInterface->Show(window); } -void Win32UIInterface::AddWindow(mt::Window* window, DesktopManager* desktopManager) +void Win32UIInterface::addWindow(mt::Window* window) { - mWindowInterface->Add(window, desktopManager); + mWindowInterface->Add(window, mDesktopManager); } \ No newline at end of file diff --git a/src/windows/ui_interfaces/win32/Win32UIInterface.h b/src/windows/ui_interfaces/win32/Win32UIInterface.h index c2cf822..4dff753 100644 --- a/src/windows/ui_interfaces/win32/Win32UIInterface.h +++ b/src/windows/ui_interfaces/win32/Win32UIInterface.h @@ -3,25 +3,26 @@ #include "Window.h" #include "Win32WindowInterface.h" +#include "AbstractUiInterface.h" class DesktopManager; -class Win32UIInterface +class Win32UIInterface : public AbstractUIInterface { public: - Win32UIInterface(); + Win32UIInterface(DesktopManager* desktopManager, std::unique_ptr fontsManager, bool useHardware = false); ~Win32UIInterface() = default; - void Initialize(DesktopManager* desktopManager); + void initialize() override; - void Loop(DesktopManager* desktopManager); + void loop() override; - void ShutDown(); + void shutDown() override; - void ShowWindow(mt::Window* window); + void showWindow(mt::Window* window) override; - void AddWindow(mt::Window* window, DesktopManager* desktopManager); + void addWindow(mt::Window* window) override; private: diff --git a/src/windows/ui_interfaces/win32/Win32Window.cpp b/src/windows/ui_interfaces/win32/Win32Window.cpp index 4dd1eb0..4851a73 100644 --- a/src/windows/ui_interfaces/win32/Win32Window.cpp +++ b/src/windows/ui_interfaces/win32/Win32Window.cpp @@ -11,14 +11,15 @@ LRESULT CALLBACK FreeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -Win32Window::Win32Window() +Win32Window::Win32Window(mt::Window* window) + : IPlatformWindow(window) { } -std::unique_ptr Win32Window::Create() +std::unique_ptr Win32Window::Create(mt::Window* window) { - return std::make_unique(); + return std::make_unique(window); } HWND Win32Window::GetHandle() const @@ -85,11 +86,11 @@ LRESULT CALLBACK Win32Window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa case WM_CHAR: { auto key_event = std::make_unique(); - key_event->SetAction(KeyboardEvent::Action::Pressed); + key_event->setAction(KeyboardEvent::Action::Pressed); auto keyChar = (wchar_t)wParam; - key_event->SetKeyString(StringUtils::convert(std::wstring(1, keyChar))); - mDesktopManager->OnUiEvent(std::move(key_event)); + key_event->setKeyString(StringUtils::convert(std::wstring(1, keyChar))); + mDesktopManager->onUiEvent(std::move(key_event)); } case WM_PAINT: diff --git a/src/windows/ui_interfaces/win32/Win32Window.h b/src/windows/ui_interfaces/win32/Win32Window.h index ea0dd75..440cb46 100644 --- a/src/windows/ui_interfaces/win32/Win32Window.h +++ b/src/windows/ui_interfaces/win32/Win32Window.h @@ -9,10 +9,10 @@ class DesktopManager; class Win32Window : public IPlatformWindow { public: - Win32Window(); + Win32Window(mt::Window* window); virtual ~Win32Window() = default; - static std::unique_ptr Create(); + static std::unique_ptr Create(mt::Window* window); LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); @@ -35,6 +35,24 @@ public: void CreateNative(Win32ApplicationContext* context, DesktopManager* desktopManager); + void show() {}; + + void map() {}; + + void clear() {}; + + void onResize(unsigned width, unsigned height) {}; + + void beforePaint(mt::Screen* screen) + { + + } + + void afterPaint(mt::Screen* screen) + { + + } + private: HWND mHandle{ 0 }; int mCmdShow{ 0 }; diff --git a/src/windows/ui_interfaces/win32/Win32WindowInterface.cpp b/src/windows/ui_interfaces/win32/Win32WindowInterface.cpp index e284fe7..3989cc1 100644 --- a/src/windows/ui_interfaces/win32/Win32WindowInterface.cpp +++ b/src/windows/ui_interfaces/win32/Win32WindowInterface.cpp @@ -5,6 +5,7 @@ #include #include "DesktopManager.h" +#include "DrawingContext.h" #include "FileLogger.h" @@ -15,18 +16,18 @@ Win32WindowInterface::Win32WindowInterface() void Win32WindowInterface::Show(mt::Window* window) { - auto platformWindow = dynamic_cast(window->GetPlatformWindow()); + auto platformWindow = dynamic_cast(window->getPlatformWindow()); MLOG_INFO("Showing platform window: " << platformWindow->GetHandle()); ::ShowWindow(platformWindow->GetHandle(), platformWindow->GetCmdShow()); } void Win32WindowInterface::Add(mt::Window* window, DesktopManager* desktopManager) { - auto context = dynamic_cast(desktopManager->GetMainApp()->GetApplicationContext()); + auto context = dynamic_cast(desktopManager->getMainApp()->GetApplicationContext()); - auto win32_window = Win32Window::Create(); + auto win32_window = Win32Window::Create(window); win32_window->CreateNative(context, desktopManager); win32_window->SetCmdShow(context->nCmdShow); - window->SetPlatformWindow(std::move(win32_window)); + window->setPlatformWindow(std::move(win32_window), nullptr, DrawingMode::GRAPH); } diff --git a/src/windows/ui_interfaces/win32/Win32WindowInterface.h b/src/windows/ui_interfaces/win32/Win32WindowInterface.h index 027c0b1..7db63f2 100644 --- a/src/windows/ui_interfaces/win32/Win32WindowInterface.h +++ b/src/windows/ui_interfaces/win32/Win32WindowInterface.h @@ -8,6 +8,7 @@ #include class DesktopManager; +class FontsManager; class Win32ApplicationContext : public IApplicationContext { diff --git a/test/test_utils/CMakeLists.txt b/test/test_utils/CMakeLists.txt index 25bd47a..7d26da5 100644 --- a/test/test_utils/CMakeLists.txt +++ b/test/test_utils/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(test_utils SHARED +add_library(test_utils STATIC TestCase.h TestCaseRunner.cpp )