1) RDF pane modes stored as enums and used in Pane creation

2) HT properties hooked for ControlBar, HTMl Pane
This commit is contained in:
radha%netscape.com 1998-10-08 21:22:26 +00:00
Родитель 4598448348
Коммит 3d745b3825
3 изменённых файлов: 298 добавлений и 114 удалений

Просмотреть файл

@ -32,6 +32,14 @@
#include "xp_core.h"
#include "Command.h"
typedef enum ERDFPaneMode {
RDF_PANE_POPUP,
RDF_PANE_DOCKED,
RDF_PANE_STANDALONE,
RDF_PANE_EMBEDDED
} ERDFPaneMode;
class XFE_RDFBase
{

Просмотреть файл

@ -26,6 +26,8 @@
#include "Command.h"
#include "xfe2_extern.h"
#include "xpgetstr.h"
#include "felocale.h"
#include "intl_csi.h"
#include <XmL/Tree.h>
#include <Xfe/Button.h>
@ -71,24 +73,32 @@ MWContext * fe_CreateNewContext(MWContextType, Widget, fe_colormap * , XP_Bool);
XFE_RDFChromeTreeView::XFE_RDFChromeTreeView(XFE_Component * toplevel,
Widget parent,
XFE_View * parent_view,
ERDFPaneMode mode,
MWContext * context) :
XFE_RDFTreeView(toplevel, parent, parent_view, context),
XFE_RDFTreeView(toplevel, parent, parent_view, context),
_viewLabel(NULL),
_controlToolBar(NULL),
_addBookmarkControl(NULL),
_closeControl(NULL),
_modeControl(NULL),
_manageControl(NULL),
_htmlPaneForm(NULL),
_divider(NULL),
_htmlPane(NULL)
_htmlPane(NULL),
_paneMode(mode)
{
createViewLabel();
createDivider();
if (getPaneMode() == RDF_PANE_DOCKED)
createViewLabel();
createDivider();
createTree();
createControlToolbar();
if (getPaneMode() != RDF_PANE_STANDALONE)
createControlToolbar();
doAttachments();
}
@ -101,8 +111,11 @@ void
XFE_RDFChromeTreeView::createControlToolbar()
{
XP_ASSERT( _controlToolBar == NULL );
XP_ASSERT( XfeIsAlive(getBaseWidget()) );
void * data= NULL;
// Control Tool Bar
_controlToolBar =
XtVaCreateManagedWidget("controlToolBar",
@ -113,30 +126,29 @@ XFE_RDFChromeTreeView::createControlToolbar()
XmNusePreferredHeight, True,
NULL);
// Add Bookmark
_addBookmarkControl = XtVaCreateManagedWidget("addBookmark",
if (getPaneMode() == RDF_PANE_POPUP) {
// Add Bookmark
_addBookmarkControl = XtVaCreateManagedWidget("addBookmark",
xfeButtonWidgetClass,
_controlToolBar,
NULL);
}
// Close
_closeControl = XtVaCreateManagedWidget("close",
xfeButtonWidgetClass,
_controlToolBar,
NULL);
#if 0
if (getPaneMode() == RDF_PANE_POPUP) {
// Mode
_modeControl = XtVaCreateManagedWidget("mode",
_manageControl = XtVaCreateManagedWidget("Manage",
xfeButtonWidgetClass,
_controlToolBar,
NULL);
#endif
}
/*
closeRdfViewCBStruct * cb_str = new closeRdfViewCBStruct;
cb_str->rdfview = this;
cb_str->ncview = (XFE_NavCenterView *)parent_view;
*/
XtAddCallback(_closeControl, XmNactivateCallback, (XtCallbackProc)closeRdfView_cb , (void *)this);
@ -163,7 +175,7 @@ XFE_RDFChromeTreeView::createDivider()
{
XP_ASSERT( XfeIsAlive(getBaseWidget()) );
XP_ASSERT( _divider == NULL );
XP_ASSERT( XfeIsAlive(_viewLabel) );
// Divider
_divider =
@ -172,8 +184,6 @@ XFE_RDFChromeTreeView::createDivider()
getBaseWidget(),
// Form constraints
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
@ -183,12 +193,124 @@ XFE_RDFChromeTreeView::createDivider()
XmNdividerType, XmDIVIDER_PERCENTAGE,
XmNdividerTarget, 1,
NULL);
if (_viewLabel) {
XtVaSetValues(_divider, XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel, NULL);
} else {
XtVaSetValues(_divider, XmNtopAttachment, XmATTACH_FORM, NULL);
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::createHtmlPane()
XFE_RDFChromeTreeView::createHtmlPaneFromResources()
{
void * data=NULL;
PRUint32 htmlPaneHeight=0;
Boolean isPercentage = False;
char * htmlPaneURL = NULL;
HT_GetTemplateData(HT_TopNode(_ht_view), gNavCenter->RDF_HTMLHeight, HT_COLUMN_STRING, &data);
if (data)
{
char * answer = (char *) data;
char * t=NULL;
if (XP_STRSTR(answer, "%")) {
// Using % method to determine the height
t = '\0';
isPercentage = True;
htmlPaneHeight = atoi(answer);
D(printf("htmlPane Percent height = %d\n", htmlPaneHeight););
}
else
htmlPaneHeight = atoi(answer);
}
// Just for testing purposes now,
isPercentage = True;
htmlPaneHeight = 50;
if (!htmlPaneHeight) // Height is 0. No HTML Pane.
return;
HT_GetTemplateData(HT_TopNode(_ht_view), gNavCenter->RDF_HTMLURL, HT_COLUMN_STRING, &data);
if (data)
{
htmlPaneURL = (char *) data;
D(printf("HTMlURL = %s\n", (char *) data););
}
else // Just for testing purposes now.
htmlPaneURL = "http://www.mozilla.org";
if (!htmlPaneURL) // No URL. No Pane.
return;
if (isPercentage) {
createHtmlPanePercent(htmlPaneHeight, htmlPaneURL);
}
else {
createHtmlPaneFixed(htmlPaneHeight, htmlPaneURL);
}
}
//////////////////////////////////////////////////////////////////////////
//
// Set the HTML pane height (as a percentage of the view)
//
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::createHtmlPanePercent(PRUint32 heightPercent, char * htmlUrl)
{
int percentage = (int) heightPercent;
// Make sure its not more than 100%
if (percentage > 100)
{
percentage = 100;
}
// Create the html pane if needed (for the first time)
if ((heightPercent > 0) && (_htmlPane == NULL))
{
createHtmlPane(htmlUrl);
}
XP_ASSERT( _htmlPaneForm != NULL );
// XP_ASSERT( _htmlPane != NULL );
XtVaSetValues(_divider,
XmNdividerType, XmDIVIDER_PERCENTAGE,
XmNdividerPercentage, percentage,
NULL);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::createHtmlPaneFixed(PRUint32 heightFixed, char * htmlUrl)
{
Dimension height = (Dimension) heightFixed;
// Create the html pane if needed (for the first time)
if ((heightFixed > 0) && (_htmlPane == NULL))
{
createHtmlPane(htmlUrl);
}
XP_ASSERT( _htmlPaneForm != NULL );
// XP_ASSERT( _htmlPane != NULL );
XtVaSetValues(_divider,
XmNdividerType, XmDIVIDER_FIXED_SIZE,
XmNdividerFixedSize, height,
NULL);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::createHtmlPane(char * url)
{
XP_ASSERT( XfeIsAlive(_divider) );
XP_ASSERT( _htmlPaneForm == NULL );
XP_ASSERT( _htmlPane == NULL );
@ -210,7 +332,7 @@ XFE_RDFChromeTreeView::createHtmlPane()
ViewGlue_addMapping(frame, context);
/* For some reason these 2 functions are not called in the context
* creation call above
* creation call. So call them explicitly.
*/
fe_init_image_callbacks(context);
fe_InitColormap(context);
@ -232,9 +354,29 @@ XFE_RDFChromeTreeView::createHtmlPane()
_htmlPane->show();
XtRealizeWidget(getBaseWidget());
// Create the compositor
context->compositor = fe_create_compositor(context);
XtVaSetValues (CONTEXT_DATA (context)->scrolled, XmNinitialFocus,
CONTEXT_DATA (context)->drawing_area, 0);
// Do the required scroller voodoo
fe_set_scrolled_default_size(context);
fe_get_final_context_resources(context);
fe_find_scrollbar_sizes(context);
fe_InitScrolling(context);
// Load the URL
if (url)
NET_GetURL(NET_CreateURLStruct(url, NET_DONT_RELOAD),
FO_CACHE_AND_PRESENT, context,
fe_url_exit);
/*
XtAddEventHandler((_htmlPane->getBaseWidget()), StructureNotifyMask, True,
(XtEventHandler) htmlPaneExposeEH, (XtPointer) _htmlPane);
*/
}
@ -243,6 +385,7 @@ XFE_RDFChromeTreeView::createHtmlPane()
/* virtual */ void
XFE_RDFChromeTreeView::doAttachments()
{
if (_controlToolBar) {
// Control toolbar on top
XtVaSetValues(_controlToolBar,
XmNtopAttachment, XmATTACH_FORM,
@ -250,7 +393,9 @@ XFE_RDFChromeTreeView::doAttachments()
XmNleftAttachment, XmATTACH_NONE,
XmNbottomAttachment, XmATTACH_NONE,
NULL);
}
if (_viewLabel) {
// View label
XtVaSetValues(_viewLabel,
XmNtopAttachment, XmATTACH_WIDGET,
@ -259,31 +404,35 @@ XFE_RDFChromeTreeView::doAttachments()
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_NONE,
NULL);
}
}
//////////////////////////////////////////////////////////////////////////
ERDFPaneMode
XFE_RDFChromeTreeView::getPaneMode()
{
return _paneMode;
// Divider
XtVaSetValues(_divider,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, _viewLabel,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::updateRoot()
{
char * label = HT_GetViewName(_ht_view);
if (_viewLabel) {
// XXX Aurora NEED TO LOCALIZE XXX
XmString xmstr = XmStringCreateLocalized(label);
XtVaSetValues(_viewLabel,XmNlabelString,xmstr,NULL);
XmStringFree(xmstr);
// Set the HT properties
setHTTitlebarProperties(_ht_view, _viewLabel);
setHTTitlebarProperties(_ht_view);
setHTControlbarProperties(_ht_view);
createHtmlPaneFromResources();
}
XFE_RDFTreeView::updateRoot();
}
@ -313,44 +462,20 @@ XFE_RDFChromeTreeView::notify(HT_Resource n,
void
XFE_RDFChromeTreeView::closeRdfView_cb(Widget /* w */, XtPointer clientData, XtPointer /* callData */)
{
XFE_RDFChromeTreeView * obj = (XFE_RDFChromeTreeView *) clientData;
Widget parent = XtParent(obj->getBaseWidget());
XtUnmanageChild(parent);
#ifdef MOZ_SELECTOR_BAR
#if 0
closeRdfViewCBStruct * obj = (closeRdfViewCBStruct *) clientData;
XFE_NavCenterView * ncview = obj->ncview;
// Widget nc_base_widget = ncview->getBaseWidget();
Widget selector = (Widget )ncview->getSelector();
/* XtVaSetValues(nc_base_widget, XmNresizable, True, NULL); */
XtUnmanageChild(parent);
XtUnmanageChild(selector);
XtVaSetValues(selector, XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
XtManageChild(selector);
#endif
#endif /*MOZ_SELECTOR_BAR*/
}
//////////////////////////////////////////////////////////////////////////
//
// XFE_RDFChromeTreeView public methods.
//
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::setHTTitlebarProperties(HT_View view, Widget titleBar)
XFE_RDFChromeTreeView::setHTTitlebarProperties(HT_View view)
{
Arg av[30];
@ -388,58 +513,98 @@ XFE_RDFChromeTreeView::setHTTitlebarProperties(HT_View view, Widget titleBar)
}
XtSetValues(titleBar, av, ac);
}
//////////////////////////////////////////////////////////////////////////
//
// Set the HTML pane height (as a percentage of the view)
//
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::setHtmlPaneHeightPercent(PRUint32 heightPercent)
{
int percentage = (int) heightPercent;
// Make sure its not more than 100%
if (percentage > 100)
{
percentage = 100;
}
// Create the html pane if needed (for the first time)
if ((heightPercent > 0) && (_htmlPane == NULL))
{
createHtmlPane();
}
XP_ASSERT( _htmlPaneForm != NULL );
// XP_ASSERT( _htmlPane != NULL );
XtVaSetValues(_divider,
XmNdividerType, XmDIVIDER_PERCENTAGE,
XmNdividerPercentage, percentage,
NULL);
XtSetValues(_viewLabel, av, ac);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFChromeTreeView::setHtmlPaneHeightFixed(PRUint32 heightFixed)
XFE_RDFChromeTreeView::setHTControlbarProperties(HT_View view)
{
Dimension height = (Dimension) heightFixed;
// Create the html pane if needed (for the first time)
if ((heightFixed > 0) && (_htmlPane == NULL))
{
createHtmlPane();
}
XP_ASSERT( _htmlPaneForm != NULL );
// XP_ASSERT( _htmlPane != NULL );
Arg av[30];
Cardinal ac=0;
void * data=NULL;
Pixel pixel;
PRBool gotit=False;
//////////////// CONTROLBAR PROPERTIES ///////////////////
ac = 0;
/* titleBarFGColor */
HT_GetTemplateData(HT_TopNode(view), gNavCenter->controlStripFGColor, HT_COLUMN_STRING, &data);
if (data)
{
gotit = fe_GetPixelFromRGBString(getContext(), (char *) data, &pixel);
if (gotit)
XtSetArg(av[ac], XmNforeground, pixel); ac++;
}
/* titleBarBGColor */
HT_GetTemplateData(HT_TopNode(view), gNavCenter->controlStripBGColor, HT_COLUMN_STRING, &data);
if (data)
{
gotit = fe_GetPixelFromRGBString(getContext(), (char *) data, &pixel);
if (gotit)
XtSetArg(av[ac], XmNbackground, pixel); ac++;
}
/* titleBarBGURL */
HT_GetTemplateData(HT_TopNode(view), gNavCenter->controlStripBGURL, HT_COLUMN_STRING, &data);
if (data)
{
/* Do the RDFImage thing */
}
XtSetValues(_controlToolBar, av, ac);
MWContext * context = getContext();
INTL_CharSetInfo charSetInfo =
LO_GetDocumentCharacterSetInfo(context);
XmString str= NULL;
XmFontList font_list;
#ifdef NOT_YET
/* controlStripAddText */
HT_GetTemplateData(HT_TopNode(view), gNavCenter->controlStripAddText, HT_COLUMN_STRING, &data);
if (data)
{
str = fe_ConvertToXmString((unsigned char *) data,
INTL_GetCSIWinCSID(charSetInfo) ,
NULL, XmFONT_IS_FONT, &font_list);
XtVaSetValues(_addBookmarkControl, XmNlabelString, str, NULL);
}
/* controlStripEditText */
HT_GetTemplateData(HT_TopNode(view), gNavCenter->controlStripEditText, HT_COLUMN_STRING, &data);
if (data)
{
str = fe_ConvertToXmString((unsigned char *) data,
INTL_GetCSIWinCSID(charSetInfo) ,
NULL, XmFONT_IS_FONT, &font_list);
XtVaSetValues(_manageControl, XmNlabelString, str, NULL);
}
#endif
/* controlStripCloseText */
HT_GetTemplateData(HT_TopNode(view), gNavCenter->controlStripCloseText, HT_COLUMN_STRING, &data);
if (data)
{
str = fe_ConvertToXmString((unsigned char *) data,
INTL_GetCSIWinCSID(charSetInfo) ,
NULL, XmFONT_IS_FONT, &font_list);
XtVaSetValues(_closeControl, XmNlabelString, str, NULL);
}
XtVaSetValues(_divider,
XmNdividerType, XmDIVIDER_FIXED_SIZE,
XmNdividerFixedSize, height,
NULL);
}
//////////////////////////////////////////////////////////////////////////
extern "C"
void

Просмотреть файл

@ -37,7 +37,7 @@ class XFE_RDFChromeTreeView : public XFE_RDFTreeView
public:
XFE_RDFChromeTreeView(XFE_Component *toplevel, Widget parent,
XFE_View *parent_view, MWContext *context);
XFE_View *parent_view, ERDFPaneMode mode, MWContext *context);
~XFE_RDFChromeTreeView();
@ -57,14 +57,18 @@ public:
void notify(HT_Resource n, HT_Event whatHappened);
// RDF Specific calls
void setHTTitlebarProperties(HT_View view, Widget titleBar);
void setHTTitlebarProperties(HT_View view);
void setHTControlbarProperties(HT_View view);
// Set the HTML pane height (as a percentage of the view)
void setHtmlPaneHeightPercent(PRUint32 heightPercent);
void createHtmlPanePercent(PRUint32 heightPercent, char * htmlUrl);
// Set the HTML pane height (as a fixed pixel height)
void setHtmlPaneHeightFixed(PRUint32 heightPercent);
void createHtmlPaneFixed(PRUint32 heightPercent, char * htmlUrl);
// return the pane mode
ERDFPaneMode getPaneMode();
protected:
// Override RDFBase methods
@ -87,7 +91,7 @@ private:
Widget _closeControl;
// Toggle tree operating mode
Widget _modeControl;
Widget _manageControl;
// The HTML pane form
Widget _htmlPaneForm;
@ -98,13 +102,20 @@ private:
// The HTML pane
XFE_HTMLView * _htmlPane;
// The RDF pane mode
ERDFPaneMode _paneMode;
static void closeRdfView_cb(Widget, XtPointer, XtPointer);
// Create widgets
void createControlToolbar();
void createViewLabel();
void createDivider();
void createHtmlPane();
void createHtmlPane(char * htmlUrl);
void createHtmlPaneFromResources();
};
#endif /* _xfe_rdfchrometreeview_h */