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
This commit is contained in:
Lars Gullik Bjønnes 2000-09-18 19:41:52 +00:00
parent 7bfd36da33
commit 4585597f47
11 changed files with 128 additions and 82 deletions

View File

@ -1,5 +1,14 @@
2000-09-18 Lars Gullik Bjønnes <larsbj@lyx.org> 2000-09-18 Lars Gullik Bjønnes <larsbj@lyx.org>
* 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 * src/mathed/math_cursor.C (MacroModeClose): don't call SetName
with strnew in arg, use correct emptystring when calling SetName. with strnew in arg, use correct emptystring when calling SetName.

View File

@ -31,5 +31,8 @@ public:
/// ///
static static
void runTime(); void runTime();
/// This is run first in the LyXGUI constructor.
static
void setDefaults();
}; };
#endif #endif

View File

@ -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);
}

View File

@ -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);
}

View File

@ -60,14 +60,15 @@ int GUIRunTime::initApplication(int , char **)
return 0; return 0;
} }
void GUIRunTime::processEvents() void GUIRunTime::processEvents()
{ {
XEvent ev; XEvent ev;
if (fl_do_forms() == FL_EVENT) { if (fl_do_forms() == FL_EVENT) {
lyxerr << "LyX: This shouldn't happen..." << endl; lyxerr << "LyX: This shouldn't happen..." << endl;
fl_XNextEvent(&ev); 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);
}

View File

@ -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);
} }

View File

@ -109,6 +109,7 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
if (!gui) if (!gui)
return; return;
//
setDefaults(); setDefaults();
static const int num_res = sizeof(res)/sizeof(FL_resource); static const int num_res = sizeof(res)/sizeof(FL_resource);
@ -172,7 +173,6 @@ LyXGUI::~LyXGUI()
delete lyxserver; delete lyxserver;
lyxserver = 0; lyxserver = 0;
delete lyxViews; delete lyxViews;
lyxViews = 0;
CloseLyXLookup(); CloseLyXLookup();
} }
@ -180,23 +180,7 @@ LyXGUI::~LyXGUI()
void LyXGUI::setDefaults() void LyXGUI::setDefaults()
{ {
FL_IOPT cntl; GUIRunTime::setDefaults();
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);
} }

View File

