зеркало из https://github.com/mozilla/pjs.git
Changed to new interfaces
This commit is contained in:
Родитель
21cd5411f7
Коммит
ad6681158e
|
@ -21,7 +21,6 @@
|
|||
#include "nsXtEventHandler.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#define DBG 0
|
||||
extern XtAppContext gAppContext;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -29,10 +28,10 @@ extern XtAppContext gAppContext;
|
|||
// nsFileWidget constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsFileWidget::nsFileWidget(nsISupports *aOuter) : nsWindow(aOuter),
|
||||
mIOwnEventLoop(PR_FALSE)
|
||||
nsFileWidget::nsFileWidget() : nsWindow(), nsIFileWidget()
|
||||
{
|
||||
//mWnd = NULL;
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mNumberOfFilters = 0;
|
||||
}
|
||||
|
||||
|
@ -65,8 +64,6 @@ void nsFileWidget:: Create(nsIWidget *aParent,
|
|||
|
||||
Widget parentWidget = nsnull;
|
||||
|
||||
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);
|
||||
|
||||
if (aParent) {
|
||||
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
} else {
|
||||
|
@ -76,8 +73,6 @@ void nsFileWidget:: Create(nsIWidget *aParent,
|
|||
InitToolkit(aToolkit, aParent);
|
||||
InitDeviceContext(aContext, parentWidget);
|
||||
|
||||
if (DBG) fprintf(stderr, "Parent 0x%x\n", parentWidget);
|
||||
|
||||
mWidget = XmCreateFileSelectionDialog(parentWidget, "filesb", NULL, 0);
|
||||
|
||||
NS_ALLOC_STR_BUF(title, aTitle, 256);
|
||||
|
@ -109,19 +104,23 @@ void nsFileWidget::Create(nsNativeWidget aParent,
|
|||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsFileWidget::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
||||
nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
// nsresult result = nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
|
||||
if (aIID.Equals(kIFileWidgetIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
static NS_DEFINE_IID(kInsFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
if (result == NS_NOINTERFACE && aIID.Equals(kInsFileWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIFileWidget*)this);
|
||||
AddRef();
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Ok's the dialog
|
||||
|
@ -295,60 +294,3 @@ nsFileWidget::~nsFileWidget()
|
|||
{
|
||||
}
|
||||
|
||||
#define GET_OUTER() ((nsFileWidget*) ((char*)this - nsFileWidget::GetOuterOffset()))
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
BASE_IWIDGET_IMPL_NO_SHOW(nsFileWidget, AggFileWidget);
|
||||
|
||||
void nsFileWidget::AggFileWidget::Create( nsIWidget *aParent,
|
||||
nsString& aTitle,
|
||||
nsMode aMode,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
void *aInitData)
|
||||
{
|
||||
GET_OUTER()->Create(aParent, aTitle, aMode, aContext, aAppShell, aToolkit, aInitData);
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::OnOk()
|
||||
{
|
||||
GET_OUTER()->OnOk();
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::OnCancel()
|
||||
{
|
||||
GET_OUTER()->OnCancel();
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::Show(PRBool bState)
|
||||
{
|
||||
GET_OUTER()->Show(bState);
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::GetFile(nsString& aFile)
|
||||
{
|
||||
GET_OUTER()->GetFile(aFile);
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::SetDefaultString(nsString& aFile)
|
||||
{
|
||||
GET_OUTER()->SetDefaultString(aFile);
|
||||
}
|
||||
|
||||
|
||||
void nsFileWidget::AggFileWidget::SetFilterList(PRUint32 aNumberOfFilters,
|
||||
const nsString aTitles[],
|
||||
const nsString aFilters[])
|
||||
{
|
||||
GET_OUTER()->SetFilterList(aNumberOfFilters, aTitles, aFilters);
|
||||
}
|
||||
|
||||
PRBool nsFileWidget::AggFileWidget::Show()
|
||||
{
|
||||
GET_OUTER()->Show(PR_TRUE);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,12 +28,17 @@
|
|||
* Native Motif FileSelector wrapper
|
||||
*/
|
||||
|
||||
class nsFileWidget : public nsWindow
|
||||
class nsFileWidget : public nsWindow, public nsIFileWidget
|
||||
{
|
||||
public:
|
||||
nsFileWidget(nsISupports *aOuter);
|
||||
nsFileWidget();
|
||||
virtual ~nsFileWidget();
|
||||
NS_IMETHOD QueryObject(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef();
|
||||
NS_IMETHOD_(nsrefcnt) Release();
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
|
@ -86,46 +91,6 @@ class nsFileWidget : public nsWindow
|
|||
|
||||
void GetFilterListArray(nsString& aFilterList);
|
||||
|
||||
private:
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsFileWidget,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIFileWidget interface to nsFileWidget w/o using multiple
|
||||
// inheritance.
|
||||
class AggFileWidget : public nsIFileWidget {
|
||||
public:
|
||||
AggFileWidget();
|
||||
virtual ~AggFileWidget();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
// nsIFileWidget
|
||||
virtual void Create( nsIWidget *aParent,
|
||||
nsString& aTitle,
|
||||
nsMode aMode,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
void *aInitData = nsnull);
|
||||
|
||||
virtual void GetFile(nsString& aFile);
|
||||
virtual void SetDefaultString(nsString& aString);
|
||||
virtual void SetFilterList(PRUint32 aNumberOfFilters,
|
||||
const nsString aTitles[],
|
||||
const nsString aFilters[]);
|
||||
|
||||
virtual PRBool Show();
|
||||
virtual void OnOk();
|
||||
virtual void OnCancel();
|
||||
};
|
||||
AggFileWidget mAggWidget;
|
||||
friend class AggFileWidget;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsFileWidget_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче