Remove old native widget code that we were only keeping around for viewer. b=326417 r+sr=roc

This commit is contained in:
dbaron%dbaron.org 2006-02-08 20:09:19 +00:00
Родитель f58434d78e
Коммит 00eb53b26a
40 изменённых файлов: 0 добавлений и 2989 удалений

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

@ -54,9 +54,6 @@
#include "nsIFormControl.h"
#include "nsIDeviceContext.h"
#include "nsHTMLAtoms.h"
#include "nsIButton.h" // remove this when GetCID is pure virtual
#include "nsICheckButton.h" //remove this
#include "nsITextWidget.h" //remove this
#include "nsISupports.h"
#include "nsStyleConsts.h"
#include "nsUnitConversion.h"
@ -520,24 +517,6 @@ nsFormControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
}
/*
* FIXME: this ::GetIID() method has no meaning in life and should be
* removed.
* Pierre Phaneuf <pp@ludusdesign.com>
*/
const nsIID&
nsFormControlFrame::GetIID()
{
return NS_GET_IID(nsIButton);
}
const nsIID&
nsFormControlFrame::GetCID()
{
static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID);
return kButtonCID;
}
NS_METHOD
nsFormControlFrame::HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent,

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

@ -125,18 +125,6 @@ public:
// new behavior
/**
* Get the class id of the widget associated with this frame
* @return the class id
*/
virtual const nsIID& GetCID();
/**
* Get the interface id of widget associated with this frame
* @return the interface id
*/
virtual const nsIID& GetIID();
/**
* Respond to a enter key being pressed
*/

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

@ -55,9 +55,6 @@
#include "nsIFormControl.h"
#include "nsIDeviceContext.h"
#include "nsHTMLAtoms.h"
#include "nsIButton.h" // remove this when GetCID is pure virtual
#include "nsICheckButton.h" //remove this
#include "nsITextWidget.h" //remove this
#include "nsISupports.h"
#include "nsStyleConsts.h"
#include "nsUnitConversion.h"

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

@ -36,7 +36,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsGfxButtonControlFrame.h"
#include "nsIButton.h"
#include "nsWidgetsCID.h"
#include "nsIFontMetrics.h"
#include "nsFormControlFrame.h"
@ -95,24 +94,6 @@ nsGfxButtonControlFrame::IsFileBrowseButton(PRInt32 type)
return rv;
}
/*
* FIXME: this ::GetIID() method has no meaning in life and should be
* removed.
* Pierre Phaneuf <pp@ludusdesign.com>
*/
const nsIID&
nsGfxButtonControlFrame::GetIID()
{
return NS_GET_IID(nsIButton);
}
const nsIID&
nsGfxButtonControlFrame::GetCID()
{
static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID);
return kButtonCID;
}
#ifdef DEBUG
NS_IMETHODIMP
nsGfxButtonControlFrame::GetFrameName(nsAString& aResult) const

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

@ -64,8 +64,6 @@ public:
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual const nsIID& GetCID();
virtual const nsIID& GetIID();
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent,

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

@ -36,7 +36,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsGfxCheckboxControlFrame.h"
#include "nsICheckButton.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLParts.h"
#include "nsIFormControl.h"

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

@ -54,9 +54,6 @@ EXPORTS = \
nsStringUtil.h \
nsIWidget.h \
nsIKBStateControl.h \
nsIButton.h \
nsICheckButton.h \
nsITextWidget.h \
nsGUIEvent.h \
nsEvent.h \
nsIMouseListener.h \
@ -64,7 +61,6 @@ EXPORTS = \
nsIMenuListener.h \
nsWidgetsCID.h \
nsILookAndFeel.h \
nsILabel.h \
nsIDragSessionGTK.h \
nsIDragSessionXlib.h \
nsIDragSessionMac.h \

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

@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIButton_h__
#define nsIButton_h__
#include "nsIWidget.h"
#include "nsString.h"
// {18032AD0-B265-11d1-AA2A-000000000000}
#define NS_IBUTTON_IID \
{ 0x18032ad0, 0xb265, 0x11d1, \
{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
/**
* Push button widget.
* Automatically shows itself as depressed when clicked on.
*/
class nsIButton : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IBUTTON_IID)
/**
* Set the label
*
* @param Set the label to aText
* @result NS_Ok if no errors
*/
NS_IMETHOD SetLabel(const nsString &aText) = 0;
/**
* Get the button label
*
* @param aBuffer contains label upon return
* @result NS_Ok if no errors
*/
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIButton, NS_IBUTTON_IID)
#endif

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

@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsICheckButton_h__
#define nsICheckButton_h__
// {961085F5-BD28-11d1-97EF-00609703C14E}
#define NS_ICHECKBUTTON_IID \
{ 0x961085f5, 0xbd28, 0x11d1, { 0x97, 0xef, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
#include "nsISupports.h"
#include "nsIWidget.h"
/**
* Checkbox widget.
* Can show itself in a checked or unchecked state.
* The checkbox widget does not automatically show itself checked or unchecked when clicked on.
*/
class nsICheckButton : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICHECKBUTTON_IID)
/**
* Set the button label
*
* @param aText button label
* @result set to NS_OK if method successful
*/
NS_IMETHOD SetLabel(const nsString &aText) = 0;
/**
* Get the button label
*
* @param aBuffer contains label upon return
* @result set to NS_OK if method successful
*/
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
/**
* Set the check state.
* @param aState PR_TRUE show as checked. PR_FALSE show unchecked.
* @result set to NS_OK if method successful
*/
NS_IMETHOD SetState(const PRBool aState) = 0;
/**
* Get the check state.
* @param aState PR_TRUE if checked. PR_FALSE if unchecked.
* @result set to NS_OK if method successful
*/
NS_IMETHOD GetState(PRBool& aState) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICheckButton, NS_ICHECKBUTTON_IID)
#endif // nsICheckButton_h__

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

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsILabel_h__
#define nsILabel_h__
#include "nsIWidget.h"
#include "nsString.h"
/* F3131891-3DC7-11d2-8DB8-00609703C14E */
#define NS_ILABEL_IID \
{ 0xf3131891, 0x3dc7, 0x11d2, \
{ 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
/**
* Label Alignments
*/
enum nsLabelAlignment {
eAlign_Right,
eAlign_Left,
eAlign_Center
};
struct nsLabelInitData : public nsWidgetInitData {
nsLabelInitData()
: mAlignment(eAlign_Left)
{
}
nsLabelAlignment mAlignment;
};
/**
* Label widget.
* Automatically shows itself as depressed when clicked on.
*/
class nsILabel : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILABEL_IID)
/**
* Set the label
*
* @param Set the label to aText
* @result NS_Ok if no errors
*/
NS_IMETHOD SetLabel(const nsString &aText) = 0;
/**
* Get the button label
*
* @param aBuffer contains label upon return
* @result NS_Ok if no errors
*/
NS_IMETHOD GetLabel(nsString &aBuffer) = 0;
/**
* Set the Label Alignemnt for creation
*
* @param aAlignment the alignment
* @result NS_Ok if no errors
*/
NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsILabel, NS_ILABEL_IID)
#endif

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

