home *** CD-ROM | disk | FTP | other *** search
- /*
- * kd_freq.library NewFR() Test
- *
- * This demonstrates the use of CreateFRequest(), DeleteFRequest() and
- * NewFReq() for a minimum of fuss in allocating stuff for the FR.
- *
- * Note the use of NextSelectEntry() to check the select list.
- *
- * You need to assemble and link glue.asm with this, or use the
- * appropriate #pragmas!
- *
- */
-
-
- #include "KDBase.h"
-
- struct Library *KD_FReqBase, *OpenLibrary();
-
- struct ExtraButton eb = {
- NULL, /* pointer to next button, unused, set to NULL */
- NULL, /* button flags, unused, set to NULL */
- NULL, /* address of function to call, fill in later */
- (UBYTE *)"My Button", /* Text to appear on button, up to 10 chars */
- (UBYTE *)"An Extra Button", /* next 3 are help lines.. all are optional */
- (UBYTE *)"for that special function",
- (UBYTE *)"in your program",
- NULL, /* Your own data here. */
- NULL /* leave this empty */
- };
-
- ULONG button(eb)
- struct ExtraButton *eb;
- {
- printf("Hey! The user clicked on the extra button!!\n");
-
- printf("Button: %s\n",eb->text);
- printf("Window: %08x\n",eb->window);
-
- return(EB_CONTINUE);
- }
-
- main()
- {
- struct FRequest *fr, *CreateFRequest();
- char *file, *NewFReq();
- UBYTE *entry, *NextSelectEntry();
-
- if (KD_FReqBase = OpenLibrary(KLIBNAME,KLIBVERSION))
- {
- if (fr = (struct FRequest *) CreateFRequest())
- {
- /* Set the requester title */
- fr->reqtitle = (UBYTE *) "FR Test";
-
- /* already set by CreateFRequest() */
- fr->flags = FR_STDFLAGS | FR_SELECTLIST | FR_EXTRABUTTONS | FR_USEPENS;
-
- /* We want to add our own button (gadget) to the FR */
- fr->extras->button = &eb;
-
- /* Address of function to call when our extrabutton is clicked */
- eb.button_function = button;
-
- /* Set the default show and hide wildcards */
- /* strcpy(fr->pattern,"#?.?"); */
- /* strcpy(fr->extras->Hide,"#?.o"); */
-
-
- /* let's set up our own color scheme... */
- /* in this case, we are using the default pens the FR normally uses */
- /* If we don't do this, we must clear the FR_USEPENS flag above */
-
- fr->extras->pen0 = 1; /* shadow pen */
- fr->extras->pen1 = 1; /* basic text pen for filenames */
- fr->extras->pen2 = 2; /* titles and info pen */
- fr->extras->pen3 = 3; /* directories pen */
-
- /* Call the file requester and get a file name */
-
- if (file = (char *)NewFReq(fr))
- printf("Selected: %s\n\n",file);
- else
- printf("Cancelled.\n\n");
-
- /* Show some of the stuff we got back from the call */
-
- printf("Path : %s\n",fr->fullname);
- printf("Title : %s\n",fr->reqtitle);
- printf("Dir : %s\n",fr->directory);
- printf("File : %s\n",fr->filename);
- printf("Show Pat: %s\n",fr->pattern);
- printf("Hide Pat: %s\n",fr->extras->Hide);
- printf("Position: %3d , %3d\n",fr->extras->LeftEdge,fr->extras->TopEdge);
- printf("Size : %3d x %3d\n",fr->extras->Width,fr->extras->Height);
-
-
- /* Check if the user selected multiple files */
-
- if (fr->extras->SelectList)
- {
- /* ok.. print them out */
- printf("\nSelect List:\n\n");
-
- while (entry = NextSelectEntry(fr))
- {
- printf("%s\n",entry);
- }
- }
-
-
- /* Don't do this unless you're done with the FRequest struct */
-
- DeleteFRequest(fr);
- }
-
- CloseLibrary(KD_FReqBase);
- }
- else
- {
- printf("Can't Open 'kd_freq.library'. Make sure it is in LIBS:\n");
- }
- }
-