123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- #define BUILDING_OPENDOORS
- #include <string.h>
- #include <stdlib.h>
- #include "OpenDoor.h"
- #include "ODGen.h"
- #include "ODCore.h"
- #include "ODKrnl.h"
- ODAPIDEF void * ODCALL od_window_create(INT nLeft, INT nTop, INT nRight,
- INT nBottom, char *pszTitle, BYTE btBorderCol, BYTE btTitleCol,
- BYTE btInsideCol, INT nReserved)
- {
- BYTE btLine;
- BYTE btBetweenSize;
- void *pBuffer;
- BYTE btTitleSize;
- BYTE btRemaining;
-
- TRACE(TRACE_API, "od_window_create()");
-
- if(!bODInitialized) od_init();
- OD_API_ENTRY();
- nReserved &= 0x00;
- btBetweenSize = (nRight - nLeft) - 1;
-
- if(od_control.od_box_chars[BOX_BOTTOM]==0)
- {
- od_control.od_box_chars[BOX_BOTTOM] = od_control.od_box_chars[BOX_TOP];
- }
- if(od_control.od_box_chars[BOX_RIGHT]==0)
- {
- od_control.od_box_chars[BOX_RIGHT] = od_control.od_box_chars[BOX_LEFT];
- }
-
-
- if(!(od_control.user_ansi || od_control.user_avatar))
- {
- od_control.od_error = ERR_NOGRAPHICS;
- OD_API_EXIT();
- return(NULL);
- }
-
- if(nLeft < 1 || nTop < 1 || nRight > 80 || nBottom > 25 || nRight-nLeft < 2
- || nBottom-nTop < 2)
- {
- od_control.od_error = ERR_PARAMETER;
- OD_API_EXIT();
- return(NULL);
- }
-
- if((pBuffer = malloc((nRight - nLeft + 1) * 2 + (nBottom - nTop + 1) * 160
- + 4)) == NULL)
- {
- od_control.od_error = ERR_MEMORY;
- OD_API_EXIT();
- return(NULL);
- }
-
- if(!od_gettext(nLeft, nTop, nRight, nBottom, (char *)pBuffer+4))
- {
- free(pBuffer);
-
- OD_API_EXIT();
- return(NULL);
- }
-
- ((char *)pBuffer)[0]=nLeft;
- ((char *)pBuffer)[1]=nTop;
- ((char *)pBuffer)[2]=nRight;
- ((char *)pBuffer)[3]=nBottom;
-
- if(pszTitle==NULL)
- {
- btTitleSize = 0;
- }
- else
- {
- if((btTitleSize = strlen(pszTitle)) > (btBetweenSize - 4))
- {
- btTitleSize = btBetweenSize - 4;
- }
- }
-
-
- od_set_cursor(nTop,nLeft);
- od_set_attrib(btBorderCol);
-
- od_putch(od_control.od_box_chars[BOX_UPPERLEFT]);
-
- if(btTitleSize == 0)
- {
-
- od_repeat(od_control.od_box_chars[BOX_TOP],btBetweenSize);
- }
- else
- {
-
-
- od_repeat(od_control.od_box_chars[BOX_TOP],btRemaining =
- ((btBetweenSize - btTitleSize - 2) / 2));
- od_set_attrib(btTitleCol);
- od_putch(' ');
- od_disp(pszTitle,btTitleSize,TRUE);
- od_putch(' ');
- od_set_attrib(btBorderCol);
- od_repeat(od_control.od_box_chars[BOX_TOP],
- (BYTE)(btBetweenSize - btRemaining - btTitleSize - 2));
- }
-
- od_putch(od_control.od_box_chars[BOX_UPPERRIGHT]);
-
- if(od_control.user_avatar)
- {
-
- od_set_cursor(nTop + 1, nLeft);
- od_putch(od_control.od_box_chars[BOX_LEFT]);
-
- od_emulate(22);
- od_emulate(12);
- od_emulate(btInsideCol);
- od_emulate((BYTE)((nBottom - nTop) - 1));
- od_emulate(btBetweenSize);
- od_set_attrib(btBorderCol);
- od_set_cursor(nTop + 1 , nRight);
-
- od_putch(od_control.od_box_chars[BOX_RIGHT]);
-
- for(btLine=nTop+2;btLine<nBottom;++btLine)
- {
-
- od_set_cursor(btLine,nLeft);
- od_putch(od_control.od_box_chars[BOX_LEFT]);
-
- od_set_cursor(btLine,nRight);
- od_putch(od_control.od_box_chars[BOX_RIGHT]);
- }
- }
-
- else
- {
-
- for(btLine=nTop+1;btLine<nBottom;++btLine)
- {
-
- od_set_cursor(btLine,nLeft);
- od_putch(od_control.od_box_chars[BOX_LEFT]);
-
- od_set_attrib(btInsideCol);
-
- od_repeat(' ',btBetweenSize);
-
- od_set_attrib(btBorderCol);
-
- od_putch(od_control.od_box_chars[BOX_RIGHT]);
- }
- }
-
- od_set_cursor(nBottom,nLeft);
- od_putch(od_control.od_box_chars[BOX_LOWERLEFT]);
- od_repeat(od_control.od_box_chars[BOX_BOTTOM],btBetweenSize);
- od_putch(od_control.od_box_chars[BOX_LOWERRIGHT]);
-
- OD_API_EXIT();
- return(pBuffer);
- }
- ODAPIDEF BOOL ODCALL od_window_remove(void *pWinInfo)
- {
-
- TRACE(TRACE_API, "od_window_remove()");
-
- if(!bODInitialized) od_init();
- OD_API_ENTRY();
- if(pWinInfo == NULL)
- {
-
- od_control.od_error = ERR_PARAMETER;
- OD_API_EXIT();
- return(FALSE);
- }
- if(!od_puttext(((char *)pWinInfo)[0], ((char *)pWinInfo)[1], ((char *)pWinInfo)[2], ((char *)pWinInfo)[3], (char *)pWinInfo + 4))
- {
-
- free(pWinInfo);
-
-
- OD_API_EXIT();
- return(FALSE);
- }
-
- free(pWinInfo);
-
- OD_API_EXIT();
- return(TRUE);
- }
|