@ -1,196 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsITextWidget_h__
#define nsITextWidget_h__
#include "nsIWidget.h"
#include "nsString.h"
// {F8030011-C342-11d1-97F0-00609703C14E}
#define NS_ITEXTWIDGET_IID \
{ 0xf8030011, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
struct nsTextWidgetInitData : public nsWidgetInitData {
nsTextWidgetInitData()
: mIsPassword(PR_FALSE),
mIsReadOnly(PR_FALSE)
{
}
PRBool mIsPassword;
PRBool mIsReadOnly;
};
/**
*
* Single line text editor.
* Unlike a nsIWidget, The text editor must automatically clear
* itself to the background color when paint messages are generated.
*
*/
class nsITextWidget : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTWIDGET_IID)
/**
* Get the text of this component.
*
* @param aTextBuffer on return contains the text of this component
* @param aBufferSize the size of the buffer passed in
* @param aActualSize the number of char copied
* @result NS_Ok if no errors
*
*/
NS_IMETHOD GetText(nsString &aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) = 0;
/**
* Set the text of this component.
*
* @param aText -- an object containing a copy of the text
* @return the number of chars in the text string
* @result NS_Ok if no errors
*
*/
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize) = 0;
/**
* Insert text into this component.
* When aStartPos and aEndPos are a valid range this function performs a replace.
* When aStartPos and aEndPos are equal this function performs an insert.
* When aStartPos and aEndPos are both -1 (0xFFFFFFFF) this function performs an append.
* If aStartPos and aEndPos are out of range they are rounded to the closest end.
*
* @param aText the text to set
* @param aStartPos starting position for inserting text
* @param aEndPos ending position for inserting text
* @result NS_Ok if no errors
*/
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) = 0;
/**
* Remove any content from this text widget
* @result NS_Ok if no errors
*/
NS_IMETHOD RemoveText(void) = 0;
/**
* Indicates a password will be entered.
*
* @param aIsPassword PR_TRUE shows contents as asterisks. PR_FALSE shows
* contents as normal text.
* @result NS_Ok if no errors
*/
NS_IMETHOD SetPassword(PRBool aIsPassword) = 0;
/**
* Sets the maximum number of characters the widget can hold
*
* @param aChars maximum number of characters for this widget. if 0 then there isn't any limit
* @result NS_Ok if no errors
*/
NS_IMETHOD SetMaxTextLength(PRUint32 aChars) = 0;
/**
* Set the text widget to be read-only
*
* @param aReadOnlyFlag PR_TRUE the widget is read-only,
* PR_FALSE indicates the widget is writable.
* @param PR_TRUE if it was read only. PR_FALSE if it was writable
* @result NS_Ok if no errors
*/
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag) = 0;
/**
* Select all of the contents
* @result NS_Ok if no errors
*/
NS_IMETHOD SelectAll() = 0;
/**
* Set the selection in this text component
* @param aStartSel starting selection position in characters
* @param aEndSel ending selection position in characters
* @result NS_Ok if no errors
*/
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) = 0;
/**
* Get the selection in this text component
* @param aStartSel starting selection position in characters
* @param aEndSel ending selection position in characters
* @result NS_Ok if no errors
*/
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) = 0;
/**
* Set the caret position
* @param aPosition caret position in characters
* @result NS_Ok if no errors
*/
NS_IMETHOD SetCaretPosition(PRUint32 aPosition) = 0;
/**
* Get the caret position
* @return caret position in characters
* @result NS_Ok if no errors
*/
NS_IMETHOD GetCaretPosition(PRUint32& aPosition) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsITextWidget, NS_ITEXTWIDGET_IID)
#endif // nsITextWidget_h__

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

