TSTATIC.CPP
上传用户:wtrl82617
上传日期:2007-01-07
资源大小:187k
文件大小:1k
源码类别:

界面编程

开发平台:

DOS

  1. /*  yyxtedit.cpp
  2. */
  3. #include "tstatic.h"
  4. /**************************************************************************/
  5. tstatic_class::tstatic_class(int ID,char *title_hotkey,
  6. int left,int top,int width,int height,char *default_text,
  7. int atype)
  8. :  control_class(ID,title_hotkey,DISABLE ,TSTATIC,
  9. left,top,width,height,0,0,0 )
  10. {
  11. title_pos_x =left ;
  12. title_pos_y =top -bar_height-1 ;
  13. text_pos_x  =left+LINE_WIDTH;
  14. text_pos_y  =top +( height-textheight("j") )/2-2;
  15. strcpy (text,default_text);
  16. static_type =atype;
  17. }
  18. /**************************************************************************/
  19. // tstatic 's text could have a lot of lines ; assuming 'n' as the seperator
  20. void tstatic_class::draw ()
  21. {
  22. if ( status & INVISIBLE) return;    // INVISIBLE
  23. FillRect (bounds,WHITE);
  24.   char buf[255];
  25.   char *p_text=text;
  26.   char *p_buf=buf;
  27.   int  line_num=0;
  28. setcolor (BLACK);
  29. do  {
  30. p_buf=buf ;
  31. while ( (*p_buf = *p_text ) !='n' && (*p_buf !='') ) {
  32. p_buf ++; p_text++;
  33. }
  34. p_text++;
  35. *p_buf =''; // get one string ,'n' included;
  36. switch (static_type ) {
  37. case ALIGN_MIDDLE:
  38. // title_pos_x =bounds.left + (bounds.right-bounds.left-textwidth (buf) )/2;
  39. text_pos_x=bounds.left + (bounds.right-bounds.left-textwidth (buf) )/2;
  40. }
  41. outtextxy (text_pos_x,text_pos_y+line_num*bar_height, buf);
  42. line_num ++;
  43. } while (*(p_text-1) !='' );
  44. control_class::draw ();
  45. }