?? area.h
字號:
/* ------------------------------------------------------------------------- *//* * Copyright (c) 1999 * GMRS Software GmbH, Innsbrucker Ring 159, 81669 Munich, Germany. * http://www.gmrs.de * All rights reserved. * Author: Arno Unkrig (arno.unkrig@gmrs.de) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by GMRS Software GmbH. * 4. The name of GMRS Software GmbH may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY GMRS SOFTWARE GMBH ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GMRS SOFTWARE GMBH BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. *//* ------------------------------------------------------------------------- */#ifndef __Area_h_INCLUDED__ /* { */#define __Area_h_INCLUDED__/* ------------------------------------------------------------------------- */#ident "$Id: Area.h,v 1.9 1999/11/02 17:58:10 arno Exp $"#include <sys/types.h>#include <string>#ifdef BOOL_DEFINITIONBOOL_DEFINITION#undef BOOL_DEFINITION#endifclass ostream;/* ------------------------------------------------------------------------- */struct Cell { char character; char attribute; enum { NONE = 0, UNDERLINE = 1, BOLD = 2, STRIKETHROUGH = 4 }; void clear() { character = ' '; attribute = NONE; }};/* ------------------------------------------------------------------------- */class Line {public: typedef size_t size_type; Line(size_type l = 0); Line(const char *); Line(const string &); ~Line(); size_type length() const { return length_; } bool empty() const { return length_ == 0; } const Cell &operator[](size_type x) const { return cells_[x]; } Cell &operator[](size_type x) { return cells_[x]; } const Cell *cells() const { return cells_; } void resize(size_type l); void enlarge(size_type l) { if (l > length_) resize(l); } void insert(const Line &, size_type x); void insert(const char *, size_type x); void insert(const string &, size_type x); void append(char c ); void append(const Line &l); void append(const char *p); const Line &operator+=(char c ) { append(c); return *this; } const Line &operator+=(const Line &l) { append(l); return *this; } const Line &operator+=(const char *p) { append(p); return *this; } void add_attribute(char addition);private: Line(const Line &); const Line &operator=(const Line &); size_type length_; Cell *cells_; friend class Area;};/* ------------------------------------------------------------------------- */class Area {public: typedef size_t size_type; enum { LEFT, CENTER, RIGHT, TOP, MIDDLE, BOTTOM }; Area(); Area(size_type w, size_type h = 0, char = ' ', char = Cell::NONE); Area(const char *); Area(const string &); Area(const Line &); ~Area(); size_type width() const { return width_; } size_type height() const { return height_; } const Cell *operator[](size_type y) const { return cells_[y]; } Cell *operator[](size_type y) { return cells_[y]; } const Area &operator>>=(size_type rs); void resize(size_type w, size_type h); void enlarge(size_type w, size_type h); void insert(const Line &l, size_type x, size_type y) { insert(l.cells_, l.length_, x, y); } void insert(const Area &, size_type x, size_type y); void insert( const Area &, size_type x, size_type y, size_type w, size_type h, int halign, int valign ); void insert(const Cell &, size_type x, size_type y); void insert(const Cell *, size_type count, size_type x, size_type y); void insert(char, size_type x, size_type y); void insert(const string &, size_type x, size_type y); void prepend(int n); // Prepend blank lines at top void append(int n) // Append blank lines at bottom { enlarge(width(), height() + n); } const Area &operator+=(const Area &); // Append at bottom! const Area &operator+=(int n) { append(n); return *this; } void fill(const Cell &, size_type x, size_type y, size_type w, size_type h); void fill(char, size_type x, size_type y, size_type w, size_type h); void add_attribute(char addition); // ...but not to left and right free areas void add_attribute( char addition, size_type x, size_type y, size_type w, size_type h ); static bool use_backspaces; // "true" by default.private: Area(const Area &); const Area &operator=(const Area &); size_type width_; size_type height_; Cell **cells_; friend ostream &operator<<(ostream &, const Area &);};/* ------------------------------------------------------------------------- */#endif /* } *//* ------------------------------------------------------------------------- */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -