Add a virtual method for specifying the parent to the tree. Have the

RDFTreeView subclasses create the tree.  All this stuff is needed to create
a hierarchy in which the html pain can be created dynamically and sized to
an either arbitrary percentage or fixed height.
This commit is contained in:
ramiro%netscape.com 1998-09-10 14:35:05 +00:00
parent a484b2b32c
commit 0790b7a045
6 changed files with 160 additions and 75 deletions

View File

@ -44,6 +44,10 @@ XFE_BuiltinTreeView::XFE_BuiltinTreeView(XFE_Component *toplevel_component,
{
printf("XFE_BuiltinTreeView::XFE_BuiltinTreeView()\n");
createTree();
doAttachments();
// Hunt the builtin_struct.
classId = LO_GetBuiltInAttribute(builtin_struct, "classid");
url = LO_GetBuiltInAttribute(builtin_struct, "data");

View File

@ -421,9 +421,10 @@ XFE_NavCenterView::createTree()
{
_rdftree = new XFE_RDFChromeTreeView(this, getBaseWidget(),
this, m_contextData);
_rdftree->setStandAloneState(_isStandalone);
// _rdftree->setHtmlPaneHeight(50);
// _rdftree->setHtmlPaneHeight(50);
}
//////////////////////////////////////////////////////////////////////////
void

View File

@ -62,16 +62,21 @@ XFE_RDFChromeTreeView::XFE_RDFChromeTreeView(XFE_Component * toplevel,
_closeControl(NULL),
_modeControl(NULL),
_htmlPaneForm(NULL),
_divisionForm(NULL),
_htmlPane(NULL),
_htmlPaneHeight(0)
_htmlPaneHeightPercent(0),
_htmlPaneHeightFixed(0),
_htmlPaneSizing(XFE_HTML_PANE_PERCENT)
{
createDivisionForm();
createTree();
createControlToolbar();
createViewLabel();
doAttachments();
XtManageChild(_tree);
}
//////////////////////////////////////////////////////////////////////////
XFE_RDFChromeTreeView::~XFE_RDFChromeTreeView()
@ -81,6 +86,9 @@ XFE_RDFChromeTreeView::~XFE_RDFChromeTreeView()
void
XFE_RDFChromeTreeView::createControlToolbar()
{
XP_ASSERT( _controlToolBar == NULL );
XP_ASSERT( XfeIsAlive(getBaseWidget()) );
// Control Tool Bar
_controlToolBar =
XtVaCreateManagedWidget("controlToolBar",
@ -127,6 +135,9 @@ XFE_RDFChromeTreeView::createControlToolbar()
void
XFE_RDFChromeTreeView::createViewLabel()
{
XP_ASSERT( XfeIsAlive(getBaseWidget()) );
XP_ASSERT( _viewLabel == NULL );
// View label
_viewLabel =
XtVaCreateManagedWidget("viewLabel",
@ -138,12 +149,37 @@ XFE_RDFChromeTreeView::createViewLabel()
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::createDivisionForm()
{
XP_ASSERT( XfeIsAlive(getBaseWidget()) );
XP_ASSERT( _divisionForm == NULL );
XP_ASSERT( XfeIsAlive(_viewLabel) );
// Division form
_divisionForm =
XtVaCreateManagedWidget("divisionForm",
xmFormWidgetClass,
getBaseWidget(),
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::createHtmlPane()
{
XP_ASSERT( XfeIsAlive(_divisionForm) );
XP_ASSERT( _htmlPaneForm == NULL );
XP_ASSERT( _htmlPane == NULL );
_htmlPaneForm = XtVaCreateWidget("htmlPaneForm",
xmFormWidgetClass,
getBaseWidget(),
_divisionForm,
XmNshadowThickness, 0,
XmNbackground, 0,
NULL);
#if 0
_htmlPane = new XFE_HTMLView(this,
@ -167,9 +203,10 @@ XFE_RDFChromeTreeView::createHtmlPane()
#endif
}
//////////////////////////////////////////////////////////////////////////
void
/* virtual */ void
XFE_RDFChromeTreeView::doAttachments()
{
// Control toolbar on top
XtVaSetValues(_controlToolBar,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
@ -177,6 +214,7 @@ XFE_RDFChromeTreeView::doAttachments()
XmNbottomAttachment, XmATTACH_NONE,
NULL);
// View label
XtVaSetValues(_viewLabel,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _controlToolBar,
@ -185,65 +223,70 @@ XFE_RDFChromeTreeView::doAttachments()
XmNbottomAttachment, XmATTACH_NONE,
NULL);
// 0%
if (_htmlPaneHeight == 0)
// Division form
XtVaSetValues(_divisionForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
// Html pane at 0%
if (_htmlPaneHeightPercent == 0)
{
XtVaSetValues(_tree,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
if (XfeIsAlive(_htmlPaneForm))
{
XtUnmanageChild(_htmlPaneForm);
}
}
// 100%
else if (_htmlPaneHeight == 100)
// Html pane at 100%
else if (_htmlPaneHeightPercent == 100)
{
XtVaSetValues(_htmlPaneForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
if (XfeIsAlive(_tree))
{
XtUnmanageChild(_tree);
}
}
// 0% < height < 100%
// Html pane between 0% and 100%
else
{
int max_html_pane_height =
XfeHeight(getBaseWidget()) -
XfeHeight(_controlToolBar) -
XfeHeight(_viewLabel);
XP_ASSERT( max_html_pane_height > 0 );
int html_pane_height = max_html_pane_height * _htmlPaneHeight / 100;
XP_ASSERT( _htmlPane != NULL );
XtVaSetValues(_htmlPaneForm,
// XmNheight, 50,
XmNheight, html_pane_height,
NULL);
XP_ASSERT( XfeIsAlive(_htmlPaneForm) );
XP_ASSERT( XfeIsAlive(_tree) );
XtVaSetValues(_htmlPaneForm,
XmNtopAttachment, XmATTACH_NONE,
XmNtopAttachment, XmATTACH_POSITION,
// XmNtopPositition, _htmlPaneHeightPercent,
XmNtopPosition, (100 - _htmlPaneHeightPercent),
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
XtVaSetValues(_tree,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_WIDGET,
XmNbottomWidget, _htmlPaneForm,
NULL);
// _htmlPane->show();
XtManageChild(_htmlPaneForm);
XtManageChild(_tree);
}
}
//////////////////////////////////////////////////////////////////////////
@ -265,9 +308,17 @@ XFE_RDFChromeTreeView::updateRoot()
XFE_RDFTreeView::updateRoot();
}
//////////////////////////////////////////////////////////////////////////
Widget
XFE_RDFChromeTreeView::getTreeParent()
{
XP_ASSERT( XfeIsAlive(_divisionForm) );
return _divisionForm;
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::notify(HT_Resource n,
HT_Event whatHappened)
XFE_RDFChromeTreeView::notify(HT_Resource n,
HT_Event whatHappened)
{
D(debugEvent(n, whatHappened,"RV"););
@ -366,36 +417,36 @@ XFE_RDFChromeTreeView::setHTTitlebarProperties(HT_View view, Widget titleBar)
//
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::setHtmlPaneHeight(PRUint32 height)
XFE_RDFChromeTreeView::setHtmlPaneHeight(PRUint32 heightPercent)
{
// Make sure it actually changed
if (_htmlPaneHeight == height)
if (_htmlPaneHeightPercent == heightPercent)
{
return;
}
// Make sure its not more than 100%
if (_htmlPaneHeight > 100)
if (_htmlPaneHeightPercent > 100)
{
_htmlPaneHeight = 100;
_htmlPaneHeightPercent = 100;
}
// Create the html pane if needed (for the first time)
if ((height > 0) && (_htmlPane == NULL))
if ((heightPercent > 0) && (_htmlPane == NULL))
{
createHtmlPane();
}
_htmlPaneHeight = height;
_htmlPaneHeightPercent = heightPercent;
XP_ASSERT( _htmlPaneForm != NULL );
XP_ASSERT( _htmlPane != NULL );
// XP_ASSERT( _htmlPane != NULL );
// Show the html pane form if needed
XfeSetManagedState(_htmlPaneForm,_htmlPaneHeight != 0);
XfeSetManagedState(_htmlPaneForm,_htmlPaneHeightPercent != 0);
// Show the tree if needed
XfeSetManagedState(_tree,_htmlPaneHeight != 100);
XfeSetManagedState(_tree,_htmlPaneHeightPercent != 100);
// Redo attachments
doAttachments();

View File

@ -32,6 +32,12 @@
#include "RDFTreeView.h"
#include "HTMLView.h"
typedef enum _EHtmlPaneSizing
{
XFE_HTML_PANE_FIXED,
XFE_HTML_PANE_PERCENT
} EHtmlPaneSizing;
class XFE_RDFChromeTreeView : public XFE_RDFTreeView
{
public:
@ -65,7 +71,9 @@ public:
protected:
// Override RDFBase methods
virtual void updateRoot ();
virtual void updateRoot ();
virtual Widget getTreeParent ();
virtual void doAttachments ();
private:
@ -87,19 +95,28 @@ private:
// The HTML pane form
Widget _htmlPaneForm;
// The tree/html division form
Widget _divisionForm;
// The HTML pane
XFE_HTMLView * _htmlPane;
// The height of the HTML pane as a percentage of the view
PRUint32 _htmlPaneHeight;
PRUint32 _htmlPaneHeightPercent;
// The height of the HTML pane as a fixed pixel count
PRUint32 _htmlPaneHeightFixed;
// Type of html pain sizing
EHtmlPaneSizing _htmlPaneSizing;
static void closeRdfView_cb(Widget, XtPointer, XtPointer);
// Create widgets
void createControlToolbar();
void createViewLabel();
void createDivisionForm();
void createHtmlPane();
void doAttachments();
};

View File

@ -182,23 +182,10 @@ XFE_RDFTreeView::XFE_RDFTreeView(XFE_Component * toplevel,
setBaseWidget(rdfMainForm);
createTree();
doAttachments();
// createTree();
init_pixmaps();
// doAttachments();
XtAddCallback(_tree, XmNexpandCallback, expand_row_cb, this);
XtAddCallback(_tree, XmNcollapseCallback, collapse_row_cb, this);
XtAddCallback(_tree, XmNdeleteCallback, delete_cb, NULL);
XtAddCallback(_tree, XmNactivateCallback, activate_cb, this);
XtAddCallback(_tree, XmNresizeCallback, resize_cb, this);
XtAddCallback(_tree, XmNeditCallback, edit_cell_cb, this);
XtAddCallback(_tree, XmNselectCallback, select_cb, this);
XtAddCallback(_tree, XmNdeselectCallback, deselect_cb, this);
XtAddCallback(_tree, XmNpopupCallback, popup_cb, this);
XtManageChild(_tree);
//fe_AddTipStringCallback(outline, XFE_Outliner::tip_cb, this);
}
//////////////////////////////////////////////////////////////////////////
@ -212,14 +199,14 @@ XFE_RDFTreeView::~XFE_RDFTreeView()
XFE_RDFImage::removeListener(this);
}
//////////////////////////////////////////////////////////////////////////
void
/* virtual */ void
XFE_RDFTreeView::createTree()
{
// Create the tree widget
_tree =
XtVaCreateWidget(TREE_NAME,
xmlTreeWidgetClass,
getBaseWidget(),
getTreeParent(),
XmNshadowThickness, 0,
XmNhorizontalSizePolicy, XmRESIZE_IF_POSSIBLE,
XmNallowColumnResize, True,
@ -235,24 +222,47 @@ XFE_RDFTreeView::createTree()
XmNcellDefaults, True,
XmNcellAlignment, XmALIGNMENT_LEFT,
NULL);
init_pixmaps();
XtAddCallback(_tree, XmNexpandCallback, expand_row_cb, this);
XtAddCallback(_tree, XmNcollapseCallback, collapse_row_cb, this);
XtAddCallback(_tree, XmNdeleteCallback, delete_cb, NULL);
XtAddCallback(_tree, XmNactivateCallback, activate_cb, this);
XtAddCallback(_tree, XmNresizeCallback, resize_cb, this);
XtAddCallback(_tree, XmNeditCallback, edit_cell_cb, this);
XtAddCallback(_tree, XmNselectCallback, select_cb, this);
XtAddCallback(_tree, XmNdeselectCallback, deselect_cb, this);
XtAddCallback(_tree, XmNpopupCallback, popup_cb, this);
XtManageChild(_tree);
}
//////////////////////////////////////////////////////////////////////////
void
/* virtual */ Widget
XFE_RDFTreeView::getTreeParent()
{
return getBaseWidget();
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFTreeView::doAttachments()
{
XtVaSetValues(_tree,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
if (XfeIsAlive(_tree))
{
XtVaSetValues(_tree,
XmNtopAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFTreeView::init_pixmaps(void)
{
XP_ASSERT( XfeIsAlive(_tree) );
Pixel bg_pixel;
XtVaGetValues(_tree, XmNbackground, &bg_pixel, 0);

View File

@ -91,6 +91,10 @@ protected:
// The XmL tree widget
Widget _tree;
virtual Widget getTreeParent ();
virtual void doAttachments ();
virtual void createTree ();
private:
// The popup menu
@ -107,8 +111,6 @@ private:
static fe_icon openedFolder;
static fe_icon closedFolder;
void createTree();
void doAttachments();
void init_pixmaps();