Updates to latest widget interface changes

This commit is contained in:
spider%netscape.com 1998-09-16 19:45:57 +00:00
Родитель 6d099f8c18
Коммит 1fe79f4f15
6 изменённых файлов: 223 добавлений и 121 удалений

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

@ -177,15 +177,20 @@ nsresult nsTrexTestShell::Init()
aRect.height-=HEIGHT;
aRect.width-=10;
mDisplay->Create(mShellInstance->GetApplicationWidget(),
nsIWidget * dw = nsnull;
res = mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
dw->Create(mShellInstance->GetApplicationWidget(),
aRect,
HandleEventTextField,
NULL);
mDisplay->SetText("TrexTest 0.1\r\n");
mDisplay->InsertText("-------------------\r\n",0x7fffffff,0x7fffffff);
mDisplay->Show(PR_TRUE);
mDisplay->SetReadOnly(PR_TRUE);
PRUint32 length;
mDisplay->SetText("TrexTest 0.1\r\n",length);
mDisplay->InsertText("-------------------\r\n",0x7fffffff,0x7fffffff,length);
dw->Show(PR_TRUE);
PRBool prev;
mDisplay->SetReadOnly(PR_TRUE,prev);
aRect.y = aRect.height - HEIGHT;
@ -196,21 +201,16 @@ nsresult nsTrexTestShell::Init()
kITextWidgetIID,
(void **)&mInput);
mInput->Create(mShellInstance->GetApplicationWidget(),
nsIWidget * iw = nsnull;
res = mInput->QueryInterface(kIWidgetIID, (void**)&iw);
iw->Create(mShellInstance->GetApplicationWidget(),
aRect,
HandleEventTextField,
NULL);
mInput->Show(PR_TRUE);
nsIWidget * inputwidget = nsnull;
if (mInput)
mInput->QueryInterface(kIWidgetIID,(void**)&inputwidget);
inputwidget->SetFocus();
NS_RELEASE(inputwidget);
iw->Show(PR_TRUE);
iw->SetFocus();
nsIWidget * app = mShellInstance->GetApplicationWidget();
@ -222,9 +222,11 @@ nsresult nsTrexTestShell::Init()
rect.x = 0;
rect.y = 0;
mDisplay->Resize(rect.x,rect.y,rect.width,rect.height-HEIGHT,PR_TRUE);
dw->Resize(rect.x,rect.y,rect.width,rect.height-HEIGHT,PR_TRUE);
iw->Resize(rect.x,rect.height-HEIGHT,rect.width,HEIGHT,PR_TRUE);
mInput->Resize(rect.x,rect.height-HEIGHT,rect.width,HEIGHT,PR_TRUE);
NS_RELEASE(dw);
NS_RELEASE(iw);
mShellInstance->ShowApplicationWindow(PR_TRUE) ;
@ -347,11 +349,17 @@ nsresult nsTrexTestShell::GetWebViewerContainer(nsIWebViewerContainer ** aWebVie
nsresult nsTrexTestShell::SendCommand(nsString& aCommand)
{
PRThread *t;
mInput->RemoveText();
mInput->Invalidate(PR_TRUE);
nsString string("COMMAND: ");
mDisplay->InsertText(string,0x7fffffff,0x7fffffff);
nsIWidget * iw = nsnull;
nsresult res = mInput->QueryInterface(kIWidgetIID, (void**)&iw);
nsIWidget * dw = nsnull;
res = mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
mInput->RemoveText();
iw->Invalidate(PR_TRUE);
nsString string("COMMAND: ");
PRUint32 length;
mDisplay->InsertText(string,0x7fffffff,0x7fffffff,length);
/*
@ -383,14 +391,24 @@ nsresult nsTrexTestShell::SendCommand(nsString& aCommand)
PR_ExitMonitor(mClientMon);
NS_RELEASE(iw);
NS_RELEASE(dw);
return (ReceiveCommand(mCommand,mCommand));
}
nsresult nsTrexTestShell::ReceiveCommand(nsString& aCommand, nsString& aReply)
{
mDisplay->InsertText(aReply,0x7fffffff,0x7fffffff);
mDisplay->InsertText("\r\n",0x7fffffff,0x7fffffff);
mDisplay->Invalidate(PR_TRUE);
PRUint32 length;
mDisplay->InsertText(aReply,0x7fffffff,0x7fffffff,length);
mDisplay->InsertText("\r\n",0x7fffffff,0x7fffffff,length);
nsIWidget * dw = nsnull;
mDisplay->QueryInterface(kIWidgetIID,(void**)&dw);
dw->Invalidate(PR_TRUE);
return NS_OK;
}
@ -416,8 +434,8 @@ nsEventStatus nsTrexTestShell::HandleEvent(nsGUIEvent *aEvent)
if (NS_VK_RETURN == ((nsKeyEvent*)aEvent)->keyCode)
{
nsString text;
mInput->GetText(text, 1000);
PRUint32 length;
mInput->GetText(text, 1000, length);
SendCommand(text);
@ -453,9 +471,16 @@ nsEventStatus nsTrexTestShell::HandleEvent(nsGUIEvent *aEvent)
rect->x = 0;
rect->y = 0;
mDisplay->Resize(rect->x,rect->y,rect->width,rect->height-HEIGHT,PR_TRUE);
nsIWidget * iw = nsnull;
mInput->QueryInterface(kIWidgetIID, (void**)&iw);
nsIWidget * dw = nsnull;
mDisplay->QueryInterface(kIWidgetIID, (void**)&dw);
mInput->Resize(rect->x,rect->height-HEIGHT,rect->width,HEIGHT,PR_TRUE);
dw->Resize(rect->x,rect->y,rect->width,rect->height-HEIGHT,PR_TRUE);
iw->Resize(rect->x,rect->height-HEIGHT,rect->width,HEIGHT,PR_TRUE);
NS_RELEASE(iw);
NS_RELEASE(dw);
return nsEventStatus_eConsumeNoDefault;
}

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

@ -121,20 +121,27 @@ nsresult nsCalCommandCanvas :: Init()
rect.width = width ;
mStaticTextField->SetReadOnly(PR_TRUE);
nsIWidget * widget = nsnull;
nsresult res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
NS_RELEASE(widget);
mStaticTextField->Create(GetWidget(),
rect,
HandleEventTextField,
nsnull, nsnull, nsnull);
if (NS_OK == res)
{
mStaticTextField->SetText(text);
mStaticTextField->Show(PR_TRUE);
PRBool old;
mStaticTextField->SetReadOnly(PR_TRUE,old);
widget->Create(GetWidget(),
rect,
HandleEventTextField,
nsnull, nsnull, nsnull);
PRUint32 length;
mStaticTextField->SetText(text,length);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
/*
* Writeable Command field
@ -152,16 +159,21 @@ nsresult nsCalCommandCanvas :: Init()
widget = nsnull;
res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
NS_RELEASE(widget);
mTextField->Create(GetWidget(),
rect,
HandleEventTextField,
NULL);
text = "TimebarScale setbackgroundcolor #FF0000";
mTextField->SetText(text);
mTextField->Show(PR_TRUE);
if (NS_OK == res)
{
widget->Create(GetWidget(),
rect,
HandleEventTextField,
NULL);
text = "TimebarScale setbackgroundcolor #FF0000";
PRUint32 length;
mTextField->SetText(text,length);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
return NS_OK;
}
@ -203,42 +215,58 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
nsRect rect = aBounds;
nscoord width = 0;
if (mStaticTextField) {
nsString text("COMMAND: ");
nsIWidget * widget = nsnull;
nsresult res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
nsFont font("Times", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_BOLD,
0,
8);
if (NS_OK == res)
{
nsIFontMetrics * fm ;
nsString text("COMMAND: ");
nsFont font("Times", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_BOLD,
0,
8);
nsIFontMetrics * fm ;
mStaticTextField->GetDeviceContext()->GetMetricsFor(font,fm);
widget->GetDeviceContext()->GetMetricsFor(font,fm);
fm->GetWidth(text,width);
fm->GetWidth(text,width);
rect.width = width ;
rect.width = width ;
mStaticTextField->Invalidate(PR_FALSE);
widget->Invalidate(PR_FALSE);
mStaticTextField->Resize(rect.x, rect.y, rect.width, rect.height, PR_FALSE);
widget->Resize(rect.x, rect.y, rect.width, rect.height, PR_FALSE);
NS_RELEASE(widget);
}
}
if (mTextField) {
rect = aBounds;
nsIWidget * widget = nsnull;
nsresult res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
rect.x += (width);
rect.width -= (width);
if (NS_OK == res)
{
rect = aBounds;
mTextField->Invalidate(PR_FALSE);
rect.x += (width);
rect.width -= (width);
mTextField->Resize(rect.x, rect.y, rect.width, rect.height, PR_FALSE);
widget->Invalidate(PR_FALSE);
widget->Resize(rect.x, rect.y, rect.width, rect.height, PR_FALSE);
NS_RELEASE(widget);
}
}
return NS_OK;
@ -248,8 +276,14 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
nsEventStatus nsCalCommandCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
mTextField->Invalidate(PR_FALSE);
mStaticTextField->Invalidate(PR_FALSE);
nsIWidget * widget = nsnull;
nsresult res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
widget->Invalidate(PR_FALSE);
NS_RELEASE(widget);
res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
widget->Invalidate(PR_FALSE);
NS_RELEASE(widget);
return nsEventStatus_eConsumeNoDefault;
}
@ -270,7 +304,9 @@ nsEventStatus nsCalCommandCanvas :: HandleEvent(nsGUIEvent *aEvent)
if (res != NS_OK)
return nsEventStatus_eIgnore;
text_widget->GetText(text, 1000);
PRUint32 length;
text_widget->GetText(text, 1000, length);
SendCommand(text,reply);

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

@ -23,11 +23,12 @@
#include "nsIDeviceContext.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCalTodoComponentCanvasCID, NS_CAL_TODOCOMPONENTCANVAS_CID);
static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
static NS_DEFINE_IID(kIListWidgetIID, NS_ILISTWIDGET_IID);
static NS_DEFINE_IID(kCListWidgetCID, NS_LISTBOX_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCalTodoComponentCanvasCID, NS_CAL_TODOCOMPONENTCANVAS_CID);
static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
static NS_DEFINE_IID(kIListWidgetIID, NS_ILISTWIDGET_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kCListWidgetCID, NS_LISTBOX_CID);
nsEventStatus PR_CALLBACK HandleEventListWidget(nsGUIEvent *aEvent);
@ -80,7 +81,7 @@ nsresult nsCalTodoComponentCanvas :: Init()
nsresult res = nsRepository::CreateInstance(kCListWidgetCID,
nsnull,
kIListWidgetIID,
kIWidgetIID,
(void **)&mWidget);
if (NS_OK != res)

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

@ -31,14 +31,14 @@
#include "nsITimer.h"
#include "nsIThrobber.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCButtonCID, NS_XPFC_BUTTON_CID);
static NS_DEFINE_IID(kCIXPFCButtonIID, NS_IXPFC_BUTTON_IID);
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID);
static NS_DEFINE_IID(kCIXPFCButtonIID,NS_IXPFC_BUTTON_IID);
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@ -138,21 +138,35 @@ nsresult nsXPFCButton :: CreateWidget()
if (NS_OK == res)
{
nsSize size ;
nsIWidget * bw = nsnull;
res = button->QueryInterface(kIWidgetIID,(void**)&bw);
if (NS_OK == res)
{
nsSize size ;
GetClassPreferredSize(size);
GetClassPreferredSize(size);
nsRect rect(0,0,size.width,size.height);
nsRect rect(0,0,size.width,size.height);
button->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
bw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
bw->SetBackgroundColor(GetBackgroundColor());
bw->SetForegroundColor(GetForegroundColor());
bw->Show(PR_TRUE);
button->SetLabel(GetLabel());
NS_RELEASE(bw);
}
button->SetLabel(GetLabel());
button->SetBackgroundColor(GetBackgroundColor());
button->SetForegroundColor(GetForegroundColor());
button->Show(PR_TRUE);
NS_RELEASE(button);
}

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

@ -23,11 +23,12 @@
#include "nsWidgetsCID.h"
#include "nsXPFCToolkit.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID);
static NS_DEFINE_IID(kCIXPFCTabWidgetIID, NS_IXPFC_TABWIDGET_IID);
static NS_DEFINE_IID(kCTabWidgetCID, NS_TABWIDGET_CID);
static NS_DEFINE_IID(kInsTabWidgetIID, NS_ITABWIDGET_IID);
static NS_DEFINE_IID(kCTabWidgetCID, NS_TABWIDGET_CID);
static NS_DEFINE_IID(kInsTabWidgetIID, NS_ITABWIDGET_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@ -101,19 +102,31 @@ nsresult nsXPFCTabWidget :: CreateWidget()
if (NS_OK == res)
{
nsSize size ;
nsIWidget * tw = nsnull;
res = tab_widget->QueryInterface(kIWidgetIID,(void**)&tw);
if (NS_OK == res)
{
nsSize size ;
GetClassPreferredSize(size);
GetClassPreferredSize(size);
nsRect rect(0,0,size.width,size.height);
nsRect rect(0,0,size.width,size.height);
tab_widget->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
tw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
tw->Show(PR_TRUE);
SetParameter(nsString("tab1"),nsString("Tab1"));
NS_RELEASE(tw);
}
tab_widget->Show(PR_TRUE);
SetParameter(nsString("tab1"),nsString("Tab1"));
NS_RELEASE(tab_widget);
}

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

@ -23,11 +23,12 @@
#include "nsWidgetsCID.h"
#include "nsXPFCToolkit.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID);
static NS_DEFINE_IID(kCIXPFCTextWidgetIID, NS_IXPFC_TEXTWIDGET_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID);
static NS_DEFINE_IID(kCIXPFCTextWidgetIID, NS_IXPFC_TEXTWIDGET_IID);
static NS_DEFINE_IID(kCTextWidgetCID, NS_TEXTFIELD_CID);
static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@ -103,24 +104,36 @@ nsresult nsXPFCTextWidget :: CreateWidget()
if (NS_OK == res)
{
nsSize size ;
nsIWidget * tw = nsnull;
res = text_widget->QueryInterface(kIWidgetIID,(void**)&tw);
if (NS_OK == res)
{
nsSize size ;
GetClassPreferredSize(size);
GetClassPreferredSize(size);
nsRect rect(0,0,size.width,size.height);
nsRect rect(0,0,size.width,size.height);
text_widget->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
tw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
text_widget->SetText(GetLabel());
text_widget->SetBackgroundColor(GetBackgroundColor());
text_widget->SetForegroundColor(GetForegroundColor());
text_widget->Show(PR_TRUE);
tw->SetBackgroundColor(GetBackgroundColor());
tw->SetForegroundColor(GetForegroundColor());
tw->Show(PR_TRUE);
if (gXPFCToolkit->GetCanvasManager()->GetFocusedCanvas() == this)
SetFocus();
PRUint32 num;
text_widget->SetText(GetLabel(),num);
if (gXPFCToolkit->GetCanvasManager()->GetFocusedCanvas() == this)
SetFocus();
NS_RELEASE(tw);
}
NS_RELEASE(text_widget);
}