cleaning up widget library and removing uneeded widgets

fixed ALT key issue for windows
bug 17027,27041; carpool a=leaf; r=kmcclusk
This commit is contained in:
rods%netscape.com 2000-02-09 19:30:25 +00:00
Родитель 39ceae847a
Коммит 6848bd8a1e
7 изменённых файлов: 90 добавлений и 255 удалений

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

@ -52,15 +52,9 @@ EXPORTS=\
nsIKBStateControl.h \
nsIButton.h \
nsICheckButton.h \
nsIListWidget.h \
nsIComboBox.h \
nsITextWidget.h \
nsITextAreaWidget.h \
nsIComboBox.h \
nsIListBox.h \
nsIScrollbar.h \
nsGUIEvent.h \
nsIRadioButton.h \
nsIMouseListener.h \
nsIEventListener.h \
nsIMenuListener.h \

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

@ -29,22 +29,17 @@
struct nsRect;
class nsITextAreaWidget;
class nsIFileWidget;
class nsIAppShell;
class nsIButton;
class nsIComboBox;
class nsIEventListener;
class nsILabel;
class nsIListBox;
class nsIListWidget;
class nsILookAndFeel;
class nsIMouseListener;
class nsIToolkit;
class nsIWidget;
class nsICheckButton;
class nsIScrollbar;
class nsIRadioButton;
class nsITextWidget;
class nsIBrowserWindow;
@ -67,13 +62,6 @@ NS_CreateCheckButton( nsISupports* aParent,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern NS_WIDGET nsresult
NS_CreateRadioButton( nsISupports* aParent,
nsIRadioButton* aButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern NS_WIDGET nsresult
NS_CreateLabel( nsISupports* aParent,
nsILabel* aLabel,
@ -88,30 +76,9 @@ NS_CreateTextWidget(nsISupports* aParent,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern NS_WIDGET nsresult
NS_CreateTextAreaWidget(nsISupports* aParent,
nsITextAreaWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern NS_WIDGET nsresult
NS_CreateListBox(nsISupports* aParent,
nsIListBox* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern NS_WIDGET nsresult
NS_CreateComboBox(nsISupports* aParent,
nsIComboBox* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern NS_WIDGET nsresult
NS_CreateScrollBar(nsISupports* aParent,
nsIScrollbar* aWidget,

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

@ -36,20 +36,6 @@
#include "nsFontRetrieverService.h"
#include "nsSound.h"
//---------------------------
// needed for viewer only
#include "nsButton.h"
#include "nsTextHelper.h"
#include "nsTextWidget.h"
#include "nsCheckButton.h"
#include "nsLabel.h"
static NS_DEFINE_IID(kCButton, NS_BUTTON_CID);
static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID);
static NS_DEFINE_IID(kCLabel, NS_LABEL_CID);
static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID);
//---------------------------
#include "nsWindowsTimer.h"
#include "nsTimerManager.h"
@ -188,14 +174,15 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
}
else if (mClassID.Equals(kCLookAndFeel)) {
inst = (nsISupports*)new nsLookAndFeel();
}
}
else if (mClassID.Equals(kCSound)) {
nsISound* aSound = nsnull;
NS_NewSound(&aSound);
inst = (nsISupports*) aSound;
}
else if (mClassID.Equals(kCFileSpecWithUI))
nsISound* aSound = nsnull;
NS_NewSound(&aSound);
inst = (nsISupports*) aSound;
}
else if (mClassID.Equals(kCFileSpecWithUI)) {
inst = (nsISupports*) (nsIFileSpecWithUI *) new nsFileSpecWithUIImpl;
}
else if (mClassID.Equals(kCTransferable)) {
inst = (nsISupports*)new nsTransferable();
}
@ -217,23 +204,6 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
else if (mClassID.Equals(kCTimerManager)) {
inst = (nsISupports*)(nsITimerQueue*) new nsTimerManager();
}
///////////////////////////////////////
// These are needed for Viewer only
///////////////////////////////////////
#if 0
else if (mClassID.Equals(kCButton)) {
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsButton();
}
else if (mClassID.Equals(kCTextField)) {
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsTextWidget();
}
else if (mClassID.Equals(kCLabel)) {
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsLabel();
}
else if (mClassID.Equals(kCCheckButton)) {
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsCheckButton();
}
#endif
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}

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

@ -23,23 +23,18 @@
#include "nsWidgetSupport.h"
#include "nsRect.h"
#include "nsITextAreaWidget.h"
#include "nsIFileWidget.h"
#include "nsIAppShell.h"
#include "nsIButton.h"
#include "nsIComboBox.h"
#include "nsIEventListener.h"
#include "nsITextWidget.h"
#include "nsILabel.h"
#include "nsIListBox.h"
#include "nsIListWidget.h"
#include "nsILookAndFeel.h"
#include "nsIMouseListener.h"
#include "nsIToolkit.h"
#include "nsIWidget.h"
#include "nsICheckButton.h"
#include "nsIScrollbar.h"
#include "nsIRadioButton.h"
#include "nsITextWidget.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@ -49,7 +44,6 @@ static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID);
static NS_DEFINE_IID(kIScrollBarIID, NS_ISCROLLBAR_IID);
@ -111,31 +105,6 @@ NS_CreateCheckButton(nsISupports* aParent,
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateRadioButton( nsISupports* aParent,
nsIRadioButton* aRadioButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsIWidget* parent = nsnull;
if (aParent != nsnull)
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
nsIWidget* widget;
if (NS_OK == aRadioButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
widget->Create(parent, aRect, aHandleEventFunction, NULL);
widget->Show(PR_TRUE);
if (aFont != nsnull)
widget->SetFont(*aFont);
NS_IF_RELEASE(widget);
}
if (aParent != nsnull)
NS_IF_RELEASE(parent);
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateLabel( nsISupports* aParent,
nsILabel* aLabel,
@ -160,37 +129,6 @@ NS_CreateLabel( nsISupports* aParent,
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateTextAreaWidget(nsISupports* aParent,
nsITextAreaWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsIWidget* parent = nsnull;
if (aParent != nsnull)
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
nsIWidget* widget = nsnull;
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
widget->Create(parent, aRect, aHandleEventFunction, NULL);
widget->Show(PR_TRUE);
if (aFont != nsnull)
widget->SetFont(*aFont);
NS_IF_RELEASE(widget);
}
else
{
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
}
if (aParent)
NS_IF_RELEASE(parent);
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateTextWidget(nsISupports* aParent,
nsITextWidget* aWidget,
@ -250,69 +188,6 @@ NS_CreateScrollBar(nsISupports* aParent,
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateListBox(nsISupports* aParent,
nsIListBox* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsIWidget* parent = nsnull;
if (aParent != nsnull)
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
nsIWidget* widget = nsnull;
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
widget->Create(parent, aRect, aHandleEventFunction, NULL);
widget->Show(PR_TRUE);
if (aFont != nsnull)
widget->SetFont(*aFont);
NS_IF_RELEASE(widget);
}
else
{
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
}
if (aParent)
NS_IF_RELEASE(parent);
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_CreateComboBox(nsISupports* aParent,
nsIComboBox* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont)
{
nsIWidget* parent = nsnull;
if (aParent != nsnull)
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
nsIWidget* widget = nsnull;
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
widget->Create(parent, aRect, aHandleEventFunction, NULL);
widget->Show(PR_TRUE);
if (aFont != nsnull)
widget->SetFont(*aFont);
NS_IF_RELEASE(widget);
}
else
{
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
}
if (aParent)
NS_IF_RELEASE(parent);
return NS_OK;
}
WIDGET_SUPPORT_EXPORT(nsresult)
NS_ShowWidget(nsISupports* aWidget, PRBool aShow)
{

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

@ -29,23 +29,17 @@
struct nsRect;
class nsITextAreaWidget;
class nsIFileWidget;
class nsIAppShell;
class nsIButton;
class nsIComboBox;
class nsIEventListener;
class nsILabel;
class nsIListBox;
class nsIListWidget;
class nsILookAndFeel;
class nsIMouseListener;
class nsITabWidget;
class nsIToolkit;
class nsIWidget;
class nsICheckButton;
class nsIScrollbar;
class nsIRadioButton;
class nsITooltipWidget;
class nsITextWidget;
class nsIBrowserWindow;
@ -68,13 +62,6 @@ NS_CreateCheckButton( nsISupports* aParent,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateRadioButton( nsISupports* aParent,
nsIRadioButton* aButton,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateLabel( nsISupports* aParent,
nsILabel* aLabel,
@ -89,13 +76,6 @@ NS_CreateTextWidget(nsISupports* aParent,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateTextAreaWidget(nsISupports* aParent,
nsITextAreaWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateTooltipWidget(nsISupports* aParent,
nsITooltipWidget* aWidget,
@ -104,29 +84,6 @@ NS_CreateTooltipWidget(nsISupports* aParent,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateListBox(nsISupports* aParent,
nsIListBox* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateComboBox(nsISupports* aParent,
nsIComboBox* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateTabWidget(nsISupports* aParent,
nsITabWidget* aWidget,
const nsRect& aRect,
EVENT_CALLBACK aHandleEventFunction,
const nsFont* aFont = nsnull);
extern nsresult
NS_CreateScrollBar(nsISupports* aParent,
nsIScrollbar* aWidget,

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

@ -49,11 +49,6 @@
#include "prtime.h"
#include "nsIRenderingContextWin.h"
#include "nsIMenu.h"
#include "nsMenu.h"
#include "nsIMenuItem.h"
#include "nsIMenuListener.h"
#include "nsMenuItem.h"
#include <imm.h>
#ifdef MOZ_AIMM
#include "aimm.h"
@ -2270,7 +2265,16 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
result = OnKeyUp(wParam, (HIWORD(lParam) ));
else
result = PR_FALSE;
// Let's consume the ALT key up so that we don't go into
// a menu bar if we don't have one.
// XXX This will cause a tiny breakage in viewer... namely
// that hitting ALT by itself in viewer won't move you into
// the menu. ALT+shortcut key will still work, though, so
// I figure this is ok.
if (wParam == NS_VK_ALT) {
result = PR_TRUE;
*aRetValue = 0;
}
break;
// Let ths fall through if it isn't a key pad

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

@ -56,6 +56,15 @@
#include "nsIAppShell.h"
#include "nsWidgetSupport.h"
#define USE_LOCAL_WIDGETS
#ifdef USE_LOCAL_WIDGETS
extern nsresult NS_NewButton(nsIButton** aControl);
extern nsresult NS_NewLabel(nsILabel** aControl);
extern nsresult NS_NewTextWidget(nsITextWidget** aControl);
extern nsresult NS_NewCheckButton(nsICheckButton** aControl);
#endif
#include <stdio.h>
#ifndef XP_MAC
@ -414,8 +423,15 @@ int createTestButton(nsIWidget * aWin,
int aWidth,
EVENT_CALLBACK aHandleEventFunction) {
nsIButton *button;
nsRect rect(aX, aY, aWidth, 25);
nsRect rect(aX, aY, aWidth, 25);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewButton(&button);
NS_ADDREF(button);
#else
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **) &button);
#endif
NS_CreateButton(aWin,button,rect,aHandleEventFunction);
button->SetLabel(aTitle);
return aX + aWidth;
@ -432,7 +448,12 @@ nsIButton* createSimpleButton(nsIWidget * aWin,
EVENT_CALLBACK aHandleEventFunction) {
nsIButton *button;
nsRect rect(aX, aY, aWidth, 25);
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewButton(&button);
NS_ADDREF(button);
#else
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void **) &button);
#endif
NS_CreateButton(aWin,button,rect,aHandleEventFunction);
button->SetLabel(aTitle);
return button;
@ -1177,7 +1198,12 @@ nsresult WidgetTest(int *argc, char **argv)
//
nsIButton *button;
rect.SetRect(x, y, 60, 25);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewButton(&button);
NS_ADDREF(button);
#else
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button);
#endif
NS_CreateButton(window,button,rect,HandleEvent);
nsString label("Slider");
button->SetLabel(label);
@ -1205,7 +1231,12 @@ nsresult WidgetTest(int *argc, char **argv)
nsICheckButton * checkButton;
rect.SetRect(x, y, 100, 25);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewCheckButton(&checkButton);
NS_ADDREF(checkButton);
#else
nsComponentManager::CreateInstance(kCCheckButtonCID, nsnull, kICheckButtonIID, (void**)&checkButton);
#endif
NS_CreateCheckButton(window,checkButton,rect,CheckButtonTestHandleEvent);
nsString cbLabel("CheckButton");
checkButton->SetLabel(cbLabel);
@ -1226,7 +1257,12 @@ nsresult WidgetTest(int *argc, char **argv)
0,
12);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewTextWidget(&textWidget);
NS_ADDREF(textWidget);
#else
nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&textWidget);
#endif
NS_CreateTextWidget(window,textWidget,rect,HandleEvent);
nsString initialText("0123456789");
@ -1243,7 +1279,12 @@ nsresult WidgetTest(int *argc, char **argv)
nsITextWidget * ptextWidget;
rect.SetRect(x, y, 100, TEXT_HEIGHT);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewTextWidget(&ptextWidget);
NS_ADDREF(ptextWidget);
#else
nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&ptextWidget);
#endif
NS_CreateTextWidget(window, ptextWidget, rect, HandleEvent);
@ -1277,7 +1318,12 @@ nsresult WidgetTest(int *argc, char **argv)
nsITextWidget * rtextWidget;
rect.SetRect(x, y, 100, TEXT_HEIGHT);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewTextWidget(&rtextWidget);
NS_ADDREF(rtextWidget);
#else
nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&rtextWidget);
#endif
NS_CreateTextWidget(window, rtextWidget, rect, HandleEvent);
PRBool old;
@ -1289,6 +1335,7 @@ nsresult WidgetTest(int *argc, char **argv)
//NS_RELEASE(rtextWidget);
y += rect.height + 5;
#if 0 // not supported anymore
//
// create a text area widget
//
@ -1303,7 +1350,7 @@ nsresult WidgetTest(int *argc, char **argv)
//NS_RELEASE(textAreaWidget);
//y += rect.height + 5;
x += rect.width + 5;
#endif
// Save these for later
int saveY = y;
saveX = x;
@ -1324,7 +1371,12 @@ nsresult WidgetTest(int *argc, char **argv)
//
y = 10;
rect.SetRect(x, y, 350, TEXT_HEIGHT);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewTextWidget(&statusText);
NS_ADDREF(statusText);
#else
nsComponentManager::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void**)&statusText);
#endif
statusText->QueryInterface(kIWidgetIID,(void**)&widget);
widget->Create(window, rect, HandleEvent, deviceContext);
widget->Show(PR_TRUE);
@ -1334,13 +1386,23 @@ nsresult WidgetTest(int *argc, char **argv)
// create a Failed Button
//
rect.SetRect(x, y, 100, 25);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewButton(&button);
NS_ADDREF(button);
#else
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button);
#endif
NS_CreateButton(window,button,rect,FailedButtonHandleEvent);
nsString failedLabel("Failed");
button->SetLabel(failedLabel);
rect.SetRect(x, y+30, 150, 25);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewButton(&button);
NS_ADDREF(button);
#else
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button);
#endif
NS_CreateButton(window,button,rect,DoSelfTests);
nsString selfTestLabel("Perform Self Tests");
button->SetLabel(selfTestLabel);
@ -1350,11 +1412,17 @@ nsresult WidgetTest(int *argc, char **argv)
// create a Succeeded Button
//
rect.SetRect(x, y, 100, 25);
#ifdef USE_LOCAL_WIDGETS
rv = NS_NewButton(&button);
NS_ADDREF(button);
#else
nsComponentManager::CreateInstance(kCButtonCID, nsnull, kIButtonIID, (void**)&button);
#endif
NS_CreateButton(window,button,rect,SucceededButtonHandleEvent);
nsString succeededLabel("Succeeded");
button->SetLabel(succeededLabel);
#if 0
//
// create a listbox widget
//
@ -1427,7 +1495,6 @@ nsresult WidgetTest(int *argc, char **argv)
radioButton->SetLabel(rbLabel2);
gRadioBtns[gNumRadioBtns++] = radioButton;
y += rect.height + 5;
//window->SetBackgroundColor(NS_RGB(0,255,0));
//
@ -1451,6 +1518,7 @@ nsresult WidgetTest(int *argc, char **argv)
x = 5;
y += 30;
#endif
nsString status("The non-visual tests: ");