X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fcounters.h;h=da7bf4467d6728aaafcdb182adb9636d1c064c94;hb=2e57f2ff0ae7cd4a6efbf634ffe6d2f4379d9cfc;hp=7f73d4eb1f34f82e4d3affee9bf62f4d4a9905a3;hpb=1e394731004491d04abe436112b5a89521bbd19a;p=lyx.git diff --git a/src/counters.h b/src/counters.h index 7f73d4eb1f..da7bf4467d 100644 --- a/src/counters.h +++ b/src/counters.h @@ -14,19 +14,12 @@ #ifndef COUNTERS_H #define COUNTERS_H -#ifdef __GNUG__ -#pragma interface -#endif - #include "LString.h" - -#include -#include - #include -/// -class Counter : public boost::trackable { + +/// This represents a single counter. +class Counter { public: /// Counter(); @@ -40,24 +33,27 @@ public: void step(); /// void reset(); - /// - boost::signal0 onstep; + /// Returns the master counter of this counter + string master() const; + /// sets the master counter for this counter + void setMaster(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". + 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(); - /// + /// Add a new counter to array. void newCounter(string const & newc); - /// + /// Add new counter having oldc as its master. void newCounter(string const & newc, string const & oldc); /// void set(string const & ctr, int val); @@ -65,14 +61,38 @@ public: void addto(string const & ctr, int val); /// int value(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(string const & ctr); - // string refstep(string const & cou); + /// Reset all counters. + void reset(); + /// Reset counters matched by match string. + void reset(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, string const & match = string()); + /// A numeric label's single item, like .1 for subsection number in + /// the 2.1.4 subsubsection number label. "first" indicates if this + /// is the first item to be displayed, usually chapter or section. + string labelItem(string const & ctr, + string const & labeltype, + string const & langtype = "latin", + bool first = false); + /// A complete numeric label, like 2.1.4 for a subsubsection. + /// "head" indicates sequence number of first item to be + /// displayed, e.g. 0 for chapter, 1 for section. + string numberLabel(string const & ctr, + string const & labeltype, + string const & langtype = "latin", + int head = 0); private: - /// - typedef std::map CounterList; - /// + /// Maps counter (layout) names to actual counters. + typedef std::map CounterList; + /// Instantiate. CounterList counterList; + }; #endif