PresetsArray.cpp (2767B)
1 /* 2 ZynAddSubFX - a software synthesizer 3 4 PresetsArray.cpp - PresetsArray and Clipboard management 5 Copyright (C) 2002-2005 Nasca Octavian Paul 6 Author: Nasca Octavian Paul 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 */ 13 14 #include "PresetsStore.h" 15 #include "PresetsArray.h" 16 #include <string.h> 17 18 namespace zyn { 19 20 PresetsArray::PresetsArray() 21 { 22 type[0] = 0; 23 } 24 25 PresetsArray::~PresetsArray() 26 {} 27 28 void PresetsArray::setpresettype(const char *type) 29 { 30 strcpy(this->type, type); 31 } 32 33 void PresetsArray::copy(PresetsStore &ps, const char *name) 34 { 35 copy(ps, -1, name); 36 } 37 38 void PresetsArray::copy(PresetsStore &ps, int nelement, const char *name) 39 { 40 XMLwrapper xml; 41 42 //used only for the clipboard 43 if(name == NULL) 44 xml.minimal = false; 45 46 char type[MAX_PRESETTYPE_SIZE]; 47 strcpy(type, this->type); 48 if(nelement != -1) 49 strcat(type, "n"); 50 if(name == NULL) 51 if(strstr(type, "Plfo") != NULL) 52 strcpy(type, "Plfo"); 53 54 xml.beginbranch(type); 55 if(nelement == -1) 56 add2XML(xml); 57 else 58 add2XMLsection(xml, nelement); 59 xml.endbranch(); 60 61 if(name == NULL) 62 ps.copyclipboard(xml, type); 63 else 64 ps.copypreset(xml, type, name); 65 } 66 67 #if 0 68 void PresetsArray::paste(PresetsStore &ps, int npreset) 69 { 70 char type[MAX_PRESETTYPE_SIZE]; 71 strcpy(type, this->type); 72 if(nelement != -1) 73 strcat(type, "n"); 74 if(npreset == 0) 75 if(strstr(type, "Plfo") != NULL) 76 strcpy(type, "Plfo"); 77 78 XMLwrapper xml; 79 if(npreset == 0) { 80 if(!checkclipboardtype(ps)) { 81 nelement = -1; 82 return; 83 } 84 if(!ps.pasteclipboard(xml)) { 85 nelement = -1; 86 return; 87 } 88 } else if(!ps.pastepreset(xml, npreset)) { 89 nelement = -1; 90 return; 91 } 92 93 if(xml.enterbranch(type) == 0) { 94 nelement = -1; 95 return; 96 } 97 if(nelement == -1) { 98 defaults(); 99 getfromXML(&xml); 100 } else { 101 defaults(nelement); 102 getfromXMLsection(&xml, nelement); 103 } 104 xml.exitbranch(); 105 106 nelement = -1; 107 } 108 109 110 bool PresetsArray::checkclipboardtype(PresetsStore &ps) 111 { 112 char type[MAX_PRESETTYPE_SIZE]; 113 strcpy(type, this->type); 114 if(nelement != -1) 115 strcat(type, "n"); 116 117 return ps.checkclipboardtype(type); 118 } 119 #endif 120 121 //void PresetsArray::rescanforpresets() 122 //{ 123 // char type[MAX_PRESETTYPE_SIZE]; 124 // strcpy(type, this->type); 125 // if(nelement != -1) 126 // strcat(type, "n"); 127 // 128 // presetsstore.rescanforpresets(type); 129 //} 130 131 }