| 18 | | virtual int getProperties() = 0; |
| 19 | | virtual PropertyInfoBase* getProperty(int index) = 0; |
| 20 | | virtual bool isData(void* data) = 0; |
| 21 | | }; |
| 22 | | |
| 23 | | class CPatternPropertyProvider : public CPropertyProvider { |
| 24 | | public: |
| 25 | | CDocument* document; |
| 26 | | zzub::metaplugin* machine; |
| 27 | | zzub::pattern* pattern; |
| 28 | | std::vector<PropertyInfoBase*> properties; |
| 29 | | |
| 30 | | CPatternPropertyProvider(HWND returnView, CDocument* doc, zzub::metaplugin* machine, zzub::pattern* pattern); |
| 31 | | virtual int getProperties(); |
| 32 | | virtual PropertyInfoBase* getProperty(int index); |
| 33 | | virtual bool isData(void* data); |
| 34 | | |
| 35 | | // pattern properties (working on selected pattern) |
| 36 | | void setPatternName(std::string name); |
| 37 | | std::string getPatternName(); |
| 38 | | void setPatternLength(int length); |
| 39 | | int getPatternLength(); |
| 40 | | BOOL getPatternRepeatLength(); |
| 41 | | void setPatternRepeatLength(BOOL state); |
| 42 | | |
| 43 | | }; |
| 44 | | |
| 45 | | class CMachinePropertyProvider; |
| 46 | | |
| 47 | | class CAttributeProperty { |
| 48 | | public: |
| 49 | | CMachinePropertyProvider* provider; |
| 50 | | zzub::metaplugin* machine; |
| 51 | | int attributeIndex; |
| 52 | | |
| 53 | | void setValue(int value); |
| 54 | | int getValue(); |
| 55 | | }; |
| 56 | | |
| 57 | | class CMachinePropertyProvider : public CPropertyProvider { |
| 58 | | public: |
| 59 | | CDocument* document; |
| 60 | | zzub::metaplugin* machine; |
| 61 | | std::vector<PropertyInfoBase*> properties; |
| 62 | | |
| 63 | | CMachinePropertyProvider(HWND returnView, CDocument* doc, zzub::metaplugin* machine); |
| 64 | | virtual int getProperties(); |
| 65 | | virtual PropertyInfoBase* getProperty(int index); |
| 66 | | virtual bool isData(void* data); |
| 67 | | |
| 68 | | // machine properties (working on selected machine) |
| 69 | | void setMachineName(std::string name); |
| 70 | | std::string getMachineName(); |
| 71 | | void setMachineTracks(int tracks); |
| 72 | | int getMachineTracks(); |
| 73 | | BOOL getMachineMuted(); |
| 74 | | void setMachineMuted(BOOL state); |
| 75 | | BOOL getMachineSolo(); |
| 76 | | void setMachineSolo(BOOL state); |
| 77 | | BOOL getMachineMidiIn(); |
| 78 | | void setMachineMidiIn(BOOL state); |
| 79 | | |
| 80 | | std::string getMachineURI(); |
| 81 | | std::string getMachineFileName(); |
| 82 | | std::string getMachineFullName(); |
| 83 | | std::string getMachineAuthor(); |
| 84 | | |
| 85 | | void setMachinePatternLength(int length); |
| 86 | | int getMachinePatternLength(); |
| 87 | | }; |
| 88 | | |
| 89 | | class CMachineLoaderPropertyProvider : public CPropertyProvider { |
| 90 | | public: |
| 91 | | CDocument* document; |
| 92 | | std::vector<PropertyInfoBase*> properties; |
| 93 | | zzub::pluginloader* loader; |
| 94 | | |
| 95 | | CMachineLoaderPropertyProvider(HWND returnView, CDocument* doc, zzub::pluginloader* loader); |
| 96 | | virtual int getProperties(); |
| 97 | | virtual PropertyInfoBase* getProperty(int index); |
| 98 | | virtual bool isData(void* data); |
| 99 | | |
| 100 | | std::string getMachineFileName(); |
| 101 | | std::string getMachineFullName(); |
| 102 | | std::string getMachineAuthor(); |
| 103 | | std::string getMachineUri(); |
| 104 | | BOOL getMachineMidiIn(); |
| 105 | | void setMachineMidiIn(BOOL state); |
| 106 | | |
| 107 | | }; |
| 108 | | |
| 109 | | |
| 110 | | class CConnectionPropertyProvider : public CPropertyProvider { |
| 111 | | public: |
| 112 | | CDocument* document; |
| 113 | | std::vector<PropertyInfoBase*> properties; |
| 114 | | zzub::connection* connection; |
| 115 | | |
| 116 | | CConnectionPropertyProvider(HWND returnView, CDocument* doc, zzub::connection* loader); |
| 117 | | virtual int getProperties(); |
| 118 | | virtual PropertyInfoBase* getProperty(int index); |
| 119 | | virtual bool isData(void* data); |
| 120 | | |
| 121 | | // connection properties (work on selected connection) |
| 122 | | void setConnectionVolume(int vol); |
| 123 | | int getConnectionVolume(); |
| 124 | | void setConnectionPan(int pan); |
| 125 | | int getConnectionPan(); |
| 126 | | void setConnectionRecord(BOOL state); |
| 127 | | BOOL getConnectionRecord(); |
| 128 | | |
| 129 | | }; |
| 130 | | |
| 131 | | class CWavePropertyProvider : public CPropertyProvider { |
| 132 | | public: |
| 133 | | CDocument* document; |
| 134 | | std::vector<PropertyInfoBase*> properties; |
| 135 | | zzub::wave_info_ex* wave; |
| 136 | | |
| 137 | | CWavePropertyProvider(HWND returnView, CDocument* doc, zzub::wave_info_ex* wave); |
| 138 | | virtual int getProperties(); |
| 139 | | virtual PropertyInfoBase* getProperty(int index); |
| 140 | | virtual bool isData(void* data); |
| 141 | | |
| 142 | | // wave properties |
| 143 | | int getWaveIndex(); |
| 144 | | void setWaveVolume(int vol); |
| 145 | | int getWaveVolume(); |
| 146 | | void setWaveLooping(BOOL ); // eller waveFlags? |
| 147 | | BOOL getWaveLooping(); |
| 148 | | void setWaveBidirLoop(BOOL ); // eller waveFlags? |
| 149 | | BOOL getWaveBidirLoop(); |
| 150 | | std::string getWaveFileName(); |
| 151 | | void setWaveFileName(std::string name); |
| 152 | | std::string getWaveName(); |
| 153 | | void setWaveName(std::string name); |
| 154 | | |
| 155 | | }; |
| 156 | | |
| 157 | | class CWaveLevelPropertyProvider : public CPropertyProvider { |
| 158 | | public: |
| 159 | | CDocument* document; |
| 160 | | std::vector<PropertyInfoBase*> properties; |
| 161 | | zzub::wave_level* waveLevel; |
| 162 | | |
| 163 | | CWaveLevelPropertyProvider(HWND hWnd, CDocument* doc, zzub::wave_level* level); |
| 164 | | virtual int getProperties(); |
| 165 | | virtual PropertyInfoBase* getProperty(int index); |
| 166 | | virtual bool isData(void* data); |
| 167 | | |
| 168 | | void setWaveLevelBaseNote(int note); // eller waveLevelProps? |
| 169 | | int getWaveLevelBaseNote(); |
| 170 | | void setWaveLevelBits(int bits); |
| 171 | | int getWaveLevelBits(); |
| 172 | | void setWaveLevelEndLoop(int bits); |
| 173 | | int getWaveLevelEndLoop(); |
| 174 | | void setWaveLevelBeginLoop(int bits); |
| 175 | | int getWaveLevelBeginLoop(); |
| 176 | | int getWaveLevelSamples(); |
| 177 | | void setWaveLevelSamples(int samples); |
| 178 | | void setWaveLevelType(int bits); |
| 179 | | int getWaveLevelType(); |
| 180 | | void setWaveLevelSampleRate(int rate); |
| 181 | | int getWaveLevelSampleRate(); |
| 182 | | std::string getWaveLevelStreamPlugin(); |
| 183 | | void setWaveLevelStreamPlugin(std::string name); |
| 184 | | std::string getWaveLevelStreamData(); |
| 185 | | void setWaveLevelStreamData(std::string name); |
| 186 | | }; |
| 187 | | |
| 188 | | class CSequencePropertyProvider : public CPropertyProvider { |
| 189 | | public: |
| 190 | | CDocument* document; |
| 191 | | std::vector<PropertyInfoBase*> properties; |
| 192 | | zzub::sequence* track; |
| 193 | | |
| 194 | | CSequencePropertyProvider(HWND returnView, CDocument* doc, zzub::sequence* track); |
| 195 | | virtual int getProperties(); |
| 196 | | virtual PropertyInfoBase* getProperty(int index); |
| 197 | | virtual bool isData(void* data); |
| 198 | | |
| 199 | | // sequence properties |
| 200 | | std::string getSequenceName(); |
| 201 | | void setSequenceName(std::string name); |
| 202 | | BOOL getSequenceMuted(); |
| 203 | | void setSequenceMuted(BOOL state); |
| 204 | | BOOL getSequenceSolo(); |
| 205 | | void setSequenceSolo(BOOL state); |
| 206 | | |
| 207 | | }; |
| | 37 | virtual int getProperties() = 0; |
| | 38 | virtual PropertyInfoBase* getProperty(int index) = 0; |
| | 39 | virtual bool isData(void* data) = 0; |
| | 40 | }; |
| | 41 | |
| | 42 | |
| | 43 | /*** |
| | 44 | |
| | 45 | ObjectPropertyInfo |
| | 46 | |
| | 47 | ... and misc other properties for the properties view |
| | 48 | |
| | 49 | ***/ |
| | 50 | |
| | 51 | template <class P, typename valuetype> |
| | 52 | class ObjectPropertyInfo : public PropertyInfoBase { |
| | 53 | public: |
| | 54 | P* frame; |
| | 55 | |
| | 56 | ObjectPropertyInfo(P* frame, const char* n, valuetype (P::*getter)(), void (P::*setter)(valuetype)) { |
| | 57 | this->frame = frame; |
| | 58 | this->name = n; |
| | 59 | this->getter = getter; |
| | 60 | this->setter = setter; |
| | 61 | } |
| | 62 | valuetype (P::*getter)(); |
| | 63 | void (P::*setter)(valuetype); |
| | 64 | |
| | 65 | virtual VARIANT& get() = 0; |
| | 66 | virtual void set(VARIANT v) = 0; |
| | 67 | }; |
| | 68 | |
| | 69 | template <class P> |
| | 70 | class IntPropertyInfo : public ObjectPropertyInfo<P, int> { |
| | 71 | public: |
| | 72 | IntPropertyInfo(P* frame, const char* n, int (P::*getter)(), void (P::*setter)(int)):ObjectPropertyInfo<P, int>(frame, n, getter, setter) { } |
| | 73 | virtual VARIANT& get() { |
| | 74 | VariantClear(&value); |
| | 75 | value.vt = VT_I4; |
| | 76 | value.intVal = (frame->*getter)(); |
| | 77 | return value; |
| | 78 | } |
| | 79 | |
| | 80 | void set(VARIANT v) { |
| | 81 | if (setter == 0) return ; |
| | 82 | if (isVariantNumber(v)) { |
| | 83 | VariantCopy(&value, &v); |
| | 84 | int i = v.intVal; |
| | 85 | (frame->*setter)(i); |
| | 86 | } |
| | 87 | } |
| | 88 | HPROPERTY create() { |
| | 89 | VARIANT& v = get(); |
| | 90 | if (this->setter == 0) { |
| | 91 | char pc[16]; |
| | 92 | itoa(v.intVal, pc, 10); |
| | 93 | return PropCreateReadOnlyItem(name.c_str(), pc); |
| | 94 | } else |
| | 95 | return PropCreateVariant(name.c_str(), v); |
| | 96 | } |
| | 97 | |
| | 98 | }; |
| | 99 | |
| | 100 | |
| | 101 | template <class P> |
| | 102 | class StringPropertyInfo : public ObjectPropertyInfo<P, std::string> { |
| | 103 | public: |
| | 104 | StringPropertyInfo(P* frame, const char* n, std::string (P::*getter)(), void (P::*setter)(std::string) ):ObjectPropertyInfo<P, std::string>(frame, n, getter, setter) { |
| | 105 | } |
| | 106 | virtual VARIANT& get() { |
| | 107 | // convert from std::string to VARIANT |
| | 108 | VariantClear(&value); |
| | 109 | |
| | 110 | std::string v = (frame->*getter)(); |
| | 111 | size_t len = v.length(); |
| | 112 | |
| | 113 | BSTR str = SysAllocStringLen(0, len); |
| | 114 | if (str == 0) return value; |
| | 115 | |
| | 116 | mbstowcs(str, v.c_str(), len+1); |
| | 117 | |
| | 118 | value.vt = VT_BSTR; |
| | 119 | value.bstrVal = str; |
| | 120 | |
| | 121 | return value; |
| | 122 | } |
| | 123 | void set(VARIANT v) { |
| | 124 | if (setter == 0) return ; |
| | 125 | if (v.vt == VT_BSTR) { |
| | 126 | VariantCopy(&value, &v); |
| | 127 | size_t len = wcslen(value.bstrVal); |
| | 128 | char* pc = new char[len+1]; |
| | 129 | wcstombs(pc, value.bstrVal, len+1); |
| | 130 | std::string str = pc; |
| | 131 | delete[] pc; |
| | 132 | (frame->*setter)(str); |
| | 133 | |
| | 134 | len = 0; |
| | 135 | } |
| | 136 | } |
| | 137 | |
| | 138 | HPROPERTY create() { |
| | 139 | VARIANT& v = get(); |
| | 140 | return PropCreateVariant(name.c_str(), v); |
| | 141 | } |
| | 142 | }; |
| | 143 | |
| | 144 | |
| | 145 | |
| | 146 | template <class P> |
| | 147 | class BoolPropertyInfo : public ObjectPropertyInfo<P, BOOL> { |
| | 148 | public: |
| | 149 | BoolPropertyInfo(P* frame, const char* n, BOOL (P::*getter)(), void (P::*setter)(BOOL) ):ObjectPropertyInfo<P, BOOL>(frame, n, getter, setter) { |
| | 150 | } |
| | 151 | virtual VARIANT& get() { |
| | 152 | VariantClear(&value); |
| | 153 | BOOL v = (frame->*getter)(); |
| | 154 | value.vt = VT_BOOL; |
| | 155 | value.boolVal = v; |
| | 156 | return value; |
| | 157 | } |
| | 158 | void set(VARIANT v) { |
| | 159 | if (setter == 0) return ; |
| | 160 | if (v.vt == VT_BOOL) { |
| | 161 | VariantCopy(&value, &v); |
| | 162 | (frame->*setter)(v.boolVal!=VARIANT_FALSE); |
| | 163 | } |
| | 164 | } |
| | 165 | |
| | 166 | HPROPERTY create() { |
| | 167 | USES_CONVERSION ; |
| | 168 | VARIANT& v = get(); |
| | 169 | HPROPERTY hprop = PropCreateCheckButton(name.c_str(), v.boolVal!=VARIANT_FALSE); |
| | 170 | return hprop; |
| | 171 | } |
| | 172 | }; |
| | 173 | |
| | 174 | |
| | 175 | |
| | 176 | template <class P> |
| | 177 | class NotePropertyInfo : public ObjectPropertyInfo<P, int> { |
| | 178 | public: |
| | 179 | HWND hWnd; |
| | 180 | CListBox listBox; |
| | 181 | |
| | 182 | NotePropertyInfo(HWND hWnd, P* frame, const char* n, int (P::*getter)(), void (P::*setter)(int)):ObjectPropertyInfo<P, int>(frame, n, getter, setter) { |
| | 183 | this->hWnd = hWnd; |
| | 184 | } |
| | 185 | virtual VARIANT& get() { |
| | 186 | value.vt = VT_I4; |
| | 187 | value.intVal = (frame->*getter)(); |
| | 188 | return value; |
| | 189 | } |
| | 190 | |
| | 191 | void set(VARIANT v) { |
| | 192 | if (setter == 0) return ; |
| | 193 | // the value is the index of the note list |
| | 194 | if (isVariantNumber(v)) { |
| | 195 | VariantCopy(&value, &v); |
| | 196 | int i = linearNoteToBuzz(v.intVal); |
| | 197 | (frame->*setter)(i); |
| | 198 | } |
| | 199 | } |
| | 200 | |
| | 201 | int linearNoteToBuzz(int v) { |
| | 202 | int note=(v%12)+1; |
| | 203 | int oct=v/12; |
| | 204 | return (note) + (oct<<4); |
| | 205 | } |
| | 206 | |
| | 207 | int buzzNoteToLinear(int v) { |
| | 208 | int note=(v&0xF)-1; |
| | 209 | int oct=(v&0xF0) >> 4; |
| | 210 | return note+12*oct; |
| | 211 | } |
| | 212 | |
| | 213 | HPROPERTY create() { |
| | 214 | VARIANT& v = get(); |
| | 215 | std::vector<std::string> notes; |
| | 216 | for (int i=0; i<16*12; i++) { |
| | 217 | notes.push_back(noteFromInt(linearNoteToBuzz(i))); |
| | 218 | } |
| | 219 | LPCTSTR* data = new LPCTSTR[16*12 + 1]; |
| | 220 | for (int i=0; i<16*12; i++) { |
| | 221 | data[i] = notes[i].c_str(); |
| | 222 | } |
| | 223 | data[16*12] = 0; |
| | 224 | |
| | 225 | int linearNote = buzzNoteToLinear(v.intVal); |
| | 226 | HPROPERTY hProp = PropCreateList(name.c_str(), data, linearNote); |
| | 227 | delete[] data; |
| | 228 | return hProp; |
| | 229 | } |
| | 230 | |
| | 231 | }; |
| | 232 | |
| | 233 | |
| | 234 | template <class P> |
| | 235 | class StringListPropertyInfo : public ObjectPropertyInfo<P, int> { |
| | 236 | public: |
| | 237 | CListBox listBox; |
| | 238 | std::vector<std::string> (P::*itemsgetter)(); |
| | 239 | |
| | 240 | StringListPropertyInfo(P* frame, const char* n, int (P::*getter)(), void (P::*setter)(int), std::vector<std::string> (P::*itemsgetter)()):ObjectPropertyInfo<P, int>(frame, n, getter, setter) { |
| | 241 | this->itemsgetter = itemsgetter; |
| | 242 | } |
| | 243 | virtual VARIANT& get() { |
| | 244 | value.vt = VT_I4; |
| | 245 | value.intVal = (frame->*getter)(); |
| | 246 | return value; |
| | 247 | } |
| | 248 | |
| | 249 | void set(VARIANT v) { |
| | 250 | if (setter == 0) return ; |
| | 251 | // the value is the index of the note list |
| | 252 | if (isVariantNumber(v)) { |
| | 253 | VariantCopy(&value, &v); |
| | 254 | int i = v.intVal; |
| | 255 | (frame->*setter)(i); |
| | 256 | } |
| | 257 | } |
| | 258 | |
| | 259 | std::vector<std::string> items; |
| | 260 | |
| | 261 | HPROPERTY create() { |
| | 262 | VARIANT& v = get(); |
| | 263 | items = (frame->*itemsgetter)(); |
| | 264 | |
| | 265 | LPCTSTR* data = new LPCTSTR[items.size() + 1]; |
| | 266 | for (size_t i = 0; i < items.size(); i++) { |
| | 267 | data[i] = items[i].c_str(); |
| | 268 | } |
| | 269 | data[items.size()] = 0; |
| | 270 | |
| | 271 | int cursel = v.intVal; |
| | 272 | HPROPERTY hProp = PropCreateList(name.c_str(), data, cursel); |
| | 273 | delete[] data; |
| | 274 | return hProp; |
| | 275 | } |
| | 276 | |
| | 277 | }; |
| | 278 | |
| | 279 | class CategoryPropertyInfo : public PropertyInfoBase { |
| | 280 | public: |
| | 281 | CategoryPropertyInfo(std::string name) { |
| | 282 | this->name = name; |
| | 283 | } |
| | 284 | virtual HPROPERTY create() { |
| | 285 | return PropCreateCategory(name.c_str()); |
| | 286 | } |
| | 287 | virtual VARIANT& get() { |
| | 288 | static VARIANT v; |
| | 289 | VariantInit(&v); |
| | 290 | return v; |
| | 291 | } |
| | 292 | virtual void set(VARIANT v) { |
| | 293 | } |
| | 294 | }; |
| | 295 | |
| | 296 | |
| | 297 | |
| | 298 | template <class P> |
| | 299 | class ColorPropertyInfo : public ObjectPropertyInfo<P, COLORREF> { |
| | 300 | public: |
| | 301 | HPROPERTY hProp; |
| | 302 | ColorPropertyInfo(P* frame, const char* n, COLORREF (P::*getter)(), void (P::*setter)(COLORREF)):ObjectPropertyInfo<P, COLORREF>(frame, n, getter, setter) { } |
| | 303 | |
| | 304 | virtual VARIANT& get() { |
| | 305 | VariantClear(&value); |
| | 306 | value.vt = VT_UI4; |
| | 307 | value.uintVal = (frame->*getter)(); |
| | 308 | return value; |
| | 309 | } |
| | 310 | |
| | 311 | void set(VARIANT v) { |
| | 312 | if (setter == 0) return ; |
| | 313 | if (isVariantNumber(v)) { |
| | 314 | VariantCopy(&value, &v); |
| | 315 | unsigned int i = v.uintVal; |
| | 316 | (frame->*setter)(i); |
| | 317 | } |
| | 318 | } |
| | 319 | HPROPERTY create() { |
| | 320 | VARIANT& v = get(); |
| | 321 | char pc[16]; |
| | 322 | itoa(v.uintVal, pc, 10); |
| | 323 | |
| | 324 | hProp = PropCreateColor(name.c_str(), v.uintVal); |
| | 325 | return hProp; |
| | 326 | } |
| | 327 | |
| | 328 | }; |