From 766b20eb766f6e38bd203c8f05b03c2f6a4cf87f Mon Sep 17 00:00:00 2001 From: kmcclusk Date: Fri, 17 Apr 1998 00:16:11 +0000 Subject: [PATCH] Added a tab widget git-svn-id: svn://10.0.0.236/trunk@341 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/public/Makefile | 1 + mozilla/widget/public/makefile.win | 2 +- mozilla/widget/public/nsGUIEvent.h | 3 +- mozilla/widget/public/nsITabWidget.h | 55 +++++++ mozilla/widget/public/nsWidgetsCID.h | 5 + mozilla/widget/src/windows/makefile.win | 60 ++++---- mozilla/widget/src/windows/nsTabWidget.cpp | 143 ++++++++++++++++++ mozilla/widget/src/windows/nsTabWidget.h | 61 ++++++++ .../widget/src/windows/nsWidgetFactory.cpp | 12 ++ mozilla/widget/src/windows/nsWindow.cpp | 63 +++++++- mozilla/widget/src/windows/nsWindow.h | 1 + mozilla/widget/tests/windows/winmain.cpp | 53 ++++++- 12 files changed, 423 insertions(+), 36 deletions(-) create mode 100644 mozilla/widget/public/nsITabWidget.h create mode 100644 mozilla/widget/src/windows/nsTabWidget.cpp create mode 100644 mozilla/widget/src/windows/nsTabWidget.h diff --git a/mozilla/widget/public/Makefile b/mozilla/widget/public/Makefile index c9f4608a5ae..7ab6900911f 100644 --- a/mozilla/widget/public/Makefile +++ b/mozilla/widget/public/Makefile @@ -21,6 +21,7 @@ DEFINES = -D_IMPL_NS_UI EXPORTS = \ nsui.h \ + nsITabWidget.h \ nsIWidget.h \ nsIButton.h \ nsICheckButton.h\ diff --git a/mozilla/widget/public/makefile.win b/mozilla/widget/public/makefile.win index f4fcb500ed6..24843a6592f 100644 --- a/mozilla/widget/public/makefile.win +++ b/mozilla/widget/public/makefile.win @@ -25,7 +25,7 @@ EXPORTS=nsui.h nsIWidget.h nsIButton.h nsICheckButton.h nsIListWidget.h \ nsIComboBox.h nsITextWidget.h nsITextAreaWidget.h nsIComboBox.h \ nsIListBox.h nsIFileWidget.h nsIScrollbar.h nsGUIEvent.h \ nsIRadioButton.h nsIRadioGroup.h nsIMouseListener.h \ - nsIEventListener.h nsIToolkit.h nsWidgetsCID.h + nsIEventListener.h nsIToolkit.h nsWidgetsCID.h nsITabWidget.h include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/widget/public/nsGUIEvent.h b/mozilla/widget/public/nsGUIEvent.h index 7c7eb121715..c8314f60163 100644 --- a/mozilla/widget/public/nsGUIEvent.h +++ b/mozilla/widget/public/nsGUIEvent.h @@ -84,6 +84,7 @@ struct nsScrollbarEvent : public nsGUIEvent { PRUint32 position; }; + /** * Keyboard event */ @@ -99,7 +100,6 @@ struct nsKeyEvent : public nsGUIEvent { PRBool isAlt; }; - /** * GUI MESSAGES */ @@ -115,6 +115,7 @@ struct nsKeyEvent : public nsGUIEvent { #define NS_KEY_UP (NS_WINDOW_START + 32) #define NS_KEY_DOWN (NS_WINDOW_START + 33) +#define NS_TABCHANGE (NS_WINDOW_START + 34) #define NS_MOUSE_MESSAGE_START 300 #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START) diff --git a/mozilla/widget/public/nsITabWidget.h b/mozilla/widget/public/nsITabWidget.h new file mode 100644 index 00000000000..3a48a15714f --- /dev/null +++ b/mozilla/widget/public/nsITabWidget.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsITabWidget_h__ +#define nsITabWidget_h__ + +#include "nsIWidget.h" +#include "nsString.h" + +#define NS_ITABWIDGET_IID \ +{ 0xf05ba6e0, 0xd4a7, 0x11d1, { 0x9e, 0xc0, 0x0, 0xaa, 0x0, 0x2f, 0xb8, 0x21 } }; + +/** + * Tab widget. + * Presents a lists of tabs to be clicked on. + */ +class nsITabWidget : public nsIWidget { + + public: + + /** + * Setup the tabs + * + * @param aNumberOfTabs The number of tabs in aTabLabels and aTabID + * @param aTabLabels title displayed in the tab + */ + + virtual void SetTabs(PRUint32 aNumberOfTabs, const nsString aTabLabels[]) = 0; + + /** + * Get selected tab + * + * @return the index of the selected tab. Index ranges between 0 and (NumberOfTabs - 1) + */ + + virtual PRUint32 GetSelectedTab() = 0; + +}; + +#endif diff --git a/mozilla/widget/public/nsWidgetsCID.h b/mozilla/widget/public/nsWidgetsCID.h index 7b3c8e38ca0..db1ca47c145 100644 --- a/mozilla/widget/public/nsWidgetsCID.h +++ b/mozilla/widget/public/nsWidgetsCID.h @@ -81,3 +81,8 @@ { 0x2d96b3dc, 0xc051, 0x11d1, \ {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} } +/* 2d96b3dc-c051-11d1-a827-0040959a28c9 */ +#define NS_TABWIDGET_CID \ +{ 0x2d96b3dd, 0xc051, 0x11d1, \ + {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} } + diff --git a/mozilla/widget/src/windows/makefile.win b/mozilla/widget/src/windows/makefile.win index 23fda8c5846..168e5f602a4 100644 --- a/mozilla/widget/src/windows/makefile.win +++ b/mozilla/widget/src/windows/makefile.win @@ -23,49 +23,51 @@ DLLNAME = raptorwidget DLL=.\$(OBJDIR)\$(DLLNAME).dll RESFILE = widget.res -MISCDEP = \ +MISCDEP = \ $(DIST)\lib\xpcom32.lib \ - $(DIST)\lib\raptorbase.lib \ + $(DIST)\lib\raptorbase.lib \ $(DIST)\lib\raptorgfx.lib MODULE=raptor DEFINES =-D_IMPL_NS_WIDGET -OBJS = \ - .\$(OBJDIR)\nsWidgetFactory.obj \ - .\$(OBJDIR)\nsObject.obj \ - .\$(OBJDIR)\nsWindow.obj \ - .\$(OBJDIR)\nsToolkit.obj \ - .\$(OBJDIR)\nsButton.obj \ - .\$(OBJDIR)\nsCheckButton.obj \ - .\$(OBJDIR)\nsRadioGroup.obj \ - .\$(OBJDIR)\nsRadioButton.obj \ - .\$(OBJDIR)\nsListBox.obj \ - .\$(OBJDIR)\nsComboBox.obj \ - .\$(OBJDIR)\nsTextWidget.obj \ - .\$(OBJDIR)\nsTextHelper.obj \ +OBJS = \ + .\$(OBJDIR)\nsWidgetFactory.obj \ + .\$(OBJDIR)\nsObject.obj \ + .\$(OBJDIR)\nsWindow.obj \ + .\$(OBJDIR)\nsToolkit.obj \ + .\$(OBJDIR)\nsButton.obj \ + .\$(OBJDIR)\nsCheckButton.obj \ + .\$(OBJDIR)\nsRadioGroup.obj \ + .\$(OBJDIR)\nsRadioButton.obj \ + .\$(OBJDIR)\nsListBox.obj \ + .\$(OBJDIR)\nsComboBox.obj \ + .\$(OBJDIR)\nsTextWidget.obj \ + .\$(OBJDIR)\nsTextHelper.obj \ .\$(OBJDIR)\nsTextAreaWidget.obj \ - .\$(OBJDIR)\nsFileWidget.obj \ - .\$(OBJDIR)\nsScrollbar.obj \ + .\$(OBJDIR)\nsFileWidget.obj \ + .\$(OBJDIR)\nsScrollbar.obj \ + .\$(OBJDIR)\nsTabWidget.obj \ $(NULL) -LINCS= \ - -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\xpcom \ +LINCS= \ + -I$(PUBLIC)\raptor \ + -I$(PUBLIC)\xpcom \ $(NULL) -LCFLAGS = \ - $(LCFLAGS) \ - -D_IMPL_NS_WIDGET \ - -DNS_DLLNAME=$(DLLNAME).dll \ +LCFLAGS = \ + $(LCFLAGS) \ + -D_IMPL_NS_WIDGET \ + -DNS_DLLNAME=$(DLLNAME).dll \ $(NULL) -LLIBS= \ - comdlg32.lib \ - $(DIST)\lib\xpcom32.lib \ - $(DIST)\lib\raptorgfx.lib \ - $(DIST)\lib\raptorbase.lib \ +LLIBS= \ + comctl32.lib \ + comdlg32.lib \ + $(DIST)\lib\xpcom32.lib \ + $(DIST)\lib\raptorgfx.lib \ + $(DIST)\lib\raptorbase.lib \ $(LIBNSPR) include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/widget/src/windows/nsTabWidget.cpp b/mozilla/widget/src/windows/nsTabWidget.cpp new file mode 100644 index 00000000000..8e660c18c69 --- /dev/null +++ b/mozilla/widget/src/windows/nsTabWidget.cpp @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsTabWidget.h" +#include "nsToolkit.h" +#include "nsColor.h" +#include "nsGUIEvent.h" +#include "nsString.h" +#include "nsStringUtil.h" +#include +#include + +//------------------------------------------------------------------------- +// +// nsTabWidget constructor +// +//------------------------------------------------------------------------- +nsTabWidget::nsTabWidget(nsISupports *aOuter) : nsWindow(aOuter) +{ + // Ensure that common controls dll is loaded + InitCommonControls(); +} + +//------------------------------------------------------------------------- +// +// nsTabWidget destructor +// +//------------------------------------------------------------------------- +nsTabWidget::~nsTabWidget() +{ +} + +//------------------------------------------------------------------------- +// +// Query interface implementation +// +//------------------------------------------------------------------------- +nsresult nsTabWidget::QueryObject(const nsIID& aIID, void** aInstancePtr) +{ + nsresult result = nsWindow::QueryObject(aIID, aInstancePtr); + + static NS_DEFINE_IID(kInsTabWidgetIID, NS_ITABWIDGET_IID); + if (result == NS_NOINTERFACE && aIID.Equals(kInsTabWidgetIID)) { + *aInstancePtr = (void*) ((nsITabWidget*)this); + AddRef(); + result = NS_OK; + } + + return result; +} + +//------------------------------------------------------------------------- +// +// Set the tab labels +// +//------------------------------------------------------------------------- + +void nsTabWidget::SetTabs(PRUint32 aNumberOfTabs, const nsString aTabLabels[]) +{ + TC_ITEM tie; + char labelTemp[256]; + + for (PRUint32 i = 0; i < aNumberOfTabs; i++) { + tie.mask = TCIF_TEXT; + aTabLabels[i].ToCString(labelTemp, 256); + tie.pszText = labelTemp; + TabCtrl_InsertItem(mWnd, i, &tie); + } +} + +//------------------------------------------------------------------------- +// +// Get the currently selected tab +// +//------------------------------------------------------------------------- + + +PRUint32 nsTabWidget::GetSelectedTab() +{ + return(TabCtrl_GetCurSel(mWnd)); +} + +//------------------------------------------------------------------------- +// +// paint message. Don't send the paint out +// +//------------------------------------------------------------------------- +PRBool nsTabWidget::OnPaint() +{ + return PR_FALSE; +} + +PRBool nsTabWidget::OnResize(nsRect &aWindowRect) +{ + return PR_FALSE; +} + +//------------------------------------------------------------------------- +// +// return the window class name and initialize the class if needed +// +//------------------------------------------------------------------------- + +LPCTSTR nsTabWidget::WindowClass() +{ + return WC_TABCONTROL; +} + +//------------------------------------------------------------------------- +// +// return window styles +// +//------------------------------------------------------------------------- +DWORD nsTabWidget::WindowStyle() +{ + return WS_CHILD | WS_CLIPSIBLINGS; +} + +//------------------------------------------------------------------------- +// +// return window extended styles +// +//------------------------------------------------------------------------- +DWORD nsTabWidget::WindowExStyle() +{ + return 0; +} + diff --git a/mozilla/widget/src/windows/nsTabWidget.h b/mozilla/widget/src/windows/nsTabWidget.h new file mode 100644 index 00000000000..fd8c6199c82 --- /dev/null +++ b/mozilla/widget/src/windows/nsTabWidget.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsTabWidget_h__ +#define nsTabWidget_h__ + +#include "nsdefs.h" +#include "nsWindow.h" +#include "nsSwitchToUIThread.h" + +#include "nsITabWidget.h" + +/** + * Native Win32 tab control wrapper + */ + +class nsTabWidget : public nsWindow, + public nsITabWidget +{ + +public: + nsTabWidget(nsISupports *aOuter); + virtual ~nsTabWidget(); + + // nsISupports. Forward to the nsObject base class + BASE_SUPPORT + + virtual nsresult QueryObject(const nsIID& aIID, void** aInstancePtr); + + // nsIWidget interface + BASE_IWIDGET_IMPL + + // nsITabWidget part + virtual void SetTabs(PRUint32 aNumberOfTabs, const nsString aTabLabels[]); + virtual PRUint32 GetSelectedTab(); + virtual PRBool OnPaint(); + virtual PRBool OnResize(nsRect &aWindowRect); + +protected: + virtual LPCTSTR WindowClass(); + virtual DWORD WindowStyle(); + virtual DWORD WindowExStyle(); + +}; + +#endif // nsTabWidget_h__ diff --git a/mozilla/widget/src/windows/nsWidgetFactory.cpp b/mozilla/widget/src/windows/nsWidgetFactory.cpp index a00461fcb98..f4d870df486 100644 --- a/mozilla/widget/src/windows/nsWidgetFactory.cpp +++ b/mozilla/widget/src/windows/nsWidgetFactory.cpp @@ -33,6 +33,7 @@ #include "nsTextHelper.h" #include "nsTextWidget.h" #include "nsToolkit.h" +#include "nsTabWidget.h" #include "nsWindow.h" static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID); @@ -48,6 +49,7 @@ static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); static NS_DEFINE_IID(kCTextArea, NS_TEXTAREA_CID); static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID); +static NS_DEFINE_IID(kCTabWidget, NS_TABWIDGET_CID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); @@ -182,6 +184,16 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCTextField)) { inst = (nsObject*)new nsTextWidget(aOuter); } + else if (mClassID.Equals(kCTabWidget)) { + inst = (nsObject*)new nsTabWidget(aOuter); + } + + printf("inside the widget factory\n"); + printf("inside the widget factory\n"); + printf("inside the widget factory\n"); + printf("inside the widget factory\n"); + printf("inside the widget factory\n"); + if (inst == NULL) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index 5e7e9f092e3..9f17c44a486 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -27,6 +27,7 @@ #include #include "nsGfxCIID.h" #include "resource.h" +#include #include "prtime.h" @@ -69,7 +70,20 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus) //------------------------------------------------------------------------- LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { + // Get the window which caused the event and ask it to process the message nsWindow *someWindow = (nsWindow*)::GetWindowLong(hWnd, GWL_USERDATA); + + + // Re-direct a tab change message destined for it's parent window to the + // the actual window which generated the event. + if (msg == WM_NOTIFY) { + LPNMHDR pnmh = (LPNMHDR) lParam; + if (pnmh->code == TCN_SELCHANGE) { + someWindow = (nsWindow*)::GetWindowLong(pnmh->hwndFrom, GWL_USERDATA); + } + } + + if (nsnull != someWindow) { LRESULT retValue; if (PR_TRUE == someWindow->ProcessMessage(msg, wParam, lParam, &retValue)) { @@ -963,11 +977,25 @@ PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode) PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *aRetValue) { PRBool result = PR_FALSE; // call the default nsWindow proc + *aRetValue = 0; switch (msg) { + + case WM_NOTIFY: + // TAB change + { + LPNMHDR pnmh = (LPNMHDR) lParam; + + if (pnmh->code == TCN_SELCHANGE) { + DispatchEventToCallback(NS_TABCHANGE); + result = PR_TRUE; + } + } + break; + case WM_DESTROY: // clean up. OnDestroy(); @@ -1424,6 +1452,40 @@ PRBool nsWindow::DispatchEvent(PRUint32 aEventType) return ConvertStatus(mEventListener->ProcessEvent(event)); } + +//------------------------------------------------------------------------- +// +// Invokes ProcessEvent method on Event Listener object +// +//------------------------------------------------------------------------- +PRBool nsWindow::DispatchEventToCallback(PRUint32 aEventType) +{ + // call the event callback + if (mEventCallback) { + nsGUIEvent event; + event.widget = this; + + DWORD pos = ::GetMessagePos(); + POINT cpos; + + cpos.x = LOWORD(pos); + cpos.y = HIWORD(pos); + + ::ScreenToClient(mWnd, &cpos); + + event.point.x = cpos.x; + event.point.y = cpos.y; + + event.time = ::GetMessageTime(); + event.message = aEventType; + + return(ConvertStatus((*mEventCallback)(&event))); + } + else + return(PR_FALSE); +} + + //------------------------------------------------------------------------- // // Deal with all sort of mouse event @@ -1525,7 +1587,6 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType) return result; } - //------------------------------------------------------------------------- // // Deal with focus messages diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index f28e545017b..d9cef0ed774 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -132,6 +132,7 @@ protected: WPARAM wParam, LPARAM lParam); + PRBool DispatchEventToCallback(PRUint32 aEventType); static PRBool ConvertStatus(nsEventStatus aStatus); protected: diff --git a/mozilla/widget/tests/windows/winmain.cpp b/mozilla/widget/tests/windows/winmain.cpp index e9efa814150..de76c18c012 100644 --- a/mozilla/widget/tests/windows/winmain.cpp +++ b/mozilla/widget/tests/windows/winmain.cpp @@ -47,6 +47,7 @@ #include "nsFont.h" #include "nsRepository.h" #include "nsWidgetsCID.h" +#include "nsITabWidget.h" #include @@ -66,6 +67,8 @@ nsIListBox *gMultiListBox = NULL; nsIWidget *movingWidget = NULL; nsIScrollbar *scrollbar = NULL; +nsITabWidget *tabWidget = NULL; + char * gFailedMsg = NULL; @@ -102,6 +105,9 @@ static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID); static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID); static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID); +static NS_DEFINE_IID(kCTabWidgetCID, NS_TABWIDGET_CID); + + // interface ids static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); @@ -114,6 +120,7 @@ static NS_DEFINE_IID(kIRadioGroupIID, NS_IRADIOGROUP_IID); static NS_DEFINE_IID(kIListBoxIID, NS_ILISTBOX_IID); static NS_DEFINE_IID(kIComboBoxIID, NS_ICOMBOBOX_IID); static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID); +static NS_DEFINE_IID(kITabWidgetIID, NS_ITABWIDGET_IID); char * eval(PRInt32 aVal) { @@ -683,15 +690,15 @@ void DumpRects() /**-------------------------------------------------------------------------------- - * Main Handler - *-------------------------------------------------------------------------------- + * Main Handler + *-------------------------------------------------------------------------------- */ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) { - //printf("aEvent->message %d\n", aEvent->message); + // printf("aEvent->message %d\n", aEvent->message); nsEventStatus result = nsEventStatus_eIgnore; switch(aEvent->message) { - + case NS_MOUSE_ENTER: if (DEBUG_MOUSE) printf("NS_MOUSE_ENTER 0x%X\n", aEvent->widget); break; @@ -742,6 +749,7 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) break; + case NS_SCROLLBAR_POS: case NS_SCROLLBAR_PAGE_NEXT: case NS_SCROLLBAR_PAGE_PREV: @@ -816,6 +824,28 @@ nsEventStatus PR_CALLBACK HandleFileButtonEvent(nsGUIEvent *aEvent) return(nsEventStatus_eConsumeDoDefault); } +/*-------------------------------------------------------------------------------- + * Tab change handler + *-------------------------------------------------------------------------------- + */ + +nsEventStatus PR_CALLBACK HandleTabEvent(nsGUIEvent *aEvent) +{ + switch(aEvent->message) { + + case NS_TABCHANGE: + PRUint32 tab = tabWidget->GetSelectedTab(); + char buf[256]; + sprintf(buf, "Selected tab %d", tab); + statusText->SetText(buf); + break; + } + + return(nsEventStatus_eConsumeDoDefault); +} + + + /**-------------------------------------------------------------------------------- * @@ -844,6 +874,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd NSRepository::RegisterFactory(kCVertScrollbarCID, "raptorwidget.dll", PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kCTextAreaCID, "raptorwidget.dll", PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kCTextFieldCID, "raptorwidget.dll", PR_FALSE, PR_FALSE); + NSRepository::RegisterFactory(kCTabWidgetCID, "raptorwidget.dll", PR_FALSE, PR_FALSE); static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID); @@ -1104,6 +1135,20 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd y += rect.height + 5; x = 10; + // + // create a tab widget + // + + rect.SetRect(x, y, 300, 50); + NSRepository::CreateInstance(kCTabWidgetCID, nsnull, kITabWidgetIID, (LPVOID*)&tabWidget); + tabWidget->Create(window, rect, HandleTabEvent, NULL); + nsString tabs[] = {"low", "medium", "high" }; + + tabWidget->SetTabs(3, tabs); + tabWidget->Show(PR_TRUE); + y += rect.height + 5; + x = 10; + // // create a Radio Group //