First Checked In.

This commit is contained in:
scc%netscape.com 1998-09-01 18:39:08 +00:00
parent 1781327873
commit 96acd82d4b
5 changed files with 479 additions and 0 deletions

View File

@ -0,0 +1,114 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "CRDFToolbar.h"
#include <cassert>
#include "htrdf.h"
static
SPaneInfo
pane_params_from( HT_View /*ht_view*/, LView* pp_superview )
{
SPaneInfo info;
info.paneID = 0;
SDimension16 superview_size;
pp_superview->GetFrameSize(superview_size);
info.width = superview_size.width;
info.height = 24; // NO! Get this value from the |HT_View|.
info.visible = true;
info.enabled = true;
SBooleanRect bindings = { true, true, true, false };
info.bindings = bindings;
info.left = 0;
info.top = 0;
info.userCon = 0;
info.superView = pp_superview;
return info;
}
static
SViewInfo
view_params_from( HT_View /*ht_view*/ )
{
SViewInfo info;
SDimension32 image_size = { 0, 0 };
info.imageSize = image_size;
SPoint32 scroll_pos = { 0, 0 };
info.scrollPos = scroll_pos;
SPoint32 scroll_unit = { 1, 1 };
info.scrollUnit = scroll_unit;
info.reconcileOverhang = 0;
return info;
}
static
bool
is_docked( HT_View /*ht_view*/ )
{
return false;
}
CRDFToolbar::CRDFToolbar( HT_View ht_view, LView* pp_superview )
: CDragBar( pane_params_from(ht_view, pp_superview), view_params_from(ht_view), is_docked(ht_view) ),
_ht_view(ht_view)
{
assert( _ht_view ); // There must be an |HT_View|...
assert( !HT_GetViewFEData(_ht_view) ); // ...and it must not be linked to any other FE object.
HT_SetViewFEData(_ht_view, this);
// TO BE FIXED: 1103 needs a better name and visibility
// TO BE FIXED: is there a better way to insert the grippy pane?
LWindow* window = LWindow::FetchWindowObject(pp_superview->GetMacPort());
UReanimator::CreateView(1103, this, window); // create the CPatternedGrippyPane
#if 0
LView* view = UReanimator::CreateView(1104, this, window); // create the CToolbarPatternBevelView
view->ResizeFrameBy(-12, 0, false);
#endif
}
CRDFToolbar::~CRDFToolbar()
{
assert( _ht_view ); // There must be an |HT_View|...
HT_SetViewFEData(_ht_view, 0);
}
void
CRDFToolbar::HandleNotification( HT_Notification, HT_Resource, HT_Event, void*, uint32 )
{
// ...
}

View File

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#pragma once
#include "CDragBar.h" // ...is a base class
#include "CRDFNotificationHandler.h" // ...is a base class
class CRDFToolbar
: public CDragBar,
public CRDFNotificationHandler
/*
...
A |CRDFToolbar| has a one-to-one relationship with a particular |HT_View|. No more
than one FE object should ever be instantiated for this |HT_View|.
*/
{
public:
CRDFToolbar( HT_View, LView* );
virtual ~CRDFToolbar();
private: // Pass-by-value is not allowed. A single |CRDFToolbar| corresponds to a single on-screen object; copying doesn't make sense.
CRDFToolbar( const CRDFToolbar& ); // DON'T IMPLEMENT
CRDFToolbar& operator=( const CRDFToolbar& ); // DON'T IMPLEMENT
public: // ...overriding the appropriate methods of |CRDFNotificationHandler|
virtual void HandleNotification( HT_Notification, HT_Resource, HT_Event, void*, uint32 );
private:
HT_View _ht_view;
};

View File

@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "CRDFToolbarContainer.h"
#include "CRDFToolbar.h"
CRDFToolbarContainer::CRDFToolbarContainer( LStream* inStream )
: CDragBarContainer(inStream),
_ht_root( HT_NewToolbarPane(CreateNotificationStruct()) )
{
HT_SetPaneFEData(_ht_root.get(), this);
}
void
CRDFToolbarContainer::HandleNotification( HT_Notification notification, HT_Resource node, HT_Event event, void* token, uint32 tokenType )
{
HT_View ht_view = HT_GetView(node);
switch ( event )
{
case HT_EVENT_VIEW_ADDED: // i.e., create a toolbar
{
CRDFToolbar* toolbar = new CRDFToolbar(ht_view, this);
AddBar(toolbar);
}
break;
case HT_EVENT_VIEW_DELETED: // i.e., destroy a toolbar
if( CRDFToolbar* toolbar = reinterpret_cast<CRDFToolbar*>(HT_GetViewFEData(ht_view)) )
delete toolbar;
break;
#if 0
case HT_EVENT_NODE_ADDED:
case HT_EVENT_NODE_DELETED_DATA:
case HT_EVENT_NODE_DELETED_NODATA:
case HT_EVENT_NODE_VPROP_CHANGED:
case HT_EVENT_NODE_SELECTION_CHANGED:
case HT_EVENT_NODE_OPENCLOSE_CHANGED:
case HT_EVENT_VIEW_SELECTED:
case HT_EVENT_NODE_OPENCLOSE_CHANGING:
case HT_EVENT_VIEW_SORTING_CHANGED:
case HT_EVENT_VIEW_REFRESH:
case HT_EVENT_VIEW_WORKSPACE_REFRESH:
case HT_EVENT_NODE_EDIT:
case HT_EVENT_WORKSPACE_EDIT:
case HT_EVENT_VIEW_HTML_ADD:
case HT_EVENT_VIEW_HTML_REMOVE:
case HT_EVENT_NODE_ENABLE:
case HT_EVENT_NODE_DISABLE:
case HT_EVENT_NODE_SCROLLTO:
case HT_EVENT_COLUMN_ADD:
case HT_EVENT_COLUMN_DELETE:
case HT_EVENT_COLUMN_SIZETO:
case HT_EVENT_COLUMN_REORDER:
case HT_EVENT_COLUMN_SHOW:
case HT_EVENT_COLUMN_HIDE:
case HT_EVENT_VIEW_MODECHANGED:
#endif
default:
if ( CRDFToolbar* toolbar = reinterpret_cast<CRDFToolbar*>(HT_GetViewFEData(ht_view)) )
toolbar->HandleNotification(notification, node, event, token, tokenType);
}
}

