home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / fm2000 / commodity.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-04  |  3.3 KB  |  143 lines

  1. /*
  2.      Filemaster - Multitasking directory utility.
  3.      Copyright (C) 2000  Toni Wilen
  4.      
  5.      This program is free software; you can redistribute it and/or
  6.      modify it under the terms of the GNU General Public License
  7.      as published by the Free Software Foundation; either version 2
  8.      of the License, or (at your option) any later version.
  9.      
  10.      This program is distributed in the hope that it will be useful,
  11.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.      GNU General Public License for more details.
  14.      
  15.      You should have received a copy of the GNU General Public License
  16.      along with this program; if not, write to the Free Software
  17.      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19.  
  20. #include <exec/types.h>
  21. #include <libraries/commodities.h>
  22. #include <proto/all.h>
  23. #include <stdio.h>
  24. #include "fmnode.h"
  25. #include "fmdos.h"
  26.  
  27. extern struct FMMain fmmain;
  28. extern struct FMConfig *fmconfig;
  29.  
  30. static struct NewBroker fmbroker = {
  31.     NB_VERSION,
  32.     "FileMaster","FileMaster 3.1 © 1992-1997 by Toni Wilen","Directory utility",
  33.     0,COF_SHOW_HIDE,0,0,0
  34. };
  35.  
  36. /*
  37. static CxObj *CustomHotKey(UBYTE *Code,struct MsgPort *Port,LONG ID)
  38. {
  39. CxObj *Filter;
  40. CxObj *Sender;
  41.  
  42. if(Filter = CxFilter(Code)) {
  43.     if(Sender = CxSender(Port,ID)) {
  44.         AttachCxObj(Filter,Sender);
  45.         if(!CxObjError(Filter)) return(Filter);
  46.     }
  47.     DeleteCxObjAll(Filter);
  48. }
  49. return(0);
  50. }
  51. */
  52.  
  53. WORD checkhotkeys(struct IntuiMessage *im)
  54. {
  55. struct InputEvent ie;
  56. WORD cnt1;
  57.  
  58. if(!CxBase) return(-1);
  59. ie.ie_Class=IECLASS_RAWKEY;
  60. ie.ie_SubClass=0;
  61. ie.ie_Code=im->Code;
  62. ie.ie_Qualifier=im->Qualifier;
  63. //ie.ie_EventAddress=(APTR*)*((ULONG*)im->IAddress);
  64. for(cnt1=0;cnt1<TOTALCOMMANDS+LISTGADGETS*WINDOWLISTS;cnt1++) {
  65.     if(fmmain.ix[cnt1]) {
  66.         if(MatchIX(&ie,fmmain.ix[cnt1])) return(cnt1);
  67.     }
  68. }
  69. return(-1);
  70. }
  71.  
  72. static void clearhotkeys(void)
  73. {
  74. WORD cnt1;
  75. for(cnt1=0;cnt1<TOTALCOMMANDS+LISTGADGETS*WINDOWLISTS;cnt1++) {
  76.     freemem(fmmain.ix[cnt1]);
  77.     fmmain.ix[cnt1]=0;
  78. }
  79. }
  80.  
  81. static void sethotkeys(void)
  82. {
  83. struct GadKeyTab *gkt;
  84. UBYTE *ptr;
  85. WORD cnt1,apu1;
  86.  
  87. clearhotkeys();
  88. if(!CxBase) return;
  89. for(cnt1=0;cnt1<TOTALCOMMANDS+LISTGADGETS*WINDOWLISTS;cnt1++) {
  90.     gkt=&fmmain.gadkeytab[cnt1];
  91.     if(gkt->cmc) ptr=gkt->cmc->shortcut; else ptr=gkt->key;
  92.     if(ptr&&*ptr) {
  93.         fmmain.ix[cnt1]=allocmem(sizeof(struct InputXpression));
  94.         if(fmmain.ix[cnt1]) {
  95.             apu1=ParseIX(ptr,fmmain.ix[cnt1]);
  96.             if(apu1) {
  97.                 freemem(fmmain.ix[cnt1]);
  98.                 fmmain.ix[cnt1]=0;
  99.             }
  100.         }
  101.     }
  102. //AttachCxObj(fmmain.broker,CustomHotKey(ptr,fmmain.cxport,cnt1+1));
  103. }
  104. }
  105.  
  106. void removebroker(void)
  107. {
  108. CxMsg *cxmsg;
  109.  
  110. clearhotkeys();
  111. if(fmmain.broker) DeleteCxObjAll(fmmain.broker);
  112. if(fmmain.cxport) {
  113.     RemPort(fmmain.cxport);
  114.     while(cxmsg=(CxMsg*)GetMsg(fmmain.cxport)) ReplyMsg((struct Message*)cxmsg);
  115.     DeleteMsgPort(fmmain.cxport);
  116. }
  117. fmmain.broker=0;
  118. fmmain.cxport=0;
  119. }
  120.  
  121. WORD createbroker(void)
  122. {
  123. if(fmmain.broker=CxBroker(&fmbroker,0)) {
  124.     sethotkeys();
  125.     ActivateCxObj(fmmain.broker,TRUE);
  126.     return(TRUE);
  127. }
  128. return(0);
  129. }
  130.  
  131. WORD createbrokerall(void)
  132. {
  133. if(!(fmmain.cxport=CreateMsgPort())) return(0);
  134. fmmain.cxport->mp_Node.ln_Name=fmbroker.nb_Name;
  135. AddPort(fmmain.cxport);
  136. fmbroker.nb_Port=fmmain.cxport;
  137. fmbroker.nb_Pri=0;
  138. if(createbroker()) return(TRUE);
  139. DeleteMsgPort(fmmain.cxport);
  140. fmmain.cxport=0;
  141. return(0);
  142. }
  143.