#include "support/LAssert.h"
+
ControlTabular::ControlTabular(Dialog & parent)
: Dialog::Controller(parent), active_cell_(-1)
{}
{
return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
}
+
+
+void ControlTabular::toggleTopLine()
+{
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(LyXTabular::M_TOGGLE_LINE_TOP);
+ else
+ set(LyXTabular::TOGGLE_LINE_TOP);
+}
+
+
+void ControlTabular::toggleBottomLine()
+{
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
+ else
+ set(LyXTabular::TOGGLE_LINE_BOTTOM);
+}
+
+
+void ControlTabular::toggleLeftLine()
+{
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(LyXTabular::M_TOGGLE_LINE_LEFT);
+ else
+ set(LyXTabular::TOGGLE_LINE_LEFT);
+}
+
+
+void ControlTabular::toggleRightLine()
+{
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(LyXTabular::M_TOGGLE_LINE_RIGHT);
+ else
+ set(LyXTabular::TOGGLE_LINE_RIGHT);
+}
+
+
+void ControlTabular::setSpecial(string const & special)
+{
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(LyXTabular::SET_SPECIAL_MULTI, special);
+ else
+ set(LyXTabular::SET_SPECIAL_COLUMN, special);
+}
+
+
+void ControlTabular::setWidth(string const & width)
+{
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(LyXTabular::SET_MPWIDTH, width);
+ else
+ set(LyXTabular::SET_PWIDTH, width);
+
+ dialog().view().update();
+}
+
+
+void ControlTabular::toggleMultiColumn()
+{
+ set(LyXTabular::MULTICOLUMN);
+ dialog().view().update();
+}
+
+
+void ControlTabular::rotateTabular(bool yes)
+{
+ if (yes)
+ set(LyXTabular::SET_ROTATE_TABULAR);
+ else
+ set(LyXTabular::UNSET_ROTATE_TABULAR);
+}
+
+
+void ControlTabular::rotateCell(bool yes)
+{
+ if (yes)
+ set(LyXTabular::SET_ROTATE_CELL);
+ else
+ set(LyXTabular::UNSET_ROTATE_CELL);
+}
+
+
+void ControlTabular::halign(ControlTabular::HALIGN h)
+{
+ LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
+ LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
+
+ switch (h) {
+ case LEFT:
+ num = LyXTabular::ALIGN_LEFT;
+ multi_num = LyXTabular::M_ALIGN_LEFT;
+ break;
+ case CENTER:
+ num = LyXTabular::ALIGN_CENTER;
+ multi_num = LyXTabular::M_ALIGN_CENTER;
+ break;
+ case RIGHT:
+ num = LyXTabular::ALIGN_RIGHT;
+ multi_num = LyXTabular::M_ALIGN_RIGHT;
+ break;
+ case BLOCK:
+ num = LyXTabular::ALIGN_BLOCK;
+ //multi_num: no equivalent
+ break;
+ }
+
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(multi_num);
+ else
+ set(num);
+}
+
+
+void ControlTabular::valign(ControlTabular::VALIGN v)
+{
+ LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
+ LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
+
+ switch (v) {
+ case TOP:
+ num = LyXTabular::VALIGN_TOP;
+ multi_num = LyXTabular::M_VALIGN_TOP;
+ break;
+ case VCENTER:
+ num = LyXTabular::VALIGN_CENTER;
+ multi_num = LyXTabular::M_VALIGN_CENTER;
+ break;
+ case BOTTOM:
+ num = LyXTabular::VALIGN_BOTTOM;
+ multi_num = LyXTabular::M_VALIGN_BOTTOM;
+ break;
+ }
+
+ if (tabular().IsMultiColumn(getActiveCell()))
+ set(multi_num);
+ else
+ set(num);
+}
+
+
+void ControlTabular::longTabular(bool yes)
+{
+ if (yes)
+ set(LyXTabular::SET_LONGTABULAR);
+ else
+ set(LyXTabular::UNSET_LONGTABULAR);
+}
/// set a parameter
void set(LyXTabular::Feature, string const & arg = string());
+ /// borders
+ void toggleTopLine();
+ void toggleBottomLine();
+ void toggleLeftLine();
+ void toggleRightLine();
+
+ void setSpecial(string const & special);
+
+ void setWidth(string const & width);
+
+ void toggleMultiColumn();
+
+ void rotateTabular(bool yes);
+ void rotateCell(bool yes);
+
+ enum HALIGN { LEFT, RIGHT, CENTER, BLOCK };
+
+ void halign(HALIGN h);
+
+ enum VALIGN { TOP, VCENTER, BOTTOM };
+
+ void valign(VALIGN h);
+
+ void longTabular(bool yes);
+
private:
///
int active_cell_;
+2003-04-10 John Levon <levon@movementarian.org>
+
+ * QTabularDialog.h:
+ * QTabularDialog.C:
+ * ui/QTabularDialog.ui: move stuff to controller
+
2003-04-10 John Levon <levon@movementarian.org>
* ui/NumberingModuleBase.ui: bug 1032
#include "lengthcombo.h"
#include "qsetborder.h"
#include "qt_helpers.h"
+#include "debug.h"
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlineedit.h>
+using std::endl;
QTabularDialog::QTabularDialog(QTabular * form)
: QTabularDialogBase(0, 0, false, 0),
}
-namespace {
-
-bool isMulticolumnCell(QTabular * form)
-{
- LyXTabular const & tabular = form->controller().tabular();
- int const cell = form->controller().getActiveCell();
- return tabular.IsMultiColumn(cell);
-}
-
-}
-
-
void QTabularDialog::leftBorder_changed()
{
- if (isMulticolumnCell(form_))
- form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
- else
- form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
+ form_->controller().toggleLeftLine();
form_->changed();
}
void QTabularDialog::rightBorder_changed()
{
- if (isMulticolumnCell(form_))
- form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
- else
- form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
+ form_->controller().toggleRightLine();
form_->changed();
}
void QTabularDialog::topBorder_changed()
{
- if (isMulticolumnCell(form_))
- form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
- else
- form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
+ form_->controller().toggleTopLine();
form_->changed();
}
void QTabularDialog::bottomBorder_changed()
{
- if (isMulticolumnCell(form_))
- form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
- else
- form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
+ form_->controller().toggleBottomLine();
form_->changed();
}
void QTabularDialog::specialAlignment_changed()
{
string special = fromqstr(specialAlignmentED->text());
- if (isMulticolumnCell(form_))
- form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
- else
- form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
+ form_->controller().setSpecial(special);
+ form_->changed();
}
void QTabularDialog::width_changed()
{
+ form_->changed();
string const width =
LyXLength(widthED->text().toDouble(),
widthUnit->currentLengthItem()).asString();
- if (isMulticolumnCell(form_))
- form_->controller().set(LyXTabular::SET_MPWIDTH, width);
- else
- form_->controller().set(LyXTabular::SET_PWIDTH, width);
- form_->changed();
- form_->update_contents();
+ form_->controller().setWidth(width);
}
void QTabularDialog::multicolumn_clicked()
{
- form_->controller().set(LyXTabular::MULTICOLUMN);
+ form_->controller().toggleMultiColumn();
form_->changed();
- form_->update_contents();
}
-void QTabularDialog::rotateTabular_checked(int state)
+void QTabularDialog::rotateTabular()
{
- switch (state) {
- case 0:
- form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
- break;
- case 1:
- // "no change state", should not happen
- break;
- case 2:
- form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
- break;
- }
+ form_->controller().rotateTabular(rotateTabularCB->isChecked());
+ form_->changed();
}
-void QTabularDialog::rotateCell_checked(int state)
+void QTabularDialog::rotateCell()
{
- switch (state) {
- case 0:
- form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
- break;
- case 1:
- // "no change state", should not happen
- break;
- case 2:
- form_->controller().set(LyXTabular::SET_ROTATE_CELL);
- break;
- }
+ form_->controller().rotateCell(rotateCellCB->isChecked());
+ form_->changed();
}
void QTabularDialog::hAlign_changed(int align)
{
- LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
- LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
+ ControlTabular::HALIGN h;
switch (align) {
- case 0:
- {
- num = LyXTabular::ALIGN_LEFT;
- multi_num = LyXTabular::M_ALIGN_LEFT;
- break;
- }
- case 1:
- {
- num = LyXTabular::ALIGN_CENTER;
- multi_num = LyXTabular::M_ALIGN_CENTER;
- break;
- }
- case 2:
- {
- num = LyXTabular::ALIGN_RIGHT;
- multi_num = LyXTabular::M_ALIGN_RIGHT;
- break;
- case 3:
- {
- num = LyXTabular::ALIGN_BLOCK;
- //multi_num: no equivalent
- break;
- }
- }
+ case 0: h = ControlTabular::LEFT; break;
+ case 1: h = ControlTabular::CENTER; break;
+ case 2: h = ControlTabular::RIGHT; break;
+ case 3: h = ControlTabular::BLOCK; break;
}
- if (isMulticolumnCell(form_))
- form_->controller().set(multi_num);
- else
- form_->controller().set(num);
+
+ form_->controller().halign(h);
}
void QTabularDialog::vAlign_changed(int align)
{
- LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
- LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
+ ControlTabular::VALIGN v;
switch (align) {
- case 0:
- {
- num = LyXTabular::VALIGN_TOP;
- multi_num = LyXTabular::M_VALIGN_TOP;
- break;
- }
- case 1:
- {
- num = LyXTabular::VALIGN_CENTER;
- multi_num = LyXTabular::M_VALIGN_CENTER;
- break;
- }
- case 2:
- {
- num = LyXTabular::VALIGN_BOTTOM;
- multi_num = LyXTabular::M_VALIGN_BOTTOM;
- break;
- }
+ case 0: v = ControlTabular::TOP; break;
+ case 1: v = ControlTabular::VCENTER; break;
+ case 2: v = ControlTabular::BOTTOM; break;
}
- if (isMulticolumnCell(form_))
- form_->controller().set(multi_num);
- else
- form_->controller().set(num);
+
+ form_->controller().valign(v);
}
-void QTabularDialog::longTabular_changed(int state)
+void QTabularDialog::longTabular()
{
- switch (state) {
- case 0:
- form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
- break;
- case 1:
- // "no change state", should not happen
- break;
- case 2:
- form_->controller().set(LyXTabular::SET_LONGTABULAR);
- break;
- }
+ form_->controller().longTabular(longTabularCB->isChecked());
form_->changed();
}
virtual void topBorder_changed();
virtual void bottomBorder_changed();
virtual void multicolumn_clicked();
- virtual void rotateTabular_checked(int state);
- virtual void rotateCell_checked(int state);
+ virtual void rotateTabular();
+ virtual void rotateCell();
virtual void hAlign_changed(int align);
virtual void vAlign_changed(int align);
virtual void specialAlignment_changed();
virtual void width_changed();
- virtual void longTabular_changed(int state);
+ virtual void longTabular();
virtual void ltNewpage_clicked();
virtual void ltHeaderStatus_clicked();
virtual void ltHeaderBorderAbove_clicked();
<rect>
<x>0</x>
<y>0</y>
- <width>463</width>
+ <width>480</width>
<height>383</height>
</rect>
</property>
</property>
<property stdset="1">
<name>text</name>
- <string>Dele&te</string>
+ <string>Delete</string>
</property>
<property stdset="1">
<name>autoDefault</name>
</property>
<property>
<name>toolTip</name>
- <string>Rotate the table by 90°</string>
+ <string>Rotate the table by 90 degrees</string>
</property>
</widget>
<widget>
</property>
<property>
<name>toolTip</name>
- <string>Rotate this cell by 90°</string>
+ <string>Rotate this cell by 90 degrees</string>
</property>
</widget>
</vbox>
<receiver>QTabularDialogBase</receiver>
<slot>borderUnset_clicked()</slot>
</connection>
- <connection>
- <sender>rotateTabularCB</sender>
- <signal>stateChanged(int)</signal>
- <receiver>QTabularDialogBase</receiver>
- <slot>rotateTabular_checked(int)</slot>
- </connection>
- <connection>
- <sender>rotateCellCB</sender>
- <signal>stateChanged(int)</signal>
- <receiver>QTabularDialogBase</receiver>
- <slot>rotateCell_checked(int)</slot>
- </connection>
<connection>
<sender>longTabularCB</sender>
<signal>toggled(bool)</signal>
<receiver>QTabularDialogBase</receiver>
<slot>multicolumn_clicked()</slot>
</connection>
- <connection>
- <sender>longTabularCB</sender>
- <signal>stateChanged(int)</signal>
- <receiver>QTabularDialogBase</receiver>
- <slot>longTabular_changed(int)</slot>
- </connection>
<connection>
<sender>newpageCB</sender>
<signal>clicked()</signal>
<receiver>QTabularDialogBase</receiver>
<slot>leftBorder_changed()</slot>
</connection>
+ <connection>
+ <sender>rotateTabularCB</sender>
+ <signal>clicked()</signal>
+ <receiver>QTabularDialogBase</receiver>
+ <slot>rotateTabular()</slot>
+ </connection>
+ <connection>
+ <sender>rotateCellCB</sender>
+ <signal>clicked()</signal>
+ <receiver>QTabularDialogBase</receiver>
+ <slot>rotateCell()</slot>
+ </connection>
+ <connection>
+ <sender>longTabularCB</sender>
+ <signal>clicked()</signal>
+ <receiver>QTabularDialogBase</receiver>
+ <slot>longTabular()</slot>
+ </connection>
<slot access="protected">borderSet_clicked()</slot>
<slot access="protected">borderUnset_clicked()</slot>
<slot access="protected">border_toggled()</slot>
+ <slot access="protected">bottomBorder_changed()</slot>
<slot access="protected">change_adaptor()</slot>
+ <slot access="protected">close_clicked()</slot>
<slot access="protected">columnAppend_clicked()</slot>
<slot access="protected">columnDelete_clicked()</slot>
<slot access="protected">hAlign_changed(int)</slot>
- <slot access="protected">vAlign_changed(int)</slot>
- <slot access="protected">rotateTabular_checked(int)</slot>
- <slot access="protected">rotateCell_checked(int)</slot>
- <slot access="protected">multicolumn_clicked()</slot>
- <slot access="protected">rowAppend_clicked()</slot>
- <slot access="protected">rowDelete_clicked()</slot>
<slot access="protected">leftBorder_changed()</slot>
- <slot access="protected">rightBorder_changed()</slot>
- <slot access="protected">topBorder_changed()</slot>
- <slot access="protected">bottomBorder_changed()</slot>
- <slot access="protected">longTabular_changed(int)</slot>
- <slot access="protected">ltNewpage_clicked()</slot>
- <slot access="protected">ltHeaderStatus_clicked()</slot>
- <slot access="protected">ltHeaderBorderAbove_clicked()</slot>
- <slot access="protected">ltHeaderBorderBelow_clicked()</slot>
- <slot access="protected">ltFirstHeaderStatus_clicked()</slot>
<slot access="protected">ltFirstHeaderBorderAbove_clicked()</slot>
<slot access="protected">ltFirstHeaderBorderBelow_clicked()</slot>
<slot access="protected">ltFirstHeaderEmpty_clicked()</slot>
- <slot access="protected">ltFooterStatus_clicked()</slot>
+ <slot access="protected">ltFirstHeaderStatus_clicked()</slot>
<slot access="protected">ltFooterBorderAbove_clicked()</slot>
<slot access="protected">ltFooterBorderBelow_clicked()</slot>
- <slot access="protected">ltLastFooterStatus_clicked()</slot>
+ <slot access="protected">ltFooterStatus_clicked()</slot>
+ <slot access="protected">ltHeaderBorderAbove_clicked()</slot>
+ <slot access="protected">ltHeaderBorderBelow_clicked()</slot>
+ <slot access="protected">ltHeaderStatus_clicked()</slot>
<slot access="protected">ltLastFooterBorderAbove_clicked()</slot>
<slot access="protected">ltLastFooterBorderBelow_clicked()</slot>
<slot access="protected">ltLastFooterEmpty_clicked()</slot>
+ <slot access="protected">ltLastFooterStatus_clicked()</slot>
+ <slot access="protected">ltNewpage_clicked()</slot>
+ <slot access="protected">multicolumn_clicked()</slot>
+ <slot access="public">longTabular()</slot>
+ <slot access="protected">rightBorder_changed()</slot>
+ <slot access="protected">rotateCell()</slot>
+ <slot access="protected">rotateTabular()</slot>
+ <slot access="protected">rowAppend_clicked()</slot>
+ <slot access="protected">rowDelete_clicked()</slot>
+ <slot access="public">setEnabled(bool)</slot>
<slot access="protected">specialAlignment_changed()</slot>
+ <slot access="protected">topBorder_changed()</slot>
+ <slot access="protected">vAlign_changed(int)</slot>
<slot access="protected">width_changed()</slot>
- <slot access="protected">close_clicked()</slot>
- <slot access="public">setEnabled(bool)</slot>
</connections>
<tabstops>
<tabstop>TabWidget</tabstop>