?? imagebutton.cpp
字號:
#include <osdef.h>//WM_**
#include <System.h>
#include <Api.h> //Sgos api
namespace System{
int Button::OnSize( int w, int h ){
Width = w;
Height = h;
Label::OnSize(w,h);
}
Button::~Button(){
}
Button::Button( BaseWindow* form, string text, int style ):
Label( form, text, LABEL_NOBACKGROUND|LABEL_NOFRAME )
{
frameColor1=Bitmap::MakeColor(0,0,0); //激活時窗體邊框顏色
frameColor2=Bitmap::MakeColor(123,123,123); //非激活時窗體邊框顏色
frameColor3=Bitmap::MakeColor(65,92,109); //按下時窗體邊框顏色
backColor1=Bitmap::MakeColor(207,207,207); //激活時窗體背景顏色
backColor2=Bitmap::MakeColor(207,207,207); //非激活時窗體背景顏色
backColor3=Bitmap::MakeColor(207,211,214); //按下時窗體背景顏色
textColor1=Bitmap::MakeColor(0,0,0); //激活時文字顏色
textColor2=Bitmap::MakeColor(0,0,0); //非激活時文字顏色
textColor3=Bitmap::MakeColor(0,0,0); //按下時文字顏色
strText =text;
type = TypeButton;
Width = strText.Length()*8+12;
Height = ch+7;
mid_space = 4;
SetSize( Width, Height );
}
int Button::DrawButton(int type){
switch( type ){
case 0:
Bitmap::RectFill( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, backColor2 );
Bitmap::Rectangle( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, frameColor2 );
break;
case 1:
Bitmap::RectFill( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, backColor1 );
Bitmap::Rectangle( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, frameColor1 );
break;
case 2:
Bitmap::RectFill( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, backColor3 );
Bitmap::Rectangle( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, frameColor3 );
break;
}
DrawLabel(0);
}
int Button::OnPaint(){
DrawButton(0);
Label::OnPaint();
}
int Button::OnMouseHover( int button ){
if( button==1 )
DrawButton(2);
else
DrawButton(1);
}
int Button::OnMouseLeave( int button ){
DrawButton(0);
}
int Button::OnMouseDown( int button, Point* p ){
if( button==1)
DrawButton(2);
}
int Button::OnMouseUp( int button, Point* p ){
DrawButton(1);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -