165 lines
4.6 KiB
C
165 lines
4.6 KiB
C
/* NOWIN.C */
|
|||
|
|
|
||
|
|
#include <notes.g>
|
||
|
|
#include <notes.rsg>
|
||
|
|
#include <hwim.h>
|
||
|
|
#include "nolayout.h"
|
||
|
|
|
||
|
|
GLREF_D PR_NOCOMMAN *DatApp2;
|
||
|
|
GLREF_D LAYOUT_DATA ld;
|
||
|
|
|
||
|
|
LOCAL_C VOID DrawTextInWindow(INT wid,TEXT *pstr)
|
||
|
|
{
|
||
|
|
W_WINDATA wd;
|
||
|
|
|
||
|
|
wInquireWindow(wid,&wd);
|
||
|
|
wd.extent.tl.x=wd.extent.tl.y=0;
|
||
|
|
gPrintBoxText((P_RECT *)(&wd.extent),ld.FontAscent+1,
|
||
|
|
G_TEXT_ALIGN_CENTRE,0,pstr,p_slen(pstr));
|
||
|
|
}
|
||
|
|
|
||
|
|
#pragma METHOD_CALL
|
||
|
|
|
||
|
|
METHOD VOID nowin_wn_key(PR_NOWIN *self,INT keycode,INT mods)
|
||
|
|
{
|
||
|
|
if (keycode==W_KEY_TAB)
|
||
|
|
p_send3(DatApp2,O_NCO_SWITCH_FOCUS,mods);
|
||
|
|
else
|
||
|
|
p_send4(self->nowin.edwin,O_WN_KEY,keycode,mods);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nowin_wn_emphasise(PR_NOWIN *self,INT emphasise)
|
||
|
|
{
|
||
|
|
p_supersend3(self,O_WN_EMPHASISE,emphasise);
|
||
|
|
p_send3(self->nowin.edwin,O_WN_EMPHASISE,emphasise);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nowin_wn_draw(PR_NOWIN *self)
|
||
|
|
{
|
||
|
|
p_supersend2(self,O_WN_DRAW);
|
||
|
|
p_send2(self->nowin.edwin,O_WN_DRAW);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nowin_wn_init(PR_NOWIN *self,IN_EDWIN *pined,IN_EDWIN_X *pinx)
|
||
|
|
{
|
||
|
|
W_WINDATA wd;
|
||
|
|
|
||
|
|
wd.extent.tl=pinx->pos;
|
||
|
|
wd.extent.width=pined->vulen;
|
||
|
|
wd.extent.height=ld.FontHeight+2;
|
||
|
|
if (pined->flags&IN_EDWIN_VISLINES_SUPPLIED)
|
||
|
|
wd.extent.height*=pinx->vislines;
|
||
|
|
wd.extent.height+=EDGE_HEIGHT;
|
||
|
|
p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd);
|
||
|
|
self->win.flags=PR_BWIN_CORNER_4|PR_BWIN_SHADOW_2;
|
||
|
|
pinx->pos.x=EDGE_TLX;
|
||
|
|
pinx->pos.y=EDGE_TLY;
|
||
|
|
pined->vulen-=EDGE_WIDTH;
|
||
|
|
p_send4(self,O_NW_INIT,pined,pinx);
|
||
|
|
self->nowin.edwin=f_newsend(CAT_NOTES_HWIM,C_EDWIN,
|
||
|
|
O_WN_INIT,pined,self,pinx);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nowin_nw_increase_width(PR_NOWIN *self,INT increase)
|
||
|
|
{
|
||
|
|
W_WINDATA wd;
|
||
|
|
PR_EDWIN *edwin;
|
||
|
|
|
||
|
|
wInvalidateWin(self->win.id);
|
||
|
|
wInquireWindow(self->win.id,&wd);
|
||
|
|
wd.extent.width+=increase;
|
||
|
|
wSetWindow(self->win.id,W_WIN_EXTENT,&wd);
|
||
|
|
edwin=self->nowin.edwin;
|
||
|
|
p_send3(edwin,O_EW_SENSE_SIZE,&wd.extent);
|
||
|
|
edwin->edwin.margins.right+=increase;
|
||
|
|
wd.extent.width+=increase;
|
||
|
|
p_send4(edwin,O_EW_SET_SIZE,&wd.extent,NULL);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID notitwin_wn_key(PR_NOWIN *self,INT keycode,INT mods)
|
||
|
|
{
|
||
|
|
if (keycode==W_KEY_RETURN)
|
||
|
|
p_send3(DatApp2,O_NCO_SWITCH_FOCUS,mods);
|
||
|
|
else
|
||
|
|
p_supersend4(self,O_WN_KEY,keycode,mods);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nofndwin_wn_key(PR_NOWIN *self,INT keycode,INT mods)
|
||
|
|
{
|
||
|
|
if (keycode==W_KEY_RETURN)
|
||
|
|
p_send3(DatApp2,O_NCO_QUICK_FIND,mods&W_SHIFT_MODIFIER? -1: +1);
|
||
|
|
else
|
||
|
|
p_supersend4(self,O_WN_KEY,keycode,mods);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nofndwin_destroy(PR_NOFNDWIN *self)
|
||
|
|
{
|
||
|
|
p_free(self->nofndwin.prompt);
|
||
|
|
p_supersend2(self,O_DESTROY);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nofndwin_nw_init(PR_NOFNDWIN *self,IN_EDWIN *pined,IN_EDWIN_X *pinx)
|
||
|
|
{
|
||
|
|
UWORD width;
|
||
|
|
|
||
|
|
self->nofndwin.x=EDGE_TLX;
|
||
|
|
self->nofndwin.y=EDGE_TLY+(1+ld.FontAscent);
|
||
|
|
self->nofndwin.len=
|
||
|
|
hLoadResource(NOSTR_FIND_PROMPT,&self->nofndwin.prompt)-1;
|
||
|
|
width=gTextWidth(WS_FONT_SYSTEM,G_STY_ITALIC,
|
||
|
|
self->nofndwin.prompt,self->nofndwin.len);
|
||
|
|
pinx->pos.x=EDGE_TLX+width;
|
||
|
|
pined->vulen-=width;
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nofndwin_wn_draw(PR_NOFNDWIN *self)
|
||
|
|
{
|
||
|
|
p_supersend2(self,O_WN_DRAW);
|
||
|
|
hSetGStyle(G_STY_ITALIC);
|
||
|
|
gPrintText(self->nofndwin.x,self->nofndwin.y,
|
||
|
|
self->nofndwin.prompt,self->nofndwin.len);
|
||
|
|
hSetGStyle(G_STY_NORMAL);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID notagwin_wn_set(PR_NOTAGWIN *self,INT on)
|
||
|
|
{
|
||
|
|
if (on==self->notagwin.on)
|
||
|
|
return;
|
||
|
|
wInvalidateWin(self->win.id);
|
||
|
|
self->notagwin.on=on;
|
||
|
|
}
|
||
|
|
|
||
|
|
#define TICK_SYM_AS_STRING "\014"
|
||
|
|
|
||
|
|
METHOD VOID notagwin_wn_draw(PR_NOTAGWIN *self)
|
||
|
|
{
|
||
|
|
DrawTextInWindow(self->win.id,self->notagwin.on? TICK_SYM_AS_STRING: "");
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD INT notagwin_wn_sense(PR_NOTAGWIN *self)
|
||
|
|
{
|
||
|
|
return(hGetSWid(TICK_SYM_AS_STRING)+TEXT_WINDOW_EDGE_WIDTH);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nocntwin_wn_set(PR_NOCNTWIN *self,INT val,INT max)
|
||
|
|
{
|
||
|
|
if (val==self->nocntwin.val && max==self->nocntwin.max)
|
||
|
|
return;
|
||
|
|
wInvalidateWin(self->win.id);
|
||
|
|
self->nocntwin.val=val;
|
||
|
|
self->nocntwin.max=max;
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD VOID nocntwin_wn_draw(PR_NOCNTWIN *self)
|
||
|
|
{
|
||
|
|
TEXT buf[10];
|
||
|
|
|
||
|
|
p_atos(&buf[0],"%d/%d",self->nocntwin.val,self->nocntwin.max);
|
||
|
|
DrawTextInWindow(self->win.id,&buf[0]);
|
||
|
|
}
|
||
|
|
|
||
|
|
METHOD INT nocntwin_wn_sense(PR_NOCNTWIN *self)
|
||
|
|
{
|
||
|
|
return(hGetSWid("99/99")+TEXT_WINDOW_EDGE_WIDTH);
|
||
|
|
}
|