home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
500-599
/
ff562.lza
/
Intuisup
/
Editor
/
source.lzh
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-19
|
5KB
|
169 lines
/*************************************
* *
* Editor v1.0 *
* by Torsten Jürgeleit in 07/91 *
* *
* Main part *
* *
*************************************/
/* Includes */
#include "includes.h"
#include "defines.h"
#include "imports.h"
#include "protos.h"
/* Globals */
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct ArpBase *ArpBase;
struct Library *IntuiSupBase = NULL; /* Clear for show_error() */
struct Library *DiskfontBase;
struct Screen wb_screen;
struct Window *ewin, *pwin;
struct TextAttr topaz60_attr = { (STRPTR)"topaz.font", TOPAZ_SIXTY,
FS_NORMAL, FPF_ROMFONT },
topaz80_attr = { (STRPTR)"topaz.font", TOPAZ_EIGHTY,
FS_NORMAL, FPF_ROMFONT };
struct NewWindow project_new_window = {
0, 0, 0, 0, PROJECT_WINDOW_DETAIL_PEN, PROJECT_WINDOW_BLOCK_PEN,
PROJECT_WINDOW_IDCMP, PROJECT_WINDOW_FLAGS, NULL, NULL,
PROJECT_WINDOW_TITLE, NULL, NULL, PROJECT_WINDOW_MIN_WIDTH,
PROJECT_WINDOW_MIN_HEIGHT, -1, -1, WBENCHSCREEN
};
struct TemplateList template_list;
struct Template *selected_template,
*info_template;
struct Box current_box;
struct GadgetData *use_gd;
struct FileRequester *project_file_requester,
*csource_file_requester;
struct Dimension min_dimension[MAX_TEMPLATE_TYPES] = {
{ 20, 10 }, { 0, 0 }, { 20, 10 }, { 21, 11 }, { 50, 10 }, { 30, 8 },
{ 30, 8 }, { 20, 8 }, { 20, 8 }, { 50, 10 }, { 40, 10 },
{ 40, 30 }, { 60, 30 } };
APTR eri, pri, egl, eml, use_gl;
BYTE *default_mx_text_array[] = { "MX1", "MX2", NULL },
*default_cycle_text_array[] = { "Cycle", "Test 1", "Test 2", NULL },
*default_listview_text_array[] = { "Entry 1", "Entry 2", "Entry 3",
"Entry 4", "Entry 5", "Entry 6", "Entry 7", "Entry 8",
"Entry 9", "Entry 10", NULL };
BYTE project_window_title[80];
USHORT snap_offset_table[] = { 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
USHORT editor_mode = DEFAULT_EDITOR_MODE,
snap_offset = DEFAULT_SNAP_OFFSET,
template_type = DEFAULT_TEMPLATE_TYPE;
USHORT modify_mode = 0, mouse_button = 0;
SHORT last_snap_x, last_snap_y;
BOOL info_displayed = FALSE;
/* Statics */
STATIC struct NewWindow editor_new_window = {
EDITOR_WINDOW_LEFT, EDITOR_WINDOW_TOP, EDITOR_WINDOW_WIDTH,
EDITOR_WINDOW_HEIGHT, 0, 1, EDITOR_WINDOW_IDCMP, EDITOR_WINDOW_FLAGS,
NULL, NULL, EDITOR_WINDOW_TITLE, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
};
/* Main routine */
LONG
main(VOID)
{
LONG return_code = RETURN_ERROR;
MWInit((BPTR)NULL, (LONG)MWF_NOATRASH);
if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
if (GfxBase = OpenLibrary("graphics.library", 0L)) {
if (!(ArpBase = OpenLibrary(ArpName, ArpVersion))) {
show_error(EDITOR_ERROR_NO_ARP);
} else {
if (!(IntuiSupBase = OpenLibrary(IntuiSupName,
IntuiSupVersion))) {
show_error(EDITOR_ERROR_NO_INTUISUP);
} else {
if (!(DiskfontBase = OpenLibrary("diskfont.library", 0L))) {
show_error(EDITOR_ERROR_NO_DISKFONT);
} else {
return_code = init_resources();
CloseLibrary(DiskfontBase);
}
CloseLibrary(IntuiSupBase);
}
CloseLibrary(ArpBase);
}
CloseLibrary(GfxBase);
}
CloseLibrary(IntuitionBase);
}
MWTerm();
return(return_code);
}
/* Init resources */
LONG
init_resources(VOID)
{
SHORT status;
LONG return_code = RETURN_OK;
GetScreenData((BYTE *)&wb_screen, (LONG)sizeof(struct Screen), (LONG)
WBENCHSCREEN, (struct Screen *)NULL);
/* Init and open editor window */
if (!(eri = IGetRenderInfo((struct Screen *)NULL,
EDIT_RENDER_INFO_FLAGS))) {
status = EDITOR_ERROR_OUT_OF_MEM;
} else {
editor_new_window.LeftEdge = (wb_screen.Width -
editor_new_window.Width) / 2;
if (!(ewin = IOpenWindow(eri, &editor_new_window,
EDIT_OPEN_WINDOW_FLAGS))) {
status = EDITOR_ERROR_NO_WINDOW;
} else {
/* Init and open project window */
pri = NULL;
pwin = NULL;
if ((status = new_project_window(TEMPLATE_LIST_FLAG_DEFAULT_WINDOW))
== EDITOR_STATUS_NORMAL) {
/* Init ARP file requester structs */
if (!(project_file_requester = ArpAllocFreq())) {
status = EDITOR_ERROR_OUT_OF_MEM;
} else {
if (!(csource_file_requester = ArpAllocFreq())) {
status = EDITOR_ERROR_OUT_OF_MEM;
} else {
status = editor_action_loop();
}
}
}
/* Free resources */
if (pwin) {
CloseWindow(pwin);
}
if (pri) {
IFreeRenderInfo(pri);
}
CloseWindow(ewin);
}
IFreeRenderInfo(eri);
}
if (status < EDITOR_STATUS_NORMAL) {
show_error(status);
return_code = RETURN_ERROR;
}
return(return_code);
}