]> git.lyx.org Git - lyx.git/blob - src/BackStack.h
89f49730b6efb9ac0974597a67cae35bc5d6cbbe
[lyx.git] / src / BackStack.h
1 // -*- C++ -*-
2 /* This file is part of
3 * ======================================================
4
5 *           LyX, The Document Processor
6 *        
7 *           Copyright (C) 1997-1998 The LyX Team.
8 *
9 *======================================================*/
10
11 #ifndef _BACK_STACK_H
12 #define _BACK_STACK_H
13
14 #include "LString.h"
15
16 // Created by Alejandro Aguilar Sierra, 970806
17
18 /**  Utility to get back from a reference or from a child document.
19  */
20 class BackStack {
21 public:
22         ///
23         struct BackStackItem {
24                 ///
25                 void set(LString f, int xx, int yy) {
26                         fname = f;  x = xx;  y = yy;
27                 }
28                 /// Filename
29                 LString fname;
30                 /// Cursor x-position
31                 int x;
32                 /// Cursor y-position
33                 int y;   
34         };
35         ///
36         BackStack(int n) : imax(n) {
37                 item = new BackStackItem[imax];
38                 i = 0;
39         }
40         ///
41         ~BackStack() {
42                 delete[] item;
43         }
44         ///
45         void push(LString f, int x, int y) {
46                 if (i<imax) 
47                         item[i++].set(f, x, y);
48         }
49         ///
50         LString &pop(int *x, int *y) {
51                 if (i>0) i--;
52                 *x = item[i].x;
53                 *y = item[i].y;
54                 return item[i].fname;
55         }
56 private:
57         ///
58         BackStackItem *item;
59         ///
60         int i;
61         ///
62         int imax;
63 };
64
65 #endif