home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / PropertySheetView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.7 KB  |  141 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.    PropertySheetView.cpp -- class definition for PropertySheetView
  20.    Created: Tao Cheng <tao@netscape.com>, 12-nov-96
  21.  */
  22.  
  23.  
  24.  
  25. #include "PropertySheetView.h"
  26. #include "PropertyTabView.h"
  27. #include <XmL/Folder.h>
  28.  
  29. XFE_PropertySheetView::XFE_PropertySheetView(XFE_Component *top,
  30.                      Widget parent, /* the dialog */
  31.                      int *tabNameId, int nTabs):
  32.   XFE_MNView(top, NULL, NULL, NULL)
  33. {
  34.   /* 1. Create the folder
  35.    */
  36.  
  37.   Widget folder = XtCreateWidget("xmlFolder",
  38.                  xmlFolderWidgetClass,
  39.                  parent, NULL, 0);  
  40.   XtAddCallback(folder, 
  41.         XmNactivateCallback, XFE_PropertySheetView::tabActivateCB, this);
  42.  
  43.   /* set base widget
  44.    */
  45.   setBaseWidget(folder);
  46.  
  47.   /* 2. Create tab view
  48.    */
  49.   if (tabNameId)
  50.     for (int i=0; i < nTabs; i++) {
  51.       XFE_PropertyTabView *tab = new XFE_PropertyTabView(top, this,
  52.                            tabNameId[i]);
  53.       addView(tab);
  54.       tab->show();
  55.     }/* for i */
  56. #if defined(DEBUG_tao_)
  57.   else {
  58.    printf("\n  Warning: [XFE_PropertySheetView::XFE_PropertySheetView]tabNameId is NULL!!");
  59.   }/* else */
  60. #endif
  61.  
  62.   /* set pos 0 as the default active tab
  63.    */
  64.   tabActivate(0);
  65. }
  66.  
  67.  
  68. XFE_PropertySheetView::~XFE_PropertySheetView()
  69. {
  70. }
  71.  
  72. void
  73. XFE_PropertySheetView::tabActivate(int pos)
  74. {
  75.   getDlgValues();
  76.   /* set active view
  77.    */
  78.   if (m_subviews && m_subviews[pos]) {
  79.     /* if need to handle ex-active tab
  80.      */
  81.  
  82.     /* reset activeTab
  83.      */
  84.     m_activeTab = (XFE_PropertyTabView *)m_subviews[pos];
  85.     m_activeTab->setDlgValues();
  86.   }/* if */
  87. }
  88.  
  89. void
  90. XFE_PropertySheetView::tabActivateCB(Widget /*w*/,
  91.                  XtPointer clientData,
  92.                  XtPointer callData)
  93. {
  94.   XFE_PropertySheetView *obj = (XFE_PropertySheetView *)clientData;
  95.   XmLFolderCallbackStruct *cbs = (XmLFolderCallbackStruct*)callData;
  96.  
  97.   obj->tabActivate(cbs->pos);
  98. }
  99.  
  100. XFE_PropertyTabView* XFE_PropertySheetView::addTab(int tabNameId)
  101. {
  102.   XFE_PropertyTabView *tab = new XFE_PropertyTabView(getToplevel(), this, 
  103.                        tabNameId);
  104.   addView(tab);
  105.   tab->show();
  106.   return tab;
  107. }/* XFE_PropertySheetView::addTab */
  108.  
  109. void XFE_PropertySheetView::addTab(XFE_PropertyTabView* tab)
  110. {
  111.   addView(tab);
  112.   tab->show();
  113. }/* XFE_PropertySheetView::addTab */
  114.  
  115. void XFE_PropertySheetView::setDlgValues()
  116. {
  117.   if (m_subviews && m_numsubviews) {
  118.     for (int i=0; i < m_numsubviews; i++) {
  119.       ((XFE_PropertyTabView *) m_subviews[i])->setDlgValues();
  120.     }/* for i */
  121.   }/* if */
  122. }/* XFE_PropertySheetView::setDlgValues() */
  123.  
  124. void XFE_PropertySheetView::getDlgValues()
  125. {
  126.   if (m_subviews && m_numsubviews) {
  127.     for (int i=0; i < m_numsubviews; i++) {
  128.       ((XFE_PropertyTabView *) m_subviews[i])->getDlgValues();
  129.     }/* for i */
  130.   }/* if */
  131. }/* XFE_PropertySheetView::getDlgValues() */
  132.  
  133. void XFE_PropertySheetView::apply()
  134. {
  135.   if (m_subviews && m_numsubviews) {
  136.     for (int i=0; i < m_numsubviews; i++) {
  137.       ((XFE_PropertyTabView *) m_subviews[i])->apply();
  138.     }/* for i */
  139.   }/* if */
  140. }/* XFE_PropertySheetView::apply() */
  141.