home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume15 / touchup / part06 / info.c next >
Encoding:
C/C++ Source or Header  |  1988-06-14  |  6.4 KB  |  275 lines

  1.  
  2. /**************************************************************************
  3.    Touchup a bitmap graphics editor for the Sun Workstation running SunView
  4.    Copyright (c) 1988 by Raymond Kreisel
  5.    1/22/88 @ Suny Stony Brook
  6.  
  7.    This program may be redistributed without fee as long as this copyright
  8.    notice is intact.
  9.  
  10. ==> PLEASE send comments and bug reports to one of the following addresses:
  11.  
  12.        Ray Kreisel
  13.        CS Dept., SUNY at Stony Brook, Stony Brook NY 11794
  14.  
  15.        UUCP: {allegra, philabs, pyramid, research}!sbcs!rayk   
  16.        ARPA-Internet: rayk@sbcs.sunysb.edu            
  17.        CSnet: rayk@suny-sb
  18.        (If nobody is home at any of the above addresses try:
  19.         S72QKRE@TOWSONVX.BITNET                    )
  20.  
  21.  "If I get home before daylight, I just might get some sleep tonight...."
  22.  
  23. **************************************************************************/
  24. /**************************************************************************
  25.     file: info.c
  26.     purpose: this file has the functions that had the "view" pop up
  27.         window.  You can view the "man page", copyright notice
  28.         with the picture of the author (me), and the cut/paste
  29.            buffer
  30.  
  31.     modifications:
  32.         date:    Tue Mar 22 22:04:58 EST 1988
  33.         author:    rayk
  34.         changes:add comments
  35. **************************************************************************/
  36.  
  37. #include "header.h"
  38.  
  39. #include <suntool/textsw.h>
  40.  
  41. Frame view_frame;
  42. Canvas view_canvas;
  43. Pixwin *view_pw;
  44. Panel view_panel;
  45. int view_flag=FALSE;
  46.  
  47.  
  48. /*
  49.  * this function will read in the copyright notice
  50.  * with my picture on it and display it in a new window
  51.  */
  52. info_init()
  53. {
  54. FILE *fp,*fopen();
  55. int color_map=NULL;
  56. struct pixrect *temp_pr;
  57.  
  58.    fp = fopen(INFO_IMAGE,"r");
  59.    if (!fp)
  60.    {
  61.       ERROR("I Could not find the information file !!!!");
  62.       view_flag = FALSE;
  63.       fclose(fp);
  64.       return(0);
  65.    }
  66.    temp_pr = (struct pixrect *)pr_load(fp,color_map);
  67.    if (!temp_pr)
  68.    {
  69.       ERROR("I Could not find the information file !!!!");
  70.       view_flag = FALSE;
  71.       fclose(fp);
  72.       return(0);
  73.    }
  74.    view_init(temp_pr,"Information on Touchup");
  75.    MY_pr_destroy(temp_pr);
  76.    fclose(fp);
  77. }
  78.  
  79.  
  80. /*
  81.  * this function will let you view the cut/paste buffer
  82.  * in a seperate window
  83.  */
  84. view_cut_paste()
  85. {
  86.    if (cut_buffer_pr)
  87.    {
  88.      view_init(cut_buffer_pr,"The current Cut/Paste Buffer");
  89.    }
  90.    else
  91.    {
  92.      ERROR("The CUT/PASTE buffer is empty.");
  93.    }
  94. }
  95.  
  96.  
  97. /*
  98.  * we got a button click on "view"
  99.  * check out what we need to view
  100.  */
  101. #define VIEW_INFO 0
  102. #define VIEW_HELP 1
  103. #define VIEW_CUT_PASTE 2
  104. viewer()
  105. {
  106.    switch((int)panel_get_value(view_cycle)) {
  107.     case VIEW_INFO: info_init();
  108.              break;
  109.     case VIEW_CUT_PASTE: view_cut_paste();
  110.               break;
  111.     case VIEW_HELP: view_help();
  112.    }
  113. }
  114.  
  115.  
  116. /*
  117.  * close up the view window
  118.  */
  119. view_done()
  120. {
  121.    if (view_flag)
  122.    {
  123.      window_set(view_frame, FRAME_NO_CONFIRM, TRUE, 0);
  124.      window_destroy(view_frame);
  125.      view_flag = FALSE;  
  126.    }
  127. }
  128.  
  129.  
  130. /*
  131.  * this function will take a pixrect and create a new window
  132.  * which we can view it in
  133.  */
  134. view_init(view_pr,frame_label)
  135. struct pixrect *view_pr;
  136. char *frame_label;
  137. {
  138. Rect *r;
  139.  
  140.    if (view_flag)
  141.    {
  142.       view_done();
  143.    }
  144.    view_flag = TRUE;
  145.  
  146.     r = (Rect *) window_get(base_frame, WIN_RECT);
  147.     view_frame = window_create(base_frame,FRAME,
  148.         FRAME_LABEL,    frame_label,
  149.             FRAME_SHOW_LABEL, TRUE,
  150.         WIN_SHOW,    TRUE,
  151.         WIN_FONT,    main_font,
  152.         WIN_WIDTH,    view_pr->pr_size.x+20,
  153.         WIN_HEIGHT,    view_pr->pr_size.y+60,
  154.             WIN_X,        (r->r_width - view_pr->pr_size.x+20)/2,
  155.             WIN_Y,        (r->r_height - view_pr->pr_size.y+50)/4,
  156.         0);
  157.  
  158.     view_canvas = 
  159.         window_create(view_frame, CANVAS, 
  160.         WIN_CONSUME_PICK_EVENTS,    WIN_NO_EVENTS,WIN_MOUSE_BUTTONS,
  161.                     LOC_DRAG, LOC_WINENTER,
  162.                     LOC_MOVE, 
  163.                     0,
  164.         WIN_X,        0,
  165.         WIN_Y,        ATTR_ROW(2)+5,
  166.         CANVAS_WIDTH,        view_pr->pr_size.x+5,
  167.         CANVAS_HEIGHT,        view_pr->pr_size.y+5,
  168.         CANVAS_AUTO_SHRINK,        TRUE,
  169.         CANVAS_FIXED_IMAGE,        FALSE,
  170.         CANVAS_AUTO_EXPAND,        TRUE,
  171.         CANVAS_RETAINED,        TRUE,
  172.         0),
  173.  
  174.     view_pw = canvas_pixwin(view_canvas);
  175.  
  176.     if (view_pr->pr_depth > 1)
  177.     {
  178.     pw_setcmsname(view_pw, "ray kreisel");
  179.     pw_putcolormap(view_pw, 0,256,temp_red,temp_green,temp_blue);
  180.     }
  181.  
  182.     view_panel = window_create(view_frame, PANEL,
  183.          PANEL_LABEL_BOLD,         TRUE,
  184.         WIN_FONT,    main_font,
  185.          WIN_X,             0,
  186.          WIN_Y,             3,
  187.          WIN_HEIGHT,         ATTR_ROW(1)+4,
  188.         0);
  189.    
  190.    (void)panel_create_item(view_panel, PANEL_BUTTON, 
  191.      PANEL_ITEM_X, ATTR_COL(0),
  192.      PANEL_ITEM_Y, ATTR_ROW(0),
  193.      PANEL_LABEL_IMAGE, panel_button_image(view_panel, "done", 5, (Pixfont *)0),
  194.      PANEL_NOTIFY_PROC, view_done,
  195.      0);
  196.  
  197.   /* write the image files to the canvas */
  198.  
  199.    pw_write(view_pw,0,0,view_pr->pr_size.x,
  200.          view_pr->pr_size.y,PIX_SRC, view_pr,0,0);
  201. }   
  202.  
  203.  
  204. /*
  205.  * this function is used to view the man page
  206.  */
  207. #define VIEW_HELP_FLAG 2
  208. view_help()
  209. {
  210. Rect *r;
  211.  
  212.    if (!file_exist(HELP_FILE))
  213.    {
  214.       ERROR("I cannot find the man page for touchup !!!");
  215.       return(0);
  216.    }
  217.  
  218.    if (view_flag == VIEW_HELP_FLAG)
  219.    {
  220.       (void)window_set(view_frame, WIN_SHOW, TRUE, 0);
  221.       return(0);
  222.    }
  223.    else
  224.    {
  225.       if (view_flag)
  226.       view_done();
  227.    }
  228.    view_flag = VIEW_HELP_FLAG;
  229.  
  230.     r = (Rect *) window_get(base_frame, WIN_RECT);
  231.     view_frame = window_create(base_frame,FRAME,
  232.         FRAME_LABEL,    "Help window",
  233.             FRAME_SHOW_LABEL, TRUE,
  234.         WIN_SHOW,    TRUE,
  235.         WIN_FONT,    main_font,
  236.             WIN_X,        (r->r_width - 600+20)/2,
  237.             WIN_Y,        (r->r_height - 512+50)/4,
  238.         0);
  239.  
  240.     view_panel = window_create(view_frame, PANEL,
  241.          PANEL_LABEL_BOLD,         TRUE,
  242.         WIN_FONT,    main_font,
  243.          WIN_X,             0,
  244.          WIN_Y,             3,
  245.          WIN_HEIGHT,         ATTR_ROW(1)+4,
  246.         0);
  247.    
  248.    (void)panel_create_item(view_panel, PANEL_BUTTON, 
  249.      PANEL_ITEM_X, ATTR_COL(0),
  250.      PANEL_ITEM_Y, ATTR_ROW(0),
  251.      PANEL_LABEL_IMAGE, panel_button_image(view_panel, "done", 5, (Pixfont *)0),
  252.      PANEL_NOTIFY_PROC, view_done,
  253.      0);
  254.  
  255.  
  256.     (void)window_create(view_frame, TEXTSW,
  257.         WIN_ERROR_MSG,         "I cannot find the man page for touchup",
  258.                 WIN_X,                  0,
  259.         WIN_Y,            ATTR_ROW(2)+5,
  260.                 WIN_HEIGHT,             512,
  261.                 WIN_WIDTH,              600,
  262.         TEXTSW_FONT,        main_font,
  263.                 TEXTSW_IGNORE_LIMIT,    TEXTSW_INFINITY,
  264.                 TEXTSW_AUTO_INDENT,     TRUE,
  265.                 TEXTSW_BROWSING,        TRUE,
  266.                 TEXTSW_DISABLE_LOAD,    TRUE,
  267.                 TEXTSW_DISABLE_CD,      TRUE,
  268.             TEXTSW_FILE,        HELP_FILE,
  269.                 0);
  270.  
  271.   window_fit(view_frame);
  272. }   
  273.  
  274.  
  275.