/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.frame;

import java.io.IOException;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;

public class FrameWrapper implements FramedContent, SelfRenderable
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private FramedContent m_content;        // the actual content
  private String m_menu_sel;              // menu selector
  private String m_page_title;            // page title
  private String m_page_qid;              // page QID

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  public FrameWrapper(FramedContent content)
  {
    m_content = content;
    m_menu_sel = content.getMenuSelector();
    m_page_title = content.getPageTitle();
    m_page_qid = content.getPageQID();

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface FramedContent
   *--------------------------------------------------------------------------------
   */

  /**
   * Returns the desired menu selector for this page.  The <EM>menu selector</EM> is a string that specifies
   * which menu is to be displayed on the left menu bar, in addition to the "global menu."  This value may
   * be <CODE>null</CODE>, in which case the current menu selector is not changed.
   *
   * @return The desired menu selector.
   */
  public String getMenuSelector()
  {
    return m_menu_sel;

  } // end getMenuSelector

  /**
   * Returns the desired title for the page.  This title is concatenated with the <EM>site title</EM> (set in
   * global properties) to form the actual page title that gets sent to the browser.
   *
   * @return The desired page title.
   */
  public String getPageTitle()
  {
    return m_page_title;

  } // end getPageTitle

  /**
   * Returns the desired quick ID for the page.  The <EM>page quick ID</EM> is a small text string which can be used
   * to "tag" the page with a unique identifier, for use with external tools such as offsite hit counters.
   * If this value is <CODE>null</CODE>, the quick ID is not used for this page.
   *
   * @return The desired page quick ID.
   */
  public String getPageQID()
  {
    return m_page_qid;

  } // end getPageQID

  /*--------------------------------------------------------------------------------
   * Implementations from interface SelfRenderable
   *--------------------------------------------------------------------------------
   */

  /**
   * Renders this object to the output.
   *
   * @param control A rendering control object that provides the means to render this object to the output, as
   *                well as providing "output services" (through the
   *                {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider} interface) for the
   *                rendering process to use.
   * @exception java.io.IOException If an I/O error occurs while writing the output.
   * @exception com.silverwrist.dynamo.except.RenderingException If the rendering process fails.
   */
  public void render(SelfRenderControl control) throws IOException, RenderingException
  {
    TextRenderControl ctl = control.getTextRender();
    ctl.renderSubObject(m_content);

  } // end render

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  public void setMenuSelector(String s)
  {
    m_menu_sel = s;

  } // end setMenuSelector

  public void setPageTitle(String s)
  {
    m_page_title = s;

  } // end setPageTitle

  public void setPageQID(String s)
  {
    m_page_qid = s;

  } // end setPageQID

} // end class FrameWrapper
