Ejemplo n.º 1
0
void OguiButton::ApplyImages()
{
	IStorm3D_Material *mat = NULL;
	IStorm3D_Material *matdown = NULL;
	IStorm3D_Material *matdisabled = NULL;
	IStorm3D_Material *mathighlighted = NULL;
	if (image != NULL) mat = ((OguiStormImage *)image)->mat;
	if (imageDown != NULL) matdown = ((OguiStormImage *)imageDown)->mat;
	if (imageDisabled != NULL) matdisabled = ((OguiStormImage *)imageDisabled)->mat;
	if (imageHighlighted != NULL) mathighlighted = ((OguiStormImage *)imageHighlighted)->mat;
	og_set_pic_button((orvgui_but *)but, mat, matdown, matdisabled, mathighlighted);
}
Ejemplo n.º 2
0
OguiButton *OguiWindow::CreateNewButton(int x, int y, int sizex, int sizey, 
	IOguiImage *img, IOguiImage *imgdown, IOguiImage *imghigh, IOguiImage *imgdisabled, bool withText, 
	const char *text, int id, const void *argument, IOguiFont *font, bool clipToWindow )
{
	orvgui_but *but;

	// NOTICE: the orvgui button is created here, but deleted in 
	// the OguiButton class destructor

	if (withText)
	{
		IStorm3D_Font *fnt = NULL;
		COL fnt_color;
		if (font != NULL)
		{
			fnt = ((OguiStormFont *)font)->fnt;
			fnt_color = ((OguiStormFont *)font)->color;
		}

		int pixwidth = 0;
		int pixheight = 0;
		int fontwidth = 0;
		int fontheight = 0;
		if (font != NULL && text != NULL)
		{
			pixwidth = font->getStringWidth(text);
			pixheight = font->getStringHeight(text);
			fontwidth = font->getWidth();
			fontheight = font->getHeight();
		}

		but = og_create_button((orvgui_win *)win, OG_BUT_PIC_AND_TEXT, x, y, sizex, sizey, clipToWindow);
		og_set_text_button(but, fnt, fnt_color, OG_H_ALIGN_CENTER, OG_V_ALIGN_MIDDLE, text, pixwidth, pixheight, fontwidth, fontheight);
	} else {
		but = og_create_button((orvgui_win *)win, OG_BUT_PIC, x, y, sizex, sizey, clipToWindow);
	}

	IStorm3D_Material *mat = NULL;
	IStorm3D_Material *matdown = NULL;
	IStorm3D_Material *mathigh = NULL;
	IStorm3D_Material *matdisabled = NULL;
	if (img != NULL) mat = ((OguiStormImage *)img)->mat;
	if (imgdown != NULL) matdown = ((OguiStormImage *)imgdown)->mat;
	if (imghigh != NULL) mathigh = ((OguiStormImage *)imghigh)->mat;
	if (imgdisabled != NULL) matdisabled = ((OguiStormImage *)imgdisabled)->mat;
	og_set_pic_button(but, mat, matdown, matdisabled, mathigh);

	OguiButton *ob = new OguiButton(ogui, id, argument);
	ob->but = but;
	ob->parent = this;
	ob->image = img;
	ob->imageDown = imgdown;
	ob->imageDisabled = NULL;
	ob->imageHighlighted = imghigh;
	ob->imageAutodel = false;
	ob->imageDownAutodel = false;
	ob->imageDisabledAutodel = false;
	ob->imageHighlightedAutodel = false;
	ob->font = font;

	og_set_click_button(but, ogui_button_click_handler, ob);
	og_set_press_button(but, ogui_button_press_handler, ob);
	og_set_out_button(but, ogui_button_out_handler, ob);
	og_set_over_button(but, ogui_button_over_handler, ob);
	og_set_leave_button(but, ogui_button_leave_handler, ob);
	og_set_hold_button(but, ogui_button_hold_handler, ob);

	buttonList->append(ob);

	return ob;
}