зеркало из https://github.com/mozilla/gecko-dev.git
added for Nexware guys.
This commit is contained in:
Родитель
e2946fd9b1
Коммит
a1430e3ffe
|
@ -0,0 +1,54 @@
|
|||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = raptorwidgetph_s
|
||||
|
||||
MODULE=widget
|
||||
|
||||
REQUIRES=util img xpcom raptor netlib
|
||||
|
||||
#DEFINES += -D_IMPL_NS_WIDGET
|
||||
|
||||
INCLUDES+= -I$(srcdir)/../xpwidgets -I$(srcdir)/.
|
||||
|
||||
INCLUDES += $(TK_CFLAGS)
|
||||
|
||||
CPPSRCS= \
|
||||
nsAppShell.cpp \
|
||||
nsDialog.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
nsWidgetSupport.cpp \
|
||||
nsWindow.cpp
|
||||
|
||||
TARGETS = $(LIBRARY)
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* 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 "nsAppShell.h"
|
||||
#include "nsIWidget.h"
|
||||
#include <Pt.h>
|
||||
|
||||
NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsAppShell::nsAppShell()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mDispatchListener = 0;
|
||||
mSelectionMgr = 0;
|
||||
mEventBufferSz = sizeof( PhEvent_t ) + 1000;
|
||||
mEvent = (PhEvent_t*) malloc( mEventBufferSz );
|
||||
NS_ASSERTION( mEvent, "Out of memory" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the application shell
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsAppShell::Create(int* argc, char ** argv)
|
||||
{
|
||||
// Create the selection manager
|
||||
// if( !mSelectionMgr )
|
||||
// NS_NewSelectionMgr( &mSelectionMgr );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
||||
{
|
||||
mDispatchListener = aDispatchListener;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Enter a message handler loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsresult nsAppShell::Run()
|
||||
{
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PhEvent_t *event;
|
||||
unsigned short locEventBufferSz = sizeof( PhEvent_t ) + 1000; /* initially */
|
||||
|
||||
if( nsnull != ( event = (PhEvent_t*) malloc( locEventBufferSz )))
|
||||
{
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
while(!done)
|
||||
{
|
||||
switch( PhEventNext( event, locEventBufferSz ))
|
||||
{
|
||||
case Ph_EVENT_MSG:
|
||||
PtEventHandler( event );
|
||||
if( mDispatchListener )
|
||||
mDispatchListener->AfterDispatch();
|
||||
break;
|
||||
|
||||
case Ph_RESIZE_MSG:
|
||||
locEventBufferSz = PhGetMsgSize( event );
|
||||
if(( event = (PhEvent_t*) realloc( event, locEventBufferSz )) == nsnull )
|
||||
{
|
||||
result = 0; // Meaningful error code?
|
||||
done = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case -1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free( event );
|
||||
}
|
||||
|
||||
|
||||
Release();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsAppShell::GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
aIsInWindow = PR_FALSE;
|
||||
|
||||
while(!done)
|
||||
{
|
||||
// This method uses the class event buffer, m_Event, and the class event
|
||||
// buffer size, m_EventBufferSz. If we receive a Ph_RESIZE_MSG event, we
|
||||
// try to realloc the buffer to the new size specified in the event, then
|
||||
// we wait for another "real" event.
|
||||
|
||||
switch( PhEventNext( mEvent, mEventBufferSz ))
|
||||
{
|
||||
case Ph_EVENT_MSG:
|
||||
switch( mEvent->type )
|
||||
{
|
||||
case Ph_EV_BUT_PRESS:
|
||||
case Ph_EV_BUT_RELEASE:
|
||||
case Ph_EV_BUT_REPEAT:
|
||||
case Ph_EV_PTR_MOTION_BUTTON:
|
||||
case Ph_EV_PTR_MOTION_NOBUTTON:
|
||||
aIsMouseEvent = PR_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
aIsMouseEvent = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
aEvent = mEvent;
|
||||
|
||||
if( nsnull != aWidget )
|
||||
{
|
||||
// Get Native Window for dialog window
|
||||
PtWidget_t* win;
|
||||
win = (PtWidget_t*)aWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
|
||||
aIsInWindow = PR_TRUE;
|
||||
}
|
||||
done = PR_TRUE;
|
||||
break;
|
||||
|
||||
case Ph_RESIZE_MSG:
|
||||
mEventBufferSz = PhGetMsgSize( mEvent );
|
||||
if(( mEvent = (PhEvent_t*)realloc( mEvent, mEventBufferSz )) == nsnull )
|
||||
{
|
||||
done = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case -1:
|
||||
done = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult nsAppShell::DispatchNativeEvent(void * aEvent)
|
||||
{
|
||||
PtEventHandler( (PhEvent_t*)aEvent );
|
||||
|
||||
// REVISIT - not sure if we're supposed to to this here:
|
||||
// if( mDispatchListener )
|
||||
// mDispatchListener->AfterDispatch();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Exit a message handler loop
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsAppShell::Exit()
|
||||
{
|
||||
// REVISIT - How do we do this under Photon???
|
||||
// PtSendEventToWidget( m_window, quit_event );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsAppShell destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsAppShell::~nsAppShell()
|
||||
{
|
||||
// NS_IF_RELEASE(mSelectionMgr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// GetNativeData
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void* nsAppShell::GetNativeData(PRUint32 aDataType)
|
||||
{
|
||||
if( aDataType == NS_NATIVE_SHELL )
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_METHOD nsAppShell::GetSelectionMgr(nsISelectionMgr** aSelectionMgr)
|
||||
{
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef nsAppShell_h__
|
||||
#define nsAppShell_h__
|
||||
|
||||
#include <Pt.h>
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
/**
|
||||
* Native Photon Application shell wrapper
|
||||
*/
|
||||
|
||||
class nsAppShell : public nsIAppShell
|
||||
{
|
||||
public:
|
||||
nsAppShell();
|
||||
virtual ~nsAppShell();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
PRBool OnPaint();
|
||||
|
||||
// nsIAppShellInterface
|
||||
|
||||
NS_IMETHOD Create(int* argc, char ** argv);
|
||||
virtual nsresult Run();
|
||||
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
|
||||
NS_IMETHOD Exit();
|
||||
virtual void* GetNativeData(PRUint32 aDataType);
|
||||
NS_IMETHOD GetSelectionMgr(nsISelectionMgr** aSelectionMgr);
|
||||
|
||||
// XXX temporary for Dialog investigation
|
||||
|
||||
NS_IMETHOD GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent);
|
||||
NS_IMETHOD DispatchNativeEvent(void * aEvent);
|
||||
|
||||
private:
|
||||
|
||||
nsDispatchListener *mDispatchListener;
|
||||
nsISelectionMgr *mSelectionMgr;
|
||||
unsigned long mEventBufferSz;
|
||||
PhEvent_t *mEvent;
|
||||
};
|
||||
|
||||
#endif // nsAppShell_h__
|
|
@ -0,0 +1,166 @@
|
|||
/* -*- 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 "nsDialog.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include <Pt.h>
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include "nsGfxCIID.h"
|
||||
//#include "resource.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsDialog)
|
||||
NS_IMPL_RELEASE(nsDialog)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsDialog constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsDialog::nsDialog() : nsWindow(), nsIDialog()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create the proper widget
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsDialog::Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
return nsWindow::Create(aParent,aRect,aHandleEventFunction,aContext,aAppShell,aToolkit,aInitData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsDialog destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsDialog::~nsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsDialog::SetLabel(const nsString& aText)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if( mWidget )
|
||||
{
|
||||
PtArg_t arg;
|
||||
NS_ALLOC_STR_BUF(label, aText, 256);
|
||||
|
||||
PtSetArg( &arg, Pt_ARG_TEXT_STRING, label, 0 );
|
||||
if( PtSetResources( mWidget, 1, &arg ) != 0 )
|
||||
result = NS_ERROR_FAILURE;
|
||||
|
||||
NS_FREE_STR_BUF(label);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsDialog::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsDialog::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
static NS_DEFINE_IID(kInsDialogIID, NS_IDIALOG_IID);
|
||||
if (result == NS_NOINTERFACE && aIID.Equals(kInsDialogIID)) {
|
||||
*aInstancePtr = (void*) ((nsIDialog*)this);
|
||||
NS_ADDREF_THIS();
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// move, paint, resizes message - ignore
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsDialog::OnMove(PRInt32, PRInt32)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsDialog::OnPaint()
|
||||
{
|
||||
return nsWindow::OnPaint();
|
||||
}
|
||||
|
||||
PRBool nsDialog::OnResize(nsRect &aWindowRect)
|
||||
{
|
||||
return nsWindow::OnResize(aWindowRect);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// get position/dimensions
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_METHOD nsDialog::GetBounds(nsRect &aRect)
|
||||
{
|
||||
return nsWindow::GetBounds(aRect);
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef nsDialog_h__
|
||||
#define nsDialog_h__
|
||||
|
||||
#include "nsWindow.h"
|
||||
#include "nsIDialog.h"
|
||||
|
||||
/**
|
||||
* Native Photon dialog wrapper
|
||||
*/
|
||||
|
||||
class nsDialog : public nsWindow,
|
||||
public nsIDialog
|
||||
{
|
||||
|
||||
public:
|
||||
nsDialog();
|
||||
virtual ~nsDialog();
|
||||
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIDialog part
|
||||
NS_IMETHOD SetLabel(const nsString& aText);
|
||||
NS_IMETHOD GetLabel(nsString& aBuffer);
|
||||
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
virtual PRBool OnPaint();
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
|
||||
protected:
|
||||
|
||||
// static BOOL CALLBACK NSDialogProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // nsDialog_h__
|
|
@ -0,0 +1,161 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 "nsLookAndFeel.h"
|
||||
#include <Pt.h>
|
||||
#include "nsFont.h"
|
||||
|
||||
NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
NS_IMPL_ISUPPORTS(nsLookAndFeel,kILookAndFeelIID);
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel() : nsILookAndFeel()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
#if 0
|
||||
switch( aID )
|
||||
{
|
||||
case eColor_WindowBackground:
|
||||
break;
|
||||
case eColor_WindowForeground:
|
||||
break;
|
||||
case eColor_WidgetBackground:
|
||||
break;
|
||||
case eColor_WidgetForeground:
|
||||
break;
|
||||
case eColor_WidgetSelectBackground:
|
||||
break;
|
||||
case eColor_WidgetSelectForeground:
|
||||
break;
|
||||
case eColor_Widget3DHighlight:
|
||||
break;
|
||||
case eColor_Widget3DShadow:
|
||||
break;
|
||||
case eColor_TextBackground:
|
||||
break;
|
||||
case eColor_TextForeground:
|
||||
break;
|
||||
case eColor_TextSelectBackground:
|
||||
break;
|
||||
case eColor_TextSelectForeground:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
switch( aID )
|
||||
{
|
||||
case eMetric_WindowTitleHeight:
|
||||
break;
|
||||
case eMetric_WindowBorderWidth:
|
||||
break;
|
||||
case eMetric_WindowBorderHeight:
|
||||
break;
|
||||
case eMetric_Widget3DBorder:
|
||||
break;
|
||||
case eMetric_TextFieldHeight:
|
||||
break;
|
||||
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
|
||||
break;
|
||||
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
|
||||
break;
|
||||
case eMetric_CheckboxSize:
|
||||
break;
|
||||
case eMetric_RadioboxSize:
|
||||
break;
|
||||
case eMetric_TextHorizontalInsideMinimumPadding:
|
||||
break;
|
||||
case eMetric_TextVerticalInsidePadding:
|
||||
break;
|
||||
case eMetric_TextShouldUseVerticalInsidePadding:
|
||||
break;
|
||||
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
|
||||
break;
|
||||
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
|
||||
break;
|
||||
case eMetric_ListHorizontalInsideMinimumPadding:
|
||||
break;
|
||||
case eMetric_ListShouldUseVerticalInsidePadding:
|
||||
break;
|
||||
case eMetric_ListVerticalInsidePadding:
|
||||
break;
|
||||
default:
|
||||
aMetric = -1;
|
||||
res = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
switch( aID )
|
||||
{
|
||||
case eMetricFloat_TextFieldVerticalInsidePadding:
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
case eMetricFloat_TextFieldHorizontalInsidePadding:
|
||||
aMetric = 0.95f;
|
||||
break;
|
||||
case eMetricFloat_TextAreaVerticalInsidePadding:
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
case eMetricFloat_TextAreaHorizontalInsidePadding:
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
case eMetricFloat_ListVerticalInsidePadding:
|
||||
aMetric = 0.10f;
|
||||
break;
|
||||
case eMetricFloat_ListHorizontalInsidePadding:
|
||||
aMetric = 0.40f;
|
||||
break;
|
||||
case eMetricFloat_ButtonVerticalInsidePadding:
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
case eMetricFloat_ButtonHorizontalInsidePadding:
|
||||
aMetric = 0.25f;
|
||||
break;
|
||||
default:
|
||||
aMetric = -1.0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __nsLookAndFeel
|
||||
#define __nsLookAndFeel
|
||||
#include "nsILookAndFeel.h"
|
||||
|
||||
class nsLookAndFeel: public nsILookAndFeel {
|
||||
public:
|
||||
nsLookAndFeel();
|
||||
virtual ~nsLookAndFeel();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor);
|
||||
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric);
|
||||
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,79 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Convience macros for converting nsString's to chars +
|
||||
// creating temporary char[] bufs.
|
||||
|
||||
#ifndef NS_STR_UTIL_H
|
||||
#define NS_STR_UTIL_H
|
||||
|
||||
// nsString to temporary char[] macro
|
||||
|
||||
// Convience MACROS to convert an nsString to a char * which use a
|
||||
// static char array if possible to reduce memory fragmentation,
|
||||
// otherwise they allocate a char[] which must be freed.
|
||||
// REMEMBER to always use the NS_FREE_STR_BUF after using the
|
||||
// NS_ALLOC_STR_BUF. You can not nest NS_ALLOC_STR_BUF's.
|
||||
|
||||
#define NS_ALLOC_STR_BUF(varName, strName, tempSize) \
|
||||
static const int _ns_kSmallBufferSize = tempSize; \
|
||||
char* varName = 0; \
|
||||
int _ns_smallBufUsed = 0; \
|
||||
char _ns_smallBuffer[_ns_kSmallBufferSize]; \
|
||||
if (strName.Length() < (_ns_kSmallBufferSize - 1)) { \
|
||||
strName.ToCString(_ns_smallBuffer, _ns_kSmallBufferSize); \
|
||||
_ns_smallBuffer[_ns_kSmallBufferSize - 1] = '\0'; \
|
||||
_ns_smallBufUsed = 1; \
|
||||
varName = _ns_smallBuffer; \
|
||||
} \
|
||||
else { \
|
||||
varName = strName.ToNewCString(); \
|
||||
}
|
||||
|
||||
#define NS_FREE_STR_BUF(varName) \
|
||||
if (! _ns_smallBufUsed) \
|
||||
delete varName;
|
||||
|
||||
// Create temporary char[] macro
|
||||
//
|
||||
// Create a temporary buffer for storing chars.
|
||||
// If the actual size is > size then the buffer
|
||||
// is allocated from the heap, otherwise the buffer
|
||||
// is a stack variable. REMEMBER: use NS_FREE_BUF
|
||||
// when finished with the buffer allocated, and do
|
||||
// NOT nest INSERT_BUF'S.
|
||||
|
||||
#define NS_ALLOC_CHAR_BUF(aBuf, aSize, aActualSize) \
|
||||
char *aBuf; \
|
||||
int _ns_smallBufUsed = 0; \
|
||||
static const int _ns_kSmallBufferSize = aSize; \
|
||||
if (aActualSize < _ns_kSmallBufferSize) { \
|
||||
char _ns_smallBuffer[_ns_kSmallBufferSize]; \
|
||||
aBuf = _ns_smallBuffer; \
|
||||
_ns_smallBufUsed = 1; \
|
||||
} \
|
||||
else { \
|
||||
aBuf = new char[aActualSize]; \
|
||||
}
|
||||
|
||||
#define NS_FREE_CHAR_BUF(aBuf) \
|
||||
if (! _ns_smallBufUsed) \
|
||||
delete aBuf;
|
||||
|
||||
|
||||
#endif // NSStringUtil
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- 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 "nsToolkit.h"
|
||||
#include "nsWindow.h"
|
||||
#include "prmon.h"
|
||||
#include "prtime.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include <Pt.h>
|
||||
|
||||
|
||||
NS_DEFINE_IID(kIToolkitIID, NS_ITOOLKIT_IID);
|
||||
NS_IMPL_ISUPPORTS(nsToolkit,kIToolkitIID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::nsToolkit()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::~nsToolkit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsToolkit::Init(PRThread *aThread)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef TOOLKIT_H
|
||||
#define TOOLKIT_H
|
||||
|
||||
#include "nsIToolkit.h"
|
||||
|
||||
class nsToolkit : public nsIToolkit
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsToolkit();
|
||||
NS_IMETHOD Init( PRThread *aThread );
|
||||
|
||||
private:
|
||||
~nsToolkit();
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // TOOLKIT_H
|
|
@ -0,0 +1,278 @@
|
|||
/* -*- Mode: C++; tab-width: 4; 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 "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
//#include "nsButton.h"
|
||||
//#include "nsCheckButton.h"
|
||||
//#include "nsComboBox.h"
|
||||
//#include "nsFileWidget.h"
|
||||
//#include "nsListBox.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
//#include "nsRadioButton.h"
|
||||
//#include "nsScrollbar.h"
|
||||
//#include "nsTextAreaWidget.h"
|
||||
//#include "nsTextHelper.h"
|
||||
//#include "nsTextWidget.h"
|
||||
#include "nsToolkit.h"
|
||||
//#include "nsTabWidget.h"
|
||||
//#include "nsTooltipWidget.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsDialog.h"
|
||||
//#include "nsLabel.h"
|
||||
//#include "nsMenuBar.h"
|
||||
//#include "nsMenu.h"
|
||||
//#include "nsMenuItem.h"
|
||||
//#include "nsPopUpMenu.h"
|
||||
//#include "nsImageButton.h"
|
||||
//#include "nsMenuButton.h"
|
||||
#include "nsAppShell.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
||||
//static NS_DEFINE_IID(kCButton, NS_BUTTON_CID);
|
||||
//static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID);
|
||||
//static NS_DEFINE_IID(kCCombobox, NS_COMBOBOX_CID);
|
||||
//static NS_DEFINE_IID(kCFileOpen, NS_FILEWIDGET_CID);
|
||||
//static NS_DEFINE_IID(kCListbox, NS_LISTBOX_CID);
|
||||
//static NS_DEFINE_IID(kCRadioButton, NS_RADIOBUTTON_CID);
|
||||
//static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID);
|
||||
//static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID);
|
||||
//static NS_DEFINE_IID(kCTextArea, NS_TEXTAREA_CID);
|
||||
//static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID);
|
||||
//static NS_DEFINE_IID(kCTabWidget, NS_TABWIDGET_CID);
|
||||
//static NS_DEFINE_IID(kCTooltipWidget, NS_TOOLTIPWIDGET_CID);
|
||||
static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_IID(kCToolkit, NS_TOOLKIT_CID);
|
||||
static NS_DEFINE_IID(kCLookAndFeel, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kCDialog, NS_DIALOG_CID);
|
||||
//static NS_DEFINE_IID(kCLabel, NS_LABEL_CID);
|
||||
//static NS_DEFINE_IID(kCMenuBar, NS_MENUBAR_CID);
|
||||
//static NS_DEFINE_IID(kCMenu, NS_MENU_CID);
|
||||
//static NS_DEFINE_IID(kCMenuItem, NS_MENUITEM_CID);
|
||||
//static NS_DEFINE_IID(kCImageButton, NS_IMAGEBUTTON_CID);
|
||||
//static NS_DEFINE_IID(kCPopUpMenu, NS_POPUPMENU_CID);
|
||||
//static NS_DEFINE_IID(kCMenuButton, NS_MENUBUTTON_CID);
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
class nsWidgetFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsWidgetFactory(const nsCID &aClass);
|
||||
~nsWidgetFactory();
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsWidgetFactory)
|
||||
NS_IMPL_RELEASE(nsWidgetFactory)
|
||||
|
||||
|
||||
nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
nsWidgetFactory::~nsWidgetFactory()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
|
||||
}
|
||||
|
||||
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = (void *)(nsIFactory*)this;
|
||||
}
|
||||
|
||||
if (*aResult == NULL) {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_ADDREF_THIS(); // Increase reference count for caller
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = NULL;
|
||||
if (nsnull != aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kCWindow)) {
|
||||
inst = (nsISupports*)new nsWindow();
|
||||
}
|
||||
else if (mClassID.Equals(kCChild)) {
|
||||
inst = (nsISupports*)new ChildWindow();
|
||||
}
|
||||
|
||||
/*
|
||||
else if (mClassID.Equals(kCButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCCheckButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsCheckButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCCombobox)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsComboBox();
|
||||
}
|
||||
else if (mClassID.Equals(kCRadioButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsRadioButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCFileOpen)) {
|
||||
inst = (nsISupports*)new nsFileWidget();
|
||||
}
|
||||
else if (mClassID.Equals(kCListbox)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsListBox();
|
||||
}
|
||||
else if (mClassID.Equals(kCHorzScrollbar)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsScrollbar(PR_FALSE);
|
||||
}
|
||||
else if (mClassID.Equals(kCVertScrollbar)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsScrollbar(PR_TRUE);
|
||||
}
|
||||
else if (mClassID.Equals(kCTextArea)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsTextAreaWidget();
|
||||
}
|
||||
else if (mClassID.Equals(kCTextField)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsTextWidget();
|
||||
}
|
||||
else if (mClassID.Equals(kCTabWidget)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsTabWidget();
|
||||
}
|
||||
else if (mClassID.Equals(kCTooltipWidget)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsTooltipWidget();
|
||||
}
|
||||
*/
|
||||
|
||||
else if (mClassID.Equals(kCAppShell)) {
|
||||
inst = (nsISupports*)new nsAppShell();
|
||||
}
|
||||
else if (mClassID.Equals(kCToolkit)) {
|
||||
inst = (nsISupports*)new nsToolkit();
|
||||
}
|
||||
else if (mClassID.Equals(kCLookAndFeel)) {
|
||||
inst = (nsISupports*)new nsLookAndFeel();
|
||||
}
|
||||
else if (mClassID.Equals(kCDialog)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsDialog();
|
||||
}
|
||||
|
||||
/*
|
||||
else if (mClassID.Equals(kCLabel)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsLabel();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenuBar)) {
|
||||
inst = (nsISupports*)(nsIMenuBar*) new nsMenuBar();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenu)) {
|
||||
inst = (nsISupports*)(nsIMenu*) new nsMenu();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenuItem)) {
|
||||
inst = (nsISupports*)(nsIMenuItem*) new nsMenuItem();
|
||||
}
|
||||
else if (mClassID.Equals(kCImageButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsImageButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenuButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsMenuButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCPopUpMenu)) {
|
||||
inst = (nsISupports*)new nsPopUpMenu();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (res != NS_OK) {
|
||||
// We didn't get the right interface, so clean up
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsWidgetFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// return the proper factory to the caller
|
||||
extern "C" NS_WIDGET nsresult
|
||||
NSGetFactory(nsISupports* serviceMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if( nsnull == aFactory )
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aFactory = new nsWidgetFactory( aClass );
|
||||
|
||||
if( nsnull == aFactory )
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,467 @@
|
|||
/* -*- 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 "nsWidgetSupport.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsITextAreaWidget.h"
|
||||
#include "nsIFileWidget.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIButton.h"
|
||||
#include "nsIComboBox.h"
|
||||
#include "nsIEventListener.h"
|
||||
#include "nsILabel.h"
|
||||
#include "nsIListBox.h"
|
||||
#include "nsIListWidget.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIMouseListener.h"
|
||||
#include "nsITabWidget.h"
|
||||
#include "nsIToolkit.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIDialog.h"
|
||||
#include "nsICheckButton.h"
|
||||
#include "nsIScrollbar.h"
|
||||
#include "nsIRadioButton.h"
|
||||
#include "nsITooltipWidget.h"
|
||||
#include "nsITextWidget.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
//static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
//static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
//static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIDialogIID, NS_IDIALOG_IID);
|
||||
//static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
//static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
|
||||
//static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID);
|
||||
//static NS_DEFINE_IID(kIScrollBarIID, NS_ISCROLLBAR_IID);
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateDialog(nsISupports* aParent,
|
||||
nsIDialog* aDialog,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aDialog->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
if (aParent != nsnull)
|
||||
NS_IF_RELEASE(parent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateButton(nsISupports* aParent,
|
||||
nsIButton* aButton,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
|
||||
if (aParent != nsnull)
|
||||
NS_IF_RELEASE(parent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateCheckButton(nsISupports* aParent,
|
||||
nsICheckButton* aCheckButton,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aCheckButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
if (aParent != nsnull)
|
||||
NS_IF_RELEASE(parent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateRadioButton( nsISupports* aParent,
|
||||
nsIRadioButton* aRadioButton,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aRadioButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
if (aParent != nsnull)
|
||||
NS_IF_RELEASE(parent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateLabel( nsISupports* aParent,
|
||||
nsILabel* aLabel,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (NS_OK == aParent->QueryInterface(kIWidgetIID,(void**)&parent))
|
||||
{
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aLabel->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
NS_IF_RELEASE(parent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateTextAreaWidget(nsISupports* aParent,
|
||||
nsITextAreaWidget* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateTextWidget(nsISupports* aParent,
|
||||
nsITextWidget* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateScrollBar(nsISupports* aParent,
|
||||
nsIScrollbar* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateListBox(nsISupports* aParent,
|
||||
nsIListBox* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateComboBox(nsISupports* aParent,
|
||||
nsIComboBox* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateTabWidget(nsISupports* aParent,
|
||||
nsITabWidget* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_CreateTooltipWidget(nsISupports* aParent,
|
||||
nsITooltipWidget* aWidget,
|
||||
const nsRect& aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
widget->SetFont(*aFont);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Call QueryInterface on a non kIWidgetIID supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
NS_IF_RELEASE(parent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_ShowWidget(nsISupports* aWidget, PRBool aShow)
|
||||
{
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Show(aShow);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_MoveWidget(nsISupports* aWidget, PRUint32 aX, PRUint32 aY)
|
||||
{
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->Move(aX,aY);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_EnableWidget(nsISupports* aWidget, PRBool aEnable)
|
||||
{
|
||||
void* result = nsnull;
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget))
|
||||
{
|
||||
widget->Enable(aEnable);
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_SetFocusToWidget(nsISupports* aWidget)
|
||||
{
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
widget->SetFocus();
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
extern NS_WIDGET nsresult
|
||||
NS_GetWidgetNativeData(nsISupports* aWidget, void** aNativeData)
|
||||
{
|
||||
void* result = nsnull;
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget))
|
||||
{
|
||||
result = widget->GetNativeData(NS_NATIVE_WIDGET);
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
*aNativeData = result;
|
||||
return NS_OK;
|
||||
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,201 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
#ifndef Window_h__
|
||||
#define Window_h__
|
||||
|
||||
#include "nsBaseWidget.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIMenuBar.h"
|
||||
#include "nsIMouseListener.h"
|
||||
#include "nsIEventListener.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include <Pt.h>
|
||||
|
||||
#define NSRGB_2_COLOREF(color) \
|
||||
RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
|
||||
|
||||
/**
|
||||
* Native Photon window wrapper.
|
||||
*/
|
||||
|
||||
class nsWindow : public nsBaseWidget
|
||||
{
|
||||
|
||||
public:
|
||||
nsWindow();
|
||||
virtual ~nsWindow();
|
||||
|
||||
// nsIWidget interface
|
||||
NS_IMETHOD Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
NS_IMETHOD Create(nsNativeWidget aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
// Utility method for implementing both Create(nsIWidget ...) and
|
||||
// Create(nsNativeWidget...)
|
||||
|
||||
virtual nsresult StandardWindowCreate(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData,
|
||||
nsNativeWidget aNativeParent = nsnull);
|
||||
|
||||
NS_IMETHOD Destroy();
|
||||
virtual nsIWidget* GetParent(void);
|
||||
NS_IMETHOD Show(PRBool bState);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
|
||||
NS_IMETHOD Move(PRUint32 aX, PRUint32 aY);
|
||||
NS_IMETHOD Resize(PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRBool aRepaint);
|
||||
NS_IMETHOD Resize(PRUint32 aX,
|
||||
PRUint32 aY,
|
||||
PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRBool aRepaint);
|
||||
NS_IMETHOD Enable(PRBool bState);
|
||||
NS_IMETHOD SetFocus(void);
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
||||
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
||||
virtual nsIFontMetrics* GetFont(void);
|
||||
NS_IMETHOD SetFont(const nsFont &aFont);
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
||||
NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous);
|
||||
NS_IMETHOD Update();
|
||||
virtual void* GetNativeData(PRUint32 aDataType);
|
||||
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
|
||||
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
|
||||
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
|
||||
NS_IMETHOD RemoveTooltips();
|
||||
NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]);
|
||||
NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect);
|
||||
NS_IMETHOD ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect);
|
||||
NS_IMETHOD BeginResizingChildren(void);
|
||||
NS_IMETHOD EndResizingChildren(void);
|
||||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
||||
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
||||
NS_IMETHOD EnableFileDrop(PRBool aEnable);
|
||||
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
|
||||
|
||||
|
||||
|
||||
virtual PRBool DispatchMouseEvent(PRUint32 aEventType, nsPoint* aPoint = nsnull);
|
||||
virtual PRBool AutoErase();
|
||||
nsPoint* GetLastPoint() { return &mLastPoint; }
|
||||
|
||||
PRInt32 GetNewCmdMenuId() { mMenuCmdId++; return mMenuCmdId;}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static int RawEventHandler( PtWidget_t *, void *, PtCallbackInfo_t * );
|
||||
PRBool HandleEvent( PtCallbackInfo_t* );
|
||||
|
||||
virtual PRBool DispatchWindowEvent(nsGUIEvent* event);
|
||||
|
||||
// Allow Derived classes to modify the height that is passed
|
||||
// when the window is created or resized.
|
||||
virtual PRInt32 GetHeight(PRInt32 aProposedHeight);
|
||||
|
||||
virtual void OnDestroy();
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
virtual PRBool OnPaint();
|
||||
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||
virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode);
|
||||
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
||||
|
||||
static PRBool ConvertStatus(nsEventStatus aStatus);
|
||||
|
||||
PRBool DispatchStandardEvent(PRUint32 aMsg);
|
||||
|
||||
void GetNonClientBounds(nsRect &aRect);
|
||||
|
||||
protected:
|
||||
static nsWindow* gCurrentWindow;
|
||||
nsPoint mLastPoint;
|
||||
PtWidget_t* mWidget;
|
||||
|
||||
PRBool mHas3DBorder;
|
||||
PRBool mIsShiftDown;
|
||||
PRBool mIsControlDown;
|
||||
PRBool mIsAltDown;
|
||||
PRBool mIsDestroying;
|
||||
PRBool mOnDestroyCalled;
|
||||
PRBool mIsVisible;
|
||||
// XXX Temporary, should not be caching the font
|
||||
nsFont * mFont;
|
||||
|
||||
PRInt32 mPreferredWidth;
|
||||
PRInt32 mPreferredHeight;
|
||||
|
||||
nsIMenuBar * mMenuBar;
|
||||
PRInt32 mMenuCmdId;
|
||||
nsIMenu * mHitMenu;
|
||||
nsVoidArray * mHitSubMenus;
|
||||
|
||||
// Enumeration of the methods which are accessable on the "main GUI thread"
|
||||
// via the CallMethod(...) mechanism...
|
||||
// see nsSwitchToUIThread
|
||||
enum {
|
||||
CREATE = 0x0101,
|
||||
CREATE_NATIVE,
|
||||
DESTROY,
|
||||
SET_FOCUS,
|
||||
SET_CURSOR,
|
||||
CREATE_HACK
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// A child window is a window with different style
|
||||
//
|
||||
class ChildWindow : public nsWindow {
|
||||
|
||||
public:
|
||||
ChildWindow(){}
|
||||
PRBool DispatchMouseEvent(PRUint32 aEventType, nsPoint* aPoint = nsnull);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // Window_h__
|
Загрузка…
Ссылка в новой задаче