summaryrefslogtreecommitdiffstats
path: root/Source/WXDialog/cmWXCacheProperty.h
blob: e1e297abbb15c7f485d8a143132b40b2e4ca4fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef CMCACHEPROPERTY_H
#define CMCACHEPROPERTY_H

#include "cmStandardIncludes.h"

#include "wxincludes.h"

class cmMainFrame;
class wxControl;
class wxPanel;
class wxSizer;
class wxWindow;

/** \class cmCacheProperty
 * \brief GUI Control class for cmake's cache property
 *
 * Stores cache property as displayed on GUI, caches its value, colors
 * red when new.
 * 
 */
class cmCacheProperty
{
public:
  cmCacheProperty(cmMainFrame*, const std::string& name);
  ~cmCacheProperty();
  const std::string& GetName() { return this->m_Name; }

  //! Get and set the value
  const std::string& GetValue() { return this->m_Value; }
  void SetValue(const std::string& s) { this->m_Value = s; }
  
  //! Get and set the help value
  void SetHelp(const std::string& s) { this->m_HelpString = s; }
  const std::string& GetHelp() { return this->m_HelpString; }

  //! Display the property in the window. Return the maximum height.
  int Display(wxSizer*, wxPanel*);

  //! Remove the property from the window
  void Remove(wxSizer*, wxPanel*);

  //! This method is called when property is changed
  void OnPropertyChanged(wxEvent& event);

  //! Mark cache entry as being removed.
  void MarkRemoved() { this->m_Removed = true; }

  //! Check if the entry was removed
  bool IsRemoved() { return this->m_Removed; }

  //! Get and set the new flag.
  void SetNewFlag(bool f) { this->m_NewValue = f; }
  bool GetNewFlag() { return this->m_NewValue; }

  //! Mark cache entry as being removed.
  void MarkAdvanced() { this->m_Advanced = true; }

  //! Check if the entry was removed
  bool IsAdvanced() { return this->m_Advanced; }

  //! Set item type
  void SetItemType(int t) { this->m_ItemType = t; }

  //! Get the main frame asociated with the cache property
  cmMainFrame* GetMainFrame() { return this->m_MainFrame; }

  enum ItemType
    {
      NOTHING = 0,
      EDIT,
      FILE,
      CHECKBOX,
      PATH      
    };

  enum 
    {
      Menu_Popup_Ignore = 200,
      Menu_Popup_Delete,
      Menu_Popup_Help
    };

protected:
  bool         m_NewValue;
  bool         m_Advanced;
  int          m_ItemType;

  wxWindow*    m_KeyWindow;
  wxWindow*    m_ValueWindow;

  std::string  m_Name;
  std::string  m_Value;
  std::string  m_HelpString;
  bool         m_Removed;

  //! The following methods set the events handling of widgets for the
  // cache property.
  void ConnectEvent(wxWindow* win, wxEventType et, wxObjectEventFunction func);
  void ConnectEventTo(wxWindow* win, wxEventType et, wxObjectEventFunction func);
  void SetupMenu(wxWindow* win);
  
  //! This are event callbacks for different events.
  void OnFileBrowseButton(wxEvent& event);
  void OnPathBrowseButton(wxEvent& event);
  void OnCheckboxButton(wxEvent& event);
  void OnEntryChanged(wxEvent& event);

private:
  cmMainFrame* m_MainFrame;
  wxControl*   m_TextControl;
};


#endif