主题:新手求助!!!
我刚接触C不久,现在要做一界面,里面的按钮控件要封装,我现在不知道这么做对不对,希望大家能够帮助我改正一下,提出更多的办法。
/*函数声明*/
void drawbutton(UGL_GC_ID gc,int button_left,int button_top,int button_right,int button_bottom,int button_linewidth ,int button_forgroundcolor,
int button_backgroundcolor,unsigned char button_word, int button_wordforgroundcolor,int button_wordbackgroundcolor,
int button_word_left,int button_word_top);
struct button
{
int left;
int top;
int right;
int bottom;
int linewidth;
int foregroundColor;
int backgroundColor;
unsigned char word[20];
int wordforgroundcolor;
int wordbackgroundcolor;
int word_left;
int word_top;
};
struct button button_red={450,880,520,930,4,LIGHTRED,RED,"红",WHITE,RED,480,900};
struct button button_green=
{590,880,660,930,4,LIGHTRED,GREEN,"绿",WHITE,GREEN,620,900};
drawbutton(gc,button.left,button.top,button.right,button.bottom,button.linewidth ,button.forgroundcolor,
button.backgroundcolor,button.word, button.wordforgroundcolor,button.wordbackgroundcolor,
button.word_left,button.word_top);
void drawbutton(UGL_GC_ID gc,int button_left,int button_top,int button_right,int button_bottom,int button_linewidth ,int button_forgroundcolor,
int button_backgroundcolor,unsigned char button_word, int button_wordforgroundcolor,int button_wordbackgroundcolor,
int button_word_left,int button_word_top)
{
unsigned char regionMessage1[23]={0};
uglBatchStart(gc);
uglLineWidthSet (gc, 4);
uglForegroundColorSet(gc, colorTable[button_forgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_backgroundcolor].uglColor);
uglRectangle(gc,button_red.left,button_red.top, button_red.right,button_red.bottom);
uglFontSet(gc, fontFixed);
uglForegroundColorSet(gc, colorTable[button_wordforgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_wordbackgroundcolor].uglColor);
sprintf(regionMessage1,"红");
stringConvert(regionMessage1,button_word_left,button_word_top);
uglForegroundColorSet(gc, colorTable[button_forgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_backgroundcolor].uglColor);
uglRectangle(gc,button_green.left,button_green.top, button_green.right,button_green.bottom);
uglFontSet(gc, fontFixed);
uglForegroundColorSet(gc, colorTable[button_wordforgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_wordbackgroundcolor].uglColor);
sprintf(regionMessage1,"绿");
stringConvert(regionMessage1,button_word_left,button_word_top);
uglBatchEnd(gc);
}
以上是我编的关于按钮控件的程序,请各位帮小妹看看,提出更多建议,谢谢了。
/*函数声明*/
void drawbutton(UGL_GC_ID gc,int button_left,int button_top,int button_right,int button_bottom,int button_linewidth ,int button_forgroundcolor,
int button_backgroundcolor,unsigned char button_word, int button_wordforgroundcolor,int button_wordbackgroundcolor,
int button_word_left,int button_word_top);
struct button
{
int left;
int top;
int right;
int bottom;
int linewidth;
int foregroundColor;
int backgroundColor;
unsigned char word[20];
int wordforgroundcolor;
int wordbackgroundcolor;
int word_left;
int word_top;
};
struct button button_red={450,880,520,930,4,LIGHTRED,RED,"红",WHITE,RED,480,900};
struct button button_green=
{590,880,660,930,4,LIGHTRED,GREEN,"绿",WHITE,GREEN,620,900};
drawbutton(gc,button.left,button.top,button.right,button.bottom,button.linewidth ,button.forgroundcolor,
button.backgroundcolor,button.word, button.wordforgroundcolor,button.wordbackgroundcolor,
button.word_left,button.word_top);
void drawbutton(UGL_GC_ID gc,int button_left,int button_top,int button_right,int button_bottom,int button_linewidth ,int button_forgroundcolor,
int button_backgroundcolor,unsigned char button_word, int button_wordforgroundcolor,int button_wordbackgroundcolor,
int button_word_left,int button_word_top)
{
unsigned char regionMessage1[23]={0};
uglBatchStart(gc);
uglLineWidthSet (gc, 4);
uglForegroundColorSet(gc, colorTable[button_forgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_backgroundcolor].uglColor);
uglRectangle(gc,button_red.left,button_red.top, button_red.right,button_red.bottom);
uglFontSet(gc, fontFixed);
uglForegroundColorSet(gc, colorTable[button_wordforgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_wordbackgroundcolor].uglColor);
sprintf(regionMessage1,"红");
stringConvert(regionMessage1,button_word_left,button_word_top);
uglForegroundColorSet(gc, colorTable[button_forgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_backgroundcolor].uglColor);
uglRectangle(gc,button_green.left,button_green.top, button_green.right,button_green.bottom);
uglFontSet(gc, fontFixed);
uglForegroundColorSet(gc, colorTable[button_wordforgroundcolor].uglColor);
uglBackgroundColorSet(gc, colorTable[button_wordbackgroundcolor].uglColor);
sprintf(regionMessage1,"绿");
stringConvert(regionMessage1,button_word_left,button_word_top);
uglBatchEnd(gc);
}
以上是我编的关于按钮控件的程序,请各位帮小妹看看,提出更多建议,谢谢了。