Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CursesDialog / cmCursesCacheEntryComposite.cxx
blob979c5a56015d9c558620e5fb0abe5985578c877f
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCursesCacheEntryComposite.cxx,v $
5 Language: C++
6 Date: $Date: 2008-03-07 21:32:09 $
7 Version: $Revision: 1.9 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmCursesCacheEntryComposite.h"
18 #include "cmCursesStringWidget.h"
19 #include "cmCursesLabelWidget.h"
20 #include "cmCursesBoolWidget.h"
21 #include "cmCursesPathWidget.h"
22 #include "cmCursesFilePathWidget.h"
23 #include "cmCursesDummyWidget.h"
24 #include "../cmSystemTools.h"
26 cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
27 int labelwidth,
28 int entrywidth) :
29 Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
31 this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
32 this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
33 this->Entry = 0;
34 this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
37 cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
38 const char* key, const cmCacheManager::CacheIterator& it, bool isNew,
39 int labelwidth, int entrywidth)
40 : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
42 this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
43 if (isNew)
45 this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*");
47 else
49 this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
52 this->Entry = 0;
53 switch ( it.GetType() )
55 case cmCacheManager::BOOL:
56 this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
57 if (cmSystemTools::IsOn(it.GetValue()))
59 static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
61 else
63 static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false);
65 break;
66 case cmCacheManager::PATH:
67 this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
68 static_cast<cmCursesPathWidget*>(this->Entry)->SetString(
69 it.GetValue());
70 break;
71 case cmCacheManager::FILEPATH:
72 this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
73 static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(
74 it.GetValue());
75 break;
76 case cmCacheManager::STRING:
77 this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
78 static_cast<cmCursesStringWidget*>(this->Entry)->SetString(
79 it.GetValue());
80 break;
81 case cmCacheManager::UNINITIALIZED:
82 cmSystemTools::Error("Found an undefined variable: ", it.GetName());
83 break;
84 default:
85 // TODO : put warning message here
86 break;
91 cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
93 delete this->Label;
94 delete this->IsNewLabel;
95 delete this->Entry;
98 const char* cmCursesCacheEntryComposite::GetValue()
100 if (this->Label)
102 return this->Label->GetValue();
104 else
106 return 0;