home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ToolboxItem.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  185 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*---------------------------------------*/
  19. /*                                                                        */
  20. /* Name:        ToolboxItem.cpp                                            */
  21. /* Description:    XFE_ToolboxItem component source.                        */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27.  
  28. #include "ToolboxItem.h"
  29. #include "Logo.h"
  30. #include "Toolbox.h"
  31.  
  32. #include <Xfe/ToolBox.h>
  33.  
  34. //
  35. // AbstractToolbar class
  36. //
  37. //////////////////////////////////////////////////////////////////////////
  38. XFE_ToolboxItem::XFE_ToolboxItem(XFE_Component *    top,
  39.                                          XFE_Toolbox *        parentToolbox) : 
  40.     XFE_Component(top),
  41.     m_logo(NULL),
  42.     m_showLogo(False),
  43.     m_parentToolbox(parentToolbox)
  44. {
  45.     XP_ASSERT( m_parentToolbox != NULL );
  46. }
  47. //////////////////////////////////////////////////////////////////////////
  48. void
  49. XFE_ToolboxItem::toggle()
  50. {
  51.   if (isShown())
  52.     hide();
  53.   else
  54.     show();
  55. }
  56. //////////////////////////////////////////////////////////////////////////
  57. int
  58. XFE_ToolboxItem::getPosition()
  59. {
  60.     XP_ASSERT( XfeIsAlive(m_widget) );
  61.     XP_ASSERT( XfeIsToolBox(XtParent(m_widget)) );
  62.  
  63.     return     m_parentToolbox->positionOfItem(m_widget);
  64. }
  65. //////////////////////////////////////////////////////////////////////////
  66. void
  67. XFE_ToolboxItem::setPosition(int position)
  68. {
  69.     XP_ASSERT( XfeIsAlive(m_widget) );
  70.     XP_ASSERT( m_parentToolbox != NULL );
  71.  
  72. //     if (XFE_ToolboxItem::getPosition() != position)
  73. //     {
  74. //         printf("setPosition(%s,%d)\n",XtName(m_widget),position);
  75. //     }
  76.  
  77.     m_parentToolbox->setItemPosition(m_widget,position);
  78. }
  79. //////////////////////////////////////////////////////////////////////////
  80. void
  81. XFE_ToolboxItem::showLogo()
  82. {
  83.     XP_ASSERT( m_logo != NULL );
  84.  
  85.     m_showLogo = True;
  86.  
  87.     configureLogo();
  88. }
  89. //////////////////////////////////////////////////////////////////////////
  90. void
  91. XFE_ToolboxItem::hideLogo()
  92. {
  93.     XP_ASSERT( m_logo != NULL );
  94.  
  95.     m_showLogo = False;
  96.  
  97.     configureLogo();
  98. }
  99. //////////////////////////////////////////////////////////////////////////
  100. XP_Bool
  101. XFE_ToolboxItem::isLogoShown()
  102. {
  103.     return m_showLogo;
  104. }
  105. //////////////////////////////////////////////////////////////////////////
  106. XP_Bool
  107. XFE_ToolboxItem::isOpen()
  108. {
  109.     XP_ASSERT( XfeIsAlive(m_widget) );
  110.     XP_ASSERT( m_parentToolbox != NULL );
  111.  
  112.     return     m_parentToolbox->stateOfItem(m_widget);
  113. }
  114. //////////////////////////////////////////////////////////////////////////
  115. void
  116. XFE_ToolboxItem::setOpen(XP_Bool open)
  117. {
  118.     XP_ASSERT( XfeIsAlive(m_widget) );
  119.     XP_ASSERT( m_parentToolbox != NULL );
  120.  
  121.  
  122.     m_parentToolbox->setItemOpen(m_widget,open);
  123. }
  124. //////////////////////////////////////////////////////////////////////////
  125. void
  126. XFE_ToolboxItem::setShowing(XP_Bool showing)
  127. {
  128.     XP_ASSERT( XfeIsAlive(m_widget) );
  129.     XP_ASSERT( m_parentToolbox != NULL );
  130.  
  131.     if (showing)
  132.     {
  133.         show();
  134.     }
  135.     else
  136.     {
  137.         hide();
  138.     }
  139. }
  140. //////////////////////////////////////////////////////////////////////////
  141. XFE_Logo *
  142. XFE_ToolboxItem::getLogo()
  143. {
  144.     return m_logo;
  145. }
  146. //////////////////////////////////////////////////////////////////////////
  147. XFE_Toolbox *
  148. XFE_ToolboxItem::getParentToolbox()
  149. {
  150.     return m_parentToolbox;
  151. }
  152. //////////////////////////////////////////////////////////////////////////
  153. void
  154. XFE_ToolboxItem::addDragWidget(Widget item)
  155. {
  156.     XP_ASSERT( m_parentToolbox != NULL );
  157.     XP_ASSERT( XfeIsAlive(item) );
  158.  
  159.     m_parentToolbox->addDragDescendant(item);
  160. }
  161. //////////////////////////////////////////////////////////////////////////
  162. void
  163. XFE_ToolboxItem::configureLogo()
  164. {
  165.     // Make sure the logo exists
  166.     if (!m_logo)
  167.     {
  168.         return;
  169.     }
  170.  
  171.     // Logo shown
  172.     if (m_showLogo)
  173.     {
  174.         m_logo->show();
  175.     }
  176.     // Logo hidden
  177.     else
  178.     {
  179.         m_logo->hide();
  180.     }
  181. }
  182. //////////////////////////////////////////////////////////////////////////
  183.  
  184.  
  185.