Add support for ActionCommand's to trickle up the canvas hierarchy

until command gets processed.  Support for LoadUrl in Container also
implemented.


git-svn-id: svn://10.0.0.236/trunk@10602 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
spider%netscape.com
1998-09-21 19:27:44 +00:00
parent 92ec0851aa
commit 3a4a8e7217
15 changed files with 214 additions and 24 deletions

View File

@@ -76,8 +76,11 @@ public:
NS_IMETHOD ShowDialog(nsIXPFCDialog * aDialog);
NS_IMETHOD_(nsEventStatus) ProcessCommand(nsIXPFCCommand * aCommand) ;
private:
NS_METHOD RegisterFactories();
NS_METHOD ProcessActionCommand(nsString& aCommand);
public:
nsICalendarShell * mCalendarShell;

View File

@@ -31,6 +31,7 @@
#include "nsViewsCID.h"
#include "nsIViewManager.h"
#include "nsXPFCToolkit.h"
#include "nsXPFCActionCommand.h"
// XXX: This code should use XML for defining the Root UI. We need to
// implement the stream manager first to do this, then lots of
@@ -150,6 +151,8 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
mViewManager->SetFrameRate(25);
#endif
gXPFCToolkit->GetCanvasManager()->SetWebViewerContainer((nsIWebViewerContainer *) this);
/*
* Create the Root UI
*/
@@ -618,3 +621,56 @@ nsresult nsCalendarContainer::RegisterFactories()
return NS_OK;
}
nsEventStatus nsCalendarContainer::ProcessCommand(nsIXPFCCommand * aCommand)
{
/*
* Check to see this is an ActionCommand
*/
nsresult res;
nsXPFCActionCommand * action_command = nsnull;
static NS_DEFINE_IID(kXPFCActionCommandCID, NS_XPFC_ACTION_COMMAND_CID);
res = aCommand->QueryInterface(kXPFCActionCommandCID,(void**)&action_command);
if (NS_OK != res)
return nsEventStatus_eIgnore;
/*
* Yeah, this is an action command. Do something
*/
ProcessActionCommand(action_command->mAction);
NS_RELEASE(action_command);
return (nsEventStatus_eIgnore);
}
nsresult nsCalendarContainer::ProcessActionCommand(nsString& aAction)
{
nsString command ;
PRUint32 offset = aAction.Find("?");
if (offset > 0)
aAction.Left(command,offset);
else
command = aAction;
if (command.EqualsIgnoreCase("LoadUrl"))
{
nsString url ;
aAction.Mid(url, offset+1, aAction.Length() - offset - 1);
LoadURL(url, nsnull);
}
return NS_OK;
}

View File

@@ -60,7 +60,7 @@
<xpbutton halign="center" valign="bottom" label="Print..." weightmajor="0" weightminor="0" miniimage="images/print_mini.gif" fullimage="resource://res/ui/images/print_full.gif" fullhoverimage="resource://res/ui/images/print_hover_full.gif" fullpressedimage="resource://res/ui/images/print_pressed_full.gif"/>
<object class="separator" weightmajor="0" weightminor="0"/>
<xpbutton halign="right" valign="center" label="GOTO:" weightmajor="0" weightminor="0"/>
<object class="editfield" weightmajor="1" weightminor="1" label=""/>
<object class="editfield" weightmajor="1" weightminor="1" label="" command="LoadUrl?$label"/>
<object class="separator"weightmajor="0" weightminor="0" />
<button label="Throbber" weightmajor="0" weightminor="0" miniimage="throbber_mini##.gif" fullimage="throbber_full##.gif" align="right"/>
</toolbar>

View File

@@ -37,11 +37,6 @@ public:
NS_IMETHOD_(CAPISession) GetCAPISession();
NS_IMETHOD_(CAPIHandle) GetCAPIHandle();
#if 0
NS_IMETHOD_(char *) GetCAPIServer();
NS_IMETHOD_(char *) GetCAPIUser() ;
#endif
NS_IMETHOD_(char *) GetCAPIPassword() ;
NS_IMETHOD_(NSCalendar *) GetNSCalendar();

View File

@@ -39,10 +39,6 @@ public:
NS_IMETHOD Init(nsIApplicationShell * aApplicationShell) = 0;
NS_IMETHOD_(CAPISession) GetCAPISession() = 0;
NS_IMETHOD_(CAPIHandle) GetCAPIHandle() = 0;
#if 0
NS_IMETHOD_(char *) GetCAPIServer() = 0;
NS_IMETHOD_(char *) GetCAPIUser() = 0;
#endif
NS_IMETHOD_(char *) GetCAPIPassword() = 0 ;
NS_IMETHOD_(NSCalendar *) GetNSCalendar() = 0;

View File

