level 11
#define __ANDROID_OS__
#include <SDL2/SDL.h>
#include "sdlgui/sdlgui.h"
using namespace std;
typedef class plane : public GUI<plane,sdl_widget>
{
public:
plane();
plane(const char*,int,int,int,int,Uint32);
int init();
int init(const char*,int,int,int,int,Uint32);
int sysevent(SDL_Event*);
protected:
sdl_widget_ptr _title;
sdl_button_ptr _min,_close;
sdl_view_ptr _view;
sdl_h_scroll_ptr _h;
}*plane_ptr;
plane::plane()
:
GUI<plane,sdl_widget>()
{
init();
}
plane::plane(const char* ptitle,int px,int py,int pw,int ph,Uint32 pflag)
:
GUI<plane,sdl_widget>()
{
init(ptitle,px,py,pw,ph,pflag);
}
int plane::init()
{
if(sdl_widget::init())return -1;
return 0;
}
int plane::init(const char* ptitle,int px,int py,int pw,int ph,Uint32 pflag)
{
if(sdl_widget::init(ptitle,px,py,pw,ph,pflag))return -1;
_title = add<sdl_widget>("title",0,0,pw,30,1);
_title->fill_rect(NULL,0xfffff0);
_min = _title->add<sdl_button>("-",pw-60,0,30,30,1);
_close = _title->add<sdl_button>("x",pw-30,0,30,30,1);
_view = add<sdl_view>("",0,30,pw-30,ph-30,1);
_view->view.init("",0,0,600,600,1);
_view->view.img_load(ptitle);
_view->scroll(1);
_h = add<sdl_h_scroll>("",pw-30,30,30,ph-30,1);
return 0;
}
int plane::sysevent(SDL_Event*e)
{
switch(e->type)
{
default:
break;
}
return sdl_widget::sysevent(e);
}
int main(int argc, char * argv[])
{
sdl_frame f("sdlgui",100,100,600,600,SDL_WINDOW_SHOWN);
f.add<plane>("bg.jpg",0,0,600,300,1);
f.run();
return 0;
}
2014年05月29日 13点05分
