/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   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 2 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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#include "mainwindow.h"

// Core
#include "direktorinstance.h"
#include "documentwidget.h"

// Dockers
#include "dockers/timelinedocker.h"
#include "dockers/elementtreedocker.h"
#include "dockers/propertywidget.h"
#include "dockers/strokedocker.h"
#include "dockers/toolboxdocker.h"
#include "dockers/styledocker.h"

// Qt / KDE
#include <qdockarea.h>
#include <klocale.h>
#include <kdebug.h>

MainWindow::MainWindow(QWidget *parent, const char *name, KActionCollection *actionCollection ) :
    KParts::DockMainWindow(parent, name),
    m_docWidget(0)
{ //: QWidget(parent, name), KXMLGUIBuilder( this ),
  Kast::self();

  setupDocks();

  // Notify the DirectorInstance of our presence
  Kast::self()->setupGUI(this, actionCollection);
}


MainWindow::~MainWindow()
{
}

void MainWindow::setupDocks( )
{
  m_mainDock = createDockWidget( "MainDockWidget", QPixmap(), 0L, "MainDockWidget");
  m_docWidget = new DocumentWidget(m_mainDock, "DocumentScrollView");
  m_mainDock->setWidget(m_docWidget);

  // allow others to dock to the 4 sides
  m_mainDock->setDockSite(KDockWidget::DockCorner);
  // forbit docking abilities of mainDock itself
  m_mainDock->setEnableDocking(KDockWidget::DockNone);
  setView( m_mainDock); // central widget in a KDE mainwindow
  setMainDockWidget( m_mainDock); // master dockwidget

  m_topDock = createDockWidget( "Top Dock", QPixmap(), 0L, i18n("TimelineDocker"));
  TimelineDocker *timeDock = new TimelineDocker( m_topDock );
  m_topDock->setWidget( timeDock );
  m_topDock->manualDock( m_mainDock,              // dock target
                       KDockWidget::DockTop, // dock site
                       25 );                  // relation target/this (in percent)

  m_leftDock = createDockWidget( "Left Dock", QPixmap(), 0L, i18n("ElementTreeDocker"));
  ElementTreeDocker *elemTreeView = new ElementTreeDocker( m_leftDock );
  m_leftDock->setWidget( elemTreeView );
  m_leftDock->manualDock( m_mainDock,              // dock target
                        KDockWidget::DockLeft, // dock site
                        20 );                  // relation target/this (in percent)

  m_toolDock = createDockWidget( "Toolbox", QPixmap(), 0L, i18n("Toolbox"));
  ToolboxDocker *toolbox = new ToolboxDocker( m_toolDock );
  m_toolDock->setWidget( toolbox );
  m_toolDock->manualDock( m_leftDock,              // dock target
                        KDockWidget::DockBottom, // dock site
                        50 );                  // relation target/this (in percent)

  KDockWidget* m_rightDock;
  m_rightDock = createDockWidget( "Properties", QPixmap(), 0L, i18n("Properties"));
  PropertyWidget *propWidget = new PropertyWidget( m_rightDock );
  m_rightDock->setWidget( propWidget );
  m_rightDock->manualDock( m_mainDock,              // dock target
                         KDockWidget::DockRight, // dock site
                         80 );                  // relation target/this (in percent)
/*
  m_strokeDock = createDockWidget( "Stroke", QPixmap(), 0L, i18n("Stroke"));
  StrokeDocker *strokeWidget = new StrokeDocker( m_strokeDock );
  m_strokeDock->setWidget( strokeWidget );
  m_strokeDock->manualDock( m_rightDock,              // dock target
                         KDockWidget::DockBottom, // dock site
                         80 );                  // relation target/this (in percent)
*/
  m_styleDock = createDockWidget( "Style", QPixmap(), 0L, i18n("Style"));
  StyleDocker *styleWidget = new StyleDocker( m_styleDock );
  m_styleDock->setWidget( styleWidget );
  m_styleDock->manualDock( m_rightDock,              // dock target
                         KDockWidget::DockBottom, // dock site
                         80 );                  // relation target/this (in percent)
}

void MainWindow::toggleStrokeDock()
{
  m_strokeDock->changeHideShowState();
  emit( strokeDockToggled(m_strokeDock->isVisible()) );
}



#include "mainwindow.moc"
