1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/*
|
|
|
|
* File: math_macro.h
|
|
|
|
* Purpose: Declaration of macro class for mathed
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: November 1996
|
|
|
|
* Description: WYSIWYG math macros
|
|
|
|
*
|
|
|
|
* Dependencies: Mathed
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, 1997 Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Version: 0.2, Mathed & Lyx project.
|
|
|
|
*
|
|
|
|
* This code is under the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
1999-10-07 18:44:17 +00:00
|
|
|
#ifndef MATH_MACRO
|
|
|
|
#define MATH_MACRO
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include <vector>
|
2001-04-24 16:13:38 +00:00
|
|
|
#include <iosfwd>
|
2001-03-01 14:07:43 +00:00
|
|
|
#include <boost/smart_ptr.hpp>
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_parinset.h"
|
2001-03-05 10:18:36 +00:00
|
|
|
#include "math_macroarg.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
class MathMacroTemplate;
|
|
|
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
/** This class contains the data for a macro
|
|
|
|
\author Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
\version November 1996
|
|
|
|
*/
|
2001-02-28 11:56:36 +00:00
|
|
|
class MathMacro : public MathParInset {
|
2000-03-07 01:14:37 +00:00
|
|
|
public:
|
2001-04-24 16:13:38 +00:00
|
|
|
/// A macro can be built from an existing template
|
|
|
|
explicit MathMacro(MathMacroTemplate const &);
|
2001-02-13 17:08:51 +00:00
|
|
|
///
|
|
|
|
void draw(Painter &, int, int);
|
|
|
|
///
|
|
|
|
void Metrics();
|
|
|
|
///
|
|
|
|
MathedInset * Clone();
|
|
|
|
///
|
|
|
|
void Write(std::ostream &, bool fragile);
|
2001-04-25 15:43:57 +00:00
|
|
|
///
|
|
|
|
void WriteNormal(std::ostream &);
|
2001-04-24 16:13:38 +00:00
|
|
|
/// Index 0 is the template, index 1..nargs() are the parameters
|
2001-02-13 17:08:51 +00:00
|
|
|
bool setArgumentIdx(int);
|
|
|
|
///
|
|
|
|
int getArgumentIdx() const;
|
|
|
|
///
|
|
|
|
int getMaxArgumentIdx() const;
|
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
int nargs() const;
|
|
|
|
///
|
2001-02-13 17:08:51 +00:00
|
|
|
int GetColumns() const;
|
|
|
|
///
|
|
|
|
void GetXY(int &, int &) const;
|
|
|
|
///
|
|
|
|
void SetFocus(int, int);
|
|
|
|
///
|
2001-02-20 16:00:22 +00:00
|
|
|
MathedArray & GetData();
|
2001-02-13 17:08:51 +00:00
|
|
|
///
|
2001-02-28 17:21:16 +00:00
|
|
|
MathedArray const & GetData() const;
|
|
|
|
///
|
2001-02-20 16:00:22 +00:00
|
|
|
void setData(MathedArray const &);
|
2001-02-13 17:08:51 +00:00
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
void setData(MathedArray const &, int);
|
|
|
|
///
|
2001-02-13 17:08:51 +00:00
|
|
|
MathedTextCodes getTCode() const;
|
|
|
|
///
|
|
|
|
bool Permit(short) const;
|
2001-03-05 10:18:36 +00:00
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
void expand();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-04-25 11:14:01 +00:00
|
|
|
void dump(std::ostream & os) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
MathParInset const * arg(int) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
MathParInset * arg(int);
|
2001-02-13 17:08:51 +00:00
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
MathMacroTemplate * tmplate() const;
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
MathMacroTemplate * tmplate_;
|
|
|
|
/// our arguments
|
|
|
|
std::vector< boost::shared_ptr<MathParInset> > args_;
|
|
|
|
/// the expanded version fror drawing
|
|
|
|
boost::shared_ptr<MathParInset> expanded_;
|
2001-02-13 17:08:51 +00:00
|
|
|
///
|
2001-04-24 16:13:38 +00:00
|
|
|
int idx_;
|
|
|
|
|
|
|
|
/// unimplemented
|
|
|
|
void operator=(MathMacro const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2001-04-24 16:13:38 +00:00
|
|
|
|
2001-04-25 11:14:01 +00:00
|
|
|
inline std::ostream & operator<<(std::ostream & os, MathMacro const & m)
|
2001-04-24 16:13:38 +00:00
|
|
|
{
|
|
|
|
m.dump(os);
|
|
|
|
return os;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|