source: branches/work_304/output/LetterFilterControl.cpp @ 445

Revision 445, 2.0 KB checked in by jls17, 5 years ago (diff)
Line 
1//Copyright (C) 2014 John Luthgers | jls17
2//
3//This file is part of ARInside.
4//
5//    ARInside is free software: you can redistribute it and/or modify
6//    it under the terms of the GNU General Public License as published by
7//    the Free Software Foundation, version 2 of the License.
8//
9//    ARInside is distributed in the hope that it will be useful,
10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12//    GNU General Public License for more details.
13//
14//    You should have received a copy of the GNU General Public License
15//    along with ARInside.  If not, see <http://www.gnu.org/licenses/>.
16
17#include "stdafx.h"
18#include "LetterFilterControl.h"
19#include "../core/ARServerObject.h"
20
21LetterFilterControl::LetterFilterControl()
22{
23        objCountPerLetter.resize(38); // see objectNameFirstCharLetters
24}
25
26LetterFilterControl::~LetterFilterControl()
27{
28}
29
30void LetterFilterControl::IncStartLetterOf(CARServerObject &obj)
31{
32        string firstChar = obj.GetNameFirstChar();
33        if (firstChar.empty()) firstChar = "*";
34
35        int index = CARObject::GetFirstCharIndex(firstChar[0]);
36        ++(objCountPerLetter[index]);
37}
38
39void LetterFilterControl::Render(std::ostream &strm)
40{
41        try
42        {
43                strm << "<table id='formLetterFilter'><tr>" << endl;
44
45                string strValue = objectNameFirstCharLetters; // "abcdefghijklmnopqrstuvwxyz0123456789#"
46                for (unsigned int i = 0; i < strValue.size(); ++i) 
47                {
48                        if (objCountPerLetter[i] > 0)
49                        {
50                                strm << "<td>";
51                                strm << CWebUtil::Link( std::string(1, strValue.at(i)), "javascript:void(0)" , "", 0);
52                        }
53                        else
54                        {
55                                strm << "<td class=\"disabledLetter\">";
56                                strm << strValue.at(i);
57                        }
58
59                        strm << "</td>" << endl;
60                }
61
62                strm << "</tr></table>" << endl;
63        }
64        catch(exception& e)
65        {
66                cout << "EXCEPTION LetterFilterControl::Render : " << e.what() << endl;
67        }
68}
69
70ostream& operator<<(ostream& strm, OUTPUT::LetterFilterControl& inst)
71{ 
72        inst.Render(strm);
73        return strm;
74}
Note: See TracBrowser for help on using the repository browser.