]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
updates to minipage inset
[lyx.git] / src / insets / insetinclude.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *      
7  *          Copyright 1997 LyX Team (this file was created this year)
8  *
9  * ====================================================== */
10
11 #ifndef INSET_INCLUDE_H
12 #define INSET_INCLUDE_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "insetcommand.h"
19
20 class Buffer;
21 struct LaTeXFeatures;
22
23 // Created by AAS 970521
24
25 /**  Used to include files
26  */
27 class InsetInclude: public InsetButton, public noncopyable {
28 public:
29         /// the type of inclusion
30         enum IncludeFlags {
31                 ///
32                 INCLUDE= 0,
33                 ///
34                 VERB = 1,
35                 ///
36                 INPUT = 2,
37                 ///
38                 VERBAST = 3
39         };
40
41         struct InsetIncludeParams {
42                 InsetIncludeParams(InsetCommandParams const & cp = InsetCommandParams(),
43                         IncludeFlags f = INCLUDE, bool nl = false, Buffer const * b = 0)
44                         : cparams(cp), flag(f), noload(nl), buffer(b) {}
45                 InsetCommandParams cparams;
46                 IncludeFlags flag;
47                 bool noload;
48                 Buffer const * buffer;
49         };
50
51         ///
52         InsetInclude(InsetIncludeParams const &);
53         ///
54         InsetInclude(InsetCommandParams const &, Buffer const &);
55         ///
56         ~InsetInclude();
57
58         /// get the parameters
59         InsetIncludeParams const & params(void) const;
60
61         /// set the parameters
62         void setFromParams(InsetIncludeParams const & params);
63
64         ///
65         Inset * Clone(Buffer const &) const;
66         ///
67         Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
68         /// This returns the list of labels on the child buffer
69         std::vector<string> const getLabelList() const;
70         /// This returns the list of bibkeys on the child buffer
71         std::vector< std::pair<string,string> > const getKeys() const;
72         ///
73         void Edit(BufferView *, int x, int y, unsigned int button);
74         ///
75         EDITABLE Editable() const
76         {
77                 return IS_EDITABLE;
78         }
79         /// With lyx3 we won't overload these 3 methods
80         void Write(Buffer const *, std::ostream &) const;
81         ///
82         void Read(Buffer const *, LyXLex &);
83         ///
84         int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
85         ///
86         int Ascii(Buffer const *, std::ostream &, int linelen) const;
87         ///
88         int Linuxdoc(Buffer const *, std::ostream &) const;
89         ///
90         int DocBook(Buffer const *, std::ostream &) const;
91         ///
92         void Validate(LaTeXFeatures &) const;
93         
94         /** Input inserts anything inside a paragraph.
95             Display can give some visual feedback
96         */
97         bool display() const;
98
99         /// return the filename stub of the included file 
100         string const getRelFileBaseName() const;
101  
102         /// return true if the included file is not loaded
103         bool isIncludeOnly() const;
104
105         /// return true if the file is or got loaded.
106         bool loadIfNeeded() const;
107  
108         /// hide a dialog if about 
109         Signal0<void> hideDialog;
110 private:
111         /// get the text displayed on the button
112         string const getScreenLabel() const;
113         /// is this a verbatim include ?
114         bool isVerbatim() const;
115         /// get the filename of the master buffer
116         string const getMasterFilename() const;
117         /// get the included file name
118         string const getFileName() const;
119
120         /// the parameters
121         InsetIncludeParams params_;
122         ///
123         string include_label;
124 };
125
126
127 inline bool InsetInclude::isVerbatim() const
128 {
129         return params_.flag == VERB || params_.flag == VERBAST;
130 }
131
132
133 inline bool InsetInclude::isIncludeOnly() const
134 {
135         return params_.flag == INCLUDE && params_.noload;
136 }
137
138 #endif