@ -52,41 +52,15 @@
{ 0xba7de611, 0x6088, 0x11d3, \
{ 0xa8, 0x3e, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
/* 2d96b3d2-c051-11d1-a827-0040959a28c9 */
#define NS_BUTTON_CID \
{ 0x2d96b3d2, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
/* 2d96b3d3-c051-11d1-a827-0040959a28c9 */
#define NS_CHECKBUTTON_CID \
{ 0x2d96b3d3, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
/* bd57cee8-1dd1-11b2-9fe7-95cf4709aea3 */
#define NS_FILEPICKER_CID \
{ 0xbd57cee8, 0x1dd1, 0x11b2, \
{0x9f, 0xe7, 0x95, 0xcf, 0x47, 0x09, 0xae, 0xa3} }
/* 2d96b3d9-c051-11d1-a827-0040959a28c9 */
#define NS_HORZSCROLLBAR_CID \
{ 0x2d96b3d9, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
/* 2d96b3da-c051-11d1-a827-0040959a28c9 */
#define NS_VERTSCROLLBAR_CID \
{ 0x2d96b3da, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
// {c2281100-3b4b-11d6-a384-f705fd0766fc}
#define NS_NATIVESCROLLBAR_CID \
{ 0xc2281100, 0x3b4b, 0x11d6, { 0xa3, 0x84, 0xf7, 0x05, 0xfd, 0x07, 0x66, 0xfc } }
/* 2d96b3dc-c051-11d1-a827-0040959a28c9 */
#define NS_TEXTFIELD_CID \
{ 0x2d96b3dc, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
/* 2d96b3df-c051-11d1-a827-0040959a28c9 */
#define NS_APPSHELL_CID \
{ 0x2d96b3df, 0xc051, 0x11d1, \
@ -105,16 +79,6 @@
{ 0xa61e6398, 0x2057, 0x40fd, \
{ 0x9c, 0x81, 0x87, 0x3b, 0x90, 0x8d, 0x24, 0xe7 } }
/* 4A781D61-3D28-11d2-8DB8-00609703C14E */
#define NS_DIALOG_CID \
{ 0x4a781d61, 0x3d28, 0x11d2, \
{ 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
/* F3131891-3DC7-11d2-8DB8-00609703C14E */
#define NS_LABEL_CID \
{ 0xf3131891, 0x3dc7, 0x11d2, \
{ 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
//-----------------------------------------------------------
// Menus
//-----------------------------------------------------------

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

@ -40,129 +40,16 @@
#include "nsWidgetSupport.h"
#include "nsRect.h"
#include "nsIAppShell.h"
#include "nsIButton.h"
#include "nsIEventListener.h"
#include "nsILabel.h"
#include "nsILookAndFeel.h"
#include "nsIMouseListener.h"
#include "nsIToolkit.h"
#include "nsIWidget.h"
#include "nsICheckButton.h"
#include "nsITextWidget.h"
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
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_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_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;
}
extern NS_WIDGET nsresult
NS_ShowWidget(nsISupports* aWidget, PRBool aShow)
{

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

@ -80,18 +80,13 @@ CSRCS = \
CPPSRCS = \
nsAppShell.cpp \
nsBidiKeyboard.cpp \
nsButton.cpp \
nsCheckButton.cpp \
nsClipboard.cpp \
nsDragService.cpp \
nsGtkEventHandler.cpp \
nsGtkUtils.cpp \
nsKeyboardUtils.cpp \
nsLabel.cpp \
nsLookAndFeel.cpp \
nsSound.cpp \
nsTextHelper.cpp \
nsTextWidget.cpp \
nsToolkit.cpp \
nsWidget.cpp \
nsWidgetFactory.cpp \

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

@ -1,163 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <gtk/gtk.h>
#include "nsGtkEventHandler.h"
#include "nsButton.h"
#include "nsString.h"
NS_IMPL_ADDREF_INHERITED(nsButton, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsButton, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsButton, nsIButton, nsIWidget)
//-------------------------------------------------------------------------
//
// nsButton constructor
//
//-------------------------------------------------------------------------
nsButton::nsButton() : nsWidget() , nsIButton()
{
}
//-------------------------------------------------------------------------
//
// Create the native Button widget
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsButton::CreateNative(GtkObject *parentWindow)
{
if (!GDK_IS_SUPERWIN(parentWindow)) {
#ifdef DEBUG
g_print("Damn, brother. That's not a superwin.\n");
#endif
return NS_ERROR_FAILURE;
}
GdkSuperWin *superwin = GDK_SUPERWIN(parentWindow);
mMozBox = gtk_mozbox_new(superwin->bin_window);
mWidget = gtk_button_new_with_label("");
gtk_widget_set_name(mWidget, "nsButton");
// make sure that we put the scrollbar into the mozbox
gtk_container_add(GTK_CONTAINER(mMozBox), mWidget);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// nsButton destructor
//
//-------------------------------------------------------------------------
nsButton::~nsButton()
{
}
void nsButton::InitCallbacks(char * aName)
{
InstallButtonPressSignal(mWidget);
InstallButtonReleaseSignal(mWidget);
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsButton::SetLabel(const nsString& aText)
{
gtk_label_set(GTK_LABEL(GTK_BIN (mWidget)->child),
NS_LossyConvertUTF16toASCII(aText).get());
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsButton::GetLabel(nsString& aBuffer)
{
char * text;
gtk_label_get(GTK_LABEL(GTK_BIN (mWidget)->child), &text);
aBuffer.SetLength(0);
aBuffer.AppendWithConversion(text);
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// set font for button
//
//-------------------------------------------------------------------------
/* virtual */
void nsButton::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(GTK_BIN (mWidget)->child->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(GTK_BIN (mWidget)->child, style);
gtk_style_unref(style);
}

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

@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsButton_h__
#define nsButton_h__
#include "nsWidget.h"
#include "nsIButton.h"
/**
* Native GTK+ button wrapper
*/
class nsButton : public nsWidget,
public nsIButton
{
public:
nsButton();
virtual ~nsButton();
NS_DECL_ISUPPORTS_INHERITED
// nsIButton part
NS_IMETHOD SetLabel(const nsString& aText);
NS_IMETHOD GetLabel(nsString& aBuffer);
virtual void SetFontNative(GdkFont *aFont);
protected:
NS_METHOD CreateNative(GtkObject *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);
};
#endif // nsButton_h__

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

@ -1,263 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCheckButton.h"
#include "nsString.h"
NS_IMPL_ADDREF_INHERITED(nsCheckButton, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsCheckButton, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsCheckButton, nsICheckButton, nsIWidget)
//-------------------------------------------------------------------------
//
// nsCheckButton constructor
//
//-------------------------------------------------------------------------
nsCheckButton::nsCheckButton() : nsWidget() , nsICheckButton()
{
mLabel = nsnull;
mCheckButton = nsnull;
mState = PR_FALSE;
}
//-------------------------------------------------------------------------
//
// nsCheckButton destructor
//
//-------------------------------------------------------------------------
nsCheckButton::~nsCheckButton()
{
}
void
nsCheckButton::OnDestroySignal(GtkWidget* aGtkWidget)
{
if (aGtkWidget == mCheckButton) {
mCheckButton = nsnull;
}
else if (aGtkWidget == mLabel) {
mLabel = nsnull;
}
else {
nsWidget::OnDestroySignal(aGtkWidget);
}
}
//-------------------------------------------------------------------------
//
// Create the native CheckButton widget
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::CreateNative(GtkObject *parentWindow)
{
mWidget = gtk_event_box_new();
mCheckButton = gtk_check_button_new();
gtk_container_add(GTK_CONTAINER(mWidget), mCheckButton);
gtk_widget_show(mCheckButton);
gtk_widget_set_name(mWidget, "nsCheckButton");
return NS_OK;
}
void nsCheckButton::InitCallbacks(char * aName)
{
InstallButtonPressSignal(mCheckButton);
InstallButtonReleaseSignal(mCheckButton);
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
// Add in destroy callback
gtk_signal_connect(GTK_OBJECT(mCheckButton),
"destroy",
GTK_SIGNAL_FUNC(DestroySignal),
this);
InstallSignal((GtkWidget *)mCheckButton,
(gchar *)"toggled",
GTK_SIGNAL_FUNC(nsCheckButton::ToggledSignal));
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetState(const PRBool aState)
{
mState = aState;
if (mWidget && mCheckButton)
{
GtkToggleButton * item = GTK_TOGGLE_BUTTON(mCheckButton);
item->active = (gboolean) mState;
gtk_widget_queue_draw(GTK_WIDGET(item));
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetState(PRBool& aState)
{
aState = mState;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set this Checkbox label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
{
if (mWidget) {
NS_LossyConvertUTF16toASCII label(aText);
if (mLabel) {
gtk_label_set(GTK_LABEL(mLabel), label.get());
} else {
mLabel = gtk_label_new(label.get());
gtk_misc_set_alignment (GTK_MISC (mLabel), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(mCheckButton), mLabel);
gtk_widget_show(mLabel);
gtk_signal_connect(GTK_OBJECT(mLabel),
"destroy",
GTK_SIGNAL_FUNC(DestroySignal),
this);
}
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer)
{
aBuffer.SetLength(0);
if (mWidget) {
char * text;
if (mLabel) {
gtk_label_get(GTK_LABEL(mLabel), &text);
aBuffer.AppendWithConversion(text);
}
}
return NS_OK;
}
/* virtual */ void
nsCheckButton::OnToggledSignal(const gboolean aState)
{
// Untoggle the sonofabitch
if (mWidget && mCheckButton)
{
GtkToggleButton * item = GTK_TOGGLE_BUTTON(mCheckButton);
item->active = !item->active;
gtk_widget_queue_draw(GTK_WIDGET(item));
}
}
//////////////////////////////////////////////////////////////////////
/* static */ gint
nsCheckButton::ToggledSignal(GtkWidget * aWidget,
gpointer aData)
{
NS_ASSERTION( nsnull != aWidget, "widget is null");
nsCheckButton * button = (nsCheckButton *) aData;
NS_ASSERTION( nsnull != button, "instance pointer is null");
button->OnToggledSignal(GTK_TOGGLE_BUTTON(aWidget)->active);
return PR_TRUE;
}
//////////////////////////////////////////////////////////////////////
// SetBackgroundColor for CheckButton
/*virtual*/
void nsCheckButton::SetBackgroundColorNative(GdkColor *aColorNor,
GdkColor *aColorBri,
GdkColor *aColorDark)
{
// use same style copy as SetFont
GtkStyle *style = gtk_style_copy(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0))->style);
style->bg[GTK_STATE_NORMAL]=*aColorNor;
// Mouse over button
style->bg[GTK_STATE_PRELIGHT]=*aColorBri;
// Button is down
style->bg[GTK_STATE_ACTIVE]=*aColorDark;
// other states too? (GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT,
// GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE)
gtk_widget_set_style(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0)), style);
// set style for eventbox too
gtk_widget_set_style(mWidget, style);
gtk_style_unref(style);
}

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

@ -1,90 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCheckButton_h__
#define nsCheckButton_h__
#include "nsWidget.h"
#include "nsICheckButton.h"
/**
* Native GTK+ Checkbox wrapper
*/
class nsCheckButton : public nsWidget,
public nsICheckButton
{
public:
nsCheckButton();
virtual ~nsCheckButton();
NS_DECL_ISUPPORTS_INHERITED
// nsICheckButton part
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetState(const PRBool aState);
NS_IMETHOD GetState(PRBool& aState);
virtual void OnToggledSignal(const gboolean aState);
protected:
NS_IMETHOD CreateNative(GtkObject *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);
virtual void OnDestroySignal(GtkWidget* aGtkWidget);
// Sets background for checkbutton
virtual void SetBackgroundColorNative(GdkColor *aColorNor,
GdkColor *aColorBri,
GdkColor *aColorDark);
GtkWidget *mLabel;
GtkWidget *mCheckButton;
// We need to maintain our own state to be in sync with the
// gecko check controlling frame.
PRBool mState;
private:
static gint ToggledSignal(GtkWidget * aWidget,
gpointer aData);
};
#endif // nsCheckButton_h__

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

@ -1,155 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* <bstell@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <gtk/gtk.h>
#include "nsLabel.h"
#include "nsString.h"
NS_IMPL_ADDREF_INHERITED(nsLabel, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsLabel, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsLabel, nsILabel, nsIWidget)
//-------------------------------------------------------------------------
//
// nsLabel constructor
//
//-------------------------------------------------------------------------
nsLabel::nsLabel() : nsWidget(), nsILabel()
{
mAlignment = eAlign_Left;
}
//-------------------------------------------------------------------------
//
// nsLabel destructor
//
//-------------------------------------------------------------------------
nsLabel::~nsLabel()
{
}
//-------------------------------------------------------------------------
//
// Create the nativeLabel widget
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsLabel::CreateNative(GtkObject *parentWindow)
{
unsigned char alignment = GetNativeAlignment();
mWidget = gtk_label_new("");
gtk_widget_set_name(mWidget, "nsLabel");
gtk_misc_set_alignment(GTK_MISC(mWidget), 0.0, alignment);
return NS_OK;
}
//-------------------------------------------------------------------------
//
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsLabel::PreCreateWidget(nsWidgetInitData *aInitData)
{
if (nsnull != aInitData) {
nsLabelInitData* data = (nsLabelInitData *) aInitData;
mAlignment = data->mAlignment;
}
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set alignment
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsLabel::SetAlignment(nsLabelAlignment aAlignment)
{
GtkJustification align;
mAlignment = aAlignment;
align = GetNativeAlignment();
gtk_misc_set_alignment(GTK_MISC(mWidget), 0.0, align);
return NS_OK;
}
//-------------------------------------------------------------------------
//
//
//
//-------------------------------------------------------------------------
GtkJustification nsLabel::GetNativeAlignment()
{
switch (mAlignment) {
case eAlign_Right : return GTK_JUSTIFY_RIGHT;
case eAlign_Left : return GTK_JUSTIFY_LEFT;
case eAlign_Center: return GTK_JUSTIFY_CENTER;
default :
return GTK_JUSTIFY_LEFT;
}
return GTK_JUSTIFY_LEFT;
}
//-------------------------------------------------------------------------
//
// Set this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsLabel::SetLabel(const nsString& aText)
{
gtk_label_set(GTK_LABEL(mWidget),
NS_LossyConvertUTF16toASCII(aText).get());
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this button label
//
//-------------------------------------------------------------------------
NS_METHOD nsLabel::GetLabel(nsString& aBuffer)
{
char * text;
gtk_label_get(GTK_LABEL(mWidget), &text);
aBuffer.SetLength(0);
aBuffer.AppendWithConversion(text);
return NS_OK;
}

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

@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsLabel_h__
#define nsLabel_h__
#include "nsWidget.h"
#include "nsILabel.h"
/**
* Native GTK+ Label wrapper
*/
class nsLabel : public nsWidget,
public nsILabel
{
public:
nsLabel();
virtual ~nsLabel();
NS_DECL_ISUPPORTS_INHERITED
// nsILabel part
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; }
virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; }
protected:
NS_METHOD CreateNative(GtkObject *parentWindow);
GtkJustification GetNativeAlignment();
nsLabelAlignment mAlignment;
};
#endif // nsLabel_h__

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

@ -1,231 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <gtk/gtk.h>
#include "nsTextHelper.h"
#include "nsTextWidget.h"
#include "nsString.h"
NS_IMPL_ADDREF_INHERITED(nsTextHelper, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsTextHelper, nsWidget)
//-------------------------------------------------------------------------
//
// nsTextHelper constructor
//
//-------------------------------------------------------------------------
nsTextHelper::nsTextHelper() : nsWidget(), nsITextWidget()
{
mIsReadOnly = PR_FALSE;
mIsPassword = PR_FALSE;
}
//-------------------------------------------------------------------------
//
// nsTextHelper destructor
//
//-------------------------------------------------------------------------
nsTextHelper::~nsTextHelper()
{
}
//-------------------------------------------------------------------------
//
// Set initial parameters
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::PreCreateWidget(nsWidgetInitData *aInitData)
{
if (nsnull != aInitData) {
nsTextWidgetInitData* data = (nsTextWidgetInitData *) aInitData;
mIsPassword = data->mIsPassword;
mIsReadOnly = data->mIsReadOnly;
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SetMaxTextLength(PRUint32 aChars)
{
// This is a normal entry only thing, not a text box
gtk_entry_set_max_length(GTK_ENTRY(mTextWidget), (int)aChars);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize)
{
char *str = nsnull;
if (GTK_IS_ENTRY(mTextWidget))
{
str = gtk_entry_get_text(GTK_ENTRY(mTextWidget));
}
else if (GTK_IS_TEXT(mTextWidget))
{
str = gtk_editable_get_chars (GTK_EDITABLE (mTextWidget), 0,
gtk_text_get_length (GTK_TEXT (mTextWidget)));
}
aTextBuffer.SetLength(0);
aTextBuffer.AppendWithConversion(str);
PRUint32 len = (PRUint32)strlen(str);
aActualSize = len;
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SetText(const nsString& aText, PRUint32& aActualSize)
{
if (GTK_IS_ENTRY(mTextWidget)) {
gtk_entry_set_text(GTK_ENTRY(mTextWidget),
(const gchar *)NS_LossyConvertUTF16toASCII(aText).get());
} else if (GTK_IS_TEXT(mTextWidget)) {
gtk_editable_delete_text(GTK_EDITABLE(mTextWidget), 0,
gtk_text_get_length(GTK_TEXT (mTextWidget)));
gtk_text_insert(GTK_TEXT(mTextWidget),
nsnull, nsnull, nsnull,
NS_LossyConvertUTF16toASCII(aText).get(),
aText.Length());
}
aActualSize = aText.Length();
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::InsertText(const nsString &aText,
PRUint32 aStartPos,
PRUint32 aEndPos,
PRUint32& aActualSize)
{
gtk_editable_insert_text(GTK_EDITABLE(mTextWidget),
(const gchar *)NS_LossyConvertUTF16toASCII(aText).get(),
(gint)aText.Length(), (gint*)&aStartPos);
aActualSize = aText.Length();
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::RemoveText()
{
if (GTK_IS_ENTRY(mTextWidget)) {
gtk_entry_set_text(GTK_ENTRY(mTextWidget), "");
} else if (GTK_IS_TEXT(mTextWidget)) {
gtk_editable_delete_text(GTK_EDITABLE(mTextWidget), 0,
gtk_text_get_length(GTK_TEXT (mTextWidget)));
}
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SetPassword(PRBool aIsPassword)
{
mIsPassword = aIsPassword?PR_FALSE:PR_TRUE;
if (GTK_IS_ENTRY(mTextWidget)) {
gtk_entry_set_visibility(GTK_ENTRY(mTextWidget), mIsPassword);
}
// this won't work for gtk_texts
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldReadOnlyFlag)
{
NS_ASSERTION(nsnull != mTextWidget,
"SetReadOnly - Widget is NULL, Create may not have been called!");
aOldReadOnlyFlag = mIsReadOnly;
mIsReadOnly = aReadOnlyFlag?PR_FALSE:PR_TRUE;
gtk_editable_set_editable(GTK_EDITABLE(mTextWidget), mIsReadOnly);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SelectAll()
{
nsString text;
PRUint32 actualSize = 0;
PRUint32 numChars = GetText(text, 0, actualSize);
SetSelection(0, numChars);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
{
gtk_editable_select_region(GTK_EDITABLE(mTextWidget), aStartSel, aEndSel);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
{
#if 0
XmTextPosition left;
XmTextPosition right;
if (XmTextGetSelectionPosition(mTextWidget, &left, &right)) {
*aStartSel = (PRUint32)left;
*aEndSel = (PRUint32)right;
} else {
printf("nsTextHelper::GetSelection Error getting positions\n");
return NS_ERROR_FAILURE;
}
#endif
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::SetCaretPosition(PRUint32 aPosition)
{
gtk_editable_set_position(GTK_EDITABLE(mTextWidget), aPosition);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextHelper::GetCaretPosition(PRUint32& aPosition)
{
aPosition = (PRUint32)GTK_EDITABLE(mTextWidget)->current_pos;
return NS_OK;
}

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

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTextHelper_h__
#define nsTextHelper_h__
#include "nsITextWidget.h"
#include "nsWidget.h"
/**
* Base class for nsTextAreaWidget (obsolete) and nsTextWidget
*/
class nsTextHelper : public nsWidget,
public nsITextWidget
{
public:
nsTextHelper();
virtual ~nsTextHelper();
// nsISupports
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
NS_IMETHOD SelectAll();
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
NS_IMETHOD SetMaxTextLength(PRUint32 aChars);
NS_IMETHOD GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize);
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize);
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize);
NS_IMETHOD RemoveText();
NS_IMETHOD SetPassword(PRBool aIsPassword);
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag);
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
NS_IMETHOD SetCaretPosition(PRUint32 aPosition);
NS_IMETHOD GetCaretPosition(PRUint32& aPosition);
protected:
GtkWidget *mTextWidget;
PRBool mIsPassword;
PRBool mIsReadOnly;
};
#endif // nsTextHelper_h__

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

@ -1,139 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <gtk/gtk.h>
#include "nsTextWidget.h"
#include "nsString.h"
#include "nsGtkEventHandler.h"
extern int mIsPasswordCallBacksInstalled;
NS_IMPL_ADDREF_INHERITED(nsTextWidget, nsWidget)
NS_IMPL_RELEASE_INHERITED(nsTextWidget, nsWidget)
NS_IMPL_QUERY_INTERFACE2(nsTextWidget, nsITextWidget, nsIWidget)
//-------------------------------------------------------------------------
//
// nsTextWidget constructor
//
//-------------------------------------------------------------------------
nsTextWidget::nsTextWidget() : nsTextHelper()
{
}
//-------------------------------------------------------------------------
//
// nsTextWidget destructor
//
//-------------------------------------------------------------------------
nsTextWidget::~nsTextWidget()
{
// avoid freeing this twice in other destructors
mTextWidget = nsnull;
}
//-------------------------------------------------------------------------
//
// Create the native Entry widget
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsTextWidget::CreateNative(GtkObject *parentWindow)
{
PRBool oldIsReadOnly;
mWidget = gtk_entry_new();
if (!GDK_IS_SUPERWIN(parentWindow)) {
#ifdef DEBUG
g_print("Damn, brother. That's not a superwin.\n");
#endif
return NS_ERROR_FAILURE;
}
GdkSuperWin *superwin = GDK_SUPERWIN(parentWindow);
mMozBox = gtk_mozbox_new(superwin->bin_window);
// used by nsTextHelper because nsTextArea needs a scrolled_window
mTextWidget = mWidget;
gtk_widget_set_name(mWidget, "nsTextWidget");
/*
* GTK's text widget does XIM for us, so we don't want to use the default key handler
* which does XIM, so we connect to a non-XIM key event for the text widget
*/
gtk_signal_connect_after(GTK_OBJECT(mWidget),
"key_press_event",
GTK_SIGNAL_FUNC(handle_key_press_event_for_text),
this);
gtk_signal_connect(GTK_OBJECT(mWidget),
"key_release_event",
GTK_SIGNAL_FUNC(handle_key_release_event_for_text),
this);
SetPassword(mIsPassword);
SetReadOnly(mIsReadOnly, oldIsReadOnly);
gtk_widget_show(mWidget);
// These are needed so that the events will go to us and not our parent.
AddToEventMask(mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
// make sure that we put the scrollbar into the mozbox
gtk_container_add(GTK_CONTAINER(mMozBox), mWidget);
return NS_OK;
}
PRBool nsTextWidget::OnKey(nsKeyEvent &aEvent)
{
if (mEventCallback) {
return DispatchWindowEvent(&aEvent);
}
return PR_FALSE;
}

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

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTextWidget_h__
#define nsTextWidget_h__
#include "nsTextHelper.h"
#include "nsITextWidget.h"
/**
* Native GTK+ single line edit control wrapper.
*/
class nsTextWidget : public nsTextHelper
{
public:
nsTextWidget();
virtual ~nsTextWidget();
NS_DECL_ISUPPORTS_INHERITED
PRBool OnKey(nsKeyEvent &aEvent);
protected:
NS_IMETHOD CreateNative(GtkObject *parentWindow);
};
#endif // nsTextWidget_h__

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

@ -44,13 +44,9 @@
#include "nsWidgetsCID.h"
#include "nsWindow.h"
#include "nsButton.h"
#include "nsCheckButton.h"
#include "nsTextWidget.h"
#include "nsAppShell.h"
#include "nsToolkit.h"
#include "nsLookAndFeel.h"
#include "nsLabel.h"
#include "nsTransferable.h"
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
@ -67,13 +63,9 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
@ -96,18 +88,6 @@ static const nsModuleComponentInfo components[] =
NS_CHILD_CID,
"@mozilla.org/widgets/child_window/gtk;1",
ChildWindowConstructor },
{ "Gtk Button",
NS_BUTTON_CID,
"@mozilla.org/widgets/button/gtk;1",
nsButtonConstructor },
{ "Gtk Check Button",
NS_CHECKBUTTON_CID,
"@mozilla.org/widgets/checkbutton/gtk;1",
nsCheckButtonConstructor },
{ "Gtk Text Widget",
NS_TEXTFIELD_CID,
"@mozilla.org/widgets/textwidget/gtk;1",
nsTextWidgetConstructor },
{ "Gtk AppShell",
NS_APPSHELL_CID,
"@mozilla.org/widget/appshell/gtk;1",
@ -120,10 +100,6 @@ static const nsModuleComponentInfo components[] =
NS_LOOKANDFEEL_CID,
"@mozilla.org/widget/lookandfeel;1",
nsLookAndFeelConstructor },
{ "Gtk Label",
NS_LABEL_CID,
"@mozilla.org/widget/label/gtk;1",
nsLabelConstructor },
{ "Gtk Sound",
NS_SOUND_CID,
// "@mozilla.org/widget/sound/gtk;1"

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

@ -66,31 +66,9 @@
#include "nsNativeThemeMac.h"
#include "nsScreenManagerMac.h"
#if USE_NATIVE_VERSION
#include "nsIButton.h"
#include "nsITextWidget.h"
#include "nsButton.h"
#include "nsCheckButton.h"
#include "nsTextWidget.h"
#include "nsLabel.h"
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
#if USE_NATIVE_VERSION
NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsComboBox)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRadioButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsListBox)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextAreaWidget)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) // used by Viewer?
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
@ -111,20 +89,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac)
static const nsModuleComponentInfo gComponents[] =
{
#if USE_NATIVE_VERSION
{ "Text Field",
NS_TEXTFIELD_CID,
"@mozilla.org/widgets/textwidget/mac;1",
nsTextWidgetConstructor },
{ "Label",
NS_LABEL_CID,
"@mozilla.org/widget/label/mac;1",
nsLabelConstructor },
{ "Button",
NS_BUTTON_CID,
"@mozilla.org/widgets/button/mac;1",
nsButtonConstructor },
#endif
{ "nsWindow",
NS_WINDOW_CID,
"@mozilla.org/widgets/window/mac;1",

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

@ -37,11 +37,7 @@
#include "nsWidgetSupport.h"
#include "nsRect.h"
#include "nsIButton.h"
#include "nsITextWidget.h"
#include "nsILabel.h"
#include "nsIWidget.h"
#include "nsICheckButton.h"
#ifdef XP_MAC
#define WIDGET_SUPPORT_EXPORT(returnType) \
@ -51,94 +47,6 @@
returnType
#endif
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateButton(nsISupports* aParent,
nsIButton* aButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsCOMPtr<nsIWidget> parent = do_QueryInterface(aParent);
if (parent) {
nsCOMPtr<nsIWidget> widget = do_QueryInterface(aButton);
if (widget) {
widget->Create(parent, aRect, aHandleEventFunction, nsnull);
widget->Show(PR_TRUE);
if (aFont) {
widget->SetFont(*aFont);
}
}
}
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateCheckButton(nsISupports* aParent,
nsICheckButton* aCheckButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsCOMPtr<nsIWidget> parent = do_QueryInterface(aParent);
if (parent) {
nsCOMPtr<nsIWidget> widget = do_QueryInterface(aCheckButton);
if (widget) {
widget->Create(parent, aRect, aHandleEventFunction, nsnull);
widget->Show(PR_TRUE);
if (aFont) {
widget->SetFont(*aFont);
}
}
}
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateLabel(nsISupports* aParent,
nsILabel* aLabel,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsCOMPtr<nsIWidget> parent = do_QueryInterface(aParent);
if (parent) {
nsCOMPtr<nsIWidget> widget = do_QueryInterface(aLabel);
if (widget) {
widget->Create(parent, aRect, aHandleEventFunction, NULL);
widget->Show(PR_TRUE);
if (aFont) {
widget->SetFont(*aFont);
}
}
}
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateTextWidget(nsISupports* aParent,
nsITextWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsCOMPtr<nsIWidget> parent = do_QueryInterface(aParent);
if (parent) {
nsCOMPtr<nsIWidget> widget = do_QueryInterface(aWidget);
if (widget) {
widget->Create(parent, aRect, aHandleEventFunction, NULL);
widget->Show(PR_TRUE);
if (aFont) {
widget->SetFont(*aFont);
}
}
}
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_ShowWidget(nsISupports* aWidget, PRBool aShow)
{

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

@ -45,16 +45,12 @@
struct nsRect;
class nsIAppShell;
class nsIButton;
class nsIEventListener;
class nsILabel;
class nsILookAndFeel;
class nsIMouseListener;
class nsIToolkit;
class nsIWidget;
class nsICheckButton;
class nsITooltipWidget;
class nsITextWidget;
#if (defined(XP_MAC) || defined(XP_MACOSX)) && !defined(MOZ_WIDGET_COCOA)
// A top-level widget stores a reference to itself as a window property
@ -66,46 +62,6 @@ enum {
};
#endif
// These are a series of support methods which help in the creation
// of widgets. They are not needed, but are provided as a convenience
// mechanism when creating widgets
extern nsresult
NS_CreateButton( nsISupports* aParent,
nsIButton* aButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateCheckButton( nsISupports* aParent,
nsICheckButton* aCheckButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateLabel( nsISupports* aParent,
nsILabel* aLabel,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateTextWidget(nsISupports* aParent,
nsITextWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateTooltipWidget(nsISupports* aParent,
nsITooltipWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_ShowWidget(nsISupports* aWidget, PRBool aShow);

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

@ -73,18 +73,13 @@ REQUIRES = xpcom \
CPPSRCS = \
nsAppShell.cpp \
nsBidiKeyboard.cpp \
nsButton.cpp \
nsCheckButton.cpp \
nsClipboard.cpp \
nsDragService.cpp \
nsKeyCode.cpp \
nsLabel.cpp \
nsLookAndFeel.cpp \
nsScreenXlib.cpp \
nsScreenManagerXlib.cpp \
nsSound.cpp \
nsTextHelper.cpp \
nsTextWidget.cpp \
nsToolkit.cpp \
nsWidget.cpp \
nsWidgetFactory.cpp \

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

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsButton.h"
nsButton::nsButton() : nsWidget()
{
mName.AssignLiteral("nsButton");
}
nsButton::~nsButton()
{
}
NS_IMPL_ISUPPORTS_INHERITED1(nsButton, nsWidget, nsIButton)
NS_METHOD nsButton::SetLabel (const nsString &aText)
{
return NS_OK;
}
NS_METHOD nsButton::GetLabel (nsString &aBuffer)
{
return NS_OK;
}
NS_METHOD nsButton::Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
return NS_OK;
}

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

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsButton_h__
#define nsButton_h__
#include "nsWidget.h"
#include "nsIButton.h"
class nsButton : public nsWidget,
public nsIButton
{
public:
nsButton();
virtual ~nsButton();
NS_DECL_ISUPPORTS_INHERITED
// from nsIButton
NS_IMETHOD SetLabel(const nsString& aText);
NS_IMETHOD GetLabel(nsString& aBuffer);
// nsBaseWidget
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
protected:
nsString mLabel;
};
#endif

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

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCheckButton.h"
nsCheckButton::nsCheckButton()
: nsWidget(),
mState(PR_FALSE)
{
}
nsCheckButton::~nsCheckButton()
{
}
NS_IMPL_ISUPPORTS_INHERITED1(nsCheckButton, nsWidget, nsICheckButton)
NS_METHOD nsCheckButton::SetState(const PRBool aState)
{
return NS_OK;
}
NS_METHOD nsCheckButton::GetState(PRBool& aState)
{
return NS_OK;
}
NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
{
return NS_OK;
}
NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer)
{
return NS_OK;
}
NS_METHOD nsCheckButton::Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
return NS_OK;
}

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

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCheckButton_h__
#define nsCheckButton_h__
#include "nsWidget.h"
#include "nsICheckButton.h"
class nsCheckButton : public nsWidget,
public nsICheckButton
{
public:
nsCheckButton();
virtual ~nsCheckButton();
NS_DECL_ISUPPORTS_INHERITED
// nsICheckButton part
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetState(const PRBool aState);
NS_IMETHOD GetState(PRBool& aState);
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
protected:
PRBool mState;
};
#endif // nsCheckButton_h__

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

@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLabel.h"
nsLabel::nsLabel() : nsWidget()
{
}
NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData)
{
return NS_OK;
}
nsLabel::~nsLabel()
{
}
NS_IMPL_ISUPPORTS_INHERITED1(nsLabel, nsWidget, nsILabel)
NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment)
{
return NS_OK;
}
NS_METHOD nsLabel::SetLabel(const nsString& aText)
{
return NS_OK;
}
NS_METHOD nsLabel::GetLabel(nsString& aBuffer)
{
return NS_OK;
}
NS_METHOD nsLabel::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
{
return NS_OK;
}
NS_METHOD nsLabel::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
{
return NS_OK;
}

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

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsLabel_h__
#define nsLabel_h__
#include "nsWidget.h"
#include "nsILabel.h"
/**
* Native Win32 Label wrapper
*/
class nsLabel : public nsWidget,
public nsILabel
{
public:
nsLabel();
virtual ~nsLabel();
NS_DECL_ISUPPORTS_INHERITED
// nsILabel part
NS_IMETHOD SetLabel(const nsString &aText);
NS_IMETHOD GetLabel(nsString &aBuffer);
NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
protected:
};
#endif // nsLabel_h__

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

@ -1,121 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsTextHelper.h"
NS_METHOD nsTextHelper::PreCreateWidget(nsWidgetInitData *aInitData)
{
return NS_OK;
}
NS_METHOD nsTextHelper::SetMaxTextLength(PRUint32 aChars)
{
return NS_OK;
}
NS_METHOD nsTextHelper::GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize)
{
aTextBuffer.SetLength(0);
aTextBuffer.Append(mText);
aActualSize = mText.Length();
return NS_OK;
}
NS_METHOD nsTextHelper::SetText(const nsString &aText, PRUint32& aActualSize)
{
aActualSize = aText.Length();
mText = aText;
return NS_OK;
}
NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize)
{
return NS_OK;
}
NS_METHOD nsTextHelper::RemoveText()
{
return NS_OK;
}
NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword)
{
return NS_OK;
}
NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldFlag)
{
return NS_OK;
}
NS_METHOD nsTextHelper::SelectAll()
{
return NS_OK;
}
NS_METHOD nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
{
return NS_OK;
}
NS_METHOD nsTextHelper::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
{
return NS_OK;
}
NS_METHOD nsTextHelper::SetCaretPosition(PRUint32 aPosition)
{
return NS_OK;
}
NS_METHOD nsTextHelper::GetCaretPosition(PRUint32& aPos)
{
return NS_OK;
}
nsTextHelper::nsTextHelper() : nsWidget(), nsITextWidget()
{
}
nsTextHelper::~nsTextHelper()
{
}
PRBool nsTextHelper::AutoErase()
{
return(PR_TRUE);
}

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

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTextHelper_h__
#define nsTextHelper_h__
#include "nsITextWidget.h"
#include "nsWidget.h"
/**
* Base class for nsTextAreaWidget (obsolete) and nsTextWidget
*/
class nsTextHelper : public nsWidget,
public nsITextWidget
{
public:
nsTextHelper();
virtual ~nsTextHelper();
NS_IMETHOD SelectAll();
NS_IMETHOD SetMaxTextLength(PRUint32 aChars);
NS_IMETHOD GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize);
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize);
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize);
NS_IMETHOD RemoveText();
NS_IMETHOD SetPassword(PRBool aIsPassword);
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag);
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
NS_IMETHOD SetCaretPosition(PRUint32 aPosition);
NS_IMETHOD GetCaretPosition(PRUint32& aPosition);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData);
virtual PRBool AutoErase();
protected:
nsString mText;
};
#endif // nsTextHelper_h__

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

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsTextWidget.h"
nsTextWidget::nsTextWidget() : nsTextHelper()
{
mName.AssignLiteral("nsTextWidget");
}
nsTextWidget::~nsTextWidget()
{
}
NS_IMPL_ISUPPORTS_INHERITED1(nsTextWidget, nsWidget, nsITextWidget)
NS_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
return NS_OK;
}

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

@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTextWidget_h__
#define nsTextWidget_h__
#include "nsWidget.h"
#include "nsTextHelper.h"
#include "nsITextWidget.h"
class nsTextWidget : public nsTextHelper
{
public:
nsTextWidget();
virtual ~nsTextWidget();
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
};
#endif // nsTextWidget_h__

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

@ -44,13 +44,9 @@
#include "nsWidgetsCID.h"
#include "nsWindow.h"
#include "nsButton.h"
#include "nsCheckButton.h"
#include "nsTextWidget.h"
#include "nsAppShell.h"
#include "nsToolkit.h"
#include "nsLookAndFeel.h"
#include "nsLabel.h"
#include "nsTransferable.h"
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
@ -63,13 +59,9 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
@ -89,18 +81,6 @@ static const nsModuleComponentInfo components[] =
NS_CHILD_CID,
"@mozilla.org/widgets/child_window/xlib;1",
ChildWindowConstructor },
{ "Xlib Button",
NS_BUTTON_CID,
"@mozilla.org/widgets/button/xlib;1",
nsButtonConstructor },
{ "Xlib Check Button",
NS_CHECKBUTTON_CID,
"@mozilla.org/widgets/checkbutton/xlib;1",
nsCheckButtonConstructor },
{ "Xlib Text Widget",
NS_TEXTFIELD_CID,
"@mozilla.org/widgets/textwidget/xlib;1",
nsTextWidgetConstructor },
{ "Xlib AppShell",
NS_APPSHELL_CID,
"@mozilla.org/widget/appshell/xlib;1",
@ -113,10 +93,6 @@ static const nsModuleComponentInfo components[] =
NS_LOOKANDFEEL_CID,
"@mozilla.org/widget/lookandfeel;1",
nsLookAndFeelConstructor },
{ "Xlib Label",
NS_LABEL_CID,
"@mozilla.org/widget/label/xlib;1",
nsLabelConstructor },
{ "Xlib Sound",
NS_SOUND_CID,
"@mozilla.org/sound;1",