zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

Presets.cpp (1992B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   Presets.cpp - Presets 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 "Presets.h"
     15 #include "../Misc/XMLwrapper.h"
     16 #include "PresetsStore.h"
     17 #include <string.h>
     18 
     19 namespace zyn {
     20 
     21 Presets::Presets()
     22 {
     23     type[0] = 0;
     24 }
     25 
     26 Presets::~Presets()
     27 {}
     28 
     29 void Presets::setpresettype(const char *type)
     30 {
     31     strcpy(this->type, type);
     32 }
     33 
     34 void Presets::copy(PresetsStore &ps, const char *name)
     35 {
     36     XMLwrapper xml;
     37 
     38     //used only for the clipboard
     39     if(name == NULL)
     40         xml.minimal = false;
     41 
     42     char type[MAX_PRESETTYPE_SIZE];
     43     strcpy(type, this->type);
     44     //strcat(type, "n");
     45     if(name == NULL)
     46         if(strstr(type, "Plfo") != NULL)
     47             strcpy(type, "Plfo");
     48 
     49     xml.beginbranch(type);
     50     add2XML(xml);
     51     xml.endbranch();
     52 
     53     if(name == NULL)
     54         ps.copyclipboard(xml, type);
     55     else
     56         ps.copypreset(xml, type, name);
     57 }
     58 
     59 #if 0
     60 void Presets::paste(PresetsStore &ps, int npreset)
     61 {
     62     char type[MAX_PRESETTYPE_SIZE];
     63     strcpy(type, this->type);
     64     //strcat(type, "n");
     65 
     66     if(npreset == 0)
     67         if(strstr(type, "Plfo") != NULL)
     68             strcpy(type, "Plfo");
     69 
     70     XMLwrapper xml;
     71     if(npreset == 0) {
     72         if(!checkclipboardtype(ps))
     73             return;
     74         if(!ps.pasteclipboard(xml))
     75             return;
     76     } else if(!ps.pastepreset(xml, npreset))
     77         return;
     78 
     79     if(xml.enterbranch(type) == 0)
     80         return;
     81 
     82     defaults();
     83     getfromXML(&xml);
     84 
     85     xml.exitbranch();
     86 }
     87 #endif
     88 
     89 bool Presets::checkclipboardtype(PresetsStore &ps)
     90 {
     91     return ps.checkclipboardtype(type);
     92 }
     93 
     94 
     95 void Presets::deletepreset(PresetsStore &ps, int npreset)
     96 {
     97     ps.deletepreset(npreset);
     98 }
     99 
    100 }