home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / beaversweeper_v101.zip / src / DrawSequencer.cpp < prev    next >
C/C++ Source or Header  |  2003-01-06  |  5KB  |  182 lines

  1. /**
  2.     
  3.     TODO:
  4.         
  5.  
  6.     Updates:
  7.         2002-10-16    gnilk    fixed a bug when outputting negative transpose values...
  8.         
  9. **/
  10. #include "stdafx.h"
  11. #include "tracker.h"
  12.  
  13. #include "mainfrm.h"
  14. #include "gtkformat.h"
  15. #include "trackerDoc.h"
  16. #include "trackerView.h"
  17.  
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. #define NUM_COL 8
  25. #define COL_WIDTH (NUM_COL*20 + 20 + NUM_COL)
  26. // 7*12+3*12
  27. void CPatternView::DrawSequencer(CDC *pDC)
  28. {
  29.     CTrackerDoc* pDoc = GetDocument();
  30.     ASSERT_VALID(pDoc);
  31.     int xpostab[]={0,20,20*2,20*3,20*4,20*5,20*6,20*7,20*8};//,120,144,166};
  32.     int xpos;
  33.     int seqStart;
  34.  
  35.     if (!pDoc->gtk ||!pDoc->synth || !pDoc->pl )
  36.         return;
  37.  
  38.  
  39.     pDC->SetBkColor  (RGB(0,0,0));
  40.     pDC->SetBkMode (TRANSPARENT);
  41.     pDC->SetTextColor (pDoc->ctrl_text);
  42.     pDC->SelectStockObject (SYSTEM_FIXED_FONT);
  43.  
  44.  
  45.     CRect rect;
  46.     int x,i,j;
  47.  
  48.  
  49.     seqStart = seqScroller.GetScrollPos ();
  50.  
  51.  
  52.     // lets shrink window for tracker data    
  53.     GetClientRect (&rect);
  54.     pDC->SetViewportOrg (0,0);
  55.     pDC->SetViewportExt (10,10);
  56.     GetClientRect (&rect);
  57.     rect.bottom = 128-16;
  58.     pDC->IntersectClipRect (&rect);
  59.  
  60.     // draw tracker bar
  61.     pDC->FillSolidRect (rect.left,rect.top, rect.Width (), 16,pDoc->ctrl_bg);
  62.     pDC->Draw3dRect (rect.left,rect.top, rect.Width (), 16,pDoc->ctrl_light,pDoc->ctrl_dark);
  63.  
  64.     for (i=seqStart;i<16;i++)
  65.     {
  66.         char tmp[64];
  67.         sprintf (tmp,"channel %d",i);
  68.             pDC->TextOut ((i-seqStart)*COL_WIDTH+rect.left+25,0,tmp);
  69.     }
  70. //------------------------------
  71.     
  72. //    pDC->SetViewportOrg (0,0);
  73. //    pDC->SetViewportExt (rect.Width (),96);
  74. //    GetClientRect (&rect);
  75.  
  76.     // draw lousy stuff beetween each track...
  77.     x = rect.left+20;
  78.     for (i=0;i<16;i++)
  79.     {
  80.         pDC->Draw3dRect (x+COL_WIDTH*i,rect.top+16,2,rect.Height (),pDoc->ctrl_light,pDoc->ctrl_dark);        
  81.         if ((x+i*COL_WIDTH) > rect.right) break;
  82.     }
  83. // draw middle "edit" bar
  84.     int middle;
  85.     pDC->SetViewportOrg (0,16);
  86.  
  87.     middle = rect.Height ();
  88.     middle = ((int)(rect.Height ()/2.0)&0xfffff0);
  89.  
  90.     pDC->FillSolidRect (rect.left,middle, rect.Width (), 16,pDoc->ctrl_bg);
  91.  
  92.     // draw cursor
  93.  
  94.     if ((!isPatternEdit) && (!pDoc->playing))
  95.     {
  96.         xpos = rect.left+25;
  97.         xpos+=seqCursor.rowcol*10;
  98.         xpos+=(seqCursor.col-seqStart)*COL_WIDTH;
  99.         if (seqCursor.rowcol & 0x01) xpos-=1;
  100.         pDC->FillSolidRect (xpos,middle,9,16,pDoc->ctrl_cursor);
  101.     }
  102.  
  103.     pDC->Draw3dRect (rect.left,middle, rect.Width (), 16,pDoc->ctrl_light,pDoc->ctrl_dark);
  104.  
  105.  
  106.     char buf[16];
  107.     int pos_count;
  108.     int pos_start; 
  109.     pDC->SetTextColor (pDoc->ctrl_text);
  110.  
  111.     if (!pDoc->playing)
  112.         pos_start = seqCursor.pos;
  113.     else
  114.         pos_start = pDoc->play_seqpos;
  115.  
  116.     pos_start-=(int)(middle/16.0);
  117.  
  118.     
  119.     pDC->SetTextColor (pDoc->ctrl_text);
  120.     pos_count = pos_start;
  121.     for (i=0;i<64;i++)
  122.     {
  123.         //        if ((pos_count>=0) && (pos_count<64))
  124.         if ((pos_count>=0) && (pos_count<pDoc->gtk->channels[i].len))
  125.         {
  126.             sprintf (buf,"%02x",pos_count);
  127.             pDC->TextOut (0,i*16,buf);
  128.         }
  129.         pos_count++;
  130.         if (i*16 > rect.bottom) break;
  131.     }
  132.  
  133.     GTK_SEQCHANNEL *schn;
  134.     GTK_SEQPOS *spos;
  135.  
  136.     for (j=seqStart;j<16;j++)
  137.     {
  138.         if (j == seqCursor.col)    pDC->SetTextColor (pDoc->ctrl_curtext);
  139.         else    pDC->SetTextColor (pDoc->ctrl_text);
  140.  
  141.         pos_count = pos_start;
  142.  
  143.  
  144.         schn = &pDoc->gtk->channels[j];
  145.         for (i=0;i<64;i++)
  146.         {
  147.             if ((pos_count>=0) && (pos_count<schn->len))
  148.             {
  149.                 spos = &schn->positions[pos_count];
  150.  
  151.                 if (!spos->pattern) sprintf (buf,"--");
  152.                 else sprintf (buf,"%02x",spos->pattern);
  153.  
  154.                 xpos = (j-seqStart)*COL_WIDTH+rect.left+25;
  155.  
  156.                 pDC->TextOut (xpos+xpostab[0],i*16,buf);
  157.                 sprintf (buf,"%02x",(unsigned char)spos->transpose);  // must be stored as char, but displayed as unsigned char
  158.                 pDC->TextOut (xpos+xpostab[1],i*16,buf);
  159.                 sprintf (buf,"%02x",spos->fx);
  160.                 pDC->TextOut (xpos+xpostab[2],i*16,buf);            
  161.                 sprintf (buf,"%02x",spos->param1);
  162.                 pDC->TextOut (xpos+xpostab[3],i*16,buf);            
  163.                 sprintf (buf,"%02x",spos->param2);
  164.                 pDC->TextOut (xpos+xpostab[4],i*16,buf);            
  165.                 sprintf (buf,"%02x",spos->param3);
  166.                 pDC->TextOut (xpos+xpostab[5],i*16,buf);            
  167.                 sprintf (buf,"%02x",0);
  168.                 pDC->TextOut (xpos+xpostab[6],i*16,buf);            
  169.                 sprintf (buf,"%02x",0);
  170.                 pDC->TextOut (xpos+xpostab[7],i*16,buf);            
  171.                 sprintf (buf,"%02x",0);
  172.                 pDC->TextOut (xpos+xpostab[8],i*16,buf);            
  173.       }
  174.             pos_count++;
  175.             if (i*16 > rect.bottom) break;
  176.  
  177.         }
  178.         if ((j-seqStart)*125+rect.left > rect.right) break;
  179.     }
  180.  
  181. } // drawchn
  182.