Added lyx-func tabular-feature for menu structure.

Use f.ex. tabular-feature align-left (for left aligning the actual column)
Some small fixes.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@936 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-07-28 14:28:54 +00:00
parent ef59101fe7
commit 68eddbdf73
11 changed files with 227 additions and 59 deletions

View File

@ -1,3 +1,12 @@
2000-07-28 Juergen Vigna <jug@sad.it>
* src/insets/insettabular.C (LocalDispatch):
(TabularFeatures): added support for lyx-functions of tabular features.
(cellstart): refixed this function after someone wrongly changed it.
* src/commandtags.h:
* src/LyXAction.C (init): added support for tabular-features
2000-07-28 Allan Rae <rae@lyx.org>
* src/frontends/xforms/FormPreferences.C (build): Setup input return

View File

@ -26,6 +26,7 @@ src/ext_l10n.h
src/filedlg.C
src/FontLoader.C
src/form1.C
src/frontends/gnome/Menubar_pimpl.C
src/frontends/xforms/FormCitation.C
src/frontends/xforms/form_citation.C
src/frontends/xforms/FormCopyright.C
@ -34,6 +35,11 @@ src/frontends/xforms/FormPreferences.C
src/frontends/xforms/form_preferences.C
src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_print.C
src/frontends/xforms/forms/form_citation.C
src/frontends/xforms/forms/form_copyright.C
src/frontends/xforms/forms/form_preferences.C
src/frontends/xforms/forms/form_print.C
src/frontends/xforms/forms/form_tabular.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular.C
src/frontends/xforms/FormUrl.C

View File

@ -381,6 +381,8 @@ void LyXAction::init()
#ifndef NEW_TABULAR
{ LFUN_TABLE, "table-insert", N_("Insert Table"), Noop },
#endif
{ LFUN_TABULAR_FEATURE, "tabular-feature",
N_("Tabular Features"), Noop },
{ LFUN_INSET_TABULAR, "tabular-insert",
N_("Insert a new Tabular Inset"), Noop },
{ LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop },

View File

@ -271,6 +271,7 @@ enum kb_action {
LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_SWITCHBUFFER, // and where is this comming from?
LFUN_INSERT_URL, // Angus 20000726
LFUN_TABULAR_FEATURE, // Jug 20000728
LFUN_LASTACTION /* this marks the end of the table */
};

View File

