4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
33 #include <proto/sysinfo.h>
37 AROS_UFP2(struct InputEvent
*, keyhandler
,
38 AROS_UFPA(struct InputEvent
*, oldevent
, A0
),
39 AROS_UFPA(APTR
, userdata
, A1
)
44 #define HOTKEY_UNICONIFY 1
45 #define HOTKEY_ABORT 3
47 #define HOTKEY_HOTKEY 10
59 void progressbar(struct ProgressBar
*bar
);
61 #ifdef INPUTDEV_HOTKEY
63 static struct InputEvent
*keyhandler(void);
65 static struct EmulLibEntry GATE_keyhandler
= { TRAP_LIB
, 0, (void (*)(void))keyhandler
};
70 NULL
,0,0,104,0,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
71 NULL
,NULL
,NULL
,0,NULL
,0,NULL
};
73 static struct NewWindow
76 IDCMP_GADGETUP
|IDCMP_RAWKEY
,WFLG_RMBTRAP
|WFLG_ACTIVATE
,
77 NULL
,NULL
,NULL
,NULL
,NULL
,0,0,0,0,CUSTOMSCREEN
};
79 static struct Window
*pwindow
;
80 static struct RastPort
*prp
;
81 static struct DOpusRemember
*prog_key
;
82 static struct ProgressBar bar
[2];
83 //int prog_barx[2],prog_bary[2],prog_texty[2],prog_val[2],prog_tot[2];
84 static int prog_xoff
,prog_yoff
,prog_xextra
,prog_yextra
,prog_areax
;
85 #ifdef INPUTDEV_HOTKEY
86 static struct Interrupt
88 #if (AROS_FLAVOUR && AROS_FLAVOUR_BINCOMPAT || !defined(__AROS__))
89 {NULL
,NULL
,2,52,"hotkeez_port"},
91 {NULL
,NULL
,"hotkeez_port",2,52},
94 NULL
,(VOID
*)&GATE_keyhandler
};
96 NULL
,(VOID
*)keyhandler
};
99 static struct NewBroker
103 "Directory Opus © Jonathan Potter",
104 "The most amazing program ever written",
105 0,COF_SHOW_HIDE
,100,NULL
,0};
107 static IX hotkey_ix
={IX_VERSION
};
109 void __saveds
hotkeytaskcode()
112 int top
,__unused sig
,waitbits
,commodity
=0,command
,x
,run
=1;
113 struct dopustaskmsg
*hmsg
;
114 #ifdef INPUTDEV_HOTKEY
115 struct IOStdReq
*inreq
;
117 struct MsgPort
*inputport
/*,*idcmpport*/;
118 struct IntuiMessage
*msg
;
119 ULONG
class,msgid
,msgtype
;
120 UWORD gadgetid
/*,norm_height,norm_width*/;
121 // struct IntuiMessage *dummymsg;
122 struct dopushotkey
*hotkey
;
123 CxObj
*broker
,*hotkey_filter
,*mmb_filter
=NULL
;
126 norm_height=scrdata_norm_height;
127 norm_width=scrdata_norm_width;
129 hotkeymsg_port
=LCreatePort(NULL
,0);
130 inputport
=LCreatePort(NULL
,0);
131 // idcmpport=LCreatePort(NULL,0);
135 && !(status_flags
&STATUS_IANSCRAP
)
138 strcpy(cxname
,"Directory Opus");
139 if (system_dopus_runcount
)
143 lsprintf(tmp
," (%ld)",(long int)(system_dopus_runcount
+1));
146 hotkey_broker
.nb_Name
= cxname
;
147 hotkey_broker
.nb_Port
=inputport
;
148 if ((broker
=CxBroker(&hotkey_broker
,NULL
))) {
150 /* Initialise main hotkey */
151 if ((hotkey_filter
=set_dopus_filter(broker
,inputport
,NULL
,config
->hotkeycode
,config
->hotkeyqual
,HOTKEY_UNICONIFY
,1))) {
153 hotkey_ix
.ix_Code
=IECODE_LBUTTON
;
154 hotkey_ix
.ix_Qualifier
=IEQUALIFIER_RBUTTON
;
155 hotkey_ix
.ix_QualMask
=0xffff&~(IEQUALIFIER_LEFTBUTTON
|IEQUALIFIER_RELATIVEMOUSE
|IEQUALIFIER_CAPSLOCK
);
156 if (set_dopus_filter(broker
,inputport
,"rawmouse lbutton",
157 0,0,HOTKEY_ABORT
,0)) {
159 hotkey_ix
.ix_Code
=IECODE_RBUTTON
;
160 hotkey_ix
.ix_Qualifier
=IEQUALIFIER_LEFTBUTTON
;
161 hotkey_ix
.ix_QualMask
=0xffff&~(IEQUALIFIER_RBUTTON
|IEQUALIFIER_RELATIVEMOUSE
|IEQUALIFIER_CAPSLOCK
);
162 if (set_dopus_filter(broker
,inputport
,"rawmouse rbutton",
163 0,0,HOTKEY_ABORT
,0)) {
165 if (config
->hotkeyflags
&HOTKEY_USEMMB
) {
166 hotkey_ix
.ix_Code
=IECODE_MBUTTON
;
167 hotkey_ix
.ix_Qualifier
=IEQUALIFIER_MIDBUTTON
;
168 hotkey_ix
.ix_QualMask
=0xffff&~(IEQUALIFIER_RELATIVEMOUSE
|IEQUALIFIER_CAPSLOCK
);
169 mmb_filter
=set_dopus_filter(broker
,inputport
,"rawmouse midbutton",
173 add_hotkey_objects(broker
,inputport
,1);
174 set_hotkey(hotkey_filter
,config
->hotkeycode
,config
->hotkeyqual
);
176 ActivateCxObj(broker
,1);
182 if (broker
&& (!commodity
)) {
183 add_hotkey_objects(broker
,inputport
,0);
184 DeleteCxObjAll(broker
);
187 #ifdef INPUTDEV_HOTKEY
189 inreq
=(struct IOStdReq
*)LCreateExtIO(inputport
,sizeof(struct IOStdReq
));
190 OpenDevice("input.device",NULL
,(struct IORequest
*)inreq
,NULL
);
191 inreq
->io_Data
=(APTR
)&hotkey_interrupt
;
192 inreq
->io_Command
=IND_ADDHANDLER
;
193 DoIO((struct IORequest
*)inreq
);
196 waitbits
=1<<hotkeymsg_port
->mp_SigBit
/*|1<<idcmpport->mp_SigBit*/;
197 if (commodity
) waitbits
|=1<<inputport
->mp_SigBit
;
198 #ifdef INPUTDEV_HOTKEY
199 else waitbits
|=INPUTSIG_UNICONIFY
|INPUTSIG_HOTKEY
;
204 //D(bug("signal received\n"));
206 while ((dummymsg=(struct IntuiMessage *)GetMsg(idcmpport)))
207 FreeMem(dummymsg,sizeof(struct IntuiMessage));
210 while ((cxmsg
=(CxMsg
*)GetMsg(inputport
))) {
211 msgid
=CxMsgID(cxmsg
);
212 msgtype
=CxMsgType(cxmsg
);
213 ReplyMsg((struct Message
*)cxmsg
);
216 if ((command
=msgid
)>=HOTKEY_HOTKEY
) {
217 x
=command
-HOTKEY_HOTKEY
; command
=HOTKEY_HOTKEY
;
218 hotkey
=dopus_firsthotkey
;
219 while (x
-- && hotkey
) hotkey
=hotkey
->next
;
220 dopus_globalhotkey
=hotkey
;
227 command
=HOTKEY_HOTKEY
;
228 dopus_globalhotkey
=(struct dopushotkey
*)-1;
232 ActivateCxObj(broker
,0);
236 ActivateCxObj(broker
,1);
240 command
=HOTKEY_UNICONIFY
;
243 case CXCMD_DISAPPEAR
:
244 command
=HOTKEY_HOTKEY
;
245 dopus_globalhotkey
=(struct dopushotkey
*)-2;
252 #ifdef INPUTDEV_HOTKEY
254 if (sig
&INPUTSIG_UNICONIFY
)
255 command
=HOTKEY_UNICONIFY
;
256 else if (sig
&INPUTSIG_HOTKEY
)
257 command
=HOTKEY_HOTKEY
;
262 if (IntuitionBase
->ActiveWindow
==Window
) {
263 status_haveaborted
=status_rexxabort
=1;
264 Signal((struct Task
*)main_proc
,INPUTSIG_ABORT
);
269 if (!(config
->hotkeyflags
&HOTKEY_USEMMB
)) break;
270 case HOTKEY_UNICONIFY
:
271 if (status_configuring
==-1) break;
272 if (status_iconified
==1) Signal((struct Task
*)main_proc
,INPUTSIG_UNICONIFY
);
273 else if (status_iconified
==0) {
275 if (!status_configuring
&& config
->screenflags
&SCRFLAGS_HALFHEIGHT
)
276 top
=main_scr
.TopEdge
;
279 if ((IntuitionBase
->FirstScreen
==MainScreen
) &&
280 (MainScreen
->TopEdge
==top
) &&
281 (!IntuitionBase
->ActiveWindow
|| (IntuitionBase
->ActiveWindow
->WScreen
==MainScreen
)))
283 ScreenToBack(MainScreen
);
284 if (Window
->Parent
&& Window
->Parent
->WScreen
==IntuitionBase
->FirstScreen
)
285 ActivateWindow(Window
->Parent
);
286 else ActivateWindow(IntuitionBase
->FirstScreen
->FirstWindow
);
290 struct Window
*window
;
292 ScreenToFront(MainScreen
);
293 if (MainScreen
->FirstWindow
==ansiread_window
) window
=Window
;
294 else window
=MainScreen
->FirstWindow
;
296 if (!(window
->Flags
&WFLG_BACKDROP
)) WindowToFront(window
);
297 ActivateWindow(window
);
299 MoveScreen(MainScreen
,0,top
-MainScreen
->TopEdge
);
302 if (IntuitionBase
->ActiveWindow
==Window
&&
303 IntuitionBase
->FirstScreen
==Window
->WScreen
&&
304 Window
->WScreen
->LayerInfo
.top_layer
==Window
->RPort
->Layer
) {
305 WindowToBack(Window
);
306 if (Window
->Parent
) ActivateWindow(Window
->Parent
);
309 ScreenToFront(Window
->WScreen
);
310 WindowToFront(Window
);
311 ActivateWindow(Window
);
318 if (!status_configuring
) Signal((struct Task
*)main_proc
,INPUTSIG_HOTKEY
);
323 while ((msg
=(struct IntuiMessage
*)GetMsg(pwindow
->UserPort
))) {
324 if ((class=msg
->Class
)==IDCMP_GADGETUP
)
325 gadgetid
=((struct Gadget
*)msg
->IAddress
)->GadgetID
;
326 ReplyMsg((struct Message
*)msg
);
327 if (class==IDCMP_GADGETUP
&& gadgetid
==0) {
328 status_haveaborted
=status_rexxabort
=1;
329 Signal((struct Task
*)main_proc
,INPUTSIG_ABORT
);
334 while ((hmsg
=(struct dopustaskmsg
*)GetMsg(hotkeymsg_port
))) {
336 #define BAR_ID (hmsg->flag)
338 switch (hmsg
->command
) {
339 case PROGRESS_UPDATE
:
341 //D(bug("UPDATE: BAR_ID=%ld\n",BAR_ID));
344 bar
[BAR_ID
].curr
= hmsg
->value
;
345 bar
[BAR_ID
].max
= hmsg
->total
;
347 progressbar(&bar
[BAR_ID
]);
349 if (bar
[BAR_ID
].hide
) break;
350 if (BAR_ID
==0 || hmsg
->data
)
351 progresstext(bar
[BAR_ID
].descY
,hmsg
->value
,hmsg
->total
,hmsg
->data
);
355 case PROGRESS_INCREASE
:
357 if (bar
[BAR_ID
].incignore
) break;
359 //D(bug("INCREASE: BAR_ID=%ld\n",BAR_ID));
360 bar
[BAR_ID
].curr
+= hmsg
->value
;
361 if (bar
[BAR_ID
].curr
> bar
[BAR_ID
].max
) bar
[BAR_ID
].curr
= bar
[BAR_ID
].max
;
363 progressbar(&bar
[BAR_ID
]);
364 if (bar
[BAR_ID
].hide
) break;
365 progresstext(bar
[BAR_ID
].descY
,bar
[BAR_ID
].curr
,bar
[BAR_ID
].max
,NULL
);
371 openprogresswindow(hmsg
->data
,hmsg
->value
,hmsg
->total
,BAR_ID
);
374 SetBusyPointer(pwindow
);
375 waitbits
|= 1<<pwindow
->UserPort
->mp_SigBit
;
382 waitbits
&= ~(1<<pwindow
->UserPort
->mp_SigBit
);
383 CloseWindow(pwindow
);
386 LFreeRemember(&prog_key
);
393 case HOTKEY_HOTKEYCHANGE
:
395 set_hotkey(hotkey_filter
,config
->hotkeycode
,config
->hotkeyqual
);
397 if (config
->hotkeyflags
&HOTKEY_USEMMB
) {
399 hotkey_ix
.ix_Code
=IECODE_MBUTTON
;
400 hotkey_ix
.ix_Qualifier
=IEQUALIFIER_MIDBUTTON
;
401 hotkey_ix
.ix_QualMask
=0xffff&~(IEQUALIFIER_RELATIVEMOUSE
|IEQUALIFIER_CAPSLOCK
);
402 mmb_filter
=set_dopus_filter(broker
,inputport
,"rawmouse midbutton",
406 else if (mmb_filter
) {
407 DeleteCxObjAll(mmb_filter
);
413 case HOTKEY_KILLHOTKEYS
:
414 if (commodity
) add_hotkey_objects(broker
,inputport
,0);
417 case HOTKEY_NEWHOTKEYS
:
418 if (commodity
) add_hotkey_objects(broker
,inputport
,1);
421 ReplyMsg((struct Message
*)hmsg
);
426 D(bug("Removing commodity objects\n"));
427 add_hotkey_objects(broker
,inputport
,0);
428 DeleteCxObjAll(broker
);
429 while ((cxmsg
=(CxMsg
*)GetMsg(inputport
)))
430 ReplyMsg((struct Message
*)cxmsg
);
432 #ifdef INPUTDEV_HOTKEY
434 inreq
->io_Data
=(APTR
)&hotkey_interrupt
;
435 inreq
->io_Command
=IND_REMHANDLER
;
436 DoIO((struct IORequest
*)inreq
);
437 CloseDevice((struct IORequest
*)inreq
);
438 LDeleteExtIO((struct IORequest
*)inreq
);
441 if (pwindow
) CloseWindow(pwindow
);
442 LFreeRemember(&prog_key
);
443 LDeletePort(inputport
);
444 // ReplyMsg((struct Message *)hmsg);
445 LDeletePort(hotkeymsg_port
);
446 // LDeletePort(idcmpport);
450 void add_hotkey_objects(broker
,port
,add
)
452 struct MsgPort
*port
;
455 static CxObj
**filter_table
;
456 static int hotkey_count
;
457 struct dopushotkey
*hotkey
;
461 for (a
= 0; a
< hotkey_count
; a
++) DeleteCxObjAll(filter_table
[a
]);
462 FreeMem(filter_table
,hotkey_count
*sizeof(CxObj
*));
466 if (add
== 0) return;
468 for (hotkey
= dopus_firsthotkey
, hotkey_count
= 0; hotkey
; hotkey
= hotkey
->next
)
470 if (hotkey_count
==0) return;
472 filter_table
= AllocMem(hotkey_count
*sizeof(CxObj
*),MEMF_CLEAR
);
473 if (filter_table
== NULL
) return;
475 for (a
= 0, hotkey
= dopus_firsthotkey
; hotkey
; hotkey
= hotkey
->next
, a
++)
476 filter_table
[a
] = set_dopus_filter(broker
,port
,NULL
,
477 hotkey
->code
,hotkey
->qualifier
,
481 CxObj
*set_dopus_filter(broker
,port
,string
,code
,qual
,command
,translate
)
483 struct MsgPort
*port
;
491 if ((filter
=CxFilter(string
))) {
493 set_hotkey(filter
,code
,qual
);
495 hotkey_ix.ix_Class=IECLASS_RAWKEY;
496 if (code==(UWORD)~0) {
498 hotkey_ix.ix_CodeMask=0;
501 hotkey_ix.ix_Code=code;
502 hotkey_ix.ix_CodeMask=0xff;
504 hotkey_ix.ix_Qualifier=qual&VALID_QUALIFIERS;
505 hotkey_ix.ix_QualMask=VALID_QUALIFIERS;
509 hotkey_ix
.ix_Class
=IECLASS_RAWMOUSE
;
510 hotkey_ix
.ix_CodeMask
=0xff;
511 hotkey_ix
.ix_QualSame
=0;
512 SetFilterIX(filter
,&hotkey_ix
);
514 AttachCxObj(broker
,filter
);
515 AttachCxObj(filter
,CxSender(port
,command
));
516 if (translate
) AttachCxObj(filter
,CxTranslate(NULL
));
523 void set_hotkey(filter
,code
,qual
)
528 hotkey_ix
.ix_Class
=IECLASS_RAWKEY
;
529 if (qual
==0 && code
==(UWORD
)~0) {
530 hotkey_ix
.ix_Code
=0xffff;
531 hotkey_ix
.ix_CodeMask
=0xffff;
532 // hotkey_ix.ix_Qualifier=0;
533 hotkey_ix
.ix_Qualifier
=0xffff;
536 if (code
==(UWORD
)~0) {
538 hotkey_ix
.ix_CodeMask
=0;
541 hotkey_ix
.ix_Code
=code
;
542 hotkey_ix
.ix_CodeMask
=0xff;
544 hotkey_ix
.ix_Qualifier
=qual
&VALID_QUALIFIERS
;
545 hotkey_ix
.ix_QualMask
=VALID_QUALIFIERS
;
547 SetFilterIX(filter
,&hotkey_ix
);
551 void openprogresswindow(title
,value
,total
,flag
)
553 int value
,total
,flag
;
555 struct TextFont
*font
;
556 char *gadtxt
[] = { globstring
[STR_ABORT
], NULL
};
563 D(bug("PROGRESS_INCREASE commands will be ignored\n"));
566 if (config
->generalscreenflags
&SCR_GENERAL_REQDRAG
) {
567 prog_xoff
=Window
->WScreen
->WBorLeft
+2;
568 prog_yoff
=Window
->WScreen
->WBorTop
+Window
->WScreen
->Font
->ta_YSize
+2;
569 prog_xextra
=prog_xoff
+Window
->WScreen
->WBorRight
-2;
577 progresswindow
.Width
=384+(scr_font
[FONT_REQUEST
]->tf_XSize
*8)+prog_xextra
;
579 if (progresswindow
.Width
>Window
->WScreen
->Width
) {
580 font
=scr_font
[FONT_GENERAL
];
581 progresswindow
.Width
=432;
582 if (config
->generalscreenflags
&SCR_GENERAL_REQDRAG
)
583 progresswindow
.Width
+=prog_xextra
;
585 else font
=scr_font
[FONT_REQUEST
];
587 progresswindow
.Height
=(font
->tf_YSize
*5)+22;
589 progresswindow
.Height
+=(font
->tf_YSize
*2)+8;
590 prog_yextra
=(font
->tf_YSize
*2)+8;
594 if (config
->generalscreenflags
&SCR_GENERAL_REQDRAG
) {
595 progresswindow
.Height
+=prog_yoff
+Window
->WScreen
->WBorBottom
-1;
596 progresswindow
.Flags
|=WFLG_DRAGBAR
|WFLG_DEPTHGADGET
;
597 progresswindow
.Title
=title
;
600 progresswindow
.Flags
|=WFLG_BORDERLESS
;
601 progresswindow
.Title
=NULL
;
604 centerwindow(&progresswindow
);
605 if (!(pwindow
=OpenWindow(&progresswindow
))) return;
607 setupwindreq(pwindow
);
613 pwindow
->Width
-prog_xextra
-56,
614 (font
->tf_YSize
*4)+prog_yextra
,
615 screen_pens
[config
->gadgetbotcol
].pen
,
616 screen_pens
[config
->gadgettopcol
].pen
);
617 SetAPen(prp
,screen_pens
[config
->requestfg
].pen
);
619 abortopgad
.LeftEdge
=(pwindow
->Width
-abortopgad
.Width
)/2;
620 abortopgad
.Height
=font
->tf_YSize
+4;
621 abortopgad
.TopEdge
=pwindow
->Height
-pwindow
->BorderBottom
-9-font
->tf_YSize
;
622 AddGadgetBorders(&prog_key
,
624 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
629 screen_pens
[config
->gadgettopcol
].pen
,
630 screen_pens
[config
->gadgetbotcol
].pen
,1);
632 SetAPen(prp
,screen_pens
[0].pen
);
637 (prog_areax
=prog_xoff
+pwindow
->Width
-prog_xextra
-31),
638 prog_yoff
+(font
->tf_YSize
*4)+prog_yextra
+5);
644 bar
[a
].incignore
= incignore
;
645 bar
[a
].hide
= (a
== 0) ? 0 : !flag
;
646 bar
[a
].barX
=(((pwindow
->Width
-356)/2)+28)-font
->tf_XSize
;
647 bar
[a
].barY
=font
->tf_YSize
+3+prog_yoff
;
648 if (a
==0) bar
[a
].barY
+= prog_yextra
+3;
653 bar
[a
].barX
,bar
[a
].barY
,
655 screen_pens
[config
->gadgetbotcol
].pen
,
656 screen_pens
[config
->gadgettopcol
].pen
);
658 bar
[a
].descY
=bar
[a
].barY
+font
->tf_YSize
+(font
->tf_YSize
/2)+font
->tf_Baseline
;
660 SetAPen(prp
,screen_pens
[1].pen
);
661 SetBPen(prp
,screen_pens
[0].pen
);
662 Move(prp
,bar
[a
].barX
-(TextLength(prp
,"0% ",3))-4,bar
[a
].barY
+font
->tf_Baseline
);
664 Move(prp
,bar
[a
].barX
+302+font
->tf_XSize
,bar
[a
].barY
+font
->tf_Baseline
);
667 if (a
==0) progresstext(bar
[a
].descY
,value
,total
,NULL
);
668 progressbar(&bar
[a
]);
673 void progresstext(y
,val
,total
,text
)
680 D(bug("progresstext(Y=%ld,V=%ld,Vmax=%ld,%s)\n",y
,val
,total
,text
?text
:"<NULL>"));
681 if (val
==-1) ptr
= globstring
[total
?STR_ABORTED
:STR_COMPLETED
];
683 if (text
) LStrnCpy(buf
,text
,(pwindow
->Width
-prog_xextra
-56)/prp
->Font
->tf_XSize
);
684 else lsprintf(buf
,globstring
[STR_REMAINING
],val
,total
);
687 x
=26+((pwindow
->Width
-prog_xextra
-56-TextLength(prp
,ptr
,(len
=strlen(ptr
))))/2)+prog_xoff
;
688 y1
=y
-prp
->Font
->tf_Baseline
;
690 if (x
>prog_xoff
+26) {
691 SetAPen(prp
,screen_pens
[0].pen
);
696 y1
+prp
->Font
->tf_YSize
);
699 SetAPen(prp
,screen_pens
[1].pen
);
703 if (prp
->cp_x
<=prog_areax
) {
704 SetAPen(prp
,screen_pens
[0].pen
);
709 y1
+prp
->Font
->tf_YSize
);
711 D(bug("progresstext() ends here\n"));
714 void progressbar(struct ProgressBar
*bar
)
719 if (bar
->hide
) return;
720 D(bug("progressbar(Y=%ld,V=%ld,Vmax=%ld)\n",bar
->barY
,bar
->curr
,bar
->max
));
722 float f
=(float)(bar
->curr
)/(float)(bar
->max
);
724 if ((w
=(int)(300*f
))>300) w
=300;
726 draw
= (w
!= bar
->last_w
);
727 SetAPen(prp
,screen_pens
[3].pen
);
732 SetAPen(prp
,screen_pens
[0].pen
);
736 RectFill(prp
,bar
->barX
,bar
->barY
,bar
->barX
+w
-1,bar
->barY
+prp
->Font
->tf_YSize
-1);
739 D(bug("progressbar() ends here\n"));
742 #ifdef INPUTDEV_HOTKEY
744 struct InputEvent
*keyhandler(void)
746 struct InputEvent
*oldevent
= (struct InputEvent
*)REG_A0
;
747 // APTR userdata = (APTR)REG_A1;
750 AROS_UFH2(struct InputEvent
*, keyhandler
,
751 AROS_UFHA(struct InputEvent
*, oldevent
, A0
),
752 AROS_UFHA(APTR
, userdata
, A1
)
757 struct InputEvent
* __saveds
keyhandler(register struct InputEvent
*oldevent
__asm("a0"),register APTR userdata
__asm("a1"))
763 struct dopushotkey
*hotkey
;
765 if (oldevent
->ie_Class
==IECLASS_RAWKEY
) {
766 if ((config
->hotkeycode
==(UWORD
)~0 || oldevent
->ie_Code
==config
->hotkeycode
) &&
767 (!config
->hotkeyqual
|| (oldevent
->ie_Qualifier
&VALID_QUALIFIERS
)==config
->hotkeyqual
))
770 hotkey
=dopus_firsthotkey
;
772 if (oldevent
->ie_Code
==hotkey
->code
&&
773 (oldevent
->ie_Qualifier
&VALID_QUALIFIERS
)==hotkey
->qualifier
) {
774 dopus_globalhotkey
=hotkey
;
775 Signal(hotkey_task
,INPUTSIG_HOTKEY
);
776 oldevent
->ie_Class
=IECLASS_NULL
;
783 else if (oldevent
->ie_Class
==IECLASS_RAWMOUSE
) {
784 if ((oldevent
->ie_Code
&~IECODE_UP_PREFIX
)==IECODE_LBUTTON
) {
785 if (oldevent
->ie_Qualifier
&IEQUALIFIER_RBUTTON
) wakeup
=2;
787 else if (oldevent
->ie_Code
==IECODE_RBUTTON
&&
788 oldevent
->ie_Qualifier
&IEQUALIFIER_LEFTBUTTON
) wakeup
=2;
789 else if (config
->hotkeyflags
&HOTKEY_USEMMB
&&
790 oldevent
->ie_Code
==IECODE_MBUTTON
) wakeup
=1;
793 if (wakeup
==1 && hotkey_task
) {
794 Signal(hotkey_task
,INPUTSIG_UNICONIFY
);
795 oldevent
->ie_Class
=IECLASS_NULL
;
797 else if (wakeup
==2) {
798 if (IntuitionBase
->ActiveWindow
==Window
) {
799 status_haveaborted
=status_rexxabort
=1;
800 Signal((struct Task
*)main_proc
,INPUTSIG_ABORT
);
812 static char *Kstr
= "K ";
814 void __saveds
clocktask()
816 ULONG chipc
,fast
,wmes
,h
,m
,s
,/*secs,micro,*/cx
,sig
,cy
,len
,ct
,chipnum
,fastnum
,a
,active
=1,usage
;
817 UWORD clock_width
,clock_height
,scr_height
;
818 char buf
[160],date
[20],time
[20],formstring
[160],memstring
[160],ampm
;
819 struct MsgPort
*clock_time_port
;
820 struct timerequest ctimereq
;
821 struct DOpusDateTime datetime
= {0};
822 struct dopustaskmsg
*cmsg
;
823 struct RastPort clock_rp
;
825 struct SI_CpuUsage sicpu
;
829 CopyMem((char *)main_rp
,(char *)&clock_rp
,sizeof(struct RastPort
));
830 SetDrawModes(&clock_rp
,config
->clockfg
,config
->clockbg
,JAM2
);
831 SetFont(&clock_rp
,scr_font
[FONT_CLOCK
]);
832 scr_height
=scrdata_height
+scrdata_yoffset
;
833 clock_width
=scrdata_clock_width
;
834 clock_height
=scrdata_clock_height
;
835 ct
=scr_height
-(clock_height
-1);
836 cy
=scrdata_clock_ypos
+scr_font
[FONT_CLOCK
]->tf_Baseline
-1;
839 clockmsg_port
=LCreatePort(NULL
,0);
840 clock_time_port
=LCreatePort(0,0);
842 OpenDevice(TIMERNAME
,UNIT_VBLANK
,(struct IORequest
*)&ctimereq
,0);
843 ctimereq
.tr_node
.io_Message
.mn_ReplyPort
=clock_time_port
;
844 ctimereq
.tr_node
.io_Command
=TR_ADDREQUEST
;
845 ctimereq
.tr_node
.io_Flags
=0;
846 ctimereq
.tr_time
.tv_secs
=0;
847 ctimereq
.tr_time
.tv_micro
=2;
848 SendIO(&ctimereq
.tr_node
);
850 chipnum
=getmaxmem(MEMF_CHIP
/*,MEMF_ANY*/);
851 fastnum
=getmaxmem(MEMF_FAST
/*ANY,MEMF_CHIP*/);
852 a
=getmaxmem(MEMF_ANY
/*,MEMF_ANY*/);
854 m
= (config
->scrclktype
&SCRCLOCK_BYTES
)?3:0;
855 s
= (config
->scrclktype
&SCRCLOCK_BYTES
)?1:0;
857 if (config
->scrclktype
&SCRCLOCK_C_AND_F
) {
858 lsprintf(memstring
,"%lc:%%-%ldld%s",globstring
[STR_CLOCK_CHIP
][0],(long int)(chipnum
+m
),Kstr
+s
);
860 lsprintf(memstring
+strlen(memstring
),"%lc:%%-%ldld%s",globstring
[STR_CLOCK_FAST
][0],(long int)(fastnum
+m
),Kstr
+s
);
861 lsprintf(memstring
+strlen(memstring
),"%lc:%%-%ldld%s",globstring
[STR_CLOCK_TOTAL
][0],(long int)(a
+m
),Kstr
+s
);
865 lsprintf(memstring
,"%s%%-%ldld%s",globstring
[STR_CLOCK_CHIP
],(long int)(chipnum
+m
),Kstr
+s
);
867 lsprintf(memstring
+strlen(memstring
),"%s%%-%ldld%s",globstring
[STR_CLOCK_FAST
],(long int)(fastnum
+m
),Kstr
+s
);
868 lsprintf(memstring
+strlen(memstring
),"%s%%-%ldld%s",globstring
[STR_CLOCK_TOTAL
],(long int)(a
+m
),Kstr
+s
);
872 if (!(config
->scrclktype
&(SCRCLOCK_MEMORY
|SCRCLOCK_CPU
|SCRCLOCK_DATE
|SCRCLOCK_TIME
)))
873 lsprintf(formstring
,"Directory Opus Version %s Compiled %s %s",
874 str_version_string
,comp_time
,comp_date
);
876 sig
= 1<<clock_time_port
->mp_SigBit
| 1<<clockmsg_port
->mp_SigBit
;
880 if (wmes
&1<<clockmsg_port
->mp_SigBit
) {
881 while ((cmsg
=(struct dopustaskmsg
*)GetMsg(clockmsg_port
))) {
882 switch (cmsg
->command
) {
884 if (!(CheckIO(&ctimereq
.tr_node
)))
885 AbortIO(&ctimereq
.tr_node
);
886 WaitIO(&ctimereq
.tr_node
);
887 CloseDevice((struct IORequest
*)&ctimereq
);
888 LDeletePort(clock_time_port
);
889 LDeletePort(clockmsg_port
); clockmsg_port
=NULL
;
890 ReplyMsg((struct Message
*)cmsg
);
898 ReplyMsg((struct Message
*)cmsg
);
901 if (wmes
&1<<clock_time_port
->mp_SigBit
) {
902 // if (CheckIO((struct IORequest *)&ctimereq.tr_node)) {
903 // WaitIO((struct IORequest *)&ctimereq.tr_node);
904 if (active
&& !(Window
->Flags
&WFLG_MENUSTATE
)) {
905 if (scr_height
>ct
+1) {
906 if (config
->scrclktype
&(SCRCLOCK_MEMORY
|SCRCLOCK_CPU
|SCRCLOCK_DATE
|SCRCLOCK_TIME
)) {
908 if (config
->scrclktype
&SCRCLOCK_MEMORY
) {
909 chipc
=AvailMem(MEMF_CHIP
);
910 fast
=AvailMem(MEMF_FAST
/*ANY*/)/*-chipc*/;
911 if (!(config
->scrclktype
&SCRCLOCK_BYTES
))
916 /*if (fastnum>1)*/ lsprintf(buf
,memstring
,chipc
,fast
,chipc
+fast
);
917 // else lsprintf(buf,memstring,chipc);
918 strcat(formstring
,buf
);
920 if (config
->scrclktype
&SCRCLOCK_CPU
) {
924 GetCpuUsage(sysinfo
,&sicpu
);
925 usage
= 100 * sicpu
.used_cputime_lastsec
/ sicpu
.used_cputime_lastsec_hz
;
928 else usage
= getusage()/*/10*/;
930 lsprintf(buf
,"CPU:%3ld%% ",(long int)usage
);
931 strcat(formstring
,buf
);
933 if (config
->scrclktype
&(SCRCLOCK_DATE
|SCRCLOCK_TIME
)) {
934 DateStamp(&(datetime
.dat_Stamp
));
935 initdatetime(&datetime
,date
,time
,0);
937 if (config
->scrclktype
&SCRCLOCK_DATE
) {
938 lsprintf(buf
,"%-9s ",date
);
939 strcat(formstring
,buf
);
941 if (config
->scrclktype
&SCRCLOCK_TIME
) {
942 if (config
->dateformat
&DATE_12HOUR
) {
943 h
=datetime
.dat_Stamp
.ds_Minute
/60; m
=datetime
.dat_Stamp
.ds_Minute
%60;
944 s
=datetime
.dat_Stamp
.ds_Tick
/TICKS_PER_SECOND
;
945 if (h
>11) { ampm
='P'; h
-=12; }
948 lsprintf(time
,"%2ld:%02ld:%02ld%lc",(long int)h
,(long int)m
,(long int)s
,ampm
);
950 strcat(formstring
,time
);
954 len
=strlen(formstring
);
955 if (len
>1 && formstring
[len
-2]==' ') len
-=2;
956 cx
=(clock_width
-dotextlength(&clock_rp
,formstring
,(int *)&len
,clock_width
-4))/2;
957 cx
+=scrdata_clock_xpos
;
958 if (cx
<scrdata_clock_xpos
) cx
=scrdata_clock_xpos
;
960 SetAPen(&clock_rp
,screen_pens
[config
->clockfg
].pen
);
961 Move(&clock_rp
,cx
,cy
);
962 Text(&clock_rp
,formstring
,len
);
963 SetAPen(&clock_rp
,screen_pens
[config
->clockbg
].pen
);
965 if (cx
>scrdata_clock_xpos
)
966 RectFill(&clock_rp
,scrdata_clock_xpos
,ct
,cx
-1,scr_height
-2);
967 if (clock_rp
.cp_x
<clock_width
-1)
968 RectFill(&clock_rp
,clock_rp
.cp_x
,ct
,clock_width
-2,scr_height
-2);
971 ctimereq
.tr_time
.tv_secs
=1;
972 ctimereq
.tr_time
.tv_micro
=0;
973 SendIO(&ctimereq
.tr_node
);