📄 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 + -