//----------------------------------------------------------------------------
#ifndef ChildWinH
#define ChildWinH
//----------------------------------------------------------------------------
#include <vcl\Controls.hpp>
#include <vcl\Forms.hpp>
#include <vcl\Graphics.hpp>
#include <vcl\Classes.hpp>
#include <vcl\Windows.hpp>
#include <vcl\System.hpp>
#include <StdCtrls.hpp>
#include <ExtCtrls.hpp>
#include "XPMenu.hpp"
#include "AdvGrid.hpp"
#include "BaseGrid.hpp"
#include <Grids.hpp>
#include <ComCtrls.hpp>
#include <Buttons.hpp>
#include <stdio.h>
#include <Menus.hpp>
#include <vector>

extern "C"{
#include "glpk.h"
}
#include "linsystem.h"
#include <Buttons.hpp>


#define MAX_VAR 1000
//----------------------------------------------------------------------------
class TMDIChild : public TForm
{
__published:
        TPanel *Panel1;
        TPageControl *PageControl1;
        TTabSheet *TabSheet1;
        TTabSheet *TabSheet2;
        TTabSheet *TabSheet3;
        TAdvStringGrid *mxGrid;
        TAdvStringGrid *luGrid;
        TAdvStringGrid *simplexGrid;
        TBitBtn *bnCreate;
        TBitBtn *bnUpdate;
        TBitBtn *bnClose;
        TMainMenu *MainMenu2;
        TMenuItem *Options1;
        TMenuItem *Rowscaling1;
        TMenuItem *Columnscaling1;
        TMenuItem *Seteps1;
        TMenuItem *N1;
        TMenuItem *Scalingrule1;
        TMenuItem *Hall1;
        TMenuItem *Gondzio1;
        TLabel *Label1;
        TTabSheet *scaledSheet;
        TAdvStringGrid *scaledGrid;
        TBitBtn *bnSimplex;
        TBitBtn *BitBtn1;
	void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall mxGridButtonClick(TObject *Sender, int ACol,
          int ARow);
        void __fastcall mxGridGetCellColor(TObject *Sender, int ARow,
          int ACol, TGridDrawState AState, TBrush *ABrush, TFont *AFont);
        void __fastcall bnCreateClick(TObject *Sender);
        void __fastcall Rowscaling1Click(TObject *Sender);
        void __fastcall Columnscaling1Click(TObject *Sender);
        void __fastcall Seteps1Click(TObject *Sender);
        void __fastcall Hall1Click(TObject *Sender);
        void __fastcall bnUpdateClick(TObject *Sender);
        void __fastcall mxGridCellsChanged(TObject *Sender, TRect &R);
        void __fastcall bnSimplexClick(TObject *Sender);
        void __fastcall BitBtn1Click(TObject *Sender);
        void __fastcall Gondzio1Click(TObject *Sender);

private:
        LPX* lp;
        linsys ls;
        double *solution;
        int nBasesSelected;
        int bases[MAX_VAR];
        void initGrids();
        void UpdateView();
        void outputX();
        void outputSigma();
        bool selectAll;
public:
	virtual __fastcall TMDIChild(TComponent *Owner);
        void LoadFromMPS(String Name);
        void NewLS(int nVar, int nEq);
        __fastcall ~TMDIChild();
        void UpdateMatrix();
};
//----------------------------------------------------------------------------
#endif	
