From 4585597f47ff6aca1a08c772d026d003586f1159 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 18 Sep 2000 19:41:52 +0000 Subject: [PATCH] add a setDefaults to GUIRuntime + some const changes in tabular + some c_str to work in spellchecker git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1027 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 9 +++++ src/frontends/GUIRunTime.h | 3 ++ src/frontends/gnome/GUIRunTime.C | 22 ++++++++++ src/frontends/kde/GUIRunTime.C | 23 +++++++++++ src/frontends/xforms/GUIRunTime.C | 32 ++++++++++++--- src/insets/insettabular.C | 5 ++- src/lyx_gui.C | 20 +-------- src/mathed/math_cursor.C | 18 +-------- src/mathed/math_cursor.h | 2 +- src/spellchecker.C | 9 +++-- src/tabular.C | 67 ++++++++++++++----------------- 11 files changed, 128 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9da00fba2e..9ec94b0e3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2000-09-18 Lars Gullik Bjønnes + * src/tabular.C: some more const to local vars move some loop vars + + * src/spellchecker.C: added some c_str after some word for pspell + + * src/frontends/GUIRunTime.h: add new static method setDefaults + * src/frontends/xforms/GUIRunTime.C (setDefaults): + * src/frontends/kde/GUIRunTime.C (setDefaults): + * src/frontends/gnome/GUIRunTime.C (setDefaults): new method + * src/mathed/math_cursor.C (MacroModeClose): don't call SetName with strnew in arg, use correct emptystring when calling SetName. diff --git a/src/frontends/GUIRunTime.h b/src/frontends/GUIRunTime.h index 39bac4997b..7b4a8e594d 100644 --- a/src/frontends/GUIRunTime.h +++ b/src/frontends/GUIRunTime.h @@ -31,5 +31,8 @@ public: /// static void runTime(); + /// This is run first in the LyXGUI constructor. + static + void setDefaults(); }; #endif diff --git a/src/frontends/gnome/GUIRunTime.C b/src/frontends/gnome/GUIRunTime.C index 928301224d..7a3c4522fe 100644 --- a/src/frontends/gnome/GUIRunTime.C +++ b/src/frontends/gnome/GUIRunTime.C @@ -90,3 +90,25 @@ void GUIRunTime::runTime() } } } + + +void GUIRunTime::setDefaults() +{ + FL_IOPT cntl; + cntl.buttonFontSize = FL_NORMAL_SIZE; + cntl.browserFontSize = FL_NORMAL_SIZE; + cntl.labelFontSize = FL_NORMAL_SIZE; + cntl.choiceFontSize = FL_NORMAL_SIZE; + cntl.inputFontSize = FL_NORMAL_SIZE; + cntl.menuFontSize = FL_NORMAL_SIZE; + cntl.borderWidth = -1; + cntl.vclass = FL_DefaultVisual; + fl_set_defaults(FL_PDVisual + | FL_PDButtonFontSize + | FL_PDBrowserFontSize + | FL_PDLabelFontSize + | FL_PDChoiceFontSize + | FL_PDInputFontSize + | FL_PDMenuFontSize + | FL_PDBorderWidth, &cntl); +} diff --git a/src/frontends/kde/GUIRunTime.C b/src/frontends/kde/GUIRunTime.C index 15cc4f1ce8..a836e50ddc 100644 --- a/src/frontends/kde/GUIRunTime.C +++ b/src/frontends/kde/GUIRunTime.C @@ -86,3 +86,26 @@ void GUIRunTime::runTime() } } } + + +void GUIRunTime::setDefaults() +{ + FL_IOPT cntl; + cntl.buttonFontSize = FL_NORMAL_SIZE; + cntl.browserFontSize = FL_NORMAL_SIZE; + cntl.labelFontSize = FL_NORMAL_SIZE; + cntl.choiceFontSize = FL_NORMAL_SIZE; + cntl.inputFontSize = FL_NORMAL_SIZE; + cntl.menuFontSize = FL_NORMAL_SIZE; + cntl.borderWidth = -1; + cntl.vclass = FL_DefaultVisual; + fl_set_defaults(FL_PDVisual + | FL_PDButtonFontSize + | FL_PDBrowserFontSize + | FL_PDLabelFontSize + | FL_PDChoiceFontSize + | FL_PDInputFontSize + | FL_PDMenuFontSize + | FL_PDBorderWidth, &cntl); +} + diff --git a/src/frontends/xforms/GUIRunTime.C b/src/frontends/xforms/GUIRunTime.C index 8e0dc35155..cc867e24fb 100644 --- a/src/frontends/xforms/GUIRunTime.C +++ b/src/frontends/xforms/GUIRunTime.C @@ -60,14 +60,15 @@ int GUIRunTime::initApplication(int , char **) return 0; } + void GUIRunTime::processEvents() { - XEvent ev; + XEvent ev; - if (fl_do_forms() == FL_EVENT) { - lyxerr << "LyX: This shouldn't happen..." << endl; - fl_XNextEvent(&ev); - } + if (fl_do_forms() == FL_EVENT) { + lyxerr << "LyX: This shouldn't happen..." << endl; + fl_XNextEvent(&ev); + } } @@ -82,3 +83,24 @@ void GUIRunTime::runTime() } } + +void GUIRunTime::setDefaults() +{ + FL_IOPT cntl; + cntl.buttonFontSize = FL_NORMAL_SIZE; + cntl.browserFontSize = FL_NORMAL_SIZE; + cntl.labelFontSize = FL_NORMAL_SIZE; + cntl.choiceFontSize = FL_NORMAL_SIZE; + cntl.inputFontSize = FL_NORMAL_SIZE; + cntl.menuFontSize = FL_NORMAL_SIZE; + cntl.borderWidth = -1; + cntl.vclass = FL_DefaultVisual; + fl_set_defaults(FL_PDVisual + | FL_PDButtonFontSize + | FL_PDBrowserFontSize + | FL_PDLabelFontSize + | FL_PDChoiceFontSize + | FL_PDInputFontSize + | FL_PDMenuFontSize + | FL_PDBorderWidth, &cntl); +} diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b0906a2509..8b07c7885f 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -879,9 +879,10 @@ int InsetTabular::Latex(Buffer const * buf, ostream & os, } -int InsetTabular::Ascii(Buffer const *, ostream &) const +int InsetTabular::Ascii(Buffer const * buf, ostream & os) const { - return 0; + // This should be changed to a real ascii export + return tabular->Latex(buf, os, false, false); } diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 1008af7151..1b090fc065 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -109,6 +109,7 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI) if (!gui) return; + // setDefaults(); static const int num_res = sizeof(res)/sizeof(FL_resource); @@ -172,7 +173,6 @@ LyXGUI::~LyXGUI() delete lyxserver; lyxserver = 0; delete lyxViews; - lyxViews = 0; CloseLyXLookup(); } @@ -180,23 +180,7 @@ LyXGUI::~LyXGUI() void LyXGUI::setDefaults() { - FL_IOPT cntl; - cntl.buttonFontSize = FL_NORMAL_SIZE; - cntl.browserFontSize = FL_NORMAL_SIZE; - cntl.labelFontSize = FL_NORMAL_SIZE; - cntl.choiceFontSize = FL_NORMAL_SIZE; - cntl.inputFontSize = FL_NORMAL_SIZE; - cntl.menuFontSize = FL_NORMAL_SIZE; - cntl.borderWidth = -1; - cntl.vclass = FL_DefaultVisual; - fl_set_defaults(FL_PDVisual - | FL_PDButtonFontSize - | FL_PDBrowserFontSize - | FL_PDLabelFontSize - | FL_PDChoiceFontSize - | FL_PDInputFontSize - | FL_PDMenuFontSize - | FL_PDBorderWidth, &cntl); + GUIRunTime::setDefaults(); } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 5e2451b55e..7d635f20a0 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -53,23 +53,9 @@ bool IsMacro(short tok, int id) !(tok == LM_TK_SYM && id < 255)); } - -// Yes, mathed isn't using string yet. -static inline -char * strnew(char const * s) -{ - char * s1 = new char[strlen(s)+1]; - strcpy(s1, s); - return s1; -} - - - static int const MAX_STACK_ITEMS = 32; - struct MathStackXIter { - int i, imax; MathedXIter * item; @@ -114,7 +100,8 @@ struct MathStackXIter { } mathstk, *selstk = 0; -MathStackXIter::MathStackXIter(MathStackXIter & stk) { +MathStackXIter::MathStackXIter(MathStackXIter & stk) +{ imax = stk.imax; item = new MathedXIter[imax]; i = stk.i; @@ -777,7 +764,6 @@ void MathedCursor::MacroModeClose() if (macroln > 0 && (!l || (l && IsMacro(l->token, l->id))) && !MathMacroTable::mathMTable.getMacro(macrobf)) { if (!l) { - //imacro->SetName(strnew(macrobf)); imacro->SetName(macrobf); // This guarantees that the string will be removed by destructor imacro->SetType(LM_OT_UNDEF); diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 8ccd85936c..b187a72fca 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -143,7 +143,7 @@ class MathedCursor { /// // LyxArrayBase *selarray; /// - Bool is_visible; + bool is_visible; /// long unsigned win; /// diff --git a/src/spellchecker.C b/src/spellchecker.C index 6783f2989e..451baa54c8 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -624,14 +624,15 @@ static isp_result * sc_check_word(string const & word) { isp_result * result = new isp_result; - int word_ok = pspell_manager_check(sc, word); + int word_ok = pspell_manager_check(sc, word.c_str()); Assert(word_ok != -1); if (word_ok) { result->flag = ISP_OK; } else { - PspellWordList const * sugs = pspell_manager_suggest(sc, word); + PspellWordList const * sugs = + pspell_manager_suggest(sc, word.c_str()); Assert(sugs != 0); result->els = pspell_word_list_elements(sugs); if (pspell_word_list_empty(sugs)) @@ -653,14 +654,14 @@ void close_spell_checker() static inline void sc_insert_word(string const & word) { - pspell_manager_add_to_personal(sc, word); + pspell_manager_add_to_personal(sc, word.c_str()); } static inline void sc_accept_word(string const & word) { - pspell_manager_add_to_session(sc, word); + pspell_manager_add_to_session(sc, word.c_str()); } diff --git a/src/tabular.C b/src/tabular.C index e29f37b40b..7707ba27b8 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -1341,12 +1341,8 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) string const LyXTabular::GetDocBookAlign(int cell, bool isColumn) const { - int i = isColumn ? cell : column_of_cell(cell); + int i = isColumn ? cell : column_of_cell(cell); - //if (isColumn) - //i = cell; - //else - //i = column_of_cell(cell); if (!isColumn && IsMultiColumn(cell)) { if (!cellinfo_of_cell(cell)->align_special.empty()) { return cellinfo_of_cell(cell)->align_special; @@ -1389,10 +1385,8 @@ string const LyXTabular::GetDocBookAlign(int cell, bool isColumn) const // returns the number of printed newlines int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const { - int i; int ret = 0; - //int tmp; // tmp2; // unused - int nvcell; // fcell; // unused + int nvcell; if (IsLastCell(cell)) { os << newlineAndDepth(--depth) << "" @@ -1420,7 +1414,7 @@ int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const << "' COLSEP='1' ROWSEP='1'>" << newlineAndDepth(++depth); ++ret; - for (i = 0; i < columns_; ++i) { + for (int i = 0; i < columns_; ++i) { os << "" @@ -1517,8 +1511,8 @@ bool LyXTabular::IsMultiColumn(int cell, bool real) const LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const { - int row = row_of_cell(cell); - int column = column_of_cell(cell); + int const row = row_of_cell(cell); + int const column = column_of_cell(cell); return &cell_info[row][column]; } @@ -1538,7 +1532,7 @@ void LyXTabular::SetMultiColumn(int cell, int number) int LyXTabular::cells_in_multicolumn(int cell) const { - int row = row_of_cell(cell); + int const row = row_of_cell(cell); int column = column_of_cell(cell); int result = 1; ++column; @@ -1554,7 +1548,7 @@ int LyXTabular::cells_in_multicolumn(int cell) const int LyXTabular::UnsetMultiColumn(int cell) { - int row = row_of_cell(cell); + int const row = row_of_cell(cell); int column = column_of_cell(cell); int result = 0; @@ -1627,7 +1621,7 @@ bool LyXTabular::NeedRotating() const bool LyXTabular::IsLastCell(int cell) const { - if ((cell+1) < GetNumberOfCells()) + if ((cell + 1) < GetNumberOfCells()) return false; return true; } @@ -1643,7 +1637,7 @@ int LyXTabular::GetCellAbove(int cell) const int LyXTabular::GetCellBelow(int cell) const { - if (row_of_cell(cell)+1 < rows_) + if (row_of_cell(cell) + 1 < rows_) return cell_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno; return cell; } @@ -1655,17 +1649,17 @@ int LyXTabular::GetLastCellAbove(int cell) const return cell; if (!IsMultiColumn(cell)) return GetCellAbove(cell); - return cell_info[row_of_cell(cell)-1][right_column_of_cell(cell)].cellno; + return cell_info[row_of_cell(cell) - 1][right_column_of_cell(cell)].cellno; } int LyXTabular::GetLastCellBelow(int cell) const { - if (row_of_cell(cell)+1 >= rows_) + if (row_of_cell(cell) + 1 >= rows_) return cell; if (!IsMultiColumn(cell)) return GetCellBelow(cell); - return cell_info[row_of_cell(cell)+1][right_column_of_cell(cell)].cellno; + return cell_info[row_of_cell(cell) + 1][right_column_of_cell(cell)].cellno; } @@ -1704,7 +1698,7 @@ int LyXTabular::GetUsebox(int cell) const void LyXTabular::SetLTHead(int cell, bool first) { int const row = row_of_cell(cell); - int const val = (row+1) * (column_of_cell(cell)? 1:-1); + int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1); if (first) { if (endfirsthead == val) @@ -1725,7 +1719,7 @@ bool LyXTabular::GetRowOfLTHead(int cell, int & row) const row = endhead; if (abs(endhead) > rows_) return false; - return (row_of_cell(cell) == (abs(endhead)-1)); + return (row_of_cell(cell) == abs(endhead) - 1); } @@ -1734,14 +1728,14 @@ bool LyXTabular::GetRowOfLTFirstHead(int cell, int & row) const row = endfirsthead; if (abs(endfirsthead) > rows_) return false; - return (row_of_cell(cell) == (abs(endfirsthead)-1)); + return (row_of_cell(cell) == abs(endfirsthead) - 1); } void LyXTabular::SetLTFoot(int cell, bool last) { int const row = row_of_cell(cell); - int const val = (row + 1) * (column_of_cell(cell)? 1:-1); + int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1); if (last) { if (endlastfoot == val) @@ -1760,9 +1754,9 @@ void LyXTabular::SetLTFoot(int cell, bool last) bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const { row = endfoot; - if ((endfoot+1) > rows_) + if ((endfoot + 1) > rows_) return false; - return (row_of_cell(cell) == (abs(endfoot)-1)); + return (row_of_cell(cell) == abs(endfoot) - 1); } @@ -1842,19 +1836,19 @@ bool LyXTabular::IsPartOfMultiColumn(int row, int column) const int LyXTabular::TeXTopHLine(ostream & os, int row) const { - int fcell = GetFirstCellInRow(row); - int n = NumberOfCellsInRow(fcell) + fcell; - int tmp=0; - int i; +#warning should this return a bool? (Lgb) + int const fcell = GetFirstCellInRow(row); + int const n = NumberOfCellsInRow(fcell) + fcell; + int tmp = 0; - for (i = fcell; i < n; ++i) { + for (int i = fcell; i < n; ++i) { if (TopLine(i)) ++tmp; } if (tmp == (n - fcell)){ os << "\\hline "; } else { - for (i = fcell; i < n; ++i) { + for (int i = fcell; i < n; ++i) { if (TopLine(i)) { os << "\\cline{" << column_of_cell(i) + 1 @@ -1874,6 +1868,7 @@ int LyXTabular::TeXTopHLine(ostream & os, int row) const int LyXTabular::TeXBottomHLine(ostream & os, int row) const { +#warning should this return a bool? (Lgb) int const fcell = GetFirstCellInRow(row); int const n = NumberOfCellsInRow(fcell) + fcell; int tmp = 0; @@ -2178,9 +2173,9 @@ void LyXTabular::Validate(LaTeXFeatures & features) const bool LyXTabular::UseParbox(int cell) const { - LyXParagraph *par = GetCellInset(cell)->par; + LyXParagraph * par = GetCellInset(cell)->par; - for(;par; par = par->next) { + for(; par; par = par->next) { for(int i = 0; i < par->Last(); ++i) { if (par->GetChar(i) == LyXParagraph::META_NEWLINE) return true; -- 2.39.2