*
* Dependencies: Mathed
*
- * Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
+ * Copyright: 1996, 1997 Alejandro Aguilar Sierra
*
* Version: 0.2, Mathed & Lyx project.
*
* This code is under the GNU General Public Licence version 2 or later.
*/
-#ifndef __MATH_MACRO__
-#define __MATH_MACRO__
+#ifndef MATH_MACRO
+#define MATH_MACRO
#ifdef __GNUG__
#pragma interface
#endif
#include "math_defs.h"
+#include "debug.h"
///
-typedef MathParInset* MathParInsetP;
+typedef MathParInset * MathParInsetP;
///
-typedef LyxArrayBase *LyxArrayBaseP;
+typedef LyxArrayBase * LyxArrayBaseP;
class MathMacroTemplate;
/// This class contains the data for a macro
-class MathMacro: public MathParInset
+class MathMacro : public MathParInset
{
- public:
+public:
/// A macro can only be builded from an existing template
+ explicit
MathMacro(MathMacroTemplate *);
/// or from another macro.
- MathMacro(MathMacro*);
+ explicit
+ MathMacro(MathMacro *);
///
~MathMacro();
- ///
- void Draw(int, int);
- ///
+ ///
+ void draw(Painter &, int, int);
+ ///
void Metrics();
///
- MathedInset *Clone();
+ MathedInset * Clone();
///
- void Write(FILE *);
- ///
- void Write(LString &);
+ void Write(std::ostream &, bool fragile);
///
bool setArgumentIdx(int);
///
///
int GetColumns();
///
- void GetXY(int&, int&) const;
+ void GetXY(int &, int &) const;
///
void SetFocus(int, int);
///
- LyxArrayBase *GetData();
+ LyxArrayBase * GetData();
///
- MathedRowSt *getRowSt() const { return args[idx].row; }
+ MathedRowSt * getRowSt() const { return args[idx].row; }
///
void SetData(LyxArrayBase *);
///
///
bool Permit(short);
- private:
+private:
///
- MathMacroTemplate *tmplate;
+ MathMacroTemplate * tmplate;
///
- struct MacroArgumentBase {
- /// Position of the macro
- int x, y;
- ///
- MathedRowSt *row;
- ///
- LyxArrayBase *array;
- ///
- MacroArgumentBase() { x = y = 0; array = 0; row = 0; }
- } *args;
+ struct MacroArgumentBase {
+ /// Position of the macro
+ int x, y;
+ ///
+ MathedRowSt * row;
+ ///
+ LyxArrayBase * array;
+ ///
+ MacroArgumentBase() { x = y = 0; array = 0; row = 0; }
+ };
+ MacroArgumentBase * args;
///
- int idx;
+ int idx;
///
- int nargs;
+ int nargs;
///
- MathedTextCodes tcode;
+ MathedTextCodes tcode;
///
- friend class MathMacroTemplate;
+ friend class MathMacroTemplate;
};
/// An argument
-class MathMacroArgument: public MathParInset
-{
- public:
+class MathMacroArgument: public MathParInset {
+public:
///
MathMacroArgument() { expnd_mode = false; number = 1; SetType(LM_OT_MACRO_ARG); }
///
+ explicit
MathMacroArgument(int);
///
- ~MathMacroArgument() { fprintf(stderr, "help, destroyme!\n"); }
+ ~MathMacroArgument() { lyxerr << "help, destroyme!" << std::endl; }
///
- MathedInset *Clone() { return this; }
+ MathedInset * Clone() { return this; }
///
void Metrics();
///
- void Draw(int x, int baseline);
+ void draw(Painter &, int x, int baseline);
///
- void Write(FILE*);
- ///
- void Write(LString &);
+ void Write(std::ostream &, bool fragile);
///
void setNumber(int n) { number = n; }
/// Is expanded or not
void setExpand(bool e) { expnd_mode = e; }
/// Is expanded or not
bool getExpand() { return expnd_mode; }
-
- private:
+private:
///
bool expnd_mode;
///
/// This class contains the macro definition
-class MathMacroTemplate: public MathParInset
-{
- public:
+class MathMacroTemplate: public MathParInset {
+public:
/// A template constructor needs all the data
- MathMacroTemplate(char const*, int na=0, int f=0);
+ explicit
+ MathMacroTemplate(char const *, int na = 0, int f = 0);
///
~MathMacroTemplate();
///
- void Draw(int, int);
+ void draw(Painter &, int, int);
///
void Metrics();
///
- void WriteDef(FILE *);
- ///
- void WriteDef(LString &);
+ void WriteDef(std::ostream &, bool fragile);
/// useful for special insets
void setTCode(MathedTextCodes t) { tcode = t; }
///
MathedTextCodes getTCode() { return tcode; }
///
- void setArgument(LyxArrayBase *, int i=0);
+ void setArgument(LyxArrayBase *, int i= 0);
/// Number of arguments
int getNoArgs() { return nargs; }
///
- void GetMacroXY(int, int&, int&) const;
+ void GetMacroXY(int, int &, int &) const;
///
- MathParInset *getMacroPar(int) const;
+ MathParInset * getMacroPar(int) const;
///
- void SetMacroFocus(int&, int, int);
+ void SetMacroFocus(int &, int, int);
///
void setEditMode(bool);
/// Replace the appropriate arguments with a specific macro's data
- void update(MathMacro* m=0);
+ void update(MathMacro * m = 0);
- private:
+private:
///
short flags;
///
MathedTextCodes tcode;
///
- MathMacroArgument *args;
+ MathMacroArgument * args;
///
int nargs;
///
///
-typedef MathMacro *MathMacroP;
+typedef MathMacro * MathMacroP;
///
-typedef MathMacroTemplate *MathMacroTemplateP;
+typedef MathMacroTemplate * MathMacroTemplateP;
///
-class MathMacroTable
-{
- public:
+class MathMacroTable {
+public:
///
+ explicit
MathMacroTable(int);
///
~MathMacroTable();
///
void addTemplate(MathMacroTemplate *);
///
- MathMacro *getMacro(char const*) const;
+ MathMacro * getMacro(char const *) const;
///
- MathMacroTemplate *getTemplate(char const*) const;
+ MathMacroTemplate * getTemplate(char const *) const;
///
void builtinMacros();
///
///
static bool built;
- private:
+private:
///
const int max_macros;
///
int num_macros;
///
- MathMacroTemplateP *macro_table;
+ MathMacroTemplateP * macro_table;
};
inline
bool MathMacro::setArgumentIdx(int i)
{
- if (i>=0 && i<nargs) {
+ if (i >= 0 && i < nargs) {
idx = i;
return true;
} else
inline
int MathMacro::getMaxArgumentIdx()
{
- return nargs-1;
+ return nargs - 1;
}
inline
-LyxArrayBase *MathMacro::GetData()
+LyxArrayBase * MathMacro::GetData()
{
return args[idx].array;
}
inline
-void MathMacro::SetData(LyxArrayBase *a)
+void MathMacro::SetData(LyxArrayBase * a)
{
args[idx].array = a;
}
inline
-MathMacro *MathMacroTable::getMacro(char const* name) const
- {
- MathMacroTemplate *mt = getTemplate(name);
- return (mt) ? new MathMacro(mt): 0;
- }
+MathMacro * MathMacroTable::getMacro(char const * name) const
+{
+ MathMacroTemplate * mt = getTemplate(name);
+ return (mt) ? new MathMacro(mt): 0;
+}
#endif