The necessary fixes to get Scribble working.

This commit is contained in:
rods 1998-07-08 16:58:51 +00:00
Родитель 9f5617a7fc
Коммит a225823e94
4 изменённых файлов: 181 добавлений и 30 удалений

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

@ -15,8 +15,116 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../..
DEPTH=../../..
include $(DEPTH)/config/config.mk
CPPSRCS = \
main.cpp \
$(NULL)
INCLUDES+= -I$(PUBLIC)/raptor -I$(PUBLIC)/xpcom -I$(PUBLIC)/shell
DIRS =
OBJS = $(CPPSRCS:.cpp=.o)
EX_LIBS = \
$(DIST)/bin/libraptorbase.so \
$(DIST)/bin/libpng.so \
$(DIST)/bin/libpref.so \
$(DIST)/bin/libraptorbase.so \
$(DIST)/bin/libwidgetunix.so \
$(DIST)/bin/libraptorgfx.so \
$(DIST)/bin/libgfxunix.so \
$(DIST)/bin/libraptorhtml.so \
$(DIST)/bin/libgmbaseunix.so \
$(DIST)/bin/libraptorhtmlbase_s.so \
$(DIST)/bin/libraptorhtmldoc_s.so \
$(DIST)/bin/libraptorhtmlforms_s.so \
$(DIST)/bin/libraptorhtmlpars.so \
$(DIST)/bin/libraptorhtmlstyle_s.so \
$(DIST)/bin/libraptorhtmltable_s.so \
$(DIST)/bin/libraptorlayout_s.so \
$(DIST)/bin/libraptorevents_s.so \
$(DIST)/bin/libraptorview.so \
$(DIST)/bin/libreg.so \
$(DIST)/bin/libabouturl.so \
$(DIST)/bin/libfileurl.so \
$(DIST)/bin/libftpurl.so \
$(DIST)/bin/libgophurl.so \
$(DIST)/bin/libhttpurl.so \
$(DIST)/bin/libimg.so \
$(DIST)/bin/libjpeg.so \
$(DIST)/bin/libjs.so \
$(DIST)/bin/libjsdom.so \
$(DIST)/bin/libjsj.so \
$(DIST)/bin/libmimetype.so \
$(DIST)/bin/libmsgc21.so \
$(DIST)/bin/libnetcache.so \
$(DIST)/bin/libnetcnvts.so \
$(DIST)/bin/libnetlib.so \
$(DIST)/bin/libnetutil.so \
$(DIST)/bin/libnetwork.so \
$(DIST)/bin/libnspr21.so \
$(DIST)/bin/libplc21.so \
$(DIST)/bin/libplds21.so \
$(DIST)/bin/libraptorwebwidget.so \
$(DIST)/bin/libreg.so \
$(DIST)/bin/libremoturl.so \
$(DIST)/bin/libsecfree.so \
$(DIST)/bin/libstubnj.so \
$(DIST)/bin/libstubsj.so \
$(DIST)/bin/libtestdynamic.so \
$(DIST)/bin/libutil.so \
$(DIST)/bin/libxp.so \
$(DIST)/bin/libxpcom.so \
$(DIST)/bin/libzlib.so \
$(DIST)/bin/libutil.so \
$(DIST)/bin/libxp.so \
$(DIST)/bin/libxpcom.so \
$(DIST)/bin/libzlib.so \
$(DIST)/bin/libnglcsslay_s.so \
$(DIST)/bin/libnglhtmlcon_s.so \
$(NULL)
ifeq ($(OS_ARCH),Linux)
EX_LIBS += \
$(DIST)/bin/libpwcac.so \
$(DIST)/bin/libdbm.so \
$(NULL)
endif
PROGS = $(addprefix $(OBJDIR)/, $(CPPSRCS:.cpp=))
TARGETS = $(PROGS)
include $(DEPTH)/config/rules.mk
$(OBJDIR)/Scribble.o:: Scribble.cpp
$(CCC) -o $@ -c $(CFLAGS) Scribble.cpp $(LDFLAGS)
$(OBJDIR)/%.o: %.cpp
@$(MAKE_OBJDIR)
$(CCC) -o $@ $(CFLAGS) -c $*.cpp
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(OBJDIR)/Scribble.o $(EX_LIBS)
@$(MAKE_OBJDIR)
ifeq ($(OS_ARCH),Linux)
$(CCC) -rdynamic -o $@ $@.o $(OBJDIR)/Scribble.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS) -L/usr/X11R6/lib -lXm -lXt -lX11 -lXp -lXext
else
$(CCC) -o $@ $@.o -woff 84,85 $(LDFLAGS) $(OBJDIR)/Scribble.o $(EX_LIBS) $(OS_LIBS) -lXm -lXt -lX11
endif
export::
install:: $(TARGETS)
$(INSTALL) $(PROGS) $(DIST)/bin
clobber::
rm -f $(DIST)/bin/viewer.exe

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

