home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / layout.h < prev    next >
C/C++ Source or Header  |  1998-04-23  |  9KB  |  458 lines

  1. // -*- C++ -*-
  2. /* This file is part of
  3.  * ======================================================
  4. *           LyX, The Document Processor
  5. *      
  6. *        Copyright (C) 1995 Matthias Ettrich
  7. *
  8. *======================================================*/
  9.  
  10. #ifndef _LAYOUT_H
  11. #define _LAYOUT_H
  12.  
  13. #ifdef __GNUG__
  14. #pragma interface
  15. #endif
  16.  
  17. #include "definitions.h"
  18. #include "lyxlex.h"
  19. #include "lyxfont.h"
  20. #include "Spacing.h"
  21.  
  22. /// Reads the style files
  23. void LyXSetStyle();
  24.  
  25. /// The different margin types
  26. enum LYX_MARGIN_TYPE {
  27.     ///
  28.     MARGIN_MANUAL,
  29.     ///
  30.     MARGIN_FIRST_DYNAMIC,
  31.     ///
  32.     MARGIN_DYNAMIC,
  33.     ///
  34.     MARGIN_STATIC,
  35.     ///
  36.     MARGIN_RIGHT_ADDRESS_BOX
  37. };
  38.  
  39. ///
  40. enum LYX_ALIGNMENT {
  41.     ///
  42.     LYX_ALIGN_BLOCK = 1,
  43.     ///
  44.     LYX_ALIGN_LEFT = 2,
  45.     ///
  46.     LYX_ALIGN_RIGHT = 4,
  47.     ///
  48.     LYX_ALIGN_CENTER = 8,
  49.     ///
  50.     LYX_ALIGN_LAYOUT = 16,
  51.     ///
  52.         LYX_ALIGN_WIDTH = 32
  53. };
  54.  
  55. /// The different LaTeX-Types
  56. enum LYX_LATEX_TYPES {
  57.     ///
  58.     LATEX_PARAGRAPH,
  59.     ///
  60.     LATEX_COMMAND,
  61.     ///
  62.     LATEX_ENVIRONMENT,
  63.     ///
  64.     LATEX_ITEM_ENVIRONMENT,
  65.     ///
  66.     LATEX_LIST_ENVIRONMENT
  67. };
  68.  
  69. /// The different label types
  70. enum LYX_LABEL_TYPES {
  71.     ///
  72.     LABEL_NO_LABEL,
  73.     ///
  74.     LABEL_MANUAL,
  75.     ///
  76.         LABEL_BIBLIO,
  77.     ///
  78.     LABEL_TOP_ENVIRONMENT,
  79.     ///
  80.     LABEL_CENTERED_TOP_ENVIRONMENT,
  81.  
  82.     // the flushright labels following now must start with LABEL_STATIC
  83.     ///
  84.     LABEL_STATIC,
  85.     ///
  86.     LABEL_SENSITIVE,
  87.     ///
  88.     LABEL_COUNTER_CHAPTER,
  89.     ///
  90.     LABEL_COUNTER_SECTION,
  91.     ///
  92.     LABEL_COUNTER_SUBSECTION,
  93.     ///
  94.     LABEL_COUNTER_SUBSUBSECTION,
  95.     ///
  96.     LABEL_COUNTER_PARAGRAPH,
  97.     ///
  98.     LABEL_COUNTER_SUBPARAGRAPH,
  99.     ///
  100.     LABEL_COUNTER_ENUMI,
  101.     ///
  102.     LABEL_COUNTER_ENUMII,
  103.     ///
  104.     LABEL_COUNTER_ENUMIII,
  105.     ///
  106.     LABEL_COUNTER_ENUMIV,
  107.     ///
  108.     LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
  109. };
  110.  
  111.  
  112. /* Fix labels are printed flushright, manual labels flushleft. 
  113. * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
  114. * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL. 
  115. * This seems a funny restriction, but I think other combinations are
  116. * not needed, so I will not change it yet. 
  117. * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC */
  118.  
  119.  
  120. /* There is a parindent and a parskip. Which one is used depends on the 
  121. * paragraph_separation-flag of the text-object. 
  122. * BUT: parindent is only thrown away, if a parskip is defined! So if you
  123. * want a space between the paragraphs and a parindent at the same time, 
  124. * you should set parskip to zero and use topsep, parsep and bottomsep.
  125. * The standard layout is an exception: its parindent is only set, if the 
  126. * previous paragraph is standard too. Well, this is LateX and it is good! */ 
  127.  
  128.  
  129. /// Attributes of a layout/paragraph environment
  130. class LyXLayoutList;
  131. ///
  132. class LyXLayout {
  133. public:
  134.     ///
  135.     LyXLayout ();
  136.  
  137.     ///
  138.     ~LyXLayout ();
  139.  
  140.     ///
  141.     void Copy (LyXLayout const &l);
  142.  
  143.     ///
  144.     bool Read (LyXLex&, LyXLayoutList *);
  145.  
  146.     /// Name of the layout/paragraph environment
  147.     LString name;
  148.  
  149.     /// Name of an layout that has replaced this layout. 
  150.     /** This is used to rename a layout, while keeping backward
  151.         compatibility 
  152.     */
  153.     LString obsoleted_by;
  154.  
  155.     /// Default font for this layout/environment
  156.     /** The main font for this kind of environment. If an attribute has
  157.     LyXFont::INHERITED_*, it means that the value is specified by
  158.     the defaultfont for the entire layout. If we are nested, the font 
  159.     is inherited from the font in the environment one level up until the 
  160.     font is resolved. The values LyXFont::IGNORE_* and LyXFont::TOGGLE 
  161.     are illegal here.
  162.     */
  163.     LyXFont font;
  164.  
  165.     /// Default font for labels
  166.     /** Interpretation the same as for font above */
  167.     LyXFont labelfont;
  168.  
  169.     /// Resolved version of the font for this layout/environment
  170.     /** This is a resolved version the default font. The font is resolved
  171.     against the defaultfont of the entire layout. */
  172.     LyXFont resfont;
  173.  
  174.     /// Resolved version of the font used for labels
  175.     /** This is a resolved version the label font. The font is resolved
  176.     against the defaultfont of the entire layout. */
  177.     LyXFont reslabelfont;
  178.  
  179.     /// Text that dictates how wide the left margin is on the screen
  180.     LString leftmargin;
  181.  
  182.     /// Text that dictates how wide the right margin is on the screen
  183.     LString rightmargin;
  184.  
  185.     /// Text that dictates how much space to leave after a potential label
  186.     LString labelsep;
  187.  
  188.     /// Text that dictates how much space to leave before a potential label
  189.     LString labelindent;
  190.  
  191.     /// Text that dictates the width of the indentation of indented paragraphs
  192.     LString parindent;
  193.  
  194.     /// Label string. "Abstract", "Reference", "Caption"...
  195.     LString labelstring;
  196.  
  197.     /// LaTeX name for environment
  198.     LString latexname;
  199.  
  200.     /// LaTeX parameter for environment
  201.         LString latexparam;   //arrae970411
  202.  
  203.         /// Macro definitions needed for this layout
  204.     LString preamble;
  205.  
  206.     ///
  207.     float parskip;
  208.  
  209.     ///
  210.     float itemsep;
  211.  
  212.     ///
  213.     float topsep;
  214.  
  215.     ///
  216.     float bottomsep;
  217.  
  218.     ///
  219.     float labelbottomsep;
  220.  
  221.     ///
  222.     float parsep;
  223.  
  224.     ///
  225.     Spacing spacing;
  226.  
  227.     ///
  228.     char align; // add approp. signedness
  229.  
  230.     ///
  231.     char alignpossible; // add approp. signedness
  232.  
  233.     ///
  234.     char labeltype; // add approp. signedness
  235.  
  236.     ///
  237.     char margintype; // add approp. signedness
  238.  
  239.     ///
  240.     bool fill_top;
  241.  
  242.     ///
  243.     bool fill_bottom;
  244.  
  245.     ///
  246.     bool newline_allowed;
  247.  
  248.     ///
  249.     bool nextnoindent;
  250.  
  251.     ///
  252.     bool free_spacing;
  253.     /// true when the fragile commands in the paragraph need to be
  254.     /// \protect'ed.
  255.     bool needprotect;
  256.     /// true when empty paragraphs should be kept.
  257.     bool keepempty;
  258.     ///
  259.     bool isParagraph() const {
  260.         return latextype == LATEX_PARAGRAPH;
  261.     }
  262.     ///
  263.     bool isCommand() const { 
  264.         return latextype == LATEX_COMMAND;
  265.     }
  266.     ///
  267.     bool isEnvironment() const {
  268.         return (latextype == LATEX_ENVIRONMENT
  269.             || latextype == LATEX_ITEM_ENVIRONMENT
  270.             || latextype == LATEX_LIST_ENVIRONMENT);
  271.     }
  272.     /// Type of LaTeX object
  273.     LYX_LATEX_TYPES latextype;
  274.     /// Does this object belong in the title part of the document?
  275.     bool intitle;
  276. };
  277.  
  278.  
  279. ///
  280. class LyXLayoutList {
  281. public:
  282.     ///
  283.     LyXLayoutList();
  284.     ///
  285.     ~LyXLayoutList();
  286.     ///
  287.     void Add (LyXLayout *l);
  288.     ///
  289.     bool Delete (LString const &name);
  290.         ///
  291.     LyXLayout *GetLayout (LString const &name);
  292.     ///
  293.     LyXLayout *ToAr();
  294.     ///
  295.     int GetNum();
  296.     ///
  297.     void Clean(); 
  298. private:
  299.     ///
  300.     struct LyXLayoutL {
  301.         ///
  302.         LyXLayout* layout;
  303.         ///
  304.         LyXLayoutL *next;
  305.     };
  306.     ///
  307.     LyXLayoutL * l;
  308.     ///
  309.     LyXLayoutL *eol;
  310.     ///
  311.     int num_layouts;
  312. };
  313.  
  314.  
  315. ///
  316. class LyXTextClass  {
  317. public:
  318.     ///
  319.     LyXTextClass (LString const & = LString(), 
  320.               LString const & = LString(), 
  321.               LString const & = LString());
  322.     ///
  323.     ~LyXTextClass();
  324.  
  325.     /// Not a real copy, just reference!
  326.     void Copy (LyXTextClass const &l);
  327.  
  328.     /// Reads a textclass structure from file
  329.     int Read (LString const & filename, LyXLayoutList *list = NULL);
  330.  
  331.     /// Sees to that the textclass structure has been loaded
  332.     void load();
  333.  
  334.     ///
  335.     LString name;
  336.     ///
  337.     LString latexname;
  338.     ///
  339.     LString description;
  340.  
  341.     /// Specific class options
  342.         LString opt_fontsize;
  343.     ///
  344.         LString opt_pagestyle;
  345.     ///
  346.     LString options;
  347.     
  348.     /// Base font. This one has to be fully instantiated.
  349.     /** Base font. The paragraph and layout fonts are resolved against
  350.     this font. Attributes LyXFont::INHERIT, LyXFont::IGNORE, and 
  351.     LyXFont::TOGGLE are extremely illegal.
  352.     */
  353.     LyXFont defaultfont;
  354.     /// Array of styles in this textclass
  355.     LyXLayout* style;
  356.     ///
  357.     unsigned char number_of_defined_layouts;
  358.     ///
  359.     unsigned char columns;
  360.     ///
  361.     unsigned char sides;
  362.     ///
  363.     signed char secnumdepth;
  364.     ///
  365.     signed char tocdepth;
  366.     ///
  367.     LString pagestyle;
  368.     ///
  369.     LString preamble;
  370.     ///
  371.     /// Text that dictates how wide the left margin is on the screen
  372.     LString leftmargin;
  373.         ///
  374.     /// Text that dictates how wide the right margin is on the screen
  375.     LString rightmargin;
  376.         ///
  377.     char maxcounter; // add approp. signedness
  378. private:
  379.     /// Has this layout file been loaded yet?
  380.     bool loaded;
  381. };
  382.  
  383.  
  384. ///
  385. class LyXTextClassList {
  386. public:
  387.     ///
  388.     LyXTextClassList();
  389.  
  390.     ///
  391.     ~LyXTextClassList();
  392.  
  393.     /// Gets layout structure from layout number and textclass number
  394.     LyXLayout *Style(char textclass, char layout);
  395.  
  396.     /// Gets layout number from textclass number and layout name
  397.     char NumberOfLayout(char textclass, LString const & name); // add approp. signedness
  398.  
  399.     /// Gets a layout name from layout number and textclass number
  400.     LString NameOfLayout(char textclass, char layout); // add approp. signedness
  401.  
  402.     /// Gets textclass number from name
  403.     /** Returns -1 if textclass name does not exist */
  404.     signed char NumberOfClass(LString const & textclass);
  405.  
  406.     ///
  407.     LString NameOfClass(char number); // add approp. signedness
  408.  
  409.     ///
  410.     LString LatexnameOfClass(char number); // add approp. signedness
  411.  
  412.     ///
  413.     LString DescOfClass(char number); // add approp. signedness
  414.  
  415.     ///
  416.     LyXTextClass * TextClass(char textclass); // add approp. signedness
  417.  
  418.     /// Read textclass list
  419.     /** Returns false if this fails */
  420.     bool Read();
  421.  
  422.     /// Load textclass
  423.     /** Returns false if this fails */
  424.     bool Load(char textclass);
  425. private:
  426.     ///
  427.     struct LyXTextClassL {
  428.         ///
  429.         LyXTextClass * textclass;
  430.         ///
  431.         LyXTextClassL * next;
  432.     };
  433.  
  434.     ///
  435.     LyXTextClassL * l;
  436.  
  437.     ///
  438.     int num_textclass;
  439.  
  440.     /// After reading, this arrays holds the textclasses
  441.     LyXTextClass * ar;
  442.  
  443.     /// Add a textclass to list
  444.     void Add (LyXTextClass *l);
  445.  
  446.     /// Convert final linked list to array
  447.     /** We read the textclasses into a linked list. After the reading,
  448.     the list is converted to an array, and the linked list is nuked. */
  449.     void ToAr();
  450. };
  451.  
  452. /// Should not be declared here!! (Lgb) Why not? (Asger)
  453. extern LyXTextClassList lyxstyle;
  454.  
  455. #endif
  456.