libyui  3.3.2
YTableHeader.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YTableHeader.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include <vector>
27 
28 #define YUILogComponent "ui"
29 #include "YUILog.h"
30 
31 #include "YTableHeader.h"
32 #include "YUIException.h"
33 
34 
35 
37 {
39  {}
40 
41  std::vector<std::string> headers;
42  std::vector<YAlignmentType> alignments;
43 };
44 
45 
46 
47 
49  : priv( new YTableHeaderPrivate )
50 {
51  YUI_CHECK_NEW( priv );
52 }
53 
54 
56 {
57  // NOP
58 }
59 
60 
61 void
62 YTableHeader::addColumn( const std::string & header, YAlignmentType alignment )
63 {
64  priv->headers.push_back( header );
65  priv->alignments.push_back( alignment );
66 }
67 
68 
69 int
71 {
72  return (int) priv->headers.size();
73 }
74 
75 
76 bool
77 YTableHeader::hasColumn( int column ) const
78 {
79  return column >= 0 && column < (int) priv->headers.size();
80 }
81 
82 
83 std::string
84 YTableHeader::header( int column ) const
85 {
86  if ( column >= 0 && column < (int) priv->headers.size() )
87  return priv->headers[ column ];
88  else
89  return "";
90 }
91 
92 
93 YAlignmentType
94 YTableHeader::alignment( int column ) const
95 {
96  if ( column >= 0 && column < (int) priv->alignments.size() )
97  return priv->alignments[ column ];
98  else
99  return YAlignBegin;
100 }
virtual ~YTableHeader()
Destructor.
Definition: YTableHeader.cc:55
bool hasColumn(int column) const
Return &#39;true&#39; if this table header has a column no.
Definition: YTableHeader.cc:77
void addColumn(const std::string &header, YAlignmentType alignment=YAlignBegin)
Add a column with the specified colum header text and alignment.
Definition: YTableHeader.cc:62
int columns() const
Return the number of columns.
Definition: YTableHeader.cc:70
YTableHeader()
Constructor.
Definition: YTableHeader.cc:48
YAlignmentType alignment(int column) const
Return the alignment for the specified column.
Definition: YTableHeader.cc:94
std::string header(int column) const
Return the header text for the specified column.
Definition: YTableHeader.cc:84