Updates to latest widget interface changes

This commit is contained in:
spider%netscape.com 1998-09-16 19:45:57 +00:00
parent 6d099f8c18
commit 1fe79f4f15
6 changed files with 223 additions and 121 deletions

View File

@ -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;
}

View File

@ -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(),
if (NS_OK == res)
{
PRBool old;
mStaticTextField->SetReadOnly(PR_TRUE,old);
widget->Create(GetWidget(),
rect,
HandleEventTextField,
nsnull, nsnull, nsnull);
mStaticTextField->SetText(text);
mStaticTextField->Show(PR_TRUE);
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(),
if (NS_OK == res)
{
widget->Create(GetWidget(),
rect,
HandleEventTextField,
NULL);
text = "TimebarScale setbackgroundcolor #FF0000";
mTextField->SetText(text);
mTextField->Show(PR_TRUE);
PRUint32 length;
mTextField->SetText(text,length);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
return NS_OK;
}
@ -203,9 +215,14 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
nsRect rect = aBounds;
nscoord width = 0;
if (mStaticTextField) {
nsIWidget * widget = nsnull;
nsresult res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
if (NS_OK == res)
{
nsString text("COMMAND: ");
nsFont font("Times", NS_FONT_STYLE_NORMAL,
@ -216,29 +233,40 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
nsIFontMetrics * fm ;
mStaticTextField->GetDeviceContext()->GetMetricsFor(font,fm);
widget->GetDeviceContext()->GetMetricsFor(font,fm);
fm->GetWidth(text,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) {
nsIWidget * widget = nsnull;
nsresult res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
if (NS_OK == res)
{
rect = aBounds;
rect.x += (width);
rect.width -= (width);
mTextField->Invalidate(PR_FALSE);
widget->Invalidate(PR_FALSE);
mTextField->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);
}
}
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);

View File

@ -27,6 +27,7 @@ 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)

View File

@ -36,7 +36,7 @@ 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(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID);
@ -138,21 +138,35 @@ nsresult nsXPFCButton :: CreateWidget()
if (NS_OK == res)
{
nsIWidget * bw = nsnull;
res = button->QueryInterface(kIWidgetIID,(void**)&bw);
if (NS_OK == res)
{
nsSize size ;
GetClassPreferredSize(size);
nsRect rect(0,0,size.width,size.height);
button->Create(parent,
bw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
bw->SetBackgroundColor(GetBackgroundColor());
bw->SetForegroundColor(GetForegroundColor());
bw->Show(PR_TRUE);
button->SetLabel(GetLabel());
button->SetBackgroundColor(GetBackgroundColor());
button->SetForegroundColor(GetForegroundColor());
button->Show(PR_TRUE);
NS_RELEASE(bw);
}
NS_RELEASE(button);
}

View File

@ -28,6 +28,7 @@ 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(kIWidgetIID, NS_IWIDGET_IID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@ -101,19 +102,31 @@ nsresult nsXPFCTabWidget :: CreateWidget()
if (NS_OK == res)
{
nsIWidget * tw = nsnull;
res = tab_widget->QueryInterface(kIWidgetIID,(void**)&tw);
if (NS_OK == res)
{
nsSize size ;
GetClassPreferredSize(size);
nsRect rect(0,0,size.width,size.height);
tab_widget->Create(parent,
tw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
tab_widget->Show(PR_TRUE);
tw->Show(PR_TRUE);
SetParameter(nsString("tab1"),nsString("Tab1"));
NS_RELEASE(tw);
}
NS_RELEASE(tab_widget);
}

View File

@ -28,6 +28,7 @@ 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(kIWidgetIID, NS_IWIDGET_IID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@ -101,6 +102,12 @@ nsresult nsXPFCTextWidget :: CreateWidget()
nsITextWidget * text_widget = nsnull;
res = QueryInterface(kInsTextWidgetIID,(void**)&text_widget);
if (NS_OK == res)
{
nsIWidget * tw = nsnull;
res = text_widget->QueryInterface(kIWidgetIID,(void**)&tw);
if (NS_OK == res)
{
nsSize size ;
@ -109,19 +116,25 @@ nsresult nsXPFCTextWidget :: CreateWidget()
nsRect rect(0,0,size.width,size.height);
text_widget->Create(parent,
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);
PRUint32 num;
text_widget->SetText(GetLabel(),num);
if (gXPFCToolkit->GetCanvasManager()->GetFocusedCanvas() == this)
SetFocus();
NS_RELEASE(tw);
}
NS_RELEASE(text_widget);
}