@ -53,23 +53,9 @@ bool IsMacro(short tok, int id)
!(tok == LM_TK_SYM && id < 255)); !(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; static int const MAX_STACK_ITEMS = 32;
struct MathStackXIter { struct MathStackXIter {
int i, imax; int i, imax;
MathedXIter * item; MathedXIter * item;
@ -114,7 +100,8 @@ struct MathStackXIter {
} mathstk, *selstk = 0; } mathstk, *selstk = 0;
MathStackXIter::MathStackXIter(MathStackXIter & stk) { MathStackXIter::MathStackXIter(MathStackXIter & stk)
{
imax = stk.imax; imax = stk.imax;
item = new MathedXIter[imax]; item = new MathedXIter[imax];
i = stk.i; i = stk.i;
@ -777,7 +764,6 @@ void MathedCursor::MacroModeClose()
if (macroln > 0 && (!l || (l && IsMacro(l->token, l->id))) && if (macroln > 0 && (!l || (l && IsMacro(l->token, l->id))) &&
!MathMacroTable::mathMTable.getMacro(macrobf)) { !MathMacroTable::mathMTable.getMacro(macrobf)) {
if (!l) { if (!l) {
//imacro->SetName(strnew(macrobf));
imacro->SetName(macrobf); imacro->SetName(macrobf);
// This guarantees that the string will be removed by destructor // This guarantees that the string will be removed by destructor
imacro->SetType(LM_OT_UNDEF); imacro->SetType(LM_OT_UNDEF);

View File

@ -143,7 +143,7 @@ class MathedCursor {
/// ///
// LyxArrayBase *selarray; // LyxArrayBase *selarray;
/// ///
Bool is_visible; bool is_visible;
/// ///
long unsigned win; long unsigned win;
/// ///

View File

@ -624,14 +624,15 @@ static
isp_result * sc_check_word(string const & word) isp_result * sc_check_word(string const & word)
{ {
isp_result * result = new isp_result; 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); Assert(word_ok != -1);
if (word_ok) { if (word_ok) {
result->flag = ISP_OK; result->flag = ISP_OK;
} else { } else {
PspellWordList const * sugs = pspell_manager_suggest(sc, word); PspellWordList const * sugs =
pspell_manager_suggest(sc, word.c_str());
Assert(sugs != 0); Assert(sugs != 0);
result->els = pspell_word_list_elements(sugs); result->els = pspell_word_list_elements(sugs);
if (pspell_word_list_empty(sugs)) if (pspell_word_list_empty(sugs))
@ -653,14 +654,14 @@ void close_spell_checker()
static inline static inline
void sc_insert_word(string const & word) 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 static inline
void sc_accept_word(string const & word) void sc_accept_word(string const & word)
{ {
pspell_manager_add_to_session(sc, word); pspell_manager_add_to_session(sc, word.c_str());
} }

View File

@ -1341,12 +1341,8 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
string const LyXTabular::GetDocBookAlign(int cell, bool isColumn) const 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 (!isColumn && IsMultiColumn(cell)) {
if (!cellinfo_of_cell(cell)->align_special.empty()) { if (!cellinfo_of_cell(cell)->align_special.empty()) {
return cellinfo_of_cell(cell)->align_special; 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 // returns the number of printed newlines
int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
{ {
int i;
int ret = 0; int ret = 0;
//int tmp; // tmp2; // unused int nvcell;
int nvcell; // fcell; // unused
if (IsLastCell(cell)) { if (IsLastCell(cell)) {
os << newlineAndDepth(--depth) os << newlineAndDepth(--depth)
<< "</ENTRY>" << "</ENTRY>"
@ -1420,7 +1414,7 @@ int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
<< "' COLSEP='1' ROWSEP='1'>" << "' COLSEP='1' ROWSEP='1'>"
<< newlineAndDepth(++depth); << newlineAndDepth(++depth);
++ret; ++ret;
for (i = 0; i < columns_; ++i) { for (int i = 0; i < columns_; ++i) {
os << "<COLSPEC ALIGN='" os << "<COLSPEC ALIGN='"
<< GetDocBookAlign(i, true) << GetDocBookAlign(i, true)
<< "' COLNAME='col" << "' COLNAME='col"
@ -1474,7 +1468,7 @@ int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
<< "' VALIGN='middle'"; << "' VALIGN='middle'";
if (IsMultiColumn(cell + 1)) { if (IsMultiColumn(cell + 1)) {
os << " NAMEST='col" os << " NAMEST='col"
<< column_of_cell(cell+1) + 1 << column_of_cell(cell + 1) + 1
<< "' NAMEEND='col" << "' NAMEEND='col"
<< column_of_cell(cell + 1) + << column_of_cell(cell + 1) +
cells_in_multicolumn(cell + 1) cells_in_multicolumn(cell + 1)
@ -1492,10 +1486,10 @@ int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
<< "' VALIGN='middle'"; << "' VALIGN='middle'";
if (IsMultiColumn(cell + 1)) { if (IsMultiColumn(cell + 1)) {
os << " NAMEST='col" os << " NAMEST='col"
<< column_of_cell(cell+1) + 1 << column_of_cell(cell + 1) + 1
<< "' NAMEEND='col" << "' NAMEEND='col"
<< column_of_cell(cell+1) + << column_of_cell(cell + 1) +
cells_in_multicolumn(cell+1) cells_in_multicolumn(cell + 1)
<< "'"; << "'";
} }
os << ">" os << ">"
@ -1517,8 +1511,8 @@ bool LyXTabular::IsMultiColumn(int cell, bool real) const
LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
{ {
int row = row_of_cell(cell); int const row = row_of_cell(cell);
int column = column_of_cell(cell); int const column = column_of_cell(cell);
return &cell_info[row][column]; 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 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 column = column_of_cell(cell);
int result = 1; int result = 1;
++column; ++column;
@ -1554,7 +1548,7 @@ int LyXTabular::cells_in_multicolumn(int cell) const
int LyXTabular::UnsetMultiColumn(int cell) 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 column = column_of_cell(cell);
int result = 0; int result = 0;
@ -1627,7 +1621,7 @@ bool LyXTabular::NeedRotating() const
bool LyXTabular::IsLastCell(int cell) const bool LyXTabular::IsLastCell(int cell) const
{ {
if ((cell+1) < GetNumberOfCells()) if ((cell + 1) < GetNumberOfCells())
return false; return false;
return true; return true;
} }
@ -1643,7 +1637,7 @@ int LyXTabular::GetCellAbove(int cell) const
int LyXTabular::GetCellBelow(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_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno;
return cell; return cell;
} }
@ -1655,17 +1649,17 @@ int LyXTabular::GetLastCellAbove(int cell) const
return cell; return cell;
if (!IsMultiColumn(cell)) if (!IsMultiColumn(cell))
return GetCellAbove(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 int LyXTabular::GetLastCellBelow(int cell) const
{ {
if (row_of_cell(cell)+1 >= rows_) if (row_of_cell(cell) + 1 >= rows_)
return cell; return cell;
if (!IsMultiColumn(cell)) if (!IsMultiColumn(cell))
return GetCellBelow(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) void LyXTabular::SetLTHead(int cell, bool first)
{ {
int const row = row_of_cell(cell); 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 (first) {
if (endfirsthead == val) if (endfirsthead == val)
@ -1725,7 +1719,7 @@ bool LyXTabular::GetRowOfLTHead(int cell, int & row) const
row = endhead; row = endhead;
if (abs(endhead) > rows_) if (abs(endhead) > rows_)
return false; 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; row = endfirsthead;
if (abs(endfirsthead) > rows_) if (abs(endfirsthead) > rows_)
return false; 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) void LyXTabular::SetLTFoot(int cell, bool last)
{ {
int const row = row_of_cell(cell); 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 (last) {
if (endlastfoot == val) if (endlastfoot == val)
@ -1760,9 +1754,9 @@ void LyXTabular::SetLTFoot(int cell, bool last)
bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const
{ {
row = endfoot; row = endfoot;
if ((endfoot+1) > rows_) if ((endfoot + 1) > rows_)
return false; 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 LyXTabular::TeXTopHLine(ostream & os, int row) const
{ {
int fcell = GetFirstCellInRow(row); #warning should this return a bool? (Lgb)
int n = NumberOfCellsInRow(fcell) + fcell; int const fcell = GetFirstCellInRow(row);
int tmp=0; int const n = NumberOfCellsInRow(fcell) + fcell;
int i; int tmp = 0;
for (i = fcell; i < n; ++i) { for (int i = fcell; i < n; ++i) {
if (TopLine(i)) if (TopLine(i))
++tmp; ++tmp;
} }
if (tmp == (n - fcell)){ if (tmp == (n - fcell)){
os << "\\hline "; os << "\\hline ";
} else { } else {
for (i = fcell; i < n; ++i) { for (int i = fcell; i < n; ++i) {
if (TopLine(i)) { if (TopLine(i)) {
os << "\\cline{" os << "\\cline{"
<< column_of_cell(i) + 1 << 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 int LyXTabular::TeXBottomHLine(ostream & os, int row) const
{ {
#warning should this return a bool? (Lgb)
int const fcell = GetFirstCellInRow(row); int const fcell = GetFirstCellInRow(row);
int const n = NumberOfCellsInRow(fcell) + fcell; int const n = NumberOfCellsInRow(fcell) + fcell;
int tmp = 0; int tmp = 0;
@ -2178,9 +2173,9 @@ void LyXTabular::Validate(LaTeXFeatures & features) const
bool LyXTabular::UseParbox(int cell) 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) { for(int i = 0; i < par->Last(); ++i) {
if (par->GetChar(i) == LyXParagraph::META_NEWLINE) if (par->GetChar(i) == LyXParagraph::META_NEWLINE)
return true; return true;