// ----
// ---- file   : dialog_ar_deletemapgroup.tks
// ---- author : Bastian Spiegel <bs@tkscript.de>
// ---- legal  : (c) 2016 by Bastian Spiegel. 
// ----          Distributed under terms of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL). See 
// ----          http://www.gnu.org/licenses/licenses.html#LGPL or COPYING for further information.
// ----
// ---- info   : This is part of the "syntracker" sequencer.
// ----
// ---- changed: 05Mar2016
// ----
// ----
// ----
module MDialog_AR_DeleteMapGroup;

use namespace ui;
use namespace st2;


class Dialog_AR_DeleteMapGroup extends ActionConsumer {
   ChoiceDialog d;

   NodeAnalogRytmEditor *editor;

   public method run(NodeAnalogRytmEditor _editor, String _name) {
      d <= ChoiceDialogMMT.NewYesNo("Delete map group", 
                                    "Are you sure to delete map group \""+_name+"\"?", 
                                    this);

      editor <= _editor;

      //d.showCentered();
      d.setMessageFont("big7");
      // d.setButtonIcons(UI.GetIcon("exit"), UI.GetIcon("cancel"), null);
      d.setButtonIcons(null, UI.GetIcon("cancel"), null);
      d.setButtonFont("big5");
      d.invalidateSizeCaches();
      d.resizeToMinimum();
      //d.showNearMouse(-150, -90);
      d.showCentered();
   }
    
   public virtual consumeAction(IntAction _action) : boolean {
      if(_action.getActionProvider() == d)
      {
         d <= null; // Delete dialog
         switch(_action.getIntValue())
         {
            case ChoiceDialog.SELECT_YES:
               editor.handleMapGroupRemove2();
               return true;

            case ChoiceDialog.SELECT_NO:
               return true;
         }
      }
      return false;
   }
}
