~ubuntu-branches/ubuntu/quantal/glom/quantal

« back to all changes in this revision

Viewing changes to glom/mode_design/layout/layout_item_dialogs/box_formatting.cc

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-01-29 15:18:17 UTC
  • mfrom: (1.1.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20100129151817-tzpjgd5tuw2pixa4
Tags: 1.13.2-0ubuntu1
* New upstream release.
* Update debian/copyright according to Debian DEP-5 spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
Box_Formatting::Box_Formatting(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder)
29
29
: Gtk::VBox(cobject),
30
30
  m_vbox_numeric_format(0),
 
31
  m_checkbox_format_use_thousands(0),
 
32
  m_checkbox_format_use_decimal_places(0),
 
33
  m_entry_format_decimal_places(0),
 
34
  m_entry_currency_symbol(0),
 
35
  m_checkbox_format_color_negatives(0),
31
36
  m_vbox_text_format(0),
 
37
  m_combo_format_text_horizontal_alignment(0),
32
38
  m_checkbox_format_text_multiline(0),
33
39
  m_label_format_text_multiline_height(0),
34
40
  m_spinbutton_format_text_multiline_height(0),
47
53
  m_checkbutton_choices_restricted(0),
48
54
  m_adddel_choices_custom(0),
49
55
  m_col_index_custom_choices(0),
50
 
  m_for_print_layout(false)
 
56
  m_for_print_layout(false),
 
57
  m_show_numeric(true),
 
58
  m_show_choices(true)
51
59
{
52
60
  //Numeric formatting:
53
61
  builder->get_widget("vbox_numeric_format", m_vbox_numeric_format);
55
63
  builder->get_widget("checkbutton_format_use_decimal_places", m_checkbox_format_use_decimal_places);
56
64
  builder->get_widget("entry_format_decimal_places", m_entry_format_decimal_places);
57
65
  builder->get_widget_derived("entry_currency_symbol", m_entry_currency_symbol);
 
66
  builder->get_widget("checkbutton_foreground_negatives", m_checkbox_format_color_negatives);
58
67
 
59
68
  //Text formatting:
60
69
  builder->get_widget("vbox_text_format", m_vbox_text_format);
 
70
  builder->get_widget("combo_format_text_horizontal_alignment", m_combo_format_text_horizontal_alignment);
61
71
  builder->get_widget("checkbutton_format_text_multiline", m_checkbox_format_text_multiline);
62
72
  builder->get_widget("label_format_text_multiline", m_label_format_text_multiline_height);
63
73
  builder->get_widget("spinbutton_format_text_multiline_height", m_spinbutton_format_text_multiline_height);
71
81
  builder->get_widget("colorbutton_background", m_colorbutton_background);
72
82
  builder->get_widget("checkbutton_color_background", m_checkbox_format_text_color_background);
73
83
 
74
 
 
 
84
  //Fill the alignment combo:
 
85
  m_model_alignment = Gtk::ListStore::create(m_columns_alignment);
 
86
 
 
87
  Gtk::TreeModel::iterator iter = m_model_alignment->append();
 
88
  (*iter)[m_columns_alignment.m_col_alignment] = FieldFormatting::HORIZONTAL_ALIGNMENT_AUTO;
 
89
  //Translators: This is Automatic text alignment.
 
90
  (*iter)[m_columns_alignment.m_col_title] = _("Automatic");
 
91
  iter = m_model_alignment->append();
 
92
  (*iter)[m_columns_alignment.m_col_alignment] = FieldFormatting::HORIZONTAL_ALIGNMENT_LEFT;
 
93
  //Translators: This is Left text alignment.
 
94
  (*iter)[m_columns_alignment.m_col_title] = _("Left");
 
95
  iter = m_model_alignment->append();
 
96
  (*iter)[m_columns_alignment.m_col_alignment] = FieldFormatting::HORIZONTAL_ALIGNMENT_RIGHT;
 
97
  //Translators: This is Right text alignment.
 
98
  (*iter)[m_columns_alignment.m_col_title] = _("Right");
 
99
 
 
100
  m_combo_format_text_horizontal_alignment->set_model(m_model_alignment);
 
101
  m_combo_format_text_horizontal_alignment->pack_start(m_columns_alignment.m_col_title);
 
102
  
75
103
 
76
104
  //Choices:
77
105
  builder->get_widget("vbox_choices", m_vbox_choices);
95
123
  m_checkbox_format_text_font->signal_toggled().connect( sigc::mem_fun(*this, &Box_Formatting::on_checkbox) );
96
124
  m_checkbox_format_text_color_foreground->signal_toggled().connect( sigc::mem_fun(*this, &Box_Formatting::on_checkbox) );
97
125
  m_checkbox_format_text_color_background->signal_toggled().connect( sigc::mem_fun(*this, &Box_Formatting::on_checkbox) );
 
126
  m_checkbox_format_color_negatives->signal_toggled().connect( sigc::mem_fun(*this, &Box_Formatting::on_checkbox) );
98
127
 
99
128
  show_all_children();
100
129
}
106
135
void Box_Formatting::set_is_for_print_layout()
107
136
{
108
137
  m_for_print_layout = true;
 
138
  m_show_choices = false;
109
139
 
110
140
  //Add labels (because we will hide the checkboxes): 
111
141
  Gtk::Label* label = Gtk::manage(new Gtk::Label(_("Font")));
130
160
  set_formatting(format);
131
161
}
132
162
 
133
 
void Box_Formatting::set_formatting(const FieldFormatting& format)
 
163
void Box_Formatting::set_formatting(const FieldFormatting& format, bool show_numeric, bool show_choices)
134
164
{
135
165
  m_format = format;
136
166
 
 
167
  m_show_numeric = show_numeric;
 
168
  m_show_choices = show_choices;
 
169
 
 
170
  //Numeric formatting:
137
171
  m_checkbox_format_use_thousands->set_active( format.m_numeric_format.m_use_thousands_separator );
138
172
  m_checkbox_format_use_decimal_places->set_active( format.m_numeric_format.m_decimal_places_restricted );
139
173
 
143
177
 
144
178
  m_entry_currency_symbol->get_entry()->set_text(format.m_numeric_format.m_currency_symbol);
145
179
 
 
180
  m_checkbox_format_color_negatives->set_active(
 
181
    format.m_numeric_format.m_alt_foreground_color_for_negatives );
 
182
 
 
183
  //Text formatting
 
184
  const FieldFormatting::HorizontalAlignment alignment = 
 
185
    format.get_horizontal_alignment();
 
186
  Gtk::TreeModel::Children children = m_model_alignment->children(); 
 
187
  for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter)
 
188
  {
 
189
    Gtk::TreeModel::Row row = *iter;
 
190
    if(row[m_columns_alignment.m_col_alignment] == alignment)
 
191
    {
 
192
      m_combo_format_text_horizontal_alignment->set_active(iter);
 
193
      break;
 
194
    }
 
195
  }
 
196
 
146
197
  m_checkbox_format_text_multiline->set_active(format.get_text_format_multiline());
147
198
 
148
199
  m_spinbutton_format_text_multiline_height->set_value(format.get_text_format_multiline_height_lines());
209
260
 
210
261
  m_format.m_numeric_format.m_currency_symbol = m_entry_currency_symbol->get_entry()->get_text();
211
262
 
 
263
  m_format.m_numeric_format.m_alt_foreground_color_for_negatives = 
 
264
    m_checkbox_format_color_negatives->get_active();
 
265
 
212
266
  //Text formatting:
 
267
  Gtk::TreeModel::iterator iter = m_combo_format_text_horizontal_alignment->get_active();
 
268
  FieldFormatting::HorizontalAlignment alignment = FieldFormatting::HORIZONTAL_ALIGNMENT_LEFT;
 
269
  if(iter)
 
270
    alignment = (*iter)[m_columns_alignment.m_col_alignment];
 
271
  m_format.set_horizontal_alignment(alignment);
 
272
 
213
273
  m_format.set_text_format_multiline(m_checkbox_format_text_multiline->get_active());
214
274
  m_format.set_text_format_multiline_height_lines( m_spinbutton_format_text_multiline_height->get_value_as_int() );
215
275
 
288
348
void Box_Formatting::enforce_constraints()
289
349
{
290
350
  //Hide inappropriate UI:
291
 
  bool is_numeric = false;
292
 
  if(m_field && (m_field->get_glom_type() == Field::TYPE_NUMERIC))
293
 
    is_numeric = true;
294
 
 
295
 
  if(is_numeric)
296
 
    m_vbox_numeric_format->show();
297
 
  else
298
 
    m_vbox_numeric_format->hide();
299
 
 
300
 
 
301
 
  bool show_text = false;
302
 
  if(m_field && (m_field->get_glom_type() != Field::TYPE_BOOLEAN) && (m_field->get_glom_type() != Field::TYPE_IMAGE)) //TODO: Allow text options when showing booleans as Yes/No on print layouts.
303
 
    show_text = true;
304
 
 
305
 
  if(m_for_print_layout)
306
 
    show_text = true;
 
351
 
 
352
  bool show_text = true;
 
353
  if(m_field)
 
354
  {
 
355
    m_show_numeric = false;
 
356
    if(m_field->get_glom_type() == Field::TYPE_NUMERIC)
 
357
      m_show_numeric = true;
 
358
 
 
359
    if((m_field->get_glom_type() == Field::TYPE_BOOLEAN) || (m_field->get_glom_type() == Field::TYPE_IMAGE)) //TODO: Allow text options when showing booleans as Yes/No on print layouts.
 
360
    {
 
361
      show_text = false;
 
362
    }
 
363
  }
307
364
 
308
365
  if(show_text)
309
366
  {
344
401
  m_colorbutton_foreground->set_sensitive( m_for_print_layout || m_checkbox_format_text_color_foreground->get_active() );
345
402
  m_colorbutton_background->set_sensitive( m_for_print_layout || m_checkbox_format_text_color_background->get_active() );
346
403
 
 
404
  if(m_show_numeric)
 
405
    m_vbox_numeric_format->show();
 
406
  else
 
407
    m_vbox_numeric_format->hide();
347
408
 
348
 
  if(!m_for_print_layout)
 
409
  if(m_show_choices)
349
410
    m_vbox_choices->show();
350
411
  else
351
412
    m_vbox_choices->hide();