/*******************************************************************************
* Copyright (c)                                                                *
*           2005   Tristan Allwood,                                            *
*           2005   Daniel Burke,                                               *
*           2005   Marc Hull,                                                  *
*           2005   Ekaterina Itskova,                                          *
*           2005   Steve Zymler                                                *
*                                                                              *
* Permission is hereby granted, free of charge, to any person obtaining a      *
* copy of this software and associated documentation files (the                *
* "Software"), to deal in the Software without restriction, including          *
* without limitation the rights to use, copy, modify, merge, publish,          *
* distribute, sublicense, and/or sell copies of the Software, and to           *
* permit persons to whom the Software is furnished to do so, subject to        *
* the following conditions:                                                    *
*                                                                              *
* The above copyright notice and this permission notice shall be included      *
* in all copies or substantial portions of the Software.                       *
*                                                                              *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS      *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                   *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.       *
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY         *
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,         *
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE            *
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                       *
*******************************************************************************/
/*
 * Created on 27-Oct-2004
 */
package uk.ac.ic.doc.kevlar.gui.internal.taskpane;

import org.eclipse.swt.graphics.Point;

import uk.ac.ic.doc.kevlar.gui.internal.animation.AnimationManager;
import uk.ac.ic.doc.kevlar.gui.internal.animation.SlideAnimation;
import uk.ac.ic.doc.kevlar.gui.internal.toolbar.ToolBarManager;
import uk.ac.ic.doc.kevlar.gui.internal.widgets.SelectableButton;


/**
 * @author Marc
 **/
class TaskPaneExpandButton extends SelectableButton {

    private static final String TASK_PANE_EXPAND_BUTTON = "taskpaneexpandbutton.png";
    private static final String TASK_PANE_EXPAND_BUTTON_ROLLOVER = "taskpaneexpandbutton_rollover.png";
    private static final String TASK_PANE_CONTRACT_BUTTON = "taskpanecontractbutton.png";
    private static final String TASK_PANE_CONTRACT_BUTTON_ROLLOVER = "taskpanecontractbutton_rollover.png";
    
    private TaskPaneManager manager;
    
    public TaskPaneExpandButton(TaskPaneManager m) {
        
        super(TASK_PANE_EXPAND_BUTTON, TASK_PANE_EXPAND_BUTTON_ROLLOVER, TASK_PANE_CONTRACT_BUTTON, TASK_PANE_CONTRACT_BUTTON_ROLLOVER);
        manager = m;
        
    }
       
    public void mouseRelease(Point position, int button) {

//        super.mouseRelease(position, button);
        
        if (button == MB_LEFT) {
        
            if (!isSelected()) {
        
/*                AnimationManager.getSingleton().addAnimation(new SlideAnimation(manager, new Point(10, 0)));
                ToolBarManager.getSingleton().setPaneVisible(false); */
                
                manager.expand();
                
            } else {
            
/*                AnimationManager.getSingleton().addAnimation(new SlideAnimation(manager, new Point(TaskPaneManager.TASK_PANE_WIDTH, 0)));
                ToolBarManager.getSingleton().setPaneVisible(true); */
                
                manager.contract();
                
            }

        }
        
    }
    
    public void updateImage(boolean selected)
    {	
    	if (selected)
    	{
    		super.deselect();
    	}
    	else
    	{
    		super.select();
    	}
  
    }
    
}