View File

@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#pragma once
#include "auto_HT_Pane.h" // ...for |auto_ptr<_HT_PaneStruct>|, a member
#include "CDragBarContainer.h" // ...is a base class
#include "CRDFNotificationHandler.h" // ...is a base class
class CRDFToolbarContainer
: public CDragBarContainer,
public CRDFNotificationHandler
/*
...
Why didn't I just fold this functionality into |CDragBarContainer|?
Well... |CDragBarContainer| seemed very comprehensible. It supplies just the
functionality of moving the individual toolbars around, and machinery very
closely related to that.
_This_ class strictly enhances that functionality with the idea that RDF
specifies the attributes of the bars rather than a resource.
*/
{
public:
enum
{
class_ID = 'RTCt'
};
CRDFToolbarContainer( LStream* );
// virtual ~CRDFToolbarContainer(); -- already virtual from bases, |auto_ptr| member means no destructor needed
private: // Pass-by-value is not allowed. A single |CRDFToolbarContainer| corresponds to a single on-screen object; copying doesn't make sense.
CRDFToolbarContainer( const CRDFToolbarContainer& ); // DON'T IMPLEMENT
CRDFToolbarContainer& operator=( const CRDFToolbarContainer& ); // DON'T IMPLEMENT
protected: // ...overriding the appropriate methods of |CRDFNotificationHandler|
virtual void HandleNotification( HT_Notification, HT_Resource, HT_Event, void*, uint32 );
private:
auto_ptr<_HT_PaneStruct> _ht_root;
};

View File

@ -0,0 +1,169 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// auto_HT_Pane.h
#pragma once
#include <memory> // for the definition of |auto_ptr| before specializing it
#include "htrdf.h" // for the definition of |HT_Pane| and the declaration of |HT_DeletePane|
/*
Please note the usual admonition: An |auto_ptr| is a the owner of a given resource.
Certain syntactic liberties have been taken so that functions that return |auto_ptr|s
can yield ownership in expressions like this where a |const| temporary might otherwise
interfere
auto_ptr<X> create_X();
auto_ptr<X> x;
// ...
x = create_X();
The machinery that allows that assignment to succeed will make other, less desirable
assigments succeed as well. To avoid problems, remember this rule of thumb
"If you don't intend to give away ownership, don't show them your |auto_ptr|."
Give them a reference (e.g., |*x|), give them a pointer (e.g., |x.get()|), but don't
even think of giving them an |auto_ptr| or a reference to it, EVEN A CONST REFERENCE,
because you may end up yielding ownership.
Additionally, when you write the equivalent of |create_X|, above, try to write to
facilitate the return-value optimization, e.g.,
auto_ptr<X>
create_X()
{
return auto_ptr<X>(new X)
}
*/
class auto_ptr<_HT_PaneStruct>
/*
...specializes |auto_ptr| template to deal with |HT_Pane| which is
really a |_HT_PaneStruct*|. This class should be transparent to anyone
who already knows how |auto_ptr| works, and already thinks of |HT_Pane|
as a pointer.
This class implements the Nov '97 version of the C++ standard, but
will require some small modifications when member templates are fully supported.
*/
{
public:
struct auto_ptr_ref
{
auto_ptr& p_;
auto_ptr_ref( const auto_ptr& a )
: p_( const_cast<auto_ptr&>(a) )
{
// nothing else to do
}
};
public:
typedef _HT_PaneStruct element_type;
explicit
auto_ptr( HT_Pane P = 0 )
: _pane(P)
{
// nothing else to do
}
auto_ptr( auto_ptr& a )
: _pane(a.release())
{
// nothing else to do
}
~auto_ptr()
{
if ( _pane )
HT_DeletePane(_pane);
}
auto_ptr&
operator=( auto_ptr& a )
{
reset(a.release());
return *this;
}
_HT_PaneStruct&
operator*() const
{
return *get();
}
HT_Pane
operator->() const
{
return get();
}
HT_Pane
get() const
{
return _pane;
}
HT_Pane
release()
{
HT_Pane result = get();
_pane = 0;
return result;
}
void
reset( HT_Pane P = 0 )
{
if ( get() != P )
{
if ( _pane )
HT_DeletePane(_pane);
_pane = P;
}
}
auto_ptr( auto_ptr_ref r )
: _pane(r.p_.release())
{
// nothing else to do
}
// not in the C++ standard (yet?), but needed for the same reason as the method above
auto_ptr&
operator=( auto_ptr_ref r )
{
reset(r.p_.release());
return *this;
}
operator auto_ptr_ref()
{
return *this;
}
private:
HT_Pane _pane;
};