Frequencies Dialog: Add the ability to specify a bar chart
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 21 Feb 2015 12:27:24 +0000 (13:27 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 21 Feb 2015 12:27:24 +0000 (13:27 +0100)
src/ui/gui/frequencies.ui
src/ui/gui/psppire-dialog-action-frequencies.c
src/ui/gui/psppire-dialog-action-frequencies.h

index 177fd01c165668a4a70c6aae94d26ba05a930f8c..b1708f764977b29f1ab0f5243e8eacfa86996a97 100644 (file)
                             <property name="position">1</property>
                           </packing>
                         </child>
                             <property name="position">1</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox6">
+                            <property name="visible">True</property>
+                            <child>
+                              <object class="GtkLabel" id="label7">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Scale:</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="freqs">
+                                <property name="label" translatable="yes">_Frequencies</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="percents">
+                                <property name="label" translatable="yes">_Percentages</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">freqs</property>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
                       </object>
                     </child>
                   </object>
                             <property name="position">1</property>
                           </packing>
                         </child>
                             <property name="position">1</property>
                           </packing>
                         </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label10">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Histograms&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame9">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment9">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox9">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
                         <child>
                         <child>
-                          <object class="GtkHBox" id="hbox6">
+                          <object class="GtkCheckButton" id="bar">
+                            <property name="label" translatable="yes">Draw _bar charts</property>
                             <property name="visible">True</property>
                             <property name="visible">True</property>
-                            <child>
-                              <object class="GtkLabel" id="label7">
-                                <property name="visible">True</property>
-                                <property name="label" translatable="yes">Scale:</property>
-                              </object>
-                              <packing>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="freqs">
-                                <property name="label" translatable="yes">_Frequencies</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="percents">
-                                <property name="label" translatable="yes">_Percentages</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">freqs</property>
-                              </object>
-                              <packing>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
                           </object>
                           <packing>
                           </object>
                           <packing>
-                            <property name="position">2</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                       </object>
                           </packing>
                         </child>
                       </object>
                   </object>
                 </child>
                 <child type="label">
                   </object>
                 </child>
                 <child type="label">
-                  <object class="GtkLabel" id="label10">
+                  <object class="GtkLabel" id="label12">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Histograms&lt;/b&gt;</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Bar Charts&lt;/b&gt;</property>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
-              </object>
+             </object>
               <packing>
               <packing>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
               </packing>
-            </child>
+           </child>
             <child>
               <object class="GtkFrame" id="frame4">
                 <property name="visible">True</property>
             <child>
               <object class="GtkFrame" id="frame4">
                 <property name="visible">True</property>
                 </child>
               </object>
               <packing>
                 </child>
               </object>
               <packing>
-                <property name="position">2</property>
+                <property name="position">3</property>
               </packing>
             </child>
           </object>
               </packing>
             </child>
           </object>
index a5c5010a09c0e69f93952a1dfeaa906e60ff092a..78400effcf5dd33ab1c0005a7a334c70544565d9 100644 (file)
@@ -1,18 +1,18 @@
 /* PSPPIRE - a graphical user interface for PSPP.
 /* PSPPIRE - a graphical user interface for PSPP.
-Copyright (C) 2012  Free Software Foundation
+   Copyright (C) 2012  Free Software Foundation
 
 
-This program is free software: you can redistribute it and/or modify
-             it under the terms of the GNU General Public License as published by
-             the Free Software Foundation, either version 3 of the License, or
-  (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
 
-     This program is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
 
-  You should have received a copy of the GNU General Public License
-  along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 
 #include <config.h>
 
 
 #include <config.h>
@@ -178,6 +178,10 @@ on_charts_clicked (PsppireDialogActionFrequencies *fd)
 
   g_signal_emit_by_name (fd->pie, "toggled");
 
 
   g_signal_emit_by_name (fd->pie, "toggled");
 
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fd->bar), fd->charts_opts_draw_bar);
+  g_signal_emit_by_name (fd->bar, "toggled");
+
   ret = psppire_dialog_run (PSPPIRE_DIALOG (fd->charts_dialog));
 
   if ( ret == PSPPIRE_RESPONSE_CONTINUE )
   ret = psppire_dialog_run (PSPPIRE_DIALOG (fd->charts_dialog));
 
   if ( ret == PSPPIRE_RESPONSE_CONTINUE )
@@ -198,6 +202,9 @@ on_charts_clicked (PsppireDialogActionFrequencies *fd)
        fd->charts_opts_draw_pie = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie));
        fd->charts_opts_pie_include_missing
           = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie_include_missing));
        fd->charts_opts_draw_pie = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie));
        fd->charts_opts_pie_include_missing
           = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->pie_include_missing));
+
+
+       fd->charts_opts_draw_bar = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fd->bar));
     }
 }
 
     }
 }
 
@@ -295,6 +302,7 @@ psppire_dialog_action_frequencies_activate (GtkAction * a)
   act->charts_opts_draw_normal = false;
   act->charts_opts_scale = FRQ_FREQ;
   act->charts_opts_draw_pie = false;
   act->charts_opts_draw_normal = false;
   act->charts_opts_scale = FRQ_FREQ;
   act->charts_opts_draw_pie = false;
+  act->charts_opts_draw_bar = false;
   act->charts_opts_pie_include_missing = false;
 
   act->freqs = get_widget_assert (xml, "freqs");
   act->charts_opts_pie_include_missing = false;
 
   act->freqs = get_widget_assert (xml, "freqs");
@@ -317,6 +325,8 @@ psppire_dialog_action_frequencies_activate (GtkAction * a)
   act->pie =  (get_widget_assert (xml, "pie"));
   act->pie_include_missing = get_widget_assert (xml, "pie-include-missing");
 
   act->pie =  (get_widget_assert (xml, "pie"));
   act->pie_include_missing = get_widget_assert (xml, "pie-include-missing");
 
+  act->bar =  (get_widget_assert (xml, "bar"));
+
 
   g_object_unref (xml);
 
 
   g_object_unref (xml);
 
@@ -461,6 +471,21 @@ generate_syntax (PsppireDialogAction * a)
         ds_put_c_format (&str, " MAX(%.15g)", fd->charts_opts_max);
     }
 
         ds_put_c_format (&str, " MAX(%.15g)", fd->charts_opts_max);
     }
 
+
+  if (fd->charts_opts_draw_bar)
+    {
+      ds_put_cstr (&str, "\n\t/BARCHART=");
+
+      if (fd->charts_opts_scale == FRQ_PERCENT)
+        ds_put_cstr (&str, " PERCENT");
+
+      if (fd->charts_opts_use_min)
+        ds_put_c_format (&str, " MIN(%.15g)", fd->charts_opts_min);
+      if (fd->charts_opts_use_max)
+        ds_put_c_format (&str, " MAX(%.15g)", fd->charts_opts_max);
+    }
+
+
   ds_put_cstr (&str, ".\n");
 
   text = ds_steal_cstr (&str);
   ds_put_cstr (&str, ".\n");
 
   text = ds_steal_cstr (&str);
index ea801581ad6b4901749b2cfbf1cad376159ba33d..a06eee3e0d2be9a8e8fcf3572f6e5ada5a0dd938 100644 (file)
@@ -126,6 +126,7 @@ struct _PsppireDialogActionFrequencies
   gboolean charts_opts_draw_pie;
   gboolean charts_opts_pie_include_missing;
 
   gboolean charts_opts_draw_pie;
   gboolean charts_opts_pie_include_missing;
 
+  gboolean charts_opts_draw_bar;
 
   enum frq_scale charts_opts_scale;
 
 
   enum frq_scale charts_opts_scale;
 
@@ -134,6 +135,8 @@ struct _PsppireDialogActionFrequencies
   GtkWidget *pie;
   GtkWidget *pie_include_missing;
 
   GtkWidget *pie;
   GtkWidget *pie_include_missing;
 
+  GtkWidget *bar;
+
   GtkWidget *charts_dialog;
 };
 
   GtkWidget *charts_dialog;
 };