home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / MSWSRC35 / AREAWIND.CPP < prev    next >
C/C++ Source or Header  |  1993-10-12  |  5KB  |  205 lines

  1. #include "allwind.h"
  2.  
  3. TMyPrinterAreaWindow::TMyPrinterAreaWindow(PTWindowsObject AParent, LPSTR ATitle)
  4. : TDialog(AParent, ATitle)
  5.    {
  6.    }
  7.  
  8. TMyPrinterAreaWindow::~TMyPrinterAreaWindow()
  9.    {
  10.    }
  11.  
  12. /* These next 4 routines fetch the active area dimensions */
  13.  
  14. void TMyPrinterAreaWindow::DoXLow(RTMessage Msg)
  15.    { 
  16.    if (TCustomFlag)
  17.       {
  18.       SelectedText[0] = '\0';
  19.       SendDlgItemMsg(ID_XLOW, WM_GETTEXT, MAX_BUFFER_SIZE, (DWORD)SelectedText);
  20.       sscanf(SelectedText,"%d",&TPrinterAreaXLow);
  21.       }
  22.    }
  23.  
  24. void TMyPrinterAreaWindow::DoXHigh(RTMessage Msg)
  25.    { 
  26.    if (TCustomFlag)
  27.       {
  28.       SelectedText[0] = '\0';
  29.       SendDlgItemMsg(ID_XHIGH, WM_GETTEXT, MAX_BUFFER_SIZE, (DWORD)SelectedText);
  30.       sscanf(SelectedText,"%d",&TPrinterAreaXHigh);
  31.       }
  32.    }
  33.  
  34. void TMyPrinterAreaWindow::DoYLow(RTMessage Msg)
  35.    { 
  36.    if (TCustomFlag)
  37.       {
  38.       SelectedText[0] = '\0';
  39.       SendDlgItemMsg(ID_YLOW, WM_GETTEXT, MAX_BUFFER_SIZE, (DWORD)SelectedText);
  40.       sscanf(SelectedText,"%d",&TPrinterAreaYLow);
  41.       }
  42.    }
  43.  
  44. void TMyPrinterAreaWindow::DoYHigh(RTMessage Msg)
  45.    { 
  46.    if (TCustomFlag)
  47.       {
  48.       SelectedText[0] = '\0';
  49.       SendDlgItemMsg(ID_YHIGH, WM_GETTEXT, MAX_BUFFER_SIZE, (DWORD)SelectedText);
  50.       sscanf(SelectedText,"%d",&TPrinterAreaYHigh);
  51.       }
  52.    }
  53.  
  54. void TMyPrinterAreaWindow::WMInitDialog(RTMessage Msg)
  55.    { 
  56.    
  57.    /* if active area display active parameters */
  58.    
  59.    if (TCustomFlag)
  60.       {
  61.       sprintf(YABuffer,"%d",TPrinterAreaXLow);
  62.       SendDlgItemMsg(ID_XLOW, WM_SETTEXT, 0, (DWORD)YABuffer);
  63.       
  64.       sprintf(YABuffer,"%d",TPrinterAreaXHigh);
  65.       SendDlgItemMsg(ID_XHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);
  66.       
  67.       sprintf(YABuffer,"%d",TPrinterAreaYLow);
  68.       SendDlgItemMsg(ID_YLOW, WM_SETTEXT, 0, (DWORD)YABuffer);
  69.       
  70.       sprintf(YABuffer,"%d",TPrinterAreaYHigh);
  71.       SendDlgItemMsg(ID_YHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);
  72.       
  73.       SendDlgItemMsg(ID_CUSTOMIMAGE, BM_SETCHECK, 1, 0);
  74.       }
  75.    
  76.    /* else display N/A */
  77.    
  78.    else
  79.       {
  80.       strcpy(YABuffer, "N/A");
  81.       
  82.       SendDlgItemMsg(ID_XLOW, WM_SETTEXT, 0, (DWORD)YABuffer);        
  83.       SendDlgItemMsg(ID_XHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);        
  84.       SendDlgItemMsg(ID_YLOW, WM_SETTEXT, 0, (DWORD)YABuffer);        
  85.       SendDlgItemMsg(ID_YHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);
  86.       
  87.       SendDlgItemMsg(ID_FULLIMAGE, BM_SETCHECK, 1, 0);
  88.       }
  89.    
  90.    TDialog::DefWndProc(Msg);
  91.    }
  92.  
  93. void TMyPrinterAreaWindow::DoFullImage(RTMessage Msg)
  94.    { 
  95.    
  96.    /* hack to init things */
  97.    
  98.    strcpy(YABuffer, "N/A");
  99.    
  100.    SendDlgItemMsg(ID_XLOW, WM_SETTEXT, 0, (DWORD)YABuffer);     
  101.    SendDlgItemMsg(ID_XHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);     
  102.    SendDlgItemMsg(ID_YLOW, WM_SETTEXT, 0, (DWORD)YABuffer);     
  103.    SendDlgItemMsg(ID_YHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);
  104.    
  105.    TPrinterAreaXLow  = -BitMapWidth/2;
  106.    TPrinterAreaXHigh = +BitMapWidth/2;
  107.    TPrinterAreaYLow  = -BitMapHeight/2;
  108.    TPrinterAreaYHigh = +BitMapHeight/2;
  109.    
  110.    SendDlgItemMsg(ID_FULLIMAGE, BM_SETCHECK, 1, 0);
  111.    TCustomFlag = 0;
  112.    
  113.    TDialog::DefWndProc(Msg);
  114.    }
  115.  
  116. void TMyPrinterAreaWindow::DoCustomImage(RTMessage Msg)
  117.    { 
  118.    
  119.    /* if user clicks on custom display current area */
  120.    
  121.    sprintf(YABuffer,"%d",TPrinterAreaXLow);
  122.    SendDlgItemMsg(ID_XLOW, WM_SETTEXT, 0, (DWORD)YABuffer);
  123.    
  124.    sprintf(YABuffer,"%d",TPrinterAreaXHigh);
  125.    SendDlgItemMsg(ID_XHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);
  126.    
  127.    sprintf(YABuffer,"%d",TPrinterAreaYLow);
  128.    SendDlgItemMsg(ID_YLOW, WM_SETTEXT, 0, (DWORD)YABuffer);
  129.    
  130.    sprintf(YABuffer,"%d",TPrinterAreaYHigh);
  131.    SendDlgItemMsg(ID_YHIGH, WM_SETTEXT, 0, (DWORD)YABuffer);
  132.    
  133.    SendDlgItemMsg(ID_CUSTOMIMAGE, BM_SETCHECK, 1, 0);
  134.    TCustomFlag = 1;
  135.    
  136.    TDialog::DefWndProc(Msg);
  137.    }
  138.  
  139. NODE *lsetactivearea(NODE *arg)
  140.    {
  141.    NODE *args;
  142.    
  143.    args = car(arg);
  144.    
  145.    // better be a list
  146.    
  147.    if (is_list(args))
  148.       {
  149.       
  150.       // apply all args that are given
  151.       
  152.       if (args != NIL)
  153.       PrinterAreaXLow = int_arg(args);
  154.       if (cdr(args) != NIL)
  155.       PrinterAreaYLow = int_arg(args=cdr(args));
  156.       if (cdr(args) != NIL)
  157.       PrinterAreaXHigh = int_arg(args=cdr(args));
  158.       if (cdr(args) != NIL)
  159.       PrinterAreaYHigh = int_arg(args=cdr(args));
  160.       
  161.       // if user specs all 0's then disable custom
  162.       
  163.       if (
  164.       (PrinterAreaXLow == 0) &&
  165.       (PrinterAreaYLow == 0) &&
  166.       (PrinterAreaXHigh == 0) &&
  167.       (PrinterAreaYHigh == 0)) CustomFlag = 0; else CustomFlag = 1;
  168.       }
  169.    
  170.    return(UNBOUND);
  171.    }
  172.  
  173. NODE *lactivearea(void)
  174.    {
  175.    NODE *targ, *val = UNBOUND;
  176.    
  177.    // if custom return settings
  178.    
  179.    if (CustomFlag)
  180.       {
  181.       return(
  182.       cons(make_intnode((FIXNUM)PrinterAreaXLow),
  183.       cons(make_intnode((FIXNUM)PrinterAreaYLow),
  184.       cons(make_intnode((FIXNUM)PrinterAreaXHigh),
  185.       cons(make_intnode((FIXNUM)PrinterAreaYHigh),
  186.       NIL
  187.       )))));
  188.       }
  189.    
  190.    // else return all 0's as an indicator
  191.    
  192.    else
  193.       {
  194.       return(
  195.       cons(make_intnode((FIXNUM)0),
  196.       cons(make_intnode((FIXNUM)0),
  197.       cons(make_intnode((FIXNUM)0),
  198.       cons(make_intnode((FIXNUM)0),
  199.       NIL
  200.       )))));
  201.       }
  202.    
  203.    }
  204.  
  205.