Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15498322
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: C/C++

2007-09-16 16:43:41

增强μC/GUI-v3.90a下2色scrollbar显示效果

  2色下scrollbar显示效果不太理想,做如下修改可以使显示效果提高一些,
效果图:
//1.向scrollbar.c添加头文件
#include "LCDConf.h"
//2.修改scrollbar.c->_Paint()函数
static void _Paint(SCROLLBAR_Obj* pObj) {
  int ArrowSize, ArrowOff;
  SCROLLBAR_POSITIONS Pos;
  GUI_RECT r, rClient;
  /*
    Get / calc position info
  */

  _CalcPositions(pObj, &Pos);
  WIDGET__GetClientRect(&pObj->Widget, &rClient);
  r = rClient;
//2007-09-14 gliethttp 单色屏支持
#if (LCD_BITSPERPIXEL == 1)
  LCD_SetColor(GUI_BLACK);
  GUI_Clear();
#endif
  ArrowSize = ((r.y1 - r.y0) /3) - 1;
  ArrowOff = 3 + ArrowSize+ ArrowSize/3;
  /*
    Draw left Arrow
  */

  LCD_SetColor(pObj->aColor[0]);
  r = rClient;
  r.x0 = Pos.x0_LeftArrow;
  r.x1 = Pos.x1_LeftArrow;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  LCD_SetColor(pObj->aBkColor[1]);
  _DrawTriangle(&pObj->Widget, r.x0 + ArrowOff, (r.y1 - r.y0) >> 1, ArrowSize, -1);
//2007-09-14 gliethttp 单色屏支持
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
  /*
    Draw the thumb area which is not covered by the thumb
  */

#define LCD_BITSPERPIXELF 1
#if (LCD_BITSPERPIXEL == 1) && LCD_BITSPERPIXELF
  LCD_SetColor(GUI_BLACK);
#else
  LCD_SetColor(pObj->aBkColor[0]);
#endif
  r.x0 = Pos.x1_LeftArrow + 1;
  r.x1 = Pos.x0_Thumb - 1;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  r = rClient;
  r.x0 = Pos.x1_Thumb + 1;
  r.x1 = Pos.x0_RightArrow - 1;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  /*
    Draw Thumb
  */

  r = rClient;
  r.x0 = Pos.x0_Thumb;
  r.x1 = Pos.x1_Thumb;
#if (LCD_BITSPERPIXEL == 1) && LCD_BITSPERPIXELF
  {
    LCD_SetColor(GUI_WHITE);
    if (pObj->Widget.State & WIDGET_STATE_VERTICAL)
     WIDGET__RotateRect90(&pObj->Widget, &r, &r);
    r.x0+=3;
    r.x1-=3;
    r.y0-=1;
    GUI_FillRectEx(&r);
    r = rClient;//恢复
  }
#else
  LCD_SetColor(pObj->aColor[0]);
  WIDGET__FillRectEx(&pObj->Widget, &r);
#endif
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
  /*
    Draw right Arrow
  */

  LCD_SetColor(pObj->aColor[0]);
  r.x0 = Pos.x0_RightArrow;
  r.x1 = Pos.x1_RightArrow;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  LCD_SetColor(pObj->aBkColor[1]);
  _DrawTriangle(&pObj->Widget, r.x1 - ArrowOff, (r.y1 - r.y0) >> 1, ArrowSize, 1);
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
  /*
    Draw overlap area (if any ...)
  */

  if (Pos.x1_RightArrow != Pos.x1) {
    r.x0 = Pos.x1_RightArrow + 1;
    r.x1 = Pos.x1;
    LCD_SetColor(pObj->aColor[0]);
    WIDGET__FillRectEx(&pObj->Widget, &r);
  }
  #if (LCD_BITSPERPIXEL == 1) && LCD_BITSPERPIXELF
  {//SCROLLBAR_POSITIONS
    LCD_SetBkColor(GUI_BLACK);
    LCD_SetColor(GUI_WHITE);
    r = rClient;
    if(pObj->Widget.State & WIDGET_STATE_VERTICAL) {
        WIDGET__RotateRect90(&pObj->Widget, &r, &r);
      }
      r.x0++;
      r.x1--;
      r.y1--;
      GUI_DrawRect(r.x0,r.y0,r.x1,r.y1);
  }
  #endif
}

阅读(2381) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-07-17 11:10:57

楼主,请问怎样配置才能在VC仿真中看到这种2色显示的效果,要不修改修改scrollbar.c->_Paint()函数和没修改是一模一样的.