@@ -100,18 +100,6 @@ CAPIHandle nsCalToolkit::GetCAPIHandle()
return (mCalendarShell->GetCAPIHandle());
}
#if 0
char * nsCalToolkit::GetCAPIServer()
{
return (mCalendarShell->GetCAPIServer());
}
char * nsCalToolkit::GetCAPIUser()
{
return (mCalendarShell->GetCAPIUser());
}
#endif
char * nsCalToolkit::GetCAPIPassword()
{
return (mCalendarShell->GetCAPIPassword());

View File

@@ -177,6 +177,9 @@ public:
NS_IMETHOD DeleteChildren();
NS_IMETHOD DeleteChildren(PRUint32 aCount);
NS_IMETHOD SetCommand(nsString& aCommand);
NS_IMETHOD_(nsString&) GetCommand();
NS_IMETHOD_(PRBool) PaintRequested();
// nsIXPFCObserver methods
@@ -240,6 +243,7 @@ public:
virtual void NotifyError(nsIImageRequest *aImageRequest,
nsImageError aErrorType);
NS_IMETHOD_(nsEventStatus) ProcessCommand(nsIXPFCCommand * aCommand) ;
#if defined(DEBUG) && defined(XP_PC)
@@ -279,6 +283,7 @@ private:
PRUint32 mTabID;
PRUint32 mTabGroup;
nsIModel * mModel;
nsString mCommand;
protected:

View File

@@ -30,6 +30,7 @@
#include "nsIXPFCCanvasManager.h"
#include "nsIView.h"
#include "nsIViewObserver.h"
#include "nsIWebViewerContainer.h"
class nsXPFCCanvasManager : public nsIXPFCCanvasManager,
public nsIViewObserver
@@ -77,6 +78,9 @@ public:
NS_IMETHOD ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight);
NS_IMETHOD_(nsIWebViewerContainer *) GetWebViewerContainer() ;
NS_IMETHOD SetWebViewerContainer(nsIWebViewerContainer * aWebViewerContainer) ;
protected:
~nsXPFCCanvasManager();
@@ -92,6 +96,7 @@ private:
nsIXPFCCanvas * mFocusedCanvas;
nsIXPFCCanvas * mMouseOverCanvas ;
nsIXPFCCanvas * mPressedCanvas ;
nsIWebViewerContainer * mWebViewerContainer;
};

View File

@@ -32,6 +32,7 @@
#include "nsIRenderingContext.h"
class nsIModel;
class nsIXPFCCommand;
// IID for the nsIXPFCCanvas interface
#define NS_IXPFC_CANVAS_IID \
@@ -613,6 +614,10 @@ public:
NS_IMETHOD FindLargestTabGroup(PRUint32& aTabGroup) = 0;
NS_IMETHOD FindLargestTabID(PRUint32 aTabGroup, PRUint32& aTabID) = 0;
NS_IMETHOD SetCommand(nsString& aCommand) = 0;
NS_IMETHOD_(nsString&) GetCommand() = 0;
NS_IMETHOD_(nsEventStatus) ProcessCommand(nsIXPFCCommand * aCommand) = 0;
/**
* Dump the canvas hierarchy to a file
* @param f, the FILE to dump to

View File

@@ -24,6 +24,7 @@
class nsIXPFCCanvas;
class nsIView;
class nsIWidget;
class nsIWebViewerContainer;
// IID for the nsIXPFCCanvasManager interface
#define NS_IXPFC_CANVAS_MANAGER_IID \
@@ -125,6 +126,11 @@ public:
*/
NS_IMETHOD SetMouseOverCanvas(nsIXPFCCanvas * aCanvas) = 0;
NS_IMETHOD_(nsIWebViewerContainer *) GetWebViewerContainer() = 0;
NS_IMETHOD SetWebViewerContainer(nsIWebViewerContainer * aWebViewerContainer) = 0;
};
#endif /* nsIXPFCCanvasManager_h___ */

View File

@@ -37,6 +37,7 @@
#include "nsxpfcCIID.h"
#include "nsxpfcstrings.h"
#include "nsXPFCMethodInvokerCommand.h"
#include "nsIWebViewerContainer.h"
#include "nsXPFCToolkit.h"
@@ -92,8 +93,9 @@ nsXPFCCanvas :: nsXPFCCanvas(nsISupports* outer) :
mChildWidgets = nsnull;
// XXX: We should probably auto-generate unique names here
mNameID = "Canvas";
mLabel = "Default Label";
mNameID = "Canvas";
mLabel = "Default Label";
mCommand = "";
mOpacity = 1.0;
mVisibility = PR_TRUE;
@@ -525,6 +527,10 @@ nsresult nsXPFCCanvas :: SetParameter(nsString& aKey, nsString& aValue)
((nsBoxLayout *)GetLayout())->SetVerticalGap(aValue.ToInteger(&error));
} else if (aKey.EqualsIgnoreCase(XPFC_STRING_COMMAND)) {
SetCommand(aValue);
}
/*
@@ -1873,6 +1879,26 @@ nsresult nsXPFCCanvas::Update(nsIXPFCSubject * aSubject, nsIXPFCCommand * aComma
return NS_OK;
}
/*
* If we cannot process the command, pass it up the food chain
*/
nsEventStatus nsXPFCCanvas::ProcessCommand(nsIXPFCCommand * aCommand)
{
if (GetParent())
return (GetParent()->ProcessCommand(aCommand));
// XXX: Until we figure out the relationship of embeddable widgets
// and containing windows, pass directly to our owner...
nsIWebViewerContainer * container = gXPFCToolkit->GetCanvasManager()->GetWebViewerContainer();
if (container)
return (container->ProcessCommand(aCommand));
return (nsEventStatus_eIgnore);
}
nsresult nsXPFCCanvas::Action(nsIXPFCCommand * aCommand)
{
@@ -2099,3 +2125,14 @@ void nsXPFCCanvas::NotifyError(nsIImageRequest *aImageRequest,
nsresult nsXPFCCanvas :: SetCommand(nsString& aCommand)
{
mCommand = aCommand;
return NS_OK;
}
nsString& nsXPFCCanvas :: GetCommand()
{
return (mCommand);
}

View File

@@ -400,3 +400,16 @@ nsresult nsXPFCCanvasManager::ResizeReflow(nsIView * aView,
return NS_OK;
}
nsresult nsXPFCCanvasManager::SetWebViewerContainer(nsIWebViewerContainer * aWebViewerContainer)
{
mWebViewerContainer = aWebViewerContainer;
return NS_OK;
}
nsIWebViewerContainer * nsXPFCCanvasManager::GetWebViewerContainer()
{
return(mWebViewerContainer);
}

View File

@@ -27,6 +27,7 @@
#include "nsIXPFCToolbar.h"
#include "nsIXPFCDialog.h"
#include "nsIApplicationShell.h"
#include "nsIXPFCCommand.h"
//06245670-306a-11d2-9247-00805f8a7ab6
#define NS_IWEB_VIEWER_CONTAINER_IID \
@@ -57,6 +58,8 @@ public:
NS_IMETHOD SetContentViewer(nsIContentViewer* aViewer) = 0;
NS_IMETHOD GetContentViewer(nsIContentViewer*& aResult) = 0;
NS_IMETHOD_(nsEventStatus) ProcessCommand(nsIXPFCCommand * aCommand) = 0;
NS_IMETHOD LoadURL(const nsString& aURLSpec,
nsIStreamObserver* aListener,
nsIPostData* aPostData = 0) = 0;

View File

@@ -37,6 +37,7 @@ public:
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
NS_IMETHOD CreateWidget();
NS_IMETHOD SetLabel(nsString& aString);
NS_IMETHOD_(nsEventStatus) OnKeyDown(nsGUIEvent *aEvent);
protected:
~nsXPFCTextWidget();

View File

@@ -22,6 +22,9 @@
#include "nsITextWidget.h"
#include "nsWidgetsCID.h"
#include "nsXPFCToolkit.h"
#include "nsXPFCActionCommand.h"
#include "nsRepository.h"
#include "nsxpfcCIID.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID);
@@ -33,6 +36,8 @@ static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
#define MAX_SIZE 2048
nsXPFCTextWidget :: nsXPFCTextWidget(nsISupports* outer) : nsXPFCCanvas(outer)
{
NS_INIT_REFCNT();
@@ -148,3 +153,75 @@ nsresult nsXPFCTextWidget :: SetLabel(nsString& aString)
nsXPFCCanvas::SetLabel(aString);
return NS_OK;
}
nsEventStatus nsXPFCTextWidget::OnKeyDown(nsGUIEvent *aEvent)
{
nsresult res = NS_OK;
if (((nsKeyEvent*)aEvent)->keyCode == NS_VK_RETURN)
{
/*
* We hit the enter key in the edit field.
*
* Pass this command up the chain....
*/
nsEventStatus status = nsEventStatus_eIgnore;
nsString command = GetCommand();
PRUint32 offset = command.Find("$label");
// If this command contains a $Label, replace it with
// our text
if (offset != -1)
{
nsITextWidget * text_widget = nsnull;
res = QueryInterface(kInsTextWidgetIID,(void**)&text_widget);
if (NS_OK == res)
{
nsString text ;
PRUint32 size;
text_widget->GetText(text, MAX_SIZE, size);
command.Cut(offset,6);
command.Insert(text,offset,text.Length());
NS_RELEASE(text_widget);
}
}
// Create an Action Command and pass it on...
nsXPFCActionCommand * action;
static NS_DEFINE_IID(kCXPFCActionCommandCID, NS_XPFC_ACTION_COMMAND_CID);
static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID);
res = nsRepository::CreateInstance(kCXPFCActionCommandCID,
nsnull,
kXPFCCommandIID,
(void **)&action);
if (NS_OK != res)
return status ;
action->Init();
action->mAction = command;
status = ProcessCommand(action);
NS_RELEASE(action);
return (status);
}
return (nsXPFCCanvas::OnKeyDown(aEvent));
}