@ -40,6 +40,19 @@
ScribbleApp scribbleData;
#ifdef XP_PC
#define WIDGET_DLL "raptorwidget.dll"
#define GFX_DLL "raptorgfxwin.dll"
#define TEXT_HEIGHT 25
#endif
#ifdef XP_UNIX
#define WIDGET_DLL "libwidgetunix.so"
#define GFX_DLL "libgfxunix.so"
#define TEXT_HEIGHT 30
#endif
static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID);
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
@ -56,7 +69,7 @@ static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
nsEventStatus PR_CALLBACK HandleEventMain(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
nsEventStatus result = nsEventStatus_eConsumeNoDefault;
switch(aEvent->message) {
@ -114,7 +127,7 @@ nsEventStatus PR_CALLBACK HandleEventMain(nsGUIEvent *aEvent)
//
nsEventStatus PR_CALLBACK HandleEventControlPane(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
nsEventStatus result = nsEventStatus_eConsumeNoDefault;
switch(aEvent->message) {
@ -139,17 +152,21 @@ nsEventStatus PR_CALLBACK HandleEventControlPane(nsGUIEvent *aEvent)
12);
drawCtx->SetFont(font);
int y = 351;
nsString red("Red");
drawCtx->SetColor(NS_RGB(255, 0, 0));
drawCtx->DrawString(red, 50, 351, 50);
drawCtx->DrawString(red, 50, y, 200);
y += TEXT_HEIGHT+2;
nsString green("Green");
drawCtx->SetColor(NS_RGB(0, 255, 0));
drawCtx->DrawString(green, 50, 372, 50);
drawCtx->DrawString(green, 50, y, 100);
y += TEXT_HEIGHT+2;
nsString blue("Blue");
drawCtx->SetColor(NS_RGB(0, 0, 255));
drawCtx->DrawString(blue, 50, 393, 50);
drawCtx->DrawString(blue, 50, y, 100);
y += TEXT_HEIGHT+2;
return nsEventStatus_eConsumeNoDefault;
}
@ -164,7 +181,7 @@ nsEventStatus PR_CALLBACK HandleEventControlPane(nsGUIEvent *aEvent)
//
nsEventStatus PR_CALLBACK HandleEventGraphicPane(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
nsEventStatus result = nsEventStatus_eConsumeNoDefault;
switch(aEvent->message) {
@ -219,7 +236,7 @@ nsEventStatus PR_CALLBACK HandleEventGraphicPane(nsGUIEvent *aEvent)
//
nsEventStatus PR_CALLBACK HandleEventButton(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
switch(aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_UP:
@ -234,7 +251,7 @@ nsEventStatus PR_CALLBACK HandleEventButton(nsGUIEvent *aEvent)
//
nsEventStatus PR_CALLBACK HandleEventRadioButton(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
switch(aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_UP: {
@ -261,8 +278,8 @@ nsEventStatus PR_CALLBACK HandleEventRadioButton(nsGUIEvent *aEvent)
//
nsEventStatus PR_CALLBACK HandleEventCheck(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
printf("aEvent->message %d == %d on 0x%X\n", aEvent->message, NS_MOUSE_LEFT_BUTTON_UP, aEvent->widget);
//printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//printf("aEvent->message %d == %d on 0x%X\n", aEvent->message, NS_MOUSE_LEFT_BUTTON_UP, aEvent->widget);
switch(aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_UP:
@ -330,7 +347,8 @@ nsEventStatus PR_CALLBACK HandleEventCheck(nsGUIEvent *aEvent)
//
nsEventStatus PR_CALLBACK HandleEventText(nsGUIEvent *aEvent)
{
printf("aEvent->message %d on 0x%X\n", aEvent->message, aEvent->widget);
//if (aEvent->message != 300)
//printf("HandleEventText message %d on 0x%X\n", aEvent->message, aEvent->widget);
switch(aEvent->message) {
case NS_LOSTFOCUS:
@ -371,13 +389,11 @@ nsEventStatus PR_CALLBACK HandleEventText(nsGUIEvent *aEvent)
return nsEventStatus_eIgnore;
}
#define WIDGET_DLL "raptorwidget.dll"
#define GFXWIN_DLL "raptorgfxwin.dll"
//
// Main application entry function
//
nsresult CreateApplication()
nsresult CreateApplication(int * argc, char ** argv)
{
scribbleData.isDrawing = PR_FALSE;
@ -387,10 +403,10 @@ nsresult CreateApplication()
static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);
NSRepository::RegisterFactory(kCRenderingContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCDeviceContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCFontMetricsIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCRenderingContextIID, GFX_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCDeviceContextIID, GFX_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCFontMetricsIID, GFX_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCImageIID, GFX_DLL, PR_FALSE, PR_FALSE);
// register widget classes
static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID);
@ -406,7 +422,7 @@ nsresult CreateApplication()
static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID);
static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);
NSRepository::RegisterFactory(kCAppShellCID, "raptorwidget.dll", PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCAppShellCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCWindowCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCChildCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
@ -436,16 +452,26 @@ nsresult CreateApplication()
// Create an application shell
nsIAppShell *appShell;
NSRepository::CreateInstance(kCAppShellCID, nsnull, kIAppShellIID, (void**)&appShell);
int argc;
char ** argv = nsnull;
appShell->Create(&argc, argv);
appShell->Create(argc, argv);
//
// create the main window
//
NSRepository::CreateInstance(kCWindowCID, nsnull, kIWidgetIID, (void **)&(scribbleData.mainWindow));
nsRect rect(100, 100, 600, 600);
//nsRect rect(100, 100, 600, 600);
//scribbleData.mainWindow->Create((nsIWidget*)NULL, rect, HandleEventMain, NULL);
#ifdef XP_PC
nsRect rect(100, 100, 600, 700);
scribbleData.mainWindow->Create((nsIWidget*)NULL, rect, HandleEventMain, NULL);
#endif
#ifdef XP_UNIX
nsRect rect(100, 100, 400, 580);
scribbleData.mainWindow->Create((nsNativeWidget)NULL, rect, HandleEventMain,
(nsIDeviceContext *)nsnull,
(nsIToolkit *)nsnull,
(nsWidgetInitData*)appShell->GetNativeData(NS_NATIVE_SHELL));
#endif
scribbleData.mainWindow->SetBackgroundColor(NS_RGB(255, 255, 255));
//
// create the control pane
@ -454,6 +480,7 @@ nsresult CreateApplication()
rect.SetRect(0, 0, 200, 580);
NSRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&controlPane);
controlPane->Create(scribbleData.mainWindow, rect, HandleEventControlPane, NULL);
controlPane->SetBackgroundColor(NS_RGB(255, 255, 255));
//
// Add the scribble/lines section
@ -511,8 +538,9 @@ nsresult CreateApplication()
// Add the color section
//
int y = 350;
// create the "red" text widget
rect.SetRect(100, 350, 50, 22);
rect.SetRect(100, y, 50, TEXT_HEIGHT);
NSRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.red));
scribbleData.red->Create(controlPane, rect, HandleEventText, NULL);
@ -520,24 +548,27 @@ nsresult CreateApplication()
scribbleData.red->SetText(initText);
scribbleData.red->SetBackgroundColor(NS_RGB(0, 0, 255));
scribbleData.red->Show(PR_TRUE);
y += rect.height +2;
// create the "green" text widget
rect.SetRect(100, 371, 50, 22);
rect.SetRect(100, y, 50, TEXT_HEIGHT);
NSRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.green));
scribbleData.green->Create(controlPane, rect, HandleEventText, NULL);
scribbleData.green->SetText(initText);
scribbleData.green->SetBackgroundColor(NS_RGB(255, 0, 0));
scribbleData.green->Show(PR_TRUE);
y += rect.height +2;
// create the "blue" text widget
rect.SetRect(100, 392, 50, 22);
rect.SetRect(100, y, 50, TEXT_HEIGHT);
NSRepository::CreateInstance(kCTextFieldCID, nsnull, kITextWidgetIID, (void **)&(scribbleData.blue));
scribbleData.blue->Create(controlPane, rect, HandleEventText, NULL);
scribbleData.blue->SetText(initText);
scribbleData.blue->SetBackgroundColor(NS_RGB(0, 255, 0));
scribbleData.blue->Show(PR_TRUE);
y += rect.height +2;
//
// create a button
@ -559,6 +590,7 @@ nsresult CreateApplication()
rect.SetRect(200, 0, 400, 580);
NSRepository::CreateInstance(kCChildCID, nsnull, kIWidgetIID, (void **)&scribbleData.drawPane);
scribbleData.drawPane->Create(scribbleData.mainWindow, rect, HandleEventGraphicPane, NULL);
scribbleData.drawPane->SetBackgroundColor(NS_RGB(255, 255, 255));
//
// show. We are in business...

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

@ -46,7 +46,7 @@ struct ScribbleApp {
};
nsresult CreateApplication();
nsresult CreateApplication(int * argc, char ** argv);
#endif

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

@ -27,13 +27,24 @@ int WINAPI WinMain(HINSTANCE hInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
return(CreateApplication());
int argC = 0;
char ** argv = NULL;
return(CreateApplication(&argc, argv));
}
void main(int argc, char **argv)
{
WinMain(GetModuleHandle(NULL), NULL, 0, SW_SHOW);
WinMain(GetModuleHandle(NULL), NULL, 0, SW_SHOW);
}
#endif
#ifdef XP_UNIX
void main(int argc, char **argv)
{
int argC = argc;
return(CreateApplication(&argC, argv));
}
#endif