X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fcounters.h;h=92da5a3c759e18def0db6e36b1c1ae3183ce7d22;hb=fdc1609e39461a297e092756ddd170c64208e183;hp=bcd900476c7466abf2e8bdb879f452b601d08f2d;hpb=83acbbd5237373926c629855379e1df9a04209b2;p=lyx.git diff --git a/src/counters.h b/src/counters.h index bcd900476c..92da5a3c75 100644 --- a/src/counters.h +++ b/src/counters.h @@ -1,29 +1,26 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor +/** + * \file counters.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. + * \author Lars Gullik Bjønnes + * \author Jean-Marc Lasgouttes + * \author John Levon + * \author Martin Vermeer * - * - * ====================================================== */ - + * Full author contact details are available in file CREDITS. + */ #ifndef COUNTERS_H #define COUNTERS_H -#ifdef __GNUG__ -#pragma interface -#endif - #include -#include -#include "LString.h" +#include + -/// -class Counter : public SigC::Object { +/// This represents a single counter. +class Counter { public: /// Counter(); @@ -37,39 +34,60 @@ public: void step(); /// void reset(); - /// - SigC::Signal0 onstep; + /// Returns the master counter of this counter + std::string master() const; + /// sets the master counter for this counter + void setMaster(std::string const & m); private: /// int value_; + /// contains master counter name; master counter is the counter + /// that, if stepped (incremented) zeroes this counter. E.g. + /// "subparagraph"'s master is "paragraph". + std::string master_; }; -/** This is a class of (La)TeX type counters. The counters is in a text - Style and can be reset by signals emitted from a single counter. -*/ +/// This is a class of (La)TeX type counters. +/// Every instantiation is an array of counters of type Counter. class Counters { public: - /// - ~Counters(); - /// - void newCounter(string const & newc); - /// - void newCounter(string const & newc, string const & oldc); - /// - void set(string const & ctr, int val); - /// - void addto(string const & ctr, int val); - /// - int value(string const & ctr) const; - /// - void step(string const & ctr); - // string refstep(string const & cou); + /// Add a new counter to array. + void newCounter(std::string const & newc); + /// Add new counter having oldc as its master. + void newCounter(std::string const & newc, std::string const & oldc); + /// + void set(std::string const & ctr, int val); + /// + void addto(std::string const & ctr, int val); + /// + int value(std::string const & ctr) const; + /// Step (increment by one) counter named by arg, and + /// zeroes slave counter(s) for which it is the master. + /// NOTE sub-slaves not zeroed! That happens at slave's + /// first step 0->1. Seems to be sufficient. + void step(std::string const & ctr); + /// Reset all counters. + void reset(); + /// Reset counters matched by match string. + void reset(std::string const & match); + /// Copy counters whose name matches match from the &from to + /// the &to array of counters. Empty string matches all. + void copy(Counters & from, Counters & to, std::string const & match = std::string()); + /// A complete expanded label, like 2.1.4 for a subsubsection + /// according to the given format + std::string counterLabel(std::string const & format); + /// A complete label, like 1.a for enumerations + std::string enumLabel(std::string const & ctr, std::string const & langtype = "latin"); private: - /// - typedef std::map CounterList; - /// + /// A counter label's single item, 1 for subsection number in + /// the 2.1.4 subsubsection number label. + std::string labelItem(std::string const & ctr, std::string const & numbertype); + /// Maps counter (layout) names to actual counters. + typedef std::map CounterList; + /// Instantiate. CounterList counterList; + }; #endif