Changeset 38

Show
Ignore:
Timestamp:
04/12/06 07:27:49 (3 years ago)
Author:
jordi
Message:

The Zoom functions works, but I had to save the scrolled window around the image because when the presenter requests the size, if the image's height is given then it returns the current image height's, which is useless (and I think is the same for the width, but I didn't see any proof of it).

Location:
trunk/src/gtk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gtk/MainView.cxx

    r37 r38  
    3434static void main_window_open_file_cb (GtkWidget *, gpointer); 
    3535static void main_window_quit_cb (GtkWidget *, gpointer); 
     36static void main_window_zoom_fit_cb (GtkWidget *, gpointer); 
     37static void main_window_zoom_in_cb (GtkWidget *, gpointer); 
     38static void main_window_zoom_out_cb (GtkWidget *, gpointer); 
     39static void main_window_zoom_width_cb (GtkWidget *, gpointer); 
    3640 
    3741//////////////////////////////////////////////////////////////// 
     
    6064    gtk_box_pack_start (GTK_BOX (m_MainBox), toolBar, FALSE, FALSE, 0); 
    6165    // Create the page view 
    62     GtkWidget *pageView = createPageView (); 
    63     gtk_box_pack_start (GTK_BOX (m_MainBox), pageView, TRUE, TRUE, 0); 
     66    createPageView (); 
     67    gtk_box_pack_start (GTK_BOX (m_MainBox), m_PageViewScroll, TRUE, TRUE, 0); 
    6468} 
    6569 
     
    231235MainView::getPageViewSize (gint *width, gint *height) 
    232236{ 
     237    g_assert (NULL != width && "Tried to save the width to a NULL pointer."); 
     238    g_assert (NULL != height && "Tried to save the height to a NULL pointer."); 
     239     
     240    *width = m_PageView->allocation.width - 12; 
     241    *height = m_PageViewScroll->allocation.height - 12; 
    233242} 
    234243 
     
    243252//////////////////////////////////////////////////////////////// 
    244253 
    245 GtkWidget * 
     254void 
    246255MainView::createPageView () 
    247256{ 
    248     GtkWidget *scrolledWindow = gtk_scrolled_window_new (NULL, NULL); 
    249     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindow), 
     257    m_PageViewScroll = gtk_scrolled_window_new (NULL, NULL); 
     258    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_PageViewScroll), 
    250259                                    GTK_POLICY_AUTOMATIC, 
    251260                                    GTK_POLICY_AUTOMATIC); 
    252261    m_PageView = gtk_image_new  (); 
    253     gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledWindow), 
    254                                            m_PageView); 
    255     return scrolledWindow; 
     262    gtk_scrolled_window_add_with_viewport ( 
     263            GTK_SCROLLED_WINDOW (m_PageViewScroll), m_PageView); 
    256264} 
    257265 
     
    267275        { "OpenFile", GTK_STOCK_OPEN, _("_Open"), "<control>O", NULL, G_CALLBACK (main_window_open_file_cb) }, 
    268276        { "Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", NULL, G_CALLBACK (main_window_quit_cb) }, 
    269         { "ZoomIn", GTK_STOCK_ZOOM_IN, _("Zoom _In"), "plus", NULL, NULL }, 
    270         { "ZoomOut", GTK_STOCK_ZOOM_OUT, _("Zoom _Out"), "minus", NULL, NULL }, 
    271         { "ZoomFit", GTK_STOCK_ZOOM_FIT, _("Zoom to _Fit"), NULL, NULL, NULL }, 
    272         { "ZoomWidth", NULL, _("Zoom to _Width"), NULL, NULL, NULL }, 
     277        { "ZoomIn", GTK_STOCK_ZOOM_IN, _("Zoom _In"), "plus", NULL, G_CALLBACK (main_window_zoom_in_cb) }, 
     278        { "ZoomOut", GTK_STOCK_ZOOM_OUT, _("Zoom _Out"), "minus", NULL, G_CALLBACK (main_window_zoom_out_cb) }, 
     279        { "ZoomFit", GTK_STOCK_ZOOM_FIT, _("Zoom to _Fit"), NULL, NULL, G_CALLBACK (main_window_zoom_fit_cb) }, 
     280        { "ZoomWidth", NULL, _("Zoom to _Width"), NULL, NULL, G_CALLBACK (main_window_zoom_width_cb) }, 
    273281        { "RotateRight", GTK_STOCK_REDO, _("Rotate _Right"), NULL, NULL, G_CALLBACK (main_window_rotate_right)}, 
    274282        { "RotateLeft", GTK_STOCK_UNDO, _("Rotate Left"), NULL, NULL, G_CALLBACK (main_window_rotate_left)}, 
     
    426434    gtk_main_quit (); 
    427435} 
     436 
     437void 
     438main_window_zoom_fit_cb (GtkWidget *widget, gpointer data) 
     439{ 
     440    g_assert ( NULL != data && "The data parameter is NULL."); 
     441 
     442    MainPter *pter = (MainPter *)data; 
     443    pter->zoomFitActivated (); 
     444} 
     445 
     446void 
     447main_window_zoom_in_cb (GtkWidget *widget, gpointer data) 
     448{ 
     449    g_assert ( NULL != data && "The data parameter is NULL."); 
     450 
     451    MainPter *pter = (MainPter *)data; 
     452    pter->zoomInActivated (); 
     453} 
     454 
     455void 
     456main_window_zoom_out_cb (GtkWidget *widget, gpointer data) 
     457{ 
     458    g_assert ( NULL != data && "The data parameter is NULL."); 
     459 
     460    MainPter *pter = (MainPter *)data; 
     461    pter->zoomOutActivated (); 
     462} 
     463 
     464void 
     465main_window_zoom_width_cb (GtkWidget *widget, gpointer data) 
     466{ 
     467    g_assert ( NULL != data && "The data parameter is NULL."); 
     468 
     469    MainPter *pter = (MainPter *)data; 
     470    pter->zoomWidthActivated (); 
     471} 
  • trunk/src/gtk/MainView.h

    r36 r38  
    5858            GtkWidget *m_MainBox; 
    5959            GtkWidget *m_PageView; 
     60            GtkWidget *m_PageViewScroll; 
    6061            GtkUIManager *m_UIManager; 
    6162 
    62             GtkWidget *createPageView (void); 
     63            void createPageView (void); 
    6364            void createUIManager (void); 
    6465            GdkPixbuf *getPixbufFromPage (DocumentPage *page);