@ -149,17 +149,18 @@ _("Credits...|e");
_("Version...|V");
_("");
_("A&A");
_("ACT");
_("AT_RISE:");
_("Abstract");
_("Accepted");
_("Acknowledgement");
_("Acknowledgement(s)");
_("Acknowledgement*");
_("Acknowledgement-numbered");
_("Acknowledgement(s)");
_("Acknowledgements");
_("Acknowledgement-unnumbered");
_("Acknowledgements");
_("Acknowledgments");
_("Acnowledgement");
_("ACT");
_("Addchap");
_("Addchap*");
_("Addition");
@ -177,15 +178,15 @@ _("Anlagen");
_("Anrede");
_("Appendices");
_("Appendix");
_("AT_RISE:");
_("Author");
_("AuthorRunning");
_("Author_Email");
_("Author_Running");
_("AuthorRunning");
_("Author_URL");
_("Axiom");
_("Axiom-numbered");
_("Axiom-plain");
_("BLZ");
_("Backaddress");
_("Bank");
_("BankAccount");
@ -193,13 +194,12 @@ _("BankCode");
_("Betreff");
_("Bibliography");
_("Biography");
_("BLZ");
_("Brieftext");
_("CC");
_("CURTAIN");
_("Caption");
_("Case");
_("Case-numbered");
_("CC");
_("cc");
_("CenteredCaption");
_("Chapter");
_("Chapter*");
@ -239,7 +239,6 @@ _("Criterion-plain");
_("CrossList");
_("Current");
_("Current_Address");
_("CURTAIN");
_("Customer");
_("Data");
_("Date");
@ -254,10 +253,10 @@ _("Definition-unnumbered");
_("Description");
_("Dialogue");
_("EMail");
_("EXT.");
_("Email");
_("Encl");
_("Encl.");
_("encl");
_("End_All_Slides");
_("Enumerate");
_("Example");
@ -268,48 +267,43 @@ _("Example-unnumbered");
_("Exercise");
_("Exercise-numbered");
_("Exercise-plain");
_("EXT.");
_("Extratitle");
_("FADE_IN:");
_("FADE_OUT:");
_("Fact");
_("Fact*");
_("Fact-numbered");
_("Fact-plain");
_("Fact-unnumbered");
_("FADE_IN:");
_("FADE_OUT:");
_("FigCaption");
_("first");
_("FirstAuthor");
_("FirstName");
_("FitBitmap");
_("FitFigure");
_("Foilhead");
_("foilhead");
_("Footernote");
_("FourAffiliations");
_("FourAuthors");
_("Gruss");
_("Headnote");
_("HTTP");
_("Headnote");
_("INT.");
_("Idea");
_("IhrSchreiben");
_("IhrZeichen");
_("Institute");
_("Institution");
_("INT.");
_("InvisibleText");
_("Invoice");
_("Itemize");
_("Journal");
_("journal");
_("Keywords");
_("Konto");
_("Labeling");
_("Land");
_("landscape");
_("LandscapeSlide");
_("LaTeX");
_("LaTeX_Title");
_("Labeling");
_("Land");
_("LandscapeSlide");
_("Lemma");
_("Lemma*");
_("Lemma-numbered");
@ -328,10 +322,8 @@ _("MarkBoth");
_("MathLetters");
_("MeinZeichen");
_("Minisec");
_("modying");
_("msnumber");
_("My_Address");
_("MyRef");
_("My_Address");
_("Myref");
_("Name");
_("Narrative");
@ -341,18 +333,18 @@ _("Note");
_("Note*");
_("Note-numbered");
_("Note-plain");
_("Note-unnumbered");
_("NoteToEditor");
_("Notetoeditor");
_("Note-unnumbered");
_("Offprint");
_("Offprints");
_("Offsets");
_("offsets");
_("Oggetto");
_("Opening");
_("Ort");
_("Overlay");
_("PACS");
_("PS");
_("Paragraph");
_("Paragraph*");
_("Paragraph-numbered");
@ -363,8 +355,8 @@ _("Petit");
_("Phone");
_("Place");
_("PlaceFigure");
_("Placefigure");
_("PlaceTable");
_("Placefigure");
_("Placetable");
_("PortraitSlide");
_("PostalCommend");
@ -381,12 +373,11 @@ _("Proposition*");
_("Proposition-numbered");
_("Proposition-plain");
_("Proposition-unnumbered");
_("PS");
_("ps");
_("Publishers");
_("Question");
_("Quotation");
_("Quote");
_("REVTEX_Title");
_("Received");
_("Recieved");
_("Recieved/Accepted");
@ -396,17 +387,17 @@ _("Remark");
_("Remark*");
_("Remark-numbered");
_("Remark-plain");
_("Remarks");
_("Remark-unnumbered");
_("Remarks");
_("RetourAdresse");
_("ReturnAddress");
_("REVTEX_Title");
_("Right_Address");
_("RightHeader");
_("Right_Address");
_("Rotatefoilhead");
_("Running_LaTeX_Title");
_("SCENE");
_("SCENE*");
_("SGML");
_("Scrap");
_("Section");
_("Section*");
@ -414,11 +405,10 @@ _("Section-numbered");
_("Send");
_("Send_To_Address");
_("Seriate");
_("SGML");
_("ShortFoilhead");
_("Shortfoilhead");
_("ShortRotatefoilhead");
_("ShortTitle");
_("Shortfoilhead");
_("Signature");
_("Slide");
_("Slide*");
@ -434,26 +424,26 @@ _("State");
_("Strasse");
_("Street");
_("Style");
_("style");
_("SubSection");
_("SubTitle");
_("Subitle");
_("Subject");
_("Subjectclass");
_("Subparagraph");
_("Subparagraph*");
_("SubSection");
_("Subsection");
_("Subsection*");
_("Subsection-numbered");
_("Subsubsection");
_("Subsubsection*");
_("Subsubsection-numbered");
_("SubTitle");
_("Subtitle");
_("Suggested");
_("Summary");
_("Summary-numbered");
_("Surname");
_("surname");
_("TOC_Author");
_("TOC_Title");
_("TableComments");
_("TableRefs");
_("Telefax");
@ -465,8 +455,8 @@ _("Theorem");
_("Theorem*");
_("Theorem-numbered");
_("Theorem-plain");
_("TheoremTemplate");
_("Theorem-unnumbered");
_("TheoremTemplate");
_("Thesaurus");
_("ThickLine");
_("This");
@ -474,29 +464,39 @@ _("ThreeAffiliations");
_("ThreeAuthors");
_("TickList");
_("Title");
_("Titlehead");
_("Title_Running");
_("TOC_Author");
_("TOC_Title");
_("Titlehead");
_("Town");
_("Transition");
_("Trans_Keywords");
_("Transition");
_("Translated");
_("TranslatedAbstract");
_("Translated_Title");
_("Translator");
_("TwoAffiliations");
_("TwoAuthors");
_("URL");
_("Unterschrift");
_("Uppertitleback");
_("URL");
_("Use");
_("Verbatim");
_("Verse");
_("Verteiler");
_("VisibleText");
_("YourMail");
_("Yourmail");
_("YourRef");
_("Yourmail");
_("Yourref");
_("Zusatz");
_("cc");
_("encl");
_("first");
_("foilhead");
_("journal");
_("landscape");
_("modying");
_("msnumber");
_("offsets");
_("ps");
_("style");
_("surname");

