diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-04-04 16:35:59 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-05-16 19:25:38 +0100 |
commit | 0de3169c52435458583955ac03fc57516d5d372e (patch) | |
tree | d865fc044d54ab13540bce95f95398004e5f6f40 | |
parent | 6bb186c3d057a1ec129d801fcf6893d378c5e12d (diff) | |
download | mupdf-0de3169c52435458583955ac03fc57516d5d372e.tar.xz |
Fix for merge of golden commits as well as initial attempt at html viewing. Issues exist though in the
xaml WebView object used in the windows UI.
-rw-r--r-- | fitz/base_time.c | 14 | ||||
-rw-r--r-- | winRT/libmupdf_winRT.vcxproj | 2 | ||||
-rw-r--r-- | winRT/libmupdf_winRT.vcxproj.filters | 6 | ||||
-rw-r--r-- | winRT/winapp/Common/StandardStyles.xaml | 11 | ||||
-rw-r--r-- | winRT/winapp/MainPage.xaml | 12 | ||||
-rw-r--r-- | winRT/winapp/MainPage.xaml.cpp | 85 | ||||
-rw-r--r-- | winRT/winapp/MainPage.xaml.h | 7 |
7 files changed, 128 insertions, 9 deletions
diff --git a/fitz/base_time.c b/fitz/base_time.c index 8bdd6977..c0d6a8c0 100644 --- a/fitz/base_time.c +++ b/fitz/base_time.c @@ -1,4 +1,4 @@ -#if defined(_WIN32) && !defined(_WINRT) +#if defined(_WIN32) #include <time.h> #ifndef METRO @@ -13,6 +13,12 @@ #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL #endif +#if defined(_WINRT) + +void fz_gettimeofday_dummy() { } + +#else + struct timeval; int gettimeofday(struct timeval *tv, struct timezone *tz) @@ -38,6 +44,8 @@ int gettimeofday(struct timeval *tv, struct timezone *tz) return 0; } +#endif + FILE *fopen_utf8(const char *name, const char *mode) { wchar_t *wname, *wmode, *d; @@ -45,7 +53,7 @@ FILE *fopen_utf8(const char *name, const char *mode) int c; FILE *file; - d = wname = malloc((strlen(name)+1) * sizeof(wchar_t)); + d = wname = (wchar_t*) malloc((strlen(name)+1) * sizeof(wchar_t)); if (d == NULL) return NULL; s = name; @@ -54,7 +62,7 @@ FILE *fopen_utf8(const char *name, const char *mode) *d++ = c; } *d = 0; - d = wmode = malloc((strlen(mode)+1) * sizeof(wchar_t)); + d = wmode = (wchar_t*) malloc((strlen(mode)+1) * sizeof(wchar_t)); if (d == NULL) { free(wname); diff --git a/winRT/libmupdf_winRT.vcxproj b/winRT/libmupdf_winRT.vcxproj index 29302301..5f93acb5 100644 --- a/winRT/libmupdf_winRT.vcxproj +++ b/winRT/libmupdf_winRT.vcxproj @@ -91,6 +91,7 @@ <ClCompile Include="..\fitz\res_bitmap.c" /> <ClCompile Include="..\fitz\res_colorspace.c" /> <ClCompile Include="..\fitz\res_font.c" /> + <ClCompile Include="..\fitz\res_func.c" /> <ClCompile Include="..\fitz\res_halftone.c" /> <ClCompile Include="..\fitz\res_path.c" /> <ClCompile Include="..\fitz\res_pixmap.c" /> @@ -112,6 +113,7 @@ <ClCompile Include="..\pdf\pdf_device.c" /> <ClCompile Include="..\pdf\pdf_encoding.c" /> <ClCompile Include="..\pdf\pdf_event.c" /> + <ClCompile Include="..\pdf\pdf_field.c" /> <ClCompile Include="..\pdf\pdf_font.c" /> <ClCompile Include="..\pdf\pdf_fontfile.c" /> <ClCompile Include="..\pdf\pdf_form.c" /> diff --git a/winRT/libmupdf_winRT.vcxproj.filters b/winRT/libmupdf_winRT.vcxproj.filters index 6845a9fb..359f4908 100644 --- a/winRT/libmupdf_winRT.vcxproj.filters +++ b/winRT/libmupdf_winRT.vcxproj.filters @@ -342,6 +342,12 @@ <ClCompile Include="..\xps\xps_zip.c"> <Filter>xps</Filter> </ClCompile> + <ClCompile Include="..\pdf\pdf_field.c"> + <Filter>pdf</Filter> + </ClCompile> + <ClCompile Include="..\fitz\res_func.c"> + <Filter>fitz</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\cbz\mucbz.h"> diff --git a/winRT/winapp/Common/StandardStyles.xaml b/winRT/winapp/Common/StandardStyles.xaml index 5d59c0a4..cae5dc9e 100644 --- a/winRT/winapp/Common/StandardStyles.xaml +++ b/winRT/winapp/Common/StandardStyles.xaml @@ -449,9 +449,14 @@ <Setter Property="AutomationProperties.AutomationId" Value="AllAppsAppBarButton"/> <Setter Property="AutomationProperties.Name" Value="Contents"/> <Setter Property="Content" Value=""/> - </Style> - - + </Style> + <Style x:Key="ReflowAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}"> + <Setter Property="AutomationProperties.AutomationId" Value="ReflowAppBarButton"/> + <Setter Property="AutomationProperties.Name" Value="Reflow"/> + <Setter Property="Content" Value=""/> + </Style> + + <!-- <Style x:Key="SkipBackAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}"> diff --git a/winRT/winapp/MainPage.xaml b/winRT/winapp/MainPage.xaml index 61e73e8b..9a557fad 100644 --- a/winRT/winapp/MainPage.xaml +++ b/winRT/winapp/MainPage.xaml @@ -31,7 +31,8 @@ <StackPanel x:Name="RightPanel" Orientation="Horizontal" HorizontalAlignment="Right"> <Button x:Name="Search" Style="{StaticResource SearchAppBarButtonStyle}" Tag="Search" Click="Searcher"/> <Button x:Name="Contents" Style="{StaticResource ContentsBarButtonStyle}" Tag="Contents" Click="ContentDisplay"/> - <Button x:Name="Links" Style="{StaticResource LinksAppBarButtonStyle}" Tag="Search" Click="Linker"/> + <Button x:Name="Links" Style="{StaticResource LinksAppBarButtonStyle}" Tag="Links" Click="Linker"/> + <Button x:Name="Reflow" Style="{StaticResource ReflowAppBarButtonStyle}" Tag="Reflow" Click="Reflower"/> <Button x:Name="Help" Style="{StaticResource HelpAppBarButtonStyle}" Tag="Help"/> </StackPanel> </Grid> @@ -81,6 +82,7 @@ </ItemsPanelTemplate> </FlipView.ItemsPanel> </FlipView> + </Canvas> <ListView x:Name="xaml_ListView" Foreground="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0" IsItemClickEnabled="True" @@ -98,6 +100,12 @@ <SolidColorBrush Color="LightGray"></SolidColorBrush> </ListView.Background> </ListView> + <WebView x:Name="xaml_WebView" HorizontalAlignment="Stretch" + VerticalAlignment="Stretch" Visibility="Collapsed" + ManipulationDelta="WebViewDelta" + ManipulationStarting="WebViewStarting" + ManipulationCompleted="WebViewCompleted" ManipulationMode="All" + /> </Grid> </Grid> -</Page> + </Page> diff --git a/winRT/winapp/MainPage.xaml.cpp b/winRT/winapp/MainPage.xaml.cpp index 87ff2415..b7e8eff7 100644 --- a/winRT/winapp/MainPage.xaml.cpp +++ b/winRT/winapp/MainPage.xaml.cpp @@ -1908,3 +1908,88 @@ void winapp::MainPage::ContentSelected(Platform::Object^ sender, Windows::UI::Xa } } + + +void winapp::MainPage::Reflower(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + if (xaml_WebView->Visibility == Windows::UI::Xaml::Visibility::Visible) + { + /* Go back to flip view */ + xaml_WebView->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + this->xaml_MainGrid->Opacity = 1.0; + this->m_curr_flipView->IsEnabled = true; + } + else if (this->m_curr_flipView->IsEnabled) + { + /* Only go from flip view to reflow */ + RenderingStatus_t *ren_status = &m_ren_status; + cancellation_token_source *ThumbCancel = &m_ThumbCancel; + /* Create a task to wait until the renderer is available */ + auto t = create_task([ren_status, ThumbCancel]() + { + if (*ren_status == REN_THUMBS) + ThumbCancel->cancel(); + while (*ren_status != REN_AVAILABLE) { + } + }).then([this]() + { + fz_rect bounds; + fz_output *out; + fz_page *page = fz_load_page(m_doc, this->m_currpage); + fz_text_sheet *sheet = fz_new_text_sheet(ctx); + fz_text_page *text = fz_new_text_page(ctx, &fz_empty_rect); + fz_device *dev = fz_new_text_device(ctx, sheet, text); + + fz_run_page(m_doc, page, dev, &fz_identity, NULL); + fz_free_device(dev); + dev = NULL; + fz_text_analysis(ctx, sheet, text); + fz_buffer *buf = fz_new_buffer(ctx, 256); + out = fz_new_output_buffer(ctx, buf); + fz_print_text_page_html(ctx, out, text); + + xaml_WebView->Visibility = Windows::UI::Xaml::Visibility::Visible; + this->xaml_MainGrid->Opacity = 0.0; + this->m_curr_flipView->IsEnabled = false; + String^ html_string = char_to_String((char*) buf->data); + // WebViewBrush^ web_brush = ref new WebViewBrush(); + this->xaml_WebView->NavigateToString(html_string); + + // web_brush->SourceName = "xaml_WebView"; + // web_brush->Redraw(); + // this->xaml_zoomCanvas->Background = web_brush; + // xaml_WebView->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + + + /* Check if thumb rendering is done. If not then restart */ + if (this->m_num_pages != this->m_thumb_page_start) + this->RenderThumbs(); + }, task_continuation_context::use_current()); + } +} + + + +void winapp::MainPage::WebViewDelta(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs^ e) +{ + double scale_val = e->Delta.Scale; +} + + +void winapp::MainPage::WebViewStarting(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartingRoutedEventArgs^ e) +{ + int zz = 1; +} + + +void winapp::MainPage::WebViewCompleted(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationCompletedRoutedEventArgs^ e) +{ + int zz = 1; +} + + +void winapp::MainPage::TempViewStarting(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartingRoutedEventArgs^ e) +{ + + int zz = 1; +} diff --git a/winRT/winapp/MainPage.xaml.h b/winRT/winapp/MainPage.xaml.h index ba826aaa..6f4cd242 100644 --- a/winRT/winapp/MainPage.xaml.h +++ b/winRT/winapp/MainPage.xaml.h @@ -183,5 +183,10 @@ namespace winapp void ListView_Single_Tap(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); void ContentSelected(Platform::Object^ sender, Windows::UI::Xaml::Controls::ItemClickEventArgs^ e); void ContentChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); - }; + void Reflower(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void WebViewDelta(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs^ e); + void WebViewStarting(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartingRoutedEventArgs^ e); + void WebViewCompleted(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationCompletedRoutedEventArgs^ e); + void TempViewStarting(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartingRoutedEventArgs^ e); +}; } |