User Tools

Site Tools


Dock Area Toggle

Summary

Below is an example demonstrating how to toggle the minimized state of dock areas.

API Areas of Interest

Example

Dock_Area_Toggle.dsa
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	/*********************************************************************/
	// Boolean : A function for determining whether or not a dock area is minimized
	function isDockAreaMinimized( oDockArea )
	{
		// Declare working variable
		var oDockColumn;
 
		// Get the number of columns/rows in the dock area
		var nColumns = oDockArea.getNumColumns();
		// Iterate over the columns
		for( var i = 0; i < nColumns; i += 1 ){
			// Get the 'current' column
			oDockColumn = oDockArea.getColumn( i );
			// If the column is minimized
			if( oDockColumn.isMinimized() ){
				// We have found our answer
				return true;
			}
		}
 
		// We have found our answer
		return false;
	};
 
	/*********************************************************************/
	// void : A function for toggling the minimized state of a dock area
	function toggleDockArea( oDockArea, bHasMinimized )
	{
		// Get the number of columns in the dock area
		var nColumns = oDockArea.getNumColumns();
		// Iterate over the columns
		for( var i = 0; i < nColumns; i += 1 ){
			// Get the 'current' column
			oDockColumn = oDockArea.getColumn( i );
			// If we do not have minimized columns
			if( !bHasMinimized ){
				// Minimize the column
				oDockColumn.minimize()
			// If we do have minimized columns
			} else {
				// Restore the column
				oDockColumn.restore()
			}
		}
	};
 
	/*********************************************************************/
	// Define the dock areas we want to toggle
	var bLeft = true;
	var bRight = true;
	var bTop = false;
	var bBottom = false;
 
	// --- Determine the minimized state of the dock areas ---
 
	// Declare working variable
	var oDockArea;
 
	// Initialize
	var bHasMinimized = false;
 
	// If we want to toggle the left dock area
	if( bLeft && !bHasMinimized ){
		// Get the left dock area
		oDockArea = MainWindow.getLeftDockArea();
		bHasMinimized = isDockAreaMinimized( oDockArea );
	}
 
	// If we want to toggle the right dock area and we have not yet found a minimized state
	if( bRight && !bHasMinimized ){
		// Get the right dock area
		oDockArea = MainWindow.getRightDockArea();
		bHasMinimized = isDockAreaMinimized( oDockArea );
	}
 
	// If we want to toggle the top dock area and we have not yet found a minimized state
	if( bTop && !bHasMinimized ){
		// Get the top dock area
		oDockArea = MainWindow.getTopDockArea();
		bHasMinimized = isDockAreaMinimized( oDockArea );
	}
 
	// If we want to toggle the bottom dock area and we have not yet found a minimized state
	if( bBottom && !bHasMinimized ){
		// Get the bottom dock area
		oDockArea = MainWindow.getBottomDockArea();
		bHasMinimized = isDockAreaMinimized( oDockArea );
	}
 
	// --- Perform the toggle using the minimized state determined ---
 
	// If we want to toggle the left dock area
	if( bLeft ){
		// Get the left dock area
		oDockArea = MainWindow.getLeftDockArea();
		toggleDockArea( oDockArea, bHasMinimized );
	}
 
	// If we want to toggle the right dock area
	if( bRight ){
		// Get the right dock area
		oDockArea = MainWindow.getRightDockArea();
		toggleDockArea( oDockArea, bHasMinimized );
	}
 
	// If we want to toggle the top dock area
	if( bTop ){
		// Get the top dock area
		oDockArea = MainWindow.getTopDockArea();
		toggleDockArea( oDockArea, bHasMinimized );
	}
 
	// If we want to toggle the bottom dock area
	if( bBottom ){
		// Get the bottom dock area
		oDockArea = MainWindow.getBottomDockArea();
		toggleDockArea( oDockArea, bHasMinimized );
	}
 
// Finalize the function and invoke
})();