diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2013-04-05 17:05:51 -0700 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-05-16 19:25:42 +0100 |
commit | 10e60105e7371aca58a08c3012c3cece7436444d (patch) | |
tree | 729a9f645ba6e58e518509b6b43d6f6b5031bbbb /winrt | |
parent | 102b040dd98446841acedf944cf2578894b25d0c (diff) | |
download | mupdf-10e60105e7371aca58a08c3012c3cece7436444d.tar.xz |
Addition of reflow page view. Also fix for crash when opening new document.
Diffstat (limited to 'winrt')
-rw-r--r-- | winrt/winapp/MainPage.xaml | 20 | ||||
-rw-r--r-- | winrt/winapp/MainPage.xaml.cpp | 76 | ||||
-rw-r--r-- | winrt/winapp/MainPage.xaml.h | 5 |
3 files changed, 50 insertions, 51 deletions
diff --git a/winrt/winapp/MainPage.xaml b/winrt/winapp/MainPage.xaml index 9a557fad..d7feaeac 100644 --- a/winrt/winapp/MainPage.xaml +++ b/winrt/winapp/MainPage.xaml @@ -38,7 +38,7 @@ </Grid> </AppBar> </Page.TopAppBar> - <Grid> + <Grid x:Name="xaml_OutsideGrid"> <Grid.Background> <LinearGradientBrush EndPoint="-0.074,-0.068" StartPoint="1.027,1.024"> <GradientStop Color="Black"/> @@ -59,7 +59,7 @@ </Grid.Background> <ProgressBar x:Name="xaml_Progress" IsIndeterminate="False" Maximum="100" Value="0" Height="10" Width="400" IsEnabled="False" Opacity="0"/> - + <Grid x:Name="xaml_MainGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SizeChanged="GridSizeChanged"> <Canvas x:Name="xaml_zoomCanvas" HorizontalAlignment="Center" VerticalAlignment="Center" DoubleTapped="Canvas_Double" ManipulationDelta="Canvas_ManipulationDelta" ManipulationStarted="Canvas_ManipulationStarted" @@ -100,12 +100,16 @@ <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> + <StackPanel x:Name="xaml_RichGrid" Orientation="Vertical" Margin="5,5,5,50" + Width="Auto" Height="Auto" Visibility="Collapsed"> + <TextBlock HorizontalAlignment="Center" Text="FontSize:" FontSize="18" Margin="0, 10, 0, -10"/> + <Slider x:Name="fontSizeSlider" Width="200" Value="20" Minimum="8" Maximum="40" + TickFrequency="4" Orientation="Horizontal" HorizontalAlignment="Center" /> + <RichEditBox x:Name="xaml_RichText" FontSize="{Binding Value, ElementName=fontSizeSlider}" + Visibility="Collapsed" HorizontalAlignment="Center" + VerticalAlignment="Top"> + </RichEditBox> + </StackPanel> </Grid> </Page> diff --git a/winrt/winapp/MainPage.xaml.cpp b/winrt/winapp/MainPage.xaml.cpp index b7e8eff7..dd668d7a 100644 --- a/winrt/winapp/MainPage.xaml.cpp +++ b/winrt/winapp/MainPage.xaml.cpp @@ -629,6 +629,11 @@ void winapp::MainPage::CleanUp() m_content.num = 0; } + + + + + m_curr_zoom = 1.0; m_canvas_translate.X = 0; m_canvas_translate.Y = 0; @@ -744,6 +749,7 @@ void winapp::MainPage::OpenDocumentPrep(StorageFile^ file) { if (this->m_num_pages != -1) { + m_init_done = false; /* If the thumbnail thread is running then we need to end that first */ RenderingStatus_t *ren_status = &m_ren_status; cancellation_token_source *ThumbCancel = &m_ThumbCancel; @@ -1533,8 +1539,14 @@ void winapp::MainPage::GridSizeChanged() xaml_vert_flipView->IsEnabled = false; xaml_vert_flipView->Opacity = 0; } - // if (m_num_pages > 0 && this->m_links_on) - // ClearLinksCanvas(); + + if (xaml_RichText->Visibility == Windows::UI::Xaml::Visibility::Visible) + { + int height = xaml_OutsideGrid->ActualHeight; + int height_app = TopAppBar1->ActualHeight; + + xaml_RichText->Height = height - height_app; + } UpDatePageSizes(); @@ -1723,7 +1735,7 @@ void winapp::MainPage::Canvas_Single_Tap(Platform::Object^ sender, Windows::UI:: /* Window string hurdles.... */ String^ char_to_String(char *char_in) { - size_t size = MultiByteToWideChar(CP_ACP, 0, char_in, -1, NULL, 0); + size_t size = MultiByteToWideChar(CP_UTF8, 0, char_in, -1, NULL, 0); wchar_t *pw; pw = new wchar_t[size]; if (!pw) @@ -1731,7 +1743,7 @@ String^ char_to_String(char *char_in) delete []pw; return nullptr; } - MultiByteToWideChar (CP_ACP, 0, char_in, -1, pw, size ); + MultiByteToWideChar (CP_UTF8, 0, char_in, -1, pw, size ); String^ str_out = ref new String(pw); delete []pw; return str_out; @@ -1908,16 +1920,20 @@ 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) + + if (this->m_num_pages < 0) return; + + if (xaml_RichText->Visibility == Windows::UI::Xaml::Visibility::Visible) { /* Go back to flip view */ - xaml_WebView->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + xaml_RichText->Visibility = Windows::UI::Xaml::Visibility::Collapsed; this->xaml_MainGrid->Opacity = 1.0; this->m_curr_flipView->IsEnabled = true; + xaml_RichGrid->Visibility = Windows::UI::Xaml::Visibility::Collapsed; + xaml_RichGrid->Opacity = 0.0; + } else if (this->m_curr_flipView->IsEnabled) { @@ -1946,20 +1962,19 @@ void winapp::MainPage::Reflower(Platform::Object^ sender, Windows::UI::Xaml::Rou 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; + fz_print_text_page(ctx, out, text); + xaml_RichText->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; + xaml_RichGrid->Visibility = Windows::UI::Xaml::Visibility::Visible; + xaml_RichGrid->Opacity = 1.0; + int height = xaml_OutsideGrid->ActualHeight; + int height_app = TopAppBar1->ActualHeight; + + xaml_RichText->Height = height - height_app; + this->xaml_RichText->Document->SetText(Windows::UI::Text::TextSetOptions::FormatRtf, html_string); /* Check if thumb rendering is done. If not then restart */ if (this->m_num_pages != this->m_thumb_page_start) @@ -1968,28 +1983,3 @@ void winapp::MainPage::Reflower(Platform::Object^ sender, Windows::UI::Xaml::Rou } } - - -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 6f4cd242..f36c2b85 100644 --- a/winrt/winapp/MainPage.xaml.h +++ b/winrt/winapp/MainPage.xaml.h @@ -188,5 +188,10 @@ namespace winapp 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); + void RichGridSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e); + void RichGridManipulationStarting(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartingRoutedEventArgs^ e); + void RichGridManipulationDelta(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs^ e); + void RichGridManipulationStarted(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationStartedRoutedEventArgs^ e); + void RichGridManipulationCompleted(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationCompletedRoutedEventArgs^ e); }; } |