make nsButton.cpp compile. Initial nsWindow as well. The header file works,

the .cpp file doesn't compile yet ( it's still Motif )
This commit is contained in:
blizzard%appliedtheory.com 1998-10-31 16:19:33 +00:00
Родитель 3bbd8557f1
Коммит 6dfdf2c380
5 изменённых файлов: 1840 добавлений и 8 удалений

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

@ -24,8 +24,6 @@
#include "nsString.h" #include "nsString.h"
#include "nsStringUtil.h" #include "nsStringUtil.h"
#include "nsXtEventHandler.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
NS_IMPL_ADDREF(nsButton) NS_IMPL_ADDREF(nsButton)
@ -51,12 +49,12 @@ NS_METHOD nsButton::Create(nsIWidget *aParent,
nsWidgetInitData *aInitData) nsWidgetInitData *aInitData)
{ {
aParent->AddChild(this); aParent->AddChild(this);
GtkWidget parentWidget = nsnull; GtkWidget *parentWidget = nsnull;
if (aParent) { if (aParent) {
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); parentWidget = (GtkWidget *) aParent->GetNativeData(NS_NATIVE_WIDGET);
} else if (aAppShell) { } else if (aAppShell) {
parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); parentWidget = (GtkWidget *) aAppShell->GetNativeData(NS_NATIVE_SHELL);
} }
InitToolkit(aToolkit, aParent); InitToolkit(aToolkit, aParent);

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

@ -60,7 +60,8 @@ public:
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
virtual PRBool OnPaint(nsPaintEvent &aEvent); virtual PRBool OnPaint(nsPaintEvent &aEvent);
virtual PRBool OnResize(nsSizeEvent &aEvent); virtual PRBool OnResize(nsSizeEvent &aEvent);
private:
GtkWidget *mWidget;
}; };
#endif // nsButton_h__ #endif // nsButton_h__

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

@ -20,7 +20,7 @@
#define TOOLKIT_H #define TOOLKIT_H
#include "nsIToolkit.h" #include "nsIToolkit.h"
#include "X11/Xlib.h" #include <gtk/gtk.h>
struct MethodInfo; struct MethodInfo;
@ -41,7 +41,7 @@ public:
NS_IMETHOD Init(PRThread *aThread); NS_IMETHOD Init(PRThread *aThread);
public: public:
NS_IMETHOD_(GC) GetSharedGC(); NS_IMETHOD_(GdkGC) GetSharedGC();
NS_IMETHOD_(void) SetSharedGC(GdkGC aGC); NS_IMETHOD_(void) SetSharedGC(GdkGC aGC);
private: private:

1600
widget/src/gtk/nsWindow.cpp Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

233
widget/src/gtk/nsWindow.h Normal file
Просмотреть файл

@ -0,0 +1,233 @@
/* -*- 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 "nsISupports.h"
#include "nsToolkit.h"
#include "nsIWidget.h"
#include "nsIEnumerator.h"
#include "nsIAppShell.h"
#include "nsIMouseListener.h"
#include "nsIEventListener.h"
#include "nsString.h"
class nsFont;
#define NSRGB_2_COLOREF(color) \
RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
/**
* Native Motif window wrapper.
*/
class nsWindow : public nsIWidget
{
public:
// nsIWidget interface
nsWindow();
virtual ~nsWindow();
// nsISupports
NS_DECL_ISUPPORTS
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK; }
// 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);
NS_IMETHOD GetClientData(void*& aClientData);
NS_IMETHOD SetClientData(void* aClientData);
NS_IMETHOD Destroy();
virtual nsIWidget* GetParent(void);
virtual nsIEnumerator* GetChildren();
virtual void AddChild(nsIWidget* aChild);
virtual void RemoveChild(nsIWidget* aChild);
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);
virtual nscolor GetForegroundColor(void);
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
virtual nscolor GetBackgroundColor(void);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
virtual nsIFontMetrics* GetFont(void);
NS_IMETHOD SetFont(const nsFont &aFont);
virtual nsCursor GetCursor();
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);
virtual nsIRenderingContext* GetRenderingContext();
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
virtual nsIDeviceContext* GetDeviceContext();
virtual nsIAppShell * GetAppShell();
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
virtual nsIToolkit* GetToolkit();
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
NS_IMETHOD SetTitle(const nsString& aTitle);
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 AddMouseListener(nsIMouseListener * aListener);
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
NS_IMETHOD BeginResizingChildren(void);
NS_IMETHOD EndResizingChildren(void);
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
virtual PRBool IsChild() { return(PR_FALSE); };
// Utility methods
void SetBounds(const nsRect &aRect);
PRBool ConvertStatus(nsEventStatus aStatus);
virtual PRBool OnPaint(nsPaintEvent &event);
virtual void OnDestroy();
PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEvent);
PRBool DispatchFocus(nsGUIEvent &aEvent);
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
void SetIgnoreResize(PRBool aIgnore);
PRBool IgnoreResize();
PRUint32 GetYCoord(PRUint32 aNewY);
PRBool DispatchMouseEvent(nsMouseEvent& aEvent);
virtual PRBool OnResize(nsSizeEvent &aEvent);
// Resize event management
void SetResizeRect(nsRect& aRect);
void SetResized(PRBool aResized);
void GetResizeRect(nsRect* aRect);
PRBool GetResized();
char gInstanceClassName[256];
protected:
void InitCallbacks(char * aName = nsnull);
PRBool DispatchWindowEvent(nsGUIEvent* event);
void CreateGC();
void CreateWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
void CreateMainWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
void CreateChildWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
void InitToolkit(nsIToolkit *aToolkit, nsIWidget * aWidgetParent);
void InitDeviceContext(nsIDeviceContext *aContext, GtkWidget *aWidgetParent);
virtual void UpdateVisibilityFlag();
virtual void UpdateDisplay();
public:
protected:
EVENT_CALLBACK mEventCallback;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsToolkit *mToolkit;
nsIAppShell *mAppShell;
nsIMouseListener * mMouseListener;
nsIEventListener * mEventListener;
nscolor mBackground;
nscolor mForeground;
nsCursor mCursor;
nsBorderStyle mBorderStyle;
nsRect mBounds;
PRBool mIgnoreResize;
PRBool mShown;
PRBool mVisible;
PRBool mDisplayed;
void* mClientData;
// XXX Temporary, should not be caching the font
nsFont * mFont;
PRInt32 mPreferredWidth;
PRInt32 mPreferredHeight;
// Resize event management
nsRect mResizeRect;
int mResized;
PRBool mLowerLeft;
private:
};
//
// A child window is a window with different style
//
class ChildWindow : public nsWindow {
public:
ChildWindow() {};
virtual PRBool IsChild() { return(PR_TRUE); };
};
#endif // Window_h__