home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / workbench / stickit2 / source.lha / source / commodgad.c < prev    next >
C/C++ Source or Header  |  1995-01-09  |  18KB  |  783 lines

  1. /*************************************************
  2.  **************   commodgad.c   ******************
  3.  *************************************************/
  4.  
  5. #define INTUI_V36_NAMES_ONLY
  6.  
  7. #include <libraries/commodities.h>
  8. #include <exec/exec.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/gadgetclass.h>
  11. #include <libraries/asl.h>
  12.  
  13. #include <clib/commodities_protos.h>
  14. #include <clib/exec_protos.h>
  15. #include <clib/gadtools_protos.h>
  16. #include <clib/intuition_protos.h>
  17. #include <clib/gadtools_protos.h>
  18. #include <clib/asl_protos.h>
  19. #include <clib/graphics_protos.h>
  20. #include <clib/diskfont_protos.h>
  21.  
  22. #include <stdio.h>    /* For printf calls, remove when finished */
  23. #include <string.h>
  24.  
  25. #include "stickit2.h"
  26.  
  27. #include "consts.h"
  28. #include "structs.h"
  29. #include "proto.h"
  30.  
  31. extern prj_p prj;
  32.  
  33. /*
  34. Function : void commodlistview(int number,ULONG seconds,ULONG micros)
  35. Purpose : The user has clicked on the listview gadget, number number. If there
  36.     is already a note in the gadgets, this info is copied out. The selected
  37.     note is then shown.
  38. */
  39.  
  40. void commodlistview(int number,ULONG seconds,ULONG micros)
  41. {
  42.     /* If there is no current note on display, de-ghost the gadgets */
  43.  
  44.     if (!prj->curr_note) {
  45.         GT_SetGadgetAttrs(commodGadgets[commod_title],commod,NULL,
  46. GA_Disabled,FALSE,TAG_END);
  47.         GT_SetGadgetAttrs(commodGadgets[commod_cyccolour],commod,NULL,
  48. GA_Disabled,FALSE,TAG_END);
  49.         GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,NULL,
  50. GA_Disabled,FALSE,TAG_END);
  51.         GT_SetGadgetAttrs(commodGadgets[commod_font],commod,NULL,
  52. GA_Disabled,FALSE,TAG_END);
  53.         GT_SetGadgetAttrs(commodGadgets[commod_pubscreen],commod,NULL,
  54. GA_Disabled,FALSE,TAG_END);
  55.     }
  56.     else
  57.         commodtonote(prj->curr_note);
  58.  
  59.     prj->curr_note = prj->notes[number];
  60.  
  61.     if (!prj->curr_note)
  62.         error("Can't find listview note",ERR_FATAL,__LINE__,__FILE__);
  63.  
  64.     notetocommod(prj->curr_note);
  65.  
  66.     /* If timings are zero, selected from menu */
  67.  
  68.     if ((!seconds) && (!micros))
  69.         return;
  70.  
  71.     /* Did the user double-click on the gadget ? */
  72.  
  73.     if ((DoubleClick(prj->doubleclickseconds,prj->doubleclickmicros,
  74. seconds,micros)) && (prj->lastclicked == number)) {
  75.         note_open(prj->curr_note);
  76.         note_refresh(prj->curr_note);
  77.     }
  78.  
  79.     /* Copy double click values */
  80.  
  81.     prj->lastclicked = number;
  82.     prj->doubleclickseconds = seconds;
  83.     prj->doubleclickmicros = micros;
  84. }
  85.  
  86. /*
  87. Function : void commodcyccolour(int number)
  88. Purpose : The user has clicked on the cycle gadget. Store the number in the
  89.     prj structure.
  90. */
  91.  
  92. void commodcyccolour(int number)
  93. {
  94.     note_p curr_note;
  95.  
  96.     prj->commodcolour = number;
  97.  
  98.     if (!prj->curr_note)
  99.         return;
  100.  
  101.     curr_note = prj->curr_note;
  102.  
  103.     /* Find out which colour to show */
  104.  
  105.     switch (prj->commodcolour) {
  106.         case COLOUR_BACKGROUND:
  107.             GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,
  108. NULL,GTPA_Color,curr_note->backcolour,TAG_END);
  109.             break;
  110.         case COLOUR_TEXT:
  111.             GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,
  112. NULL,GTPA_Color,curr_note->textcolour,TAG_END);
  113.             break;
  114.         case COLOUR_CARAT:
  115.             GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,
  116. NULL,GTPA_Color,curr_note->caratcolour,TAG_END);
  117.             break;
  118.         default:
  119.             break;
  120.     }
  121. }
  122.  
  123. /*
  124. Function : void commodpalette(int number)
  125. Purpose : The user has clicked on the palette gadget. Refresh the note and
  126.     carat colours as appropriate.
  127. */
  128.  
  129. void commodpalette(int number)
  130. {
  131.     note_p curr_note;
  132.  
  133.     if (!prj->curr_note)
  134.         return;
  135.  
  136.     curr_note = prj->curr_note;
  137.  
  138.     switch (prj->commodcolour) {
  139.         case COLOUR_BACKGROUND:
  140.             if (curr_note->backcolour == number)
  141.                 break;
  142.  
  143.             curr_note->backcolour = number;
  144.  
  145.             if (curr_note->win)
  146.                 note_refresh(curr_note);
  147.             break;
  148.         case COLOUR_TEXT:
  149.             if (curr_note->textcolour == number)
  150.                 break;
  151.  
  152.             curr_note->textcolour = number;
  153.  
  154.             if (curr_note->win)
  155.                 note_refresh(curr_note);
  156.             break;
  157.         case COLOUR_CARAT:
  158.             if (curr_note->caratcolour == number)
  159.                 break;
  160.  
  161.             if (!curr_note->carat.text) {
  162.                 curr_note->caratcolour = number;
  163.                 break;
  164.             }
  165.             break;
  166.         default:
  167.             break;
  168.     }
  169.  
  170.     /* Colour probably changed */
  171.  
  172.     prj->projectchanged = TRUE;
  173. }
  174.  
  175. /*
  176. Function : void commodtitle()
  177. Purpose : The user has clicked on the title gadget. Copy the new title text
  178.     to the window's title bar.
  179. */
  180.  
  181. void commodtitle()
  182. {
  183.     struct Window *curr_win;
  184.     struct Gadget *curr_gad;
  185.  
  186.     note_p curr_note;
  187.  
  188.     if (!prj->curr_note)
  189.         return;
  190.  
  191.     curr_note = prj->curr_note;
  192.  
  193.     curr_win = curr_note->win;
  194.  
  195.     if (!curr_win)
  196.         return;
  197.  
  198.     curr_gad = commodGadgets[commod_title];
  199.  
  200.     strncpy(curr_note->title,
  201. ((struct StringInfo *)curr_gad->SpecialInfo)->Buffer,STRLEN_NOTETITLE);
  202.  
  203.     SetWindowTitles(curr_win,curr_note->title,(UBYTE *)-1);
  204.  
  205.     /* Data has probably changed */
  206.  
  207.     prj->projectchanged = TRUE;
  208. }
  209.  
  210. /*
  211. Function : void commodfont()
  212. Purpose : The user has clicked on the font... gadget, so pop up a font
  213.     requester.
  214. */
  215.  
  216. void commodfont()
  217. {
  218.     struct FontRequester *fontreq;
  219.     struct Window *curr_win;
  220.     struct RastPort *curr_rport;
  221.  
  222.     note_p curr_note;
  223.  
  224.     if (!prj->curr_note)
  225.         return;
  226.  
  227.     curr_note = prj->curr_note;
  228.     curr_win = curr_note->win;
  229.     curr_rport = curr_win->RPort;
  230.  
  231.     if (curr_note->fontname[0] != '\0')
  232.         fontreq = (struct FontRequester *)AllocAslRequestTags(
  233. ASL_FontRequest,ASL_FontName,prj->curr_note->fontname,ASL_FontHeight,
  234. prj->curr_note->textattr.ta_YSize,ASL_FontStyles,
  235. prj->curr_note->textattr.ta_Style,ASL_HookFunc,(ULONG)hookfunc,
  236. ASL_FuncFlags,FONF_STYLES|FONF_DOMSGFUNC,ASL_Window,commod,TAG_DONE);
  237.     else
  238.         fontreq = (struct FontRequester *)AllocAslRequestTags(
  239. ASL_FontRequest,ASL_FontName,"topaz.font",ASL_FontHeight,8,ASL_FontStyles,
  240. prj->curr_note->textattr.ta_Style,ASL_HookFunc,(ULONG)hookfunc,
  241. ASL_FuncFlags,FONF_STYLES|FONF_DOMSGFUNC,ASL_Window,commod,TAG_DONE);
  242.  
  243.     if (!fontreq)
  244.         return;
  245.  
  246.     /* Block mouse input to all open windows */
  247.  
  248.     note_blockall();
  249.     commod_block();
  250.  
  251.     if (AslRequest(fontreq,NULL)) {
  252.         /* If existing font open, close it */
  253.  
  254.         if (curr_note->font) {
  255.             CloseFont(curr_note->font);
  256.             curr_note->font = NULL;
  257.         }
  258.  
  259.         /* Copy new font details to note */
  260.  
  261.         strncpy(curr_note->fontname,fontreq->fo_Attr.ta_Name,STRLEN_FONTNAME);
  262.         curr_note->textattr.ta_Name = curr_note->fontname;
  263.         curr_note->textattr.ta_YSize = fontreq->fo_Attr.ta_YSize;
  264.         curr_note->textattr.ta_Style = fontreq->fo_Attr.ta_Style;
  265.         curr_note->textattr.ta_Flags = prj->prefs.textattr.ta_Flags;
  266.  
  267.         /* Open new font */
  268.  
  269.         curr_note->font = OpenDiskFont(&curr_note->textattr);
  270.  
  271.         if (!curr_note->font)
  272.             curr_note->fontname[0] = '\0';
  273.  
  274.         if ((curr_note->win) && (curr_note->font)) {
  275.             /* Add any font styles */
  276.  
  277.             SetFont(curr_rport,curr_note->font);
  278.             SetSoftStyle(curr_rport,
  279. curr_note->textattr.ta_Style ^ curr_note->font->tf_Style,
  280. (FSF_BOLD | FSF_UNDERLINED | FSF_ITALIC));
  281.         }
  282.  
  283.         /* If default font */
  284.  
  285.         if ((curr_note->win) && (!curr_note->font)) {
  286.             note_close(curr_note,FALSE);
  287.             note_open(curr_note);
  288.         }
  289.  
  290.         /* Only do the rest if the window is open */
  291.  
  292.         if (curr_note->win)
  293.             note_refresh(curr_note);
  294.  
  295.         /* Update text string */
  296.  
  297.         build_fontstring(curr_note);
  298.         GT_SetGadgetAttrs(commodGadgets[commod_fontstr],commod,
  299. NULL,GTTX_Text,curr_note->fontstring,TAG_END);
  300.  
  301.         /* Data has probably changed */
  302.  
  303.         prj->projectchanged = TRUE;
  304.     }
  305.  
  306.     /* Clear input to all open windows */
  307.  
  308.     note_blockclearall();
  309.     commod_blockclear();
  310.  
  311.     FreeAslRequest(fontreq);
  312. }
  313.  
  314. CPTR hookfunc(LONG type,CPTR obj,struct FontRequester *fontreq)
  315. {
  316.     struct IntuiMessage *curr_msg;
  317.  
  318.     note_p curr_note;
  319.  
  320.     curr_msg = (struct IntuiMessage *)obj;
  321.  
  322.     switch(type) {
  323.         case FONF_DOMSGFUNC:
  324.             switch (curr_msg->Class) {
  325.                 case IDCMP_REFRESHWINDOW:
  326.                     if (curr_msg->IDCMPWindow == commod)
  327.                         break;
  328.  
  329.                     /* Must be a note message */
  330.  
  331.                     curr_note = note_from_window(
  332. curr_msg->IDCMPWindow);
  333.  
  334.                     if (!curr_note)
  335.                         break;
  336.  
  337.                     BeginRefresh(curr_msg->IDCMPWindow);
  338.                     note_refresh(curr_note);
  339.                     EndRefresh(curr_msg->IDCMPWindow,TRUE);
  340.  
  341.                     break;
  342.                 default:
  343.                     break;
  344.             }
  345.         default:
  346.             break;
  347.     }
  348.  
  349.     return (obj);
  350. }
  351.  
  352. /*
  353. Function : void commodpubscreen()
  354. Purpose : The user has clicked on the pubscreen gadget. When the presses
  355.     on ENTER, we try and open the note on the new window.
  356. */
  357.  
  358. void commodpubscreen()
  359. {
  360.     struct Window *curr_win;
  361.     struct Gadget *curr_gad;
  362.  
  363.     note_p curr_note;
  364.  
  365.     if (!prj->curr_note)
  366.         return;
  367.  
  368.     curr_note = prj->curr_note;
  369.  
  370.     curr_win = curr_note->win;
  371.  
  372.     if (!curr_win)
  373.         return;
  374.  
  375.     curr_gad = commodGadgets[commod_pubscreen];
  376.  
  377.     strncpy(curr_note->pubscreen,
  378. ((struct StringInfo *)curr_gad->SpecialInfo)->Buffer,STRLEN_PUBSCREEN);
  379.  
  380.     if (curr_win) {
  381.         note_close(curr_note,FALSE);
  382.         note_open(curr_note);
  383.         note_refresh(curr_note);
  384.     }
  385.  
  386.     /* Data has probably changed */
  387.  
  388.     prj->projectchanged = TRUE;
  389. }
  390.  
  391. /*
  392. Function : void commodnew()
  393. Purpose : The user has clicked on the "New" in the listview or "New note" from
  394.     the commod menu. If there is room, a note is created and added at the
  395.     head of the list.
  396. */
  397.  
  398. void commodnew()
  399. {
  400.     int l;
  401.  
  402.     /* Is there any space in the notes array? */
  403.  
  404.     if (next_free_note() == NO_FREE_NOTES) {
  405.         error("Maximum number of notes in use",ERR_WARNING,__LINE__,
  406. __FILE__);
  407.         return;
  408.     }
  409.  
  410.     /* Copy the stuff from the gadgets into the current selected note */
  411.  
  412.     if ((commod) && (prj->curr_note))
  413.         commodtonote(prj->curr_note);
  414.  
  415.     /* Shift all the notes in the array up one to make space at [0] */
  416.  
  417.     /* Temporarily disconnect then list */
  418.  
  419.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  420. GTLV_Labels,~0,TAG_END);
  421.  
  422.     for (l = (NO_NOTES - 2); l >= 0; l--) {
  423.         prj->notes[l + 1] = prj->notes[l];
  424.         prj->notes[l + 1]->node.ln_Pri = - (BYTE)(l + 1);
  425.     }
  426.  
  427.     /* Re-connect with new priorities */
  428.  
  429.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  430. GTLV_Labels,&prj->commodlist,TAG_END);
  431.  
  432.     prj->notes[0] = NULL;
  433.  
  434.     /* Create the note */
  435.  
  436.     note_create(0);
  437.  
  438.     /* Open the note */
  439.  
  440.     note_open(prj->notes[0]);
  441.     note_refresh(prj->notes[0]);
  442.  
  443.     /* If the listview is selected, copy the stuff into it */
  444.  
  445.     if ((commod) && (prj->curr_note)) {
  446.         prj->curr_note = prj->notes[0];
  447.         notetocommod(prj->curr_note);
  448.  
  449.         GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  450. GTLV_Selected,0,TAG_END);
  451.     }
  452.  
  453.     /* Data changed */
  454.  
  455.     prj->projectchanged = TRUE;
  456. }
  457.  
  458. /*
  459. Function : void commoddel()
  460. Purpose : Removes the prj->curr_note from the array and shifts the rest around.
  461. */
  462.  
  463. void commoddel()
  464. {
  465.     int notepos;
  466.     int l;
  467.  
  468.     /* If there's no current note, can't do anything */
  469.  
  470.     if (!prj->curr_note) {
  471.         error("No note selected",ERR_WARNING,__LINE__,__FILE__);
  472.         return;
  473.     }
  474.  
  475.     /* Ghost out all the gadgets */
  476.  
  477.     if (commod) {
  478.         GT_SetGadgetAttrs(commodGadgets[commod_title],commod,NULL,
  479. GA_Disabled,TRUE,TAG_END);
  480.         GT_SetGadgetAttrs(commodGadgets[commod_cyccolour],commod,NULL,
  481. GA_Disabled,TRUE,TAG_END);
  482.         GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,NULL,
  483. GA_Disabled,TRUE,TAG_END);
  484.         GT_SetGadgetAttrs(commodGadgets[commod_font],commod,NULL,
  485. GA_Disabled,TRUE,TAG_END);
  486.         GT_SetGadgetAttrs(commodGadgets[commod_pubscreen],commod,NULL,
  487. GA_Disabled,TRUE,TAG_END);
  488.     }
  489.  
  490.     /* Deselect it from the list */
  491.  
  492.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  493. GTLV_Selected,~0,TAG_END);
  494.  
  495.     note_close(prj->curr_note,TRUE);
  496.  
  497.     /* Where abouts in the array is it ? */
  498.  
  499.     notepos = positionfromnote(prj->curr_note);
  500.  
  501.     prj->curr_note = NULL;
  502.  
  503.     if (notepos == NOT_IN_ARRAY)
  504.         error("Can't find deleted note in array",ERR_FATAL,__LINE__,
  505. __FILE__);
  506.  
  507.     /* Shift the rest of the array, disconnect first */
  508.  
  509.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  510. GTLV_Labels,~0,TAG_END);
  511.  
  512.     for (l = notepos; l < (NO_NOTES - 1); l++) {
  513.         prj->notes[l] = prj->notes[l + 1];
  514.         prj->notes[l]->node.ln_Pri = - (BYTE)(l);
  515.     }
  516.  
  517.     prj->notes[NO_NOTES - 1] = NULL;
  518.  
  519.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  520. GTLV_Labels,&prj->commodlist,TAG_END);
  521.  
  522.     /* Data changed */
  523.  
  524.     prj->projectchanged = TRUE;
  525. }
  526.  
  527. /*
  528. Function : void commodup()
  529. Purpose : Moves the prj->curr_note up in the listview.
  530. */
  531.  
  532. void commodup()
  533. {
  534.     note_p temp_note;
  535.  
  536.     int notepos;
  537.  
  538.     /* If no note selected */
  539.  
  540.     if (!prj->curr_note)
  541.         return;
  542.  
  543.     notepos = positionfromnote(prj->curr_note);
  544.  
  545.     if (notepos == NOT_IN_ARRAY)
  546.         error("Can't find note in array",ERR_FATAL,__LINE__,__FILE__);
  547.  
  548.     /* Can't move top note up */
  549.  
  550.     if (notepos == 0)
  551.         return;
  552.  
  553.     /* Disconnect the list */
  554.  
  555.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  556. GTLV_Labels,~0,TAG_END);
  557.  
  558.     /* Swap priorities first */
  559.  
  560.     prj->notes[notepos]->node.ln_Pri = - (BYTE)(notepos - 1);
  561.     prj->notes[notepos - 1]->node.ln_Pri = - (BYTE)(notepos);
  562.  
  563.     /* Swap positions notepos and notepos - 1 */
  564.  
  565.     temp_note = prj->notes[notepos];
  566.     prj->notes[notepos] = prj->notes[notepos - 1];
  567.     prj->notes[notepos - 1] = temp_note;
  568.  
  569.     /* Remove both from the list and re-enque */
  570.  
  571.     Remove(&prj->notes[notepos]->node);
  572.     Remove(&prj->notes[notepos - 1]->node);
  573.  
  574.     Enqueue(&prj->commodlist,&prj->notes[notepos]->node);
  575.     Enqueue(&prj->commodlist,&prj->notes[notepos - 1]->node);
  576.  
  577.     /* Reconnect list */
  578.  
  579.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  580. GTLV_Labels,&prj->commodlist,TAG_END);
  581.  
  582.     /* Select the next one */
  583.  
  584.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  585. GTLV_Selected,notepos - 1,TAG_END);
  586.  
  587.     /* Data changed */
  588.  
  589.     prj->projectchanged = TRUE;
  590. }
  591.  
  592. /*
  593. Function : void commoddown()
  594. Purpose : Moves the prj->curr_note down in the listview.
  595. */
  596.  
  597. void commoddown()
  598. {
  599.     note_p temp_note;
  600.  
  601.     int notepos;
  602.  
  603.     /* If no note selected */
  604.  
  605.     if (!prj->curr_note)
  606.         return;
  607.  
  608.     notepos = positionfromnote(prj->curr_note);
  609.  
  610.     if (notepos == NOT_IN_ARRAY)
  611.         error("Can't find note in array",ERR_FATAL,__LINE__,__FILE__);
  612.  
  613.     /* Can't move bottom note down */
  614.  
  615.     if ((notepos == (NO_NOTES - 1)) || !(prj->notes[notepos + 1]))
  616.         return;
  617.  
  618.     /* Disconnect the list */
  619.  
  620.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  621. GTLV_Labels,~0,TAG_END);
  622.  
  623.     /* Swap priorities first */
  624.  
  625.     prj->notes[notepos]->node.ln_Pri = - (BYTE)(notepos + 1);
  626.     prj->notes[notepos + 1]->node.ln_Pri = - (BYTE)(notepos);
  627.  
  628.     /* Swap positions notepos and notepos + 1 */
  629.  
  630.     temp_note = prj->notes[notepos];
  631.     prj->notes[notepos] = prj->notes[notepos + 1];
  632.     prj->notes[notepos + 1] = temp_note;
  633.  
  634.     /* Remove both from the list and re-enque */
  635.  
  636.     Remove(&prj->notes[notepos]->node);
  637.     Remove(&prj->notes[notepos + 1]->node);
  638.  
  639.     Enqueue(&prj->commodlist,&prj->notes[notepos]->node);
  640.     Enqueue(&prj->commodlist,&prj->notes[notepos + 1]->node);
  641.  
  642.     /* Reconnect list */
  643.  
  644.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  645. GTLV_Labels,&prj->commodlist,TAG_END);
  646.  
  647.     /* Select the next one */
  648.  
  649.     GT_SetGadgetAttrs(commodGadgets[commod_listview],commod,NULL,
  650. GTLV_Selected,notepos + 1,TAG_END);
  651.  
  652.     /* Data changed */
  653.  
  654.     prj->projectchanged = TRUE;
  655. }
  656.  
  657. /*** Utility routines (not direct gadget presses) *****************************/
  658.  
  659. /*
  660. Function : void commodtonote(note_p curr_note)
  661. Purpose : Copies all the info in the gadgets in the commodities window into
  662.     curr_note.
  663. */
  664.  
  665. void commodtonote(note_p curr_note)
  666. {
  667.     struct Gadget *curr_gad;
  668.     struct Window *curr_win;
  669.  
  670.     curr_win = curr_note->win;
  671.  
  672.     if (!curr_win)
  673.         return;
  674.  
  675.     /* Copy title text from gadget to note */
  676.  
  677.     curr_gad = commodGadgets[commod_title];
  678.  
  679.     /* See if data changed */
  680.  
  681.     if (strncmp(curr_note->title,
  682. ((struct StringInfo *)curr_gad->SpecialInfo)->Buffer,STRLEN_NOTETITLE))
  683.         prj->projectchanged = TRUE;
  684.  
  685.     strncpy(curr_note->title,
  686. ((struct StringInfo *)curr_gad->SpecialInfo)->Buffer,STRLEN_NOTETITLE);
  687.  
  688.     SetWindowTitles(curr_win,curr_note->title,(UBYTE *)-1);
  689.  
  690.     /* Copy pub screen name into note and refresh if needed */
  691.  
  692.     curr_gad = commodGadgets[commod_pubscreen];
  693.  
  694.     if (strcmp(((struct StringInfo *)curr_gad->SpecialInfo)->Buffer,
  695. curr_note->pubscreen)) {
  696.         strncpy(curr_note->pubscreen,
  697. ((struct StringInfo *)curr_gad->SpecialInfo)->Buffer,STRLEN_PUBSCREEN);
  698.  
  699.         note_close(curr_note,FALSE);
  700.         note_open(curr_note);
  701.         note_refresh(curr_note);
  702.  
  703.         prj->projectchanged = TRUE;
  704.     }
  705. }
  706.  
  707. /*
  708. Function : void notetocommod(note_p curr_note)
  709. Purpose : Copies all the info in the curr_note into the commodities window.
  710. */
  711.  
  712. void notetocommod(note_p curr_note)
  713. {
  714.     /* Copy title bar text */
  715.  
  716.     GT_SetGadgetAttrs(commodGadgets[commod_title],commod,NULL,
  717. GTST_String,curr_note->title,TAG_END);
  718.  
  719.     /* Copy fontname */
  720.  
  721.     if (curr_note->fontname[0] == '\0')
  722.         GT_SetGadgetAttrs(commodGadgets[commod_fontstr],commod,NULL,
  723. GTTX_Text,"Default font",TAG_END);
  724.     else
  725.         GT_SetGadgetAttrs(commodGadgets[commod_fontstr],commod,NULL,
  726. GTTX_Text,curr_note->fontstring,TAG_END);
  727.  
  728.     /* Find out which colour to show */
  729.  
  730.     switch (prj->commodcolour) {
  731.         case COLOUR_BACKGROUND:
  732.             GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,
  733. NULL,GTPA_Color,curr_note->backcolour,TAG_END);
  734.             break;
  735.         case COLOUR_TEXT:
  736.             GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,
  737. NULL,GTPA_Color,curr_note->textcolour,TAG_END);
  738.             break;
  739.         case COLOUR_CARAT:
  740.             GT_SetGadgetAttrs(commodGadgets[commod_palette],commod,
  741. NULL,GTPA_Color,curr_note->caratcolour,TAG_END);
  742.             break;
  743.         default:
  744.             break;
  745.     }
  746.  
  747.     /* Copy pub screen name */
  748.  
  749.     GT_SetGadgetAttrs(commodGadgets[commod_pubscreen],commod,NULL,
  750. GTST_String,curr_note->pubscreen,TAG_END);
  751. }
  752.  
  753. /*
  754. Function : BOOL commodclose()
  755. Purpose : If the user clicks on the close gadget or selects "hide" from the
  756.     menu, this function is called. If the tooltype HIDEWARN=YES then
  757.     a requester is popped up if the data has been changed. Returns TRUE
  758.     if the window is to close.
  759. */
  760.  
  761. BOOL commodclose()
  762. {
  763.     struct EasyStruct hidereq = {
  764.         sizeof(struct EasyStruct),
  765.         0,
  766.         "StickIt2",
  767.         "Data has changed, continue with hide ?",
  768.         "Okay|Cancel"
  769.     };
  770.  
  771.     if (!commod)
  772.         return (FALSE);
  773.  
  774.     if ((prj->prefs.hidewarn) && (prj->projectchanged)) {
  775.         if (EasyRequest(commod,&hidereq,NULL,TAG_END))
  776.             return (TRUE);
  777.         else
  778.             return (FALSE);
  779.     }
  780.     else
  781.         return (TRUE);
  782. }
  783.