View File

@ -1,2 +1,6 @@
Makefile
Makefile.in
*.deps
*.lo
.libs
libgnome.la

View File

@ -44,11 +44,68 @@ using std::max;
using std::endl;
using std::swap;
struct tabular_features {
int action;
string feature;
};
//static tabular_features * tabularFeatures = 0;
static tabular_features tabularFeatures[] =
{
{ LyXTabular::APPEND_ROW, "append-row" },
{ LyXTabular::APPEND_COLUMN, "append-column" },
{ LyXTabular::DELETE_ROW, "delete-row" },
{ LyXTabular::DELETE_COLUMN, "delete-column" },
{ LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
{ LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
{ LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
{ LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
{ LyXTabular::ALIGN_LEFT, "align-left" },
{ LyXTabular::ALIGN_RIGHT, "align-right" },
{ LyXTabular::ALIGN_CENTER, "align-center" },
{ LyXTabular::VALIGN_TOP, "valign-top" },
{ LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
{ LyXTabular::VALIGN_CENTER, "valign-center" },
{ LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
{ LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
{ LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
{ LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
{ LyXTabular::M_ALIGN_LEFT, "m-align-left" },
{ LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
{ LyXTabular::M_ALIGN_CENTER, "m-align-center" },
{ LyXTabular::M_VALIGN_TOP, "m-valign-top" },
{ LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
{ LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
{ LyXTabular::DELETE_TABULAR, "delete-tabular" },
{ LyXTabular::MULTICOLUMN, "multicolumn" },
{ LyXTabular::SET_ALL_LINES, "set-all-lines" },
{ LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
{ LyXTabular::SET_LONGTABULAR, "set-longtabular" },
{ LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
{ LyXTabular::SET_PWIDTH, "set-pwidth" },
{ LyXTabular::SET_MPWIDTH, "set-mpwidth" },
{ LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
{ LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
{ LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
{ LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
{ LyXTabular::SET_LINEBREAKS, "set-linebreaks" },
{ LyXTabular::SET_LTHEAD, "set-lthead" },
{ LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
{ LyXTabular::SET_LTFOOT, "set-ltfoot" },
{ LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
{ LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
{ LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
{ LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
{ LyXTabular::LAST_ACTION, "" }
};
//#define cellstart(p) ((p % 2) == 0)
static inline
bool cellstart(LyXParagraph::size_type p)
{
return ((p & 2) == 0);
return ((p % 2) == 0);
}
@ -71,6 +128,7 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
dialogs_ = 0;
need_update = INIT;
initFeatures();
}
@ -90,6 +148,61 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
}
void InsetTabular::initFeatures()
{
if (tabularFeatures)
return;
tabular_features tf[] = {
{ LyXTabular::APPEND_ROW, "append-row" },
{ LyXTabular::APPEND_COLUMN, "append-column" },
{ LyXTabular::DELETE_ROW, "delete-row" },
{ LyXTabular::DELETE_COLUMN, "delete-column" },
{ LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
{ LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
{ LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
{ LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
{ LyXTabular::ALIGN_LEFT, "align-left" },
{ LyXTabular::ALIGN_RIGHT, "align-right" },
{ LyXTabular::ALIGN_CENTER, "align-center" },
{ LyXTabular::VALIGN_TOP, "valign-top" },
{ LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
{ LyXTabular::VALIGN_CENTER, "valign-center" },
{ LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
{ LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
{ LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
{ LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
{ LyXTabular::M_ALIGN_LEFT, "m-align-left" },
{ LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
{ LyXTabular::M_ALIGN_CENTER, "m-align-center" },
{ LyXTabular::M_VALIGN_TOP, "m-valign-top" },
{ LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
{ LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
{ LyXTabular::DELETE_TABULAR, "delete-tabular" },
{ LyXTabular::MULTICOLUMN, "multicolumn" },
{ LyXTabular::SET_ALL_LINES, "set-all-lines" },
{ LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
{ LyXTabular::SET_LONGTABULAR, "set-longtabular" },
{ LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
{ LyXTabular::SET_PWIDTH, "set-pwidth" },
{ LyXTabular::SET_MPWIDTH, "set-mpwidth" },
{ LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
{ LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
{ LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
{ LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
{ LyXTabular::SET_LINEBREAKS, "set-linebreaks" },
{ LyXTabular::SET_LTHEAD, "set-lthead" },
{ LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
{ LyXTabular::SET_LTFOOT, "set-ltfoot" },
{ LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
{ LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
{ LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
{ LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
{ LyXTabular::LAST_ACTION, "" }
};
}
InsetTabular::~InsetTabular()
{
delete tabular;
@ -722,6 +835,11 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
dialogs_->showTabular(this);
}
break;
case LFUN_TABULAR_FEATURE:
if (!TabularFeatures(bv, arg))
result = UNDISPATCHED;
break;
default:
result = UNDISPATCHED;
break;
@ -1031,6 +1149,28 @@ void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
}
bool InsetTabular::TabularFeatures(BufferView * bv, string what)
{
int action = LyXTabular::LAST_ACTION;
string val;
int i;
for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
tabularFeatures[i].feature.length())) {
action = tabularFeatures[i].action;
break;
}
}
if (action == LyXTabular::LAST_ACTION)
return false;
val = frontStrip(what.substr(tabularFeatures[i].feature.length()));
TabularFeatures(bv, action, val);
return true;
}
void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
{
int
@ -1405,10 +1545,9 @@ int InsetTabular::getMaxWidth(Painter & pain,
if (cell >= n)
return -1;
int w = GetMaxWidthOfCell(pain, cell);
// this because text insets remove the xpos from the maxwidth because
// otherwise the would not break good!!!
// w += getCellXPos(cell) + tabular->GetBeginningOfTextInCell(cell);
// w += inset->x();
if (w > 0)
// because the inset then subtracts it's top_x
w += inset->x();
return w;
}

View File

@ -148,6 +148,8 @@ public:
///
void ToggleInsetCursor(BufferView *);
///
bool TabularFeatures(BufferView * bv, string what);
///
void TabularFeatures(BufferView * bv, int feature, string val = string());
///
int GetActCell() { return actcell; }
@ -167,6 +169,7 @@ public:
LyXTabular * tabular;
private:
bool calculate_dimensions_of_cells(BufferView *, LyXFont const &,
bool =false) const;
///
@ -206,6 +209,8 @@ private:
int GetMaxWidthOfCell(Painter &, int cell) const;
///
void recomputeTextInsets(BufferView *, const LyXFont &) const;
///
void initFeatures();
///
/// Private structures and variables

View File

@ -234,19 +234,14 @@ int InsetText::textWidth(Painter & pain) const
{
int w = getMaxWidth(pain, this);
if (w < 0) {
// printf("WW1: %d\n",w);
return w;
}
#if 1
if (owner()) {
w = w - top_x + owner()->x();
// printf("WW2: %d\n",w);
return w; // - top_x + owner()->x();
return w;
}
#endif
w -= (2 * TEXT_TO_INSET_OFFSET);
// printf("WW2: %d\n",w);
return w - top_x; // - top_x - (2 * TEXT_TO_INSET_OFFSET);
return w - top_x;
}

View File

@ -911,6 +911,12 @@ string LyXFunc::Dispatch(int ac,
#endif
break;
case LFUN_TABULAR_FEATURE:
// this is not handled here as this funktion is only aktive
// if we have a locking_inset and that one is (or contains)
// a tabular-inset
break;
case LFUN_FIGURE:
Figure();
break;

View File

@ -75,7 +75,8 @@ public:
SET_LTLASTFOOT,
SET_LTNEWPAGE,
SET_SPECIAL_COLUMN,
SET_SPECIAL_MULTI
SET_SPECIAL_MULTI,
LAST_ACTION
};
enum {