/************************************************************************/
/* PluginBoss plugin manager                                            */
/*																		*/
/* By Steve Pedler, March 2012		     						*/
/************************************************************************/

// pib.h

/*
Copyright (C) 2012  Steve Pedler

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#include "ge_dynamicarray.h"

// unique ID
#ifndef ID_PLUGINBOSS
#define ID_PLUGINBOSS 1027318
#endif

// menu constants
#define PIBMENU_FILE_COMMIT 15000
#define PIBMENU_FILE_RESET 15010
#define PIBMENU_FILE_RESTART 15015
#define PIBMENU_FILE_EXIT 15020
#define PIBMENU_EDIT_ACTALL 15100
#define PIBMENU_EDIT_DEACTALL 15110
#define PIBMENU_EDIT_ACT 15120
#define PIBMENU_EDIT_DEACT 15130
#define PIBLMENU_HELP_HELP 15200
#define PIBMENU_HELP_ABOUT 15210

// other constants
#define APP_PLUGIN_FOLDER 10000
#define PREF_PLUGIN_FOLDER 10001

// user area derived objects - dialog banner
class Banner : public GeUserArea
{
	BaseBitmap* bmp;
	Filename bmpToLoad;
	virtual Bool Init(void);
	virtual void DrawMsg(LONG x1, LONG y1, LONG x2, LONG y2, const BaseContainer& msg);
public:
	Banner();
	virtual ~Banner();
};

// definitions for the dialog class
class PIBDialog : public GeDialog
{
private:
	SimpleListView lvActive, lvDeact;
	Banner bannerUA;
	Filename appPluginpath, prefPluginPath;
	LONG livePlugCount, deadPlugCount;
	GeAutoDynamicArray<Filename>livePlugs;
	GeAutoDynamicArray<Filename>deadPlugs;
public:
	PIBDialog(void);														// constructor
	virtual Bool CreateLayout(void);
	virtual Bool InitValues(void);
	virtual Bool Command(LONG id,const BaseContainer &msg);
	virtual Bool AskClose(void);

	Bool GetPluginPaths();
	void RecursivePluginFinder(Filename pluginFolder);
	void ClearPluginLists(void);
	void MoveToInactive(void);
	void MoveToActive(void);
	void DeactivateAll(void);
	void ActivateAll(void);
	void FillLists(void);
	Bool CommitChanges(void);
	void RebuildLists(void);
	void ShowAbout(void);

};

// definitions for the CommandData class
class PluginBoss : public CommandData
{
private:
	PIBDialog dlg;

public:
	virtual Bool Execute(BaseDocument *doc);
	virtual LONG GetState(BaseDocument *doc);
};

