1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCursesCacheEntryComposite.cxx,v $
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
,
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, " ");
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
);
45 this->IsNewLabel
= new cmCursesLabelWidget(1, 1, 1, 1, "*");
49 this->IsNewLabel
= new cmCursesLabelWidget(1, 1, 1, 1, " ");
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);
63 static_cast<cmCursesBoolWidget
*>(this->Entry
)->SetValueAsBool(false);
66 case cmCacheManager::PATH
:
67 this->Entry
= new cmCursesPathWidget(this->EntryWidth
, 1, 1, 1);
68 static_cast<cmCursesPathWidget
*>(this->Entry
)->SetString(
71 case cmCacheManager::FILEPATH
:
72 this->Entry
= new cmCursesFilePathWidget(this->EntryWidth
, 1, 1, 1);
73 static_cast<cmCursesFilePathWidget
*>(this->Entry
)->SetString(
76 case cmCacheManager::STRING
:
77 this->Entry
= new cmCursesStringWidget(this->EntryWidth
, 1, 1, 1);
78 static_cast<cmCursesStringWidget
*>(this->Entry
)->SetString(
81 case cmCacheManager::UNINITIALIZED
:
82 cmSystemTools::Error("Found an undefined variable: ", it
.GetName());
85 // TODO : put warning message here
91 cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
94 delete this->IsNewLabel
;
98 const char* cmCursesCacheEntryComposite::GetValue()
102 return this->Label
->GetValue();