File: ButtonBar.cpp

package info (click to toggle)
quickplot 0.8.6-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,548 kB
  • ctags: 1,019
  • sloc: cpp: 10,052; sh: 7,597; makefile: 176
file content (109 lines) | stat: -rw-r--r-- 3,183 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* Copyright (c) 1998, 1999, 2003, 2004  Lance Arsenault, (GNU GPL (v2+))
 */
#include "config.h"

#include <list>

#ifdef QP_ARCH_DARWIN
# include <limits.h>
# include <float.h>
#else
# include <values.h>
#endif

#include <gtkmm.h>

using namespace Gtk;
#include "errorStr.h"
#include "value_t.h"
#include "Field.h"
#include "Plot.h"
#include "ColorGen.h"
#include "Graph.h"
#include "PlotSelector.h"
#include "ValueSlider.h"
#include "PlotLister.h"
#include "PlotConfig.h"
#include "GraphConfig.h"

#include "MainMenuBar.h"
#include "ButtonBar.h"
#include "StatusBar.h"
#include "MainWindow.h"
#include "App.h"

#include "Globel.h"


ButtonBar::ButtonBar(MainWindow *mainWindow_in):
  HButtonBox(BUTTONBOX_START), // makes all the buttons the same size.
  openButton("_Open File ...", true),
  newButton("_New Graph Tab", true),
  showGraphConfigButton(opShowGraphConfig?
                        "Hide Config":"Show Config", true),
  savePNGButton("Save PNG _Image ...", true)
{
  mainWindow = mainWindow_in;
  add(openButton);
  add(newButton);
  add(showGraphConfigButton);
  add(savePNGButton);

  openButton.signal_activate().connect(sigc::mem_fun(*app, &App::openDialog));
  openButton.signal_pressed().connect(sigc::mem_fun(*app, &App::openDialog));
  
  newButton.signal_activate().
    connect(sigc::mem_fun(*mainWindow,
                       &MainWindow::makeNewGraphWithGraphConfig));
  newButton.signal_pressed().
    connect(sigc::mem_fun(*mainWindow,
                       &MainWindow::makeNewGraphWithGraphConfig));
  savePNGButton.signal_pressed().connect(sigc::mem_fun(*mainWindow,
                                                    &MainWindow::savePNGFile));
  
  showGraphConfigButton.signal_activate().
      connect(sigc::mem_fun(*this,
                         &ButtonBar::on_showGraphConfigButton));
  showGraphConfigButton.signal_pressed().
      connect(sigc::mem_fun(*this,
                         &ButtonBar::on_showGraphConfigButton));
  
  signal_show().connect(sigc::mem_fun(mainWindow->menuBar,
                                   &MainMenuBar::checkButtonBarState));
  signal_hide().connect(sigc::mem_fun(mainWindow->menuBar,
                                   &MainMenuBar::checkButtonBarState));
  
  openButton.show();
  newButton.show();
  showGraphConfigButton.show();
  savePNGButton.show();
}

void ButtonBar::checkGraphConfigButton(void)
{
  if(mainWindow->graphConfig && mainWindow->graphConfig->is_visible() &&
     showGraphConfigButton.get_label() != "Hide Config")
    showGraphConfigButton.set_label("Hide Config");
  else if((!mainWindow->graphConfig || !mainWindow->graphConfig->is_visible()) &&
          showGraphConfigButton.get_label() != "Show Config")
    showGraphConfigButton.set_label("Show Config");
}

void ButtonBar::on_showGraphConfigButton(void)
{
  if(!mainWindow->graphConfig || !mainWindow->graphConfig->is_visible())
  {
    mainWindow->showGraphConfig();
  }
  else if(mainWindow->graphConfig && mainWindow->graphConfig->is_visible())
  {
    mainWindow->graphConfig->hide();
  }
}


FancyButton::FancyButton(const Glib::ustring& label, bool mnemonic) :
  Button(label, mnemonic)
{
  // plan to add more here
}