~ubuntu-branches/ubuntu/utopic/gnome-chemistry-utils/utopic

« back to all changes in this revision

Viewing changes to plugins/paint/arrows/arrowtool.cc

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-10 21:30:51 UTC
  • mfrom: (1.1.15) (2.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20130510213051-mswxsp3vitsgqspm
Tags: 0.14.2-1ubuntu1
* Sync with Debian. Remaining change:
  - Build-depend on firefox-dev instead of xulrunner-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// -*- C++ -*-
2
2
 
3
 
/* 
 
3
/*
4
4
 * GChemPaint arrows plugin
5
 
 * arrowtool.cc 
6
 
 *
7
 
 * Copyright (C) 2001-2007 Jean Bréfort <jean.brefort@normalesup.org>
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or 
10
 
 * modify it under the terms of the GNU General Public License as 
11
 
 * published by the Free Software Foundation; either version 2 of the
 
5
 * arrowtool.cc
 
6
 *
 
7
 * Copyright (C) 2001-2011 Jean Bréfort <jean.brefort@normalesup.org>
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public License as
 
11
 * published by the Free Software Foundation; either version 3 of the
12
12
 * License, or (at your option) any later version.
13
13
 *
14
14
 * This program is distributed in the hope that it will be useful,
38
38
#include <gccv/group.h>
39
39
#include <gccv/line.h>
40
40
#include <gccv/poly-line.h>
41
 
#include <gcu/ui-builder.h>
 
41
#include <gcugtk/ui-builder.h>
42
42
#include <glib/gi18n-lib.h>
43
43
#include <cmath>
44
44
 
66
66
 
67
67
gcpArrowTool::~gcpArrowTool ()
68
68
{
69
 
}       
 
69
}
70
70
 
71
71
bool gcpArrowTool::OnClicked ()
72
72
{
348
348
                        pDoc->AddObject (a);
349
349
                }
350
350
        }
 
351
        gcp::Operation *op = pDoc->GetNewOperation (gcp::GCP_ADD_OPERATION);
 
352
        op->AddObject (a);
351
353
        pDoc->FinishOperation ();
352
354
}
353
355
 
364
366
GtkWidget *gcpArrowTool::GetPropertyPage ()
365
367
{
366
368
        bool show_all = m_ArrowType == gcp::ReversibleArrow || m_ArrowType == gcp::FullReversibleArrow;
367
 
        gcu::UIBuilder *builder = new gcu::UIBuilder (UIDIR"/arrowtool.ui", GETTEXT_PACKAGE);
 
369
        gcugtk::UIBuilder *builder = new gcugtk::UIBuilder (UIDIR"/arrowtool.ui", GETTEXT_PACKAGE);
 
370
        GtkWidget *res = builder->GetRefdWidget ("arrow-grid");
368
371
        if (show_all) {
369
 
                GtkTable *table = GTK_TABLE (builder->GetWidget ("heads-table"));
 
372
                GtkGrid *grid = GTK_GRID (res);
370
373
                gccv::Canvas *canvas = new gccv::Canvas (NULL);
371
374
                gcp::Theme *Theme = gcp::TheThemeManager.GetTheme ("Default");
372
375
                double width = (Theme->GetArrowLength () * Theme->GetZoomFactor () + 2 * Theme->GetArrowPadding ()),
373
376
                        height = Theme->GetArrowDist () + Theme->GetArrowWidth () + 2 * (Theme->GetArrowHeadB () + Theme->GetPadding ());
374
377
                gtk_widget_set_size_request (canvas->GetWidget (), (int) width, (int) height);
375
 
                GOColor color = GO_COLOR_FROM_GDK (m_pApp->GetStyle ()->fg[0]);
376
378
                gccv::Arrow *arrow = new gccv::Arrow (canvas,
377
379
                                                                                          (width - Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
378
380
                                                                                          (height - Theme->GetArrowDist  ()) / 2.,
379
381
                                                                                          (width + Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
380
382
                                                                                          (height - Theme->GetArrowDist  ()) / 2.);
381
 
                arrow->SetLineColor (color);
382
383
                arrow->SetLineWidth (Theme->GetArrowWidth ());
383
384
                arrow->SetA (Theme->GetArrowHeadA ());
384
385
                arrow->SetB (Theme->GetArrowHeadB ());
385
386
                arrow->SetC (Theme->GetArrowHeadC ());
386
387
                arrow->SetEndHead (gccv::ArrowHeadLeft);
 
388
                arrow->SetAutoColor (true);
387
389
                arrow = new gccv::Arrow (canvas,
388
390
                                                                 (width + Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
389
391
                                                                 (height + Theme->GetArrowDist  ()) / 2.,
390
392
                                                                 (width - Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
391
393
                                                                 (height + Theme->GetArrowDist  ()) / 2.);
392
 
                arrow->SetLineColor (color);
393
394
                arrow->SetLineWidth (Theme->GetArrowWidth ());
394
395
                arrow->SetA (Theme->GetArrowHeadA ());
395
396
                arrow->SetB (Theme->GetArrowHeadB ());
396
397
                arrow->SetC (Theme->GetArrowHeadC ());
397
398
                arrow->SetEndHead (gccv::ArrowHeadLeft);
 
399
                arrow->SetAutoColor (true);
398
400
                gtk_widget_show (canvas->GetWidget ());
399
 
                gtk_table_attach (table, canvas->GetWidget (), 1, 2, 0, 1, GTK_FILL, GTK_FILL, 10, 0);
 
401
                gtk_grid_attach (grid, canvas->GetWidget (), 1, 2, 1, 1);
400
402
                canvas = new gccv::Canvas (NULL);
401
403
                arrow = new gccv::Arrow (canvas,
402
404
                                                                 (width - Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
403
405
                                                                 (height - Theme->GetArrowDist  ()) / 2.,
404
406
                                                                 (width + Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
405
407
                                                                 (height - Theme->GetArrowDist  ()) / 2.);
406
 
                arrow->SetLineColor (color);
407
408
                arrow->SetLineWidth (Theme->GetArrowWidth ());
408
409
                arrow->SetA (Theme->GetArrowHeadA ());
409
410
                arrow->SetB (Theme->GetArrowHeadB ());
410
411
                arrow->SetC (Theme->GetArrowHeadC ());
 
412
                arrow->SetAutoColor (true);
411
413
                arrow = new gccv::Arrow (canvas,
412
414
                                                                 (width + Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
413
415
                                                                 (height + Theme->GetArrowDist  ()) / 2.,
414
416
                                                                 (width - Theme->GetArrowLength () * Theme->GetZoomFactor ()) / 2.,
415
417
                                                                 (height + Theme->GetArrowDist  ()) / 2.);
416
 
                arrow->SetLineColor (color);
417
418
                arrow->SetLineWidth (Theme->GetArrowWidth ());
418
419
                arrow->SetA (Theme->GetArrowHeadA ());
419
420
                arrow->SetB (Theme->GetArrowHeadB ());
420
421
                arrow->SetC (Theme->GetArrowHeadC ());
 
422
                arrow->SetAutoColor (true);
421
423
                gtk_widget_show (canvas->GetWidget ());
422
 
                gtk_table_attach (table, canvas->GetWidget (), 1, 2, 1, 2, GTK_FILL, GTK_FILL, 10, 0);
 
424
                gtk_grid_attach (grid, canvas->GetWidget (), 1, 3, 1, 1);
423
425
                GtkWidget *b = builder->GetWidget ("full");
424
426
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b), m_ArrowType == gcp::FullReversibleArrow);
425
427
                g_signal_connect (G_OBJECT (b), "toggled", G_CALLBACK (on_full_toggled), this);
426
428
                GtkWidget *w = builder->GetWidget ("default");
427
429
                g_signal_connect_swapped (w, "clicked", G_CALLBACK (on_default), b);
428
430
        } else {
429
 
                gtk_widget_hide (builder->GetWidget ("heads-table"));
430
 
                gtk_widget_hide (builder->GetWidget ("hseparator1"));
431
 
                gtk_widget_hide (builder->GetWidget ("hbox2"));
 
431
                gtk_widget_hide (builder->GetWidget ("half"));
 
432
                gtk_widget_hide (builder->GetWidget ("full"));
 
433
                gtk_widget_hide (builder->GetWidget ("arrow-sep"));
 
434
                gtk_widget_hide (builder->GetWidget ("default"));
432
435
        }
433
436
        m_LengthBtn = GTK_SPIN_BUTTON (builder->GetWidget ("arrow-length"));
434
437
        g_signal_connect (m_LengthBtn, "value-changed", G_CALLBACK (on_length_changed), this);
435
 
        GtkWidget *res = builder->GetRefdWidget ("arrow-box");
436
438
        delete builder;
437
439
        return res;
438
440
}