工具/软件:Code Composer Studio
您好!
我正在使用 TI 图形库、想知道熟悉例程的人是否可以帮助我修改 DrawButton 命令。
当前该命令要求按钮中文本开头的 x、y 坐标、但结果当然会因字符串的字体和长度而异。 很高兴让常规的自动将代码置于框中的中心、因为它知道框坐标。 有一个 DrawStringCentered 例程作为一个单独的函数、但我不能轻易地确定如何实现它。 我们非常感谢 Ant 的帮助。 以下是 drawButton 的代码;
谢谢、
Jerry
//
//
//! 绘制一个按钮。
//!
//! \param 上下文是要使用的绘图上下文的指针。
//! \param 按钮是指向包含扩展名的结构的指针
//! 按钮。
//!
//! 此函数绘制一个按钮。 该按钮将包含一个文本字符串、并且将
//! 基于在 Button 结构中传递的参数创建。
//!
//! \无返回。
//
//
void Graphics_drawButton (const Graphics_context *上下文、
const Graphics_Button *按钮)
{unsigned int colorb1;
uint32_t origFrgnd = g_sContext.for前景;
Graphics_Font * origFont =(Graphics_Font *) g_sContext.font;
graphics_Rectangle borderRect ={
button->xMin、
button->yMin、
button->Xmax、
button->yMax、
};
graphics_Rectangle innerRect ={
button->xMin + button->borderWidth、
button->yMin + button->borderWidth、
button->Xmax - button->borderWidth、
button->yMax - button->borderWidth、
};
graphics_setForegroundColor (&G) sContext、button->bordercolor);
//colorb1=Graphics_button *button->bordercolor;
// w_recb (button->xMin-3、button->yMin+1、button->Xmax-button->xMin+8、button->yMax-button->yMin+1、黑色、红色);//新边框
graphics_fillRectangle (&g_sContext、&borderRect);
if (button->selected){
graphics_setForegroundColor (&G) sContext、button->SelectedColor);
}否则{
graphics_setForegroundColor (&G) sContext、button->fillColor);
}
graphics_fillRectangle (&g_sContext、innerRect);
graphics_setFont (&g_sContext、button->font);
if (button->selected){
graphics_setForegroundColor (&G) sContext、button->selectedTextColor);
}否则{
graphics_setForegroundColor (&G) sContext、button->textColor);
}
graphics_drawstring (&g_sContext、
按钮->文本,
AUTO_STRING_LENGTH、
button->textXPos、
button->textYPos、
Transparent_text);
graphics_setFont (&g_sContext、origFont);
graphics_setForegroundColor (&g_sContext、origFrgnd);
}