?? imagebox.cpp
字號:
#include <osdef.h>//WM_**
#include <System.h>
#include <Api.h> //Sgos api
namespace System{
int ImageBox::OnSize( int w, int h ){
Width = w;
Height = h;
BaseWindow::OnSize(w,h);
}
ImageBox::~ImageBox(){
if( mypic ){
Bitmap::DestroyBitmap( mypic );
}
}
ImageBox::ImageBox( BaseWindow* parent, int style ):
BaseWindow( parent, string("ImageBox"), style )
{
frameColor1=Bitmap::MakeColor(206,168,66); //激活時窗體邊框顏色
frameColor2=Bitmap::MakeColor(155,155,140); //非激活時窗體邊框顏色
backColor1=Bitmap::MakeColor(237,237,226); //激活時窗體背景顏色
backColor2=Bitmap::MakeColor(225,225,225); //非激活時窗體背景顏色
textColor=Bitmap::MakeColor(0,0,0); //激活時文字顏色
this->style = style;
type = TypeImageBox;
Width = 240;
Height = 160;
SetSize( Width, Height );
mypic=(BitmapInfo*)0;
}
BitmapInfo* ImageBox::LoadPicture( string fileName )
{
if( mypic ){
Bitmap::DestroyBitmap( mypic );
}
mypic = Bitmap::LoadBitmap( fileName.GetData() );
return mypic;
}
int ImageBox::DrawImageBox(int type){
if( this->style&IMAGEBOX_TRANSPARENT ){
Bitmap::RectFill( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, Bitmap::MAGENTA );
}
switch( type ){
case 0:
if(!(style&LABEL_NOBACKGROUND))
Bitmap::RectFill( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, backColor2 );
if(!(style&LABEL_NOFRAME))
Bitmap::Rectangle( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, frameColor2 );
break;
case 1:
if(!(style&LABEL_NOBACKGROUND))
Bitmap::RectFill( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, backColor1 );
if(!(style&LABEL_NOFRAME))
Bitmap::Rectangle( bitmap, 0, 0, bitmap->Width-1, bitmap->Height-1, frameColor1 );
break;
}
if( mypic )
Bitmap::Blit( bitmap, 0, 0, mypic, 0, 0, mypic->Width, mypic->Height, 0 );
Refresh();
}
int ImageBox::OnPaint(){
DrawImageBox(0);
BaseWindow::OnPaint();
}
BitmapInfo* ImageBox::GetBitmap(){
return mypic;
}
int ImageBox::OnMessage( Message* msg ){
BaseWindow::OnMessage(msg);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -