From ced8337a902cfb9988d014c099b90b2b66212825 Mon Sep 17 00:00:00 2001 From: Michael Vrhel Date: Sat, 4 May 2013 22:59:31 -0700 Subject: Major changes in the entire design. Initial commit of this and it has several issues that have to be worked through. Lots of broken stuff but I needed to get it in place. Added 2 new classes. One is muctx which contains all the interfacing to mupdf and uses standard c++ types. The other is mudocument which interfaces between muctx and the WinRT world. It passes WinRT objects to and from applications which can be written in C++, C#, Visual Basic, Javascript etc. mudocument and muctx will reside in a winRT DLL. The Viewer application (c++ version) is now in mupdf_cpp project and now has a flip view structure that includes a scroll viewer which has data binding to a collection. This enables much easier zooming and updating, however I am still trying how to bind the canvas elements that contain the text search or link information. --- winrt/mupdf_cpp/App.xaml | 20 + winrt/mupdf_cpp/App.xaml.cpp | 107 ++ winrt/mupdf_cpp/App.xaml.h | 24 + winrt/mupdf_cpp/Assets/mupdf_logo.png | Bin 0 -> 12690 bytes winrt/mupdf_cpp/Assets/mupdf_smallogo.png | Bin 0 -> 4108 bytes winrt/mupdf_cpp/Assets/mupdf_splash.png | Bin 0 -> 23297 bytes winrt/mupdf_cpp/Assets/mupdf_storelogo.png | Bin 0 -> 5382 bytes winrt/mupdf_cpp/Common/StandardStyles.xaml | 1879 ++++++++++++++++++++++++++++ winrt/mupdf_cpp/DocumentPage.cpp | 14 + winrt/mupdf_cpp/DocumentPage.h | 97 ++ winrt/mupdf_cpp/LVContents.cpp | 9 + winrt/mupdf_cpp/LVContents.h | 12 + winrt/mupdf_cpp/MainPage.xaml | 149 +++ winrt/mupdf_cpp/MainPage.xaml.cpp | 1565 +++++++++++++++++++++++ winrt/mupdf_cpp/MainPage.xaml.h | 198 +++ winrt/mupdf_cpp/Package.appxmanifest | 48 + winrt/mupdf_cpp/RectList.cpp | 16 + winrt/mupdf_cpp/RectList.h | 68 + winrt/mupdf_cpp/mupdf_cpp.vcxproj | 202 +++ winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters | 56 + winrt/mupdf_cpp/pch.cpp | 6 + winrt/mupdf_cpp/pch.h | 9 + 22 files changed, 4479 insertions(+) create mode 100644 winrt/mupdf_cpp/App.xaml create mode 100644 winrt/mupdf_cpp/App.xaml.cpp create mode 100644 winrt/mupdf_cpp/App.xaml.h create mode 100644 winrt/mupdf_cpp/Assets/mupdf_logo.png create mode 100644 winrt/mupdf_cpp/Assets/mupdf_smallogo.png create mode 100644 winrt/mupdf_cpp/Assets/mupdf_splash.png create mode 100644 winrt/mupdf_cpp/Assets/mupdf_storelogo.png create mode 100644 winrt/mupdf_cpp/Common/StandardStyles.xaml create mode 100644 winrt/mupdf_cpp/DocumentPage.cpp create mode 100644 winrt/mupdf_cpp/DocumentPage.h create mode 100644 winrt/mupdf_cpp/LVContents.cpp create mode 100644 winrt/mupdf_cpp/LVContents.h create mode 100644 winrt/mupdf_cpp/MainPage.xaml create mode 100644 winrt/mupdf_cpp/MainPage.xaml.cpp create mode 100644 winrt/mupdf_cpp/MainPage.xaml.h create mode 100644 winrt/mupdf_cpp/Package.appxmanifest create mode 100644 winrt/mupdf_cpp/RectList.cpp create mode 100644 winrt/mupdf_cpp/RectList.h create mode 100644 winrt/mupdf_cpp/mupdf_cpp.vcxproj create mode 100644 winrt/mupdf_cpp/mupdf_cpp.vcxproj.filters create mode 100644 winrt/mupdf_cpp/pch.cpp create mode 100644 winrt/mupdf_cpp/pch.h (limited to 'winrt/mupdf_cpp') diff --git a/winrt/mupdf_cpp/App.xaml b/winrt/mupdf_cpp/App.xaml new file mode 100644 index 00000000..4dabc5cc --- /dev/null +++ b/winrt/mupdf_cpp/App.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/winrt/mupdf_cpp/App.xaml.cpp b/winrt/mupdf_cpp/App.xaml.cpp new file mode 100644 index 00000000..1b84a1ab --- /dev/null +++ b/winrt/mupdf_cpp/App.xaml.cpp @@ -0,0 +1,107 @@ +// +// App.xaml.cpp +// Implementation of the App class. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +using namespace mupdf_cpp; + +using namespace Platform; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Interop; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 + +/// +/// Initializes the singleton application object. This is the first line of authored code +/// executed, and as such is the logical equivalent of main() or WinMain(). +/// +App::App() +{ + InitializeComponent(); + Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); +} + +/// +/// Invoked when the application is launched normally by the end user. Other entry points +/// will be used when the application is launched to open a specific file, to display +/// search results, and so forth. +/// +/// Details about the launch request and process. +void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ args) +{ + auto rootFrame = dynamic_cast(Window::Current->Content); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == nullptr) + { + // Create a Frame to act as the navigation context and associate it with + // a SuspensionManager key + rootFrame = ref new Frame(); + + if (args->PreviousExecutionState == ApplicationExecutionState::Terminated) + { + // TODO: Restore the saved session state only when appropriate, scheduling the + // final launch steps after the restore is complete + + } + + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + if (!rootFrame->Navigate(TypeName(MainPage::typeid), args->Arguments)) + { + throw ref new FailureException("Failed to create initial page"); + } + } + // Place the frame in the current Window + Window::Current->Content = rootFrame; + // Ensure the current window is active + Window::Current->Activate(); + } + else + { + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + if (!rootFrame->Navigate(TypeName(MainPage::typeid), args->Arguments)) + { + throw ref new FailureException("Failed to create initial page"); + } + } + // Ensure the current window is active + Window::Current->Activate(); + } +} + +/// +/// Invoked when application execution is being suspended. Application state is saved +/// without knowing whether the application will be terminated or resumed with the contents +/// of memory still intact. +/// +/// The source of the suspend request. +/// Details about the suspend request. +void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) +{ + (void) sender; // Unused parameter + (void) e; // Unused parameter + + //TODO: Save application state and stop any background activity +} diff --git a/winrt/mupdf_cpp/App.xaml.h b/winrt/mupdf_cpp/App.xaml.h new file mode 100644 index 00000000..2ed35bd1 --- /dev/null +++ b/winrt/mupdf_cpp/App.xaml.h @@ -0,0 +1,24 @@ +// +// App.xaml.h +// Declaration of the App class. +// + +#pragma once + +#include "App.g.h" + +namespace mupdf_cpp +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + ref class App sealed + { + public: + App(); + virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ args) override; + + private: + void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); + }; +} diff --git a/winrt/mupdf_cpp/Assets/mupdf_logo.png b/winrt/mupdf_cpp/Assets/mupdf_logo.png new file mode 100644 index 00000000..ba6b005d Binary files /dev/null and b/winrt/mupdf_cpp/Assets/mupdf_logo.png differ diff --git a/winrt/mupdf_cpp/Assets/mupdf_smallogo.png b/winrt/mupdf_cpp/Assets/mupdf_smallogo.png new file mode 100644 index 00000000..15997f5c Binary files /dev/null and b/winrt/mupdf_cpp/Assets/mupdf_smallogo.png differ diff --git a/winrt/mupdf_cpp/Assets/mupdf_splash.png b/winrt/mupdf_cpp/Assets/mupdf_splash.png new file mode 100644 index 00000000..5f011d17 Binary files /dev/null and b/winrt/mupdf_cpp/Assets/mupdf_splash.png differ diff --git a/winrt/mupdf_cpp/Assets/mupdf_storelogo.png b/winrt/mupdf_cpp/Assets/mupdf_storelogo.png new file mode 100644 index 00000000..1b6473d4 Binary files /dev/null and b/winrt/mupdf_cpp/Assets/mupdf_storelogo.png differ diff --git a/winrt/mupdf_cpp/Common/StandardStyles.xaml b/winrt/mupdf_cpp/Common/StandardStyles.xaml new file mode 100644 index 00000000..414be872 --- /dev/null +++ b/winrt/mupdf_cpp/Common/StandardStyles.xaml @@ -0,0 +1,1879 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mouse + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/winrt/mupdf_cpp/DocumentPage.cpp b/winrt/mupdf_cpp/DocumentPage.cpp new file mode 100644 index 00000000..c705c237 --- /dev/null +++ b/winrt/mupdf_cpp/DocumentPage.cpp @@ -0,0 +1,14 @@ +#include "pch.h" +#include "DocumentPage.h" + +namespace mupdf_cpp +{ + DocumentPage::DocumentPage(void) + { + this->Image = nullptr; + this->Height = 0; + this->Width = 0; + this->Zoom = 1.0; + this->Content = NOTSET; + } +} diff --git a/winrt/mupdf_cpp/DocumentPage.h b/winrt/mupdf_cpp/DocumentPage.h new file mode 100644 index 00000000..98bbeb0e --- /dev/null +++ b/winrt/mupdf_cpp/DocumentPage.h @@ -0,0 +1,97 @@ +#pragma once + +#include "RectList.h" +#include + + +/* Used for binding to the xaml in the scroll view. */ +using namespace Windows::UI::Xaml::Media::Imaging; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::Foundation::Collections; + +typedef enum { + FULL_RESOLUTION = 0, + THUMBNAIL, + DUMMY, + NOTSET +} Page_Content_t; + + +namespace mupdf_cpp +{ + [Windows::UI::Xaml::Data::Bindable] // in c++, adding this attribute to ref classes enables data binding for more info search for 'Bindable' on the page http://go.microsoft.com/fwlink/?LinkId=254639 + + public ref class DocumentPage sealed + { + private: + int height; + int width; + double zoom; + WriteableBitmap^ image; + Page_Content_t content; + + public: + DocumentPage(void); + + property int Content + { + int get() { return ((int) content); } + void set(int value) + { + if (value > NOTSET) + { + throw ref new Platform::InvalidArgumentException(); + } + content = (Page_Content_t) value; + } + } + + property int Height + { + int get() { return height; } + void set(int value) + { + if (value < 0) + { + throw ref new Platform::InvalidArgumentException(); + } + height = value; + } + } + + property int Width + { + int get() { return width; } + void set(int value) + { + if (value < 0) + { + throw ref new Platform::InvalidArgumentException(); + } + width = value; + } + } + + property double Zoom + { + double get() { return zoom; } + void set(double value) + { + if (value < 0) + { + throw ref new Platform::InvalidArgumentException(); + } + zoom = value; + } + } + + property WriteableBitmap^ Image + { + WriteableBitmap^ get() { return image; } + void set(WriteableBitmap^ value) + { + image = value; + } + } + }; +} diff --git a/winrt/mupdf_cpp/LVContents.cpp b/winrt/mupdf_cpp/LVContents.cpp new file mode 100644 index 00000000..1905c10c --- /dev/null +++ b/winrt/mupdf_cpp/LVContents.cpp @@ -0,0 +1,9 @@ +#include "pch.h" +#include "LVContents.h" + +using namespace ListViewContents; +LVContents::LVContents(void) +{ + ContentItem = ""; + Page = -1; +} diff --git a/winrt/mupdf_cpp/LVContents.h b/winrt/mupdf_cpp/LVContents.h new file mode 100644 index 00000000..1ca4179c --- /dev/null +++ b/winrt/mupdf_cpp/LVContents.h @@ -0,0 +1,12 @@ +#pragma once +namespace ListViewContents { + [Windows::UI::Xaml::Data::Bindable] + public ref class LVContents sealed + { + public: + LVContents(void); + property Platform::String^ ContentItem; + property int Page; + + }; +} diff --git a/winrt/mupdf_cpp/MainPage.xaml b/winrt/mupdf_cpp/MainPage.xaml new file mode 100644 index 00000000..99ae0f3b --- /dev/null +++ b/winrt/mupdf_cpp/MainPage.xaml @@ -0,0 +1,149 @@ + + + + + + + + + + +