SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIColorer.h
Go to the documentation of this file.
1 /****************************************************************************/
10 //
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef GUIColorer_h
24 #define GUIColorer_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <fx.h>
39 #include "GUIColorScheme.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
50 class GUIColorer {
51 public:
54 
56  virtual ~GUIColorer() { }
57 
59  void fill(FXComboBox& cb) {
60  for (std::vector<GUIColorScheme>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
61  cb.appendItem((*i).getName().c_str());
62  }
63  cb.setCurrentItem((FXint)myActiveScheme);
64  }
65 
66  void setActive(size_t scheme) {
67  if (scheme < mySchemes.size()) {
68  myActiveScheme = scheme;
69  }
70  }
71 
72  size_t getActive() const {
73  return myActiveScheme;
74  }
75 
77  return mySchemes[myActiveScheme];
78  }
79 
80  const GUIColorScheme& getScheme() const {
81  return mySchemes[myActiveScheme];
82  }
83 
84  GUIColorScheme* getSchemeByName(std::string name) {
85  for (std::vector<GUIColorScheme>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
86  if ((*i).getName() == name) {
87  return &(*i);
88  }
89  }
90  return 0;
91  }
92 
93  void save(OutputDevice& dev) const {
94  for (std::vector<GUIColorScheme>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
95  i->save(dev);
96  }
97  }
98 
99  bool operator==(const GUIColorer& c) const {
100  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
101  }
102 
103 
104  void addScheme(GUIColorScheme scheme) {
105  mySchemes.push_back(scheme);
106  }
107 
108 
109 protected:
111  std::vector<GUIColorScheme> mySchemes;
112 
113 };
114 
115 
116 #endif
117 
118 /****************************************************************************/