Beispiel #1
0
void Game::welcome_screen()
{
    screen.clear( sdl::Color( 0 , 0 , 0 ) );

    std::string welcome_text = "Welcome to The Pong";
    sdl::Point  text_pos( SCREEN_WIDTH / 2 - text.size( welcome_text.c_str() ).getx() / 2 , SCREEN_HEIGHT / 2 - 48 );

    text.blended( text_pos , welcome_text.c_str() , screen );

    welcome_text = "Press any key to continue";
    text_pos.y += 32;
    text_pos.x = ( SCREEN_WIDTH - text.size( welcome_text.c_str() ).getx() ) / 2;

    SDL_Delay( 500 );
    text.blended( text_pos , welcome_text.c_str() , screen );

    screen.flip();

    while( true )
    {
        event.wait();
        if( event.type() == SDL_KEYDOWN || event.type() == SDL_MOUSEBUTTONDOWN )
            break;

        if( event.type() == SDL_QUIT )
            throw "";
    }
}
void WTextSourceViewerLine::drawFoldingLineHidden(QPainter &p,const QPointF &pt)
{
  float demi_char_space=char_space/2.0f;
  QPointF pos(0,pt.y()-demi_char_space);
  QRectF  text_pos(pos,QSizeF(char_space,char_space));

  QPointF p3(pt.x(),pt.y());
  QPointF p1c(char_space,pt.y());
  QBrush b=p.brush();
  p.setBrush(Qt::black);
  QRectF endPoint3(p3.x()-2,p3.y()-2,4,4);

  p.drawEllipse(endPoint3);
  p.setBrush(b);
  p.drawLine(p1c,p3);
  float pos_size=char_space;
  QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
  p.drawRoundRect(rectangle);
  float _x1=pos.x()+3.0f;
  float _y=pos.y()+pos_size/2.0f;
  float _x2=pos.x()+pos_size-3.0f;
  float _x=pos.x()+pos_size/2;
  float _y1=pos.y()+3;
  float _y2=pos.y()+pos_size-3;
  p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
  p.drawLine(QPointF(_x,_y1),QPointF(_x,_y2));
}
Beispiel #3
0
void drawLabelInfo(cv::Mat3b& canvas,
    const std::vector<cv::Point2f>& points,
    const std::vector<std::string>& texts,
    const cv::Scalar color,
    double font_scale)
{
    for (size_t i = 0; i < points.size(); ++i)
    {
        cv::Size text_size = cv::getTextSize(texts[i], cv::FONT_HERSHEY_SIMPLEX, font_scale, 1, NULL);
        cv::Point text_pos(points[i].x - text_size.width / 2, points[i].y + text_size.height / 2);
        cv::putText(canvas, texts[i], text_pos, cv::FONT_HERSHEY_SIMPLEX, font_scale, color);
    }
}
Beispiel #4
0
void Game::end_screen()
{
    screen.clear( sdl::Color( 0 , 0 , 0 ) );

    std::string end_message1;
    std::string end_message2;

    if( player_score == MAX_SCORE )
    {
        end_message1 = "Congratulations!";
        end_message2 = "You win!";
    }

    else if( ai_score == MAX_SCORE )
    {
        end_message1 = "Too bad.";
        end_message2 = "You lose.";
    }

    sdl::Point  text_pos( ( SCREEN_WIDTH - text.size( end_message1.c_str() ).getx() ) / 2 , SCREEN_HEIGHT / 2 - 48 );

    text.blended( text_pos , end_message1.c_str() , screen );

    text_pos.x = ( SCREEN_WIDTH - text.size( end_message2.c_str() ).getx() ) / 2;
    text_pos.y += 32;

    text.blended( text_pos , end_message2.c_str() , screen );

    screen.flip();

    while( true )
    {
        event.wait();

        if( event.type() == SDL_QUIT )
            return;

        else if( event.type() == SDL_KEYDOWN )
            if( event.key() == SDLK_ESCAPE )
                return;
    }

}
void WTextSourceViewerLine::drawFoldingLineVisible(QPainter &p,const QPointF &p1,const QPointF &p2)
{
  QPolygonF area;
  float demi_char_space=char_space/2.0f;
  QPointF pos(0.0f,(p1.y()+p2.y())/2.0f-demi_char_space);
  QRectF  text_pos(pos,QSizeF(char_space,char_space));

  QPointF p3(demi_char_space,p2.y());
  QRectF endPoint2(p2.x()-2,p2.y()-2,4,4);
  QBrush b=p.brush();
  p.setBrush(Qt::black);
  if (p1!=p2)
  {
    QPointF p0(demi_char_space,p1.y());
    QPointF p1b(demi_char_space,pos.y());
    QPointF p2b(demi_char_space,pos.y()+char_space);
    QRectF endPoint1(p1.x()-2,p1.y()-2,4,4);
    area << p0 << p1 ;
    area << p0 << p1b ;
    area << p2b << p3 ;
    area << p3 << p2 ;
    p.drawEllipse(endPoint1);
  }
  else
  {
    QPointF p1c(char_space,p2.y());
    area << p1c << p2 ;
  }

  p.drawEllipse(endPoint2);
  p.setBrush(b);
  p.drawLines(area);
  float pos_size=char_space;
  QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
  p.drawRoundRect(rectangle);
  float _x1=pos.x()+3.0f;
  float _y=pos.y()+pos_size/2.0f;
  float _x2=pos.x()+pos_size-3.0f;
  p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
}
Beispiel #6
0
void GameChat::draw_player_chat(GameState* gs) const {
	perf_timer_begin(FUNCNAME);
	const ldraw::Font& font = gs->font();
	const int padding = 5;
	int line_sep = font.height() + 2;

	Size vsize(gs->view().size());
	Size chat_size(vsize.w, 100);
	Pos chat_pos(0, 0);
	Pos text_pos(chat_pos.x + padding, chat_pos.y + padding);

	ldraw::draw_rectangle(COL_CONSOLE_BOX.alpha(50 * fade_out),
			BBox(chat_pos, chat_size));

	bool draw_typed_message = is_typing || !typing_field.empty();

	int start_msg = 0;
	int message_space = chat_size.h - padding * 2
			- (draw_typed_message ? line_sep : 0);
	int msgs_in_screen = message_space / line_sep;
	if (messages.size() > msgs_in_screen) {
		start_msg = messages.size() - msgs_in_screen;
	}

	for (int i = start_msg; i < messages.size(); i++) {
		messages[i].draw(font, fade_out, text_pos);
		text_pos.y += line_sep;
	}

	if (draw_typed_message) {
		int type_y = chat_pos.y + chat_size.h - padding - line_sep;

		ldraw::draw_line(Colour(200, 200, 200, fade_out * 180),
				Pos(chat_pos.x, type_y), Pos(chat_pos.x + chat_size.w, type_y));
		ChatMessage typed_message = get_field_as_chat_message(gs, false);
		typed_message.draw(font, fade_out,
				Pos(text_pos.x, type_y + padding - 1));
	}
	perf_timer_end(FUNCNAME);
}
Beispiel #7
0
void generate_video_comparer(const cv::Mat1b & query,
                             bool crop_img_before,
                             int gallerycols,
                             const std::string out_prefix = "comparer_") {
  // init iterators
  static const unsigned int nimpls = 3;
  std::string impls[] = {IMPL_MORPH, IMPL_ZHANG_SUEN_FAST, IMPL_GUO_HALL_FAST};
  cv::Mat3b curr, curr_resized;
  VoronoiIterator its[nimpls];
  for (unsigned int impl_idx = 0; impl_idx < nimpls; ++impl_idx)
    its[impl_idx].init(query, impls[impl_idx], crop_img_before);
  cv::Mat3b first_img_color;
  // first_img_color = its[0].contour_color(its[0].first_img());
  cv::cvtColor(its[0].first_img(), first_img_color, CV_GRAY2BGR);
  int /*cols1 = first_img_color.cols, */ rows1 = first_img_color.rows;
  //cv::Point text_pos(cols1 / 2, rows1 - 10);
  // image_utils::draw_text_centered
  cv::Point text_pos(10, rows1 - 10);
  cv::putText(first_img_color, "query",
              text_pos, CV_FONT_HERSHEY_PLAIN, 1, CV_RGB(0, 255, 0));

  // video writer
  // for a weird reason, odd width and height result in an empty video
  cv::Size output_size
      (gallerycols * 2 * its[0].cols(), ceil(4 / gallerycols) * 2 * its[0].rows());
  unsigned int fps = 5;
  std::ostringstream out_filename;
  out_filename << out_prefix << ".avi";
  cv::VideoWriter writer(out_filename.str(), codec, fps, output_size, true); // color
  assert(writer.isOpened());
  unsigned int n_terminated = 0, iters = 0;
  while(n_terminated < nimpls) {
    ++iters;
    // iterate all implementations
    n_terminated = 0;
    std::vector<cv::Mat3b> curr_imgs;
    curr_imgs.push_back(first_img_color);
    for (unsigned int impl_idx = 0; impl_idx < nimpls; ++impl_idx) {
      if (its[impl_idx].has_converged())
        ++n_terminated;
      else
        its[impl_idx].iter();
      cv::Mat3b curr_img_color = its[impl_idx].contour_color(its[impl_idx].current_skel());
      cv::dilate(curr_img_color, curr_img_color, cv::Mat());
      //image_utils::draw_text_centered
      cv::putText
          (curr_img_color, impls[impl_idx],
           text_pos, CV_FONT_HERSHEY_PLAIN, 1, CV_RGB(0, 255, 0));
      curr_imgs.push_back(curr_img_color);
    } // end for impl_idx
    // now make collage
    paste_images_gallery(curr_imgs, curr, gallerycols, cv::Vec3b(0, 0, 0), true, CV_RGB(255, 255, 255));
    cv::resize(curr, curr_resized, output_size, CV_INTER_NN);
    writer << curr_resized;
    cv::imshow("curr", curr); cv::waitKey(10);
    // http://denislantsman.com/?p=111 - save as png too
    // convert: ffmpeg -i out_%d.png -vcodec png out.avi
    // http://stackoverflow.com/questions/4839303/convert-image-sequence-to-lossless-movie
    std::ostringstream name; name << "comparer_" << std::setprecision(3) << std::setfill('0') << iters << ".png";
    cv::imwrite(name.str(), curr);
  } // end while1
  // add the last image for twp second
  for (unsigned int i = 0; i < 2 * fps; ++i) {
    writer << curr_resized;
    std::ostringstream name; name << "comparer_" << std::setprecision(3) << std::setfill('0') << ++iters << ".png";
    cv::imwrite(name.str(), curr);
  } // end loop i

  std::ostringstream out_filename_lossless;
  out_filename_lossless << out_prefix << "_lossless.avi";
  std::ostringstream command;
  command << "ffmpeg -r " << fps << " -y -i comparer_%d.png "
          << " -vcodec png "
             //<< " -vcodec huffyuv "
             // << " -vcodec mjpeg "
          << out_filename_lossless.str() << "; rm comparer_*.png";
  system(command.str().c_str());

  printf("generated '%s' and '%s' (%i frames, %ix%i)\n",
         out_filename.str().c_str(), out_filename_lossless.str().c_str(),
         iters, output_size.width, output_size.height);
} // end generate_video_comparer();
Beispiel #8
0
void
label::gl_render( const view& scene)
{
	if (text_changed) {
		boost::shared_ptr<font> texmap_font =
			font::find_font( font_description, int(font_size));
		if (text.empty())
			text_layout = texmap_font->lay_out( L" " );
		else
			text_layout = texmap_font->lay_out( text);
		text_changed = false;
	}
	// Compute the width of the text box.
	vector extents = text_layout->extent( scene );
	double box_width = extents.x + 2.0*border;

	// Compute the positions of the text in the text box, and the height of the
	// text box.  The text positions are relative to the lower left corner of
	// the text box.
	double box_height = extents.y + 2.0*border;

	vector text_pos( border, box_height - border);

	clear_gl_error();
	vector label_pos = pos.scale(scene.gcfvec);
	tmatrix lst = tmatrix().gl_projection_get() * tmatrix().gl_modelview_get();
	{
		tmatrix translate;
		translate.w_column( label_pos);
		lst = lst * translate;
	}
	vector origin = (lst * vertex(vector(), 1.0)).project();

	// It is very important to make sure that the texture is positioned
	// accurately at a screen pixel location, to avoid artifacts around the texture.
	double kx = scene.view_width/2.0;
	double ky = scene.view_height/2.0;
	if (origin.x >= 0) {
		origin.x = ((int)(kx*origin.x+0.5))/kx;
	} else {
		origin.x = -((int)(-kx*origin.x+0.5))/kx;
	}
	if (origin.y >= 0) {
		origin.y = ((int)(ky*origin.y+0.5))/ky;
	} else {
		origin.y = -((int)(-ky*origin.y+0.5))/ky;
	}
	double halfwidth = (int)(0.5*box_width+0.5);
	double halfheight = (int)(0.5*box_height+0.5);

	rgb stereo_linecolor = linecolor;
	if (scene.anaglyph)
		if (scene.coloranaglyph)
			stereo_linecolor = linecolor.desaturate();
		else
			stereo_linecolor = linecolor.grayscale();

	displaylist list;
	list.gl_compile_begin();
	{
		stereo_linecolor.gl_set(1.0f);
		// Zero out the existing matrices, rendering will be in screen coords.
		gl_matrix_stackguard guard;
		tmatrix identity;
		identity.gl_load();
		glMatrixMode( GL_PROJECTION); { //< Zero out the projection matrix, too
		gl_matrix_stackguard guard2;
		identity.gl_load();

		glTranslated( origin.x, origin.y, origin.z);
		glScaled( 1.0/kx, 1.0/ky, 1.0);
		// At this point, all further translations are in direction of label space.
		if (space && (xoffset || yoffset)) {
			// Move the origin away from the body.
			vector space_offset = vector(xoffset, yoffset).norm() * std::fabs(space);
			glTranslated( space_offset.x, space_offset.y, space_offset.z);
		}
		// Optionally draw the line, and move the origin to the bottom left
		// corner of the text box.
		if (xoffset || yoffset) {
			if (line_enabled) {
				glBegin( GL_LINES);
					vector().gl_render();
					vector(xoffset, yoffset).gl_render();
				glEnd();
			}
			if (std::fabs(xoffset) > std::fabs(yoffset)) {
				glTranslated(
					xoffset + ((xoffset > 0) ? 0 : -2.0*halfwidth),
					yoffset - halfheight,
					0);
			}
			else {
				glTranslated(
					xoffset - halfwidth,
					yoffset + ((yoffset > 0) ? 0 : -2.0*halfheight),
					0);
			}
		}
		else {
			glTranslated( -halfwidth, -halfheight, 0.0);
		}

		if (opacity) {
			// Occlude objects behind the label.
			rgba( background[0], background[1], background[2], opacity).gl_set();
			glBegin( GL_QUADS);
				vector().gl_render();
				vector( 2.0*halfwidth, 0).gl_render();
				vector( 2.0*halfwidth, 2.0*halfheight).gl_render();
				vector( 0, 2.0*halfheight).gl_render();
			glEnd();
		}
		if (box_enabled) {
			// Draw a box around the text.
			stereo_linecolor.gl_set(1.0f);
			glBegin( GL_LINE_LOOP);
				vector().gl_render();
				vector( 2.0*halfwidth, 0).gl_render();
				vector( 2.0*halfwidth, 2.0*halfheight).gl_render();
				vector( 0, 2.0*halfheight).gl_render();
			glEnd();
		}

		// Render the text itself.
		color.gl_set(1.0f);
		text_layout->gl_render(scene, text_pos);
	} glMatrixMode( GL_MODELVIEW); } // Pops the matrices back off the stack
	list.gl_compile_end();
	check_gl_error();
	scene.screen_objects.insert( std::make_pair(pos, list));
}
Beispiel #9
0
void TabContainer::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_DRAW: {

			RID canvas = get_canvas_item();
			Size2 size = get_size();

			// Draw only the tab area if the header is hidden.
			Ref<StyleBox> panel = get_stylebox("panel");
			if (!tabs_visible) {
				panel->draw(canvas, Rect2(0, 0, size.width, size.height));
				return;
			}

			Vector<Control *> tabs = _get_tabs();
			Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
			Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
			Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
			Ref<Texture> increment = get_icon("increment");
			Ref<Texture> decrement = get_icon("decrement");
			Ref<Texture> menu = get_icon("menu");
			Ref<Texture> menu_hl = get_icon("menu_hl");
			Ref<Font> font = get_font("font");
			Color font_color_fg = get_color("font_color_fg");
			Color font_color_bg = get_color("font_color_bg");
			Color font_color_disabled = get_color("font_color_disabled");
			int side_margin = get_constant("side_margin");
			int icon_text_distance = get_constant("hseparation");

			// Find out start and width of the header area.
			int header_x = side_margin;
			int header_width = size.width - side_margin * 2;
			int header_height = _get_top_margin();
			if (popup)
				header_width -= menu->get_width();

			// Check if all tabs would fit into the header area.
			int all_tabs_width = 0;
			for (int i = 0; i < tabs.size(); i++) {
				int tab_width = _get_tab_width(i);
				all_tabs_width += tab_width;

				if (all_tabs_width > header_width) {
					// Not all tabs are visible at the same time - reserve space for navigation buttons.
					buttons_visible_cache = true;
					header_width -= decrement->get_width() + increment->get_width();
					break;
				} else {
					buttons_visible_cache = false;
				}
			}
			// With buttons, a right side margin does not need to be respected.
			if (popup || buttons_visible_cache) {
				header_width += side_margin;
			}

			// Go through the visible tabs to find the width they occupy.
			all_tabs_width = 0;
			Vector<int> tab_widths;
			for (int i = first_tab_cache; i < tabs.size(); i++) {
				int tab_width = _get_tab_width(i);
				if (all_tabs_width + tab_width > header_width && tab_widths.size() > 0)
					break;
				all_tabs_width += tab_width;
				tab_widths.push_back(tab_width);
			}

			// Find the offset at which to draw tabs, according to the alignment.
			switch (align) {
				case ALIGN_LEFT:
					tabs_ofs_cache = header_x;
					break;
				case ALIGN_CENTER:
					tabs_ofs_cache = header_x + (header_width / 2) - (all_tabs_width / 2);
					break;
				case ALIGN_RIGHT:
					tabs_ofs_cache = header_x + header_width - all_tabs_width;
					break;
			}

			// Draw all visible tabs.
			int x = 0;
			for (int i = 0; i < tab_widths.size(); i++) {
				Ref<StyleBox> tab_style;
				Color font_color;
				if (get_tab_disabled(i + first_tab_cache)) {
					tab_style = tab_disabled;
					font_color = font_color_disabled;
				} else if (i + first_tab_cache == current) {
					tab_style = tab_fg;
					font_color = font_color_fg;
				} else {
					tab_style = tab_bg;
					font_color = font_color_bg;
				}

				// Draw the tab background.
				int tab_width = tab_widths[i];
				Rect2 tab_rect(tabs_ofs_cache + x, 0, tab_width, header_height);
				tab_style->draw(canvas, tab_rect);

				// Draw the tab contents.
				Control *control = tabs[i + first_tab_cache]->cast_to<Control>();
				String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());

				int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT);
				int top_margin = tab_style->get_margin(MARGIN_TOP);
				int y_center = top_margin + (tab_rect.size.y - tab_style->get_minimum_size().y) / 2;

				// Draw the tab icon.
				if (control->has_meta("_tab_icon")) {
					Ref<Texture> icon = control->get_meta("_tab_icon");
					if (icon.is_valid()) {
						int y = y_center - (icon->get_height() / 2);
						icon->draw(canvas, Point2i(x_content, y));
						if (text != "")
							x_content += icon->get_width() + icon_text_distance;
					}
				}

				// Draw the tab text.
				Point2i text_pos(x_content, y_center - (font->get_height() / 2) + font->get_ascent());
				font->draw(canvas, text_pos, text, font_color);

				x += tab_width;
				last_tab_cache = i + first_tab_cache;
			}

			// Draw the popup menu.
			x = get_size().width;
			if (popup) {
				x -= menu->get_width();
				if (mouse_x_cache > x)
					menu_hl->draw(get_canvas_item(), Size2(x, 0));
				else
					menu->draw(get_canvas_item(), Size2(x, 0));
			}

			// Draw the navigation buttons.
			if (buttons_visible_cache) {
				int y_center = header_height / 2;

				x -= increment->get_width();
				increment->draw(canvas,
						Point2(x, y_center - (increment->get_height() / 2)),
						Color(1, 1, 1, last_tab_cache < tabs.size() - 1 ? 1.0 : 0.5));

				x -= decrement->get_width();
				decrement->draw(canvas,
						Point2(x, y_center - (decrement->get_height() / 2)),
						Color(1, 1, 1, first_tab_cache > 0 ? 1.0 : 0.5));
			}

			// Draw the tab area.
			panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height));
		} break;
		case NOTIFICATION_THEME_CHANGED: {
			if (get_tab_count() > 0) {
				call_deferred("set_current_tab", get_current_tab()); //wait until all changed theme
			}
		} break;
	}
}
Beispiel #10
0
//=================================================================================================
void GamePanel::UpdateBoxIndex(float dt, int index)
{
	if(index != INDEX_INVALID)
	{
		if(index != last_index)
		{
			box_state = BOX_COUNTING;
			last_index = index;
			show_timer = 0.3f;
		}
		else
			show_timer -= dt;

		if(box_state == BOX_COUNTING)
		{
			if(show_timer <= 0.f)
			{
				box_state = BOX_VISIBLE;
				box_alpha = 0.f;

				FormatBox();

				if(box_img)
				{
					D3DSURFACE_DESC desc;
					box_img->GetLevelDesc(0, &desc);
					box_img_size = INT2(desc.Width, desc.Height);
				}
			}
		}
		else
		{
			box_alpha += dt*5;
			if(box_alpha >= 1.f)
				box_alpha = 1.f;
		}
	}
	else
	{
		box_state = BOX_NOT_VISIBLE;
		last_index = INDEX_INVALID;
	}

	if(box_state == BOX_VISIBLE)
	{
		INT2 text_size = GUI.default_font->CalculateSize(box_text);
		box_big.left = 0;
		box_big.right = text_size.x;
		box_big.top = 0;
		box_big.bottom = text_size.y;
		INT2 size = text_size + INT2(24,24);
		INT2 pos2 = INT2(GUI.cursor_pos) + INT2(24,24);
		INT2 text_pos(12,12);

		// uwzglêdnij rozmiar obrazka
		if(box_img)
		{
			text_pos.x += box_img_size.x+8;
			size.x += box_img_size.x+8;
			if(size.y < box_img_size.y+24)
				size.y = box_img_size.y+24;
		}

		// minimalna szerokoϾ
		if(size.x < 256)
			size.x = 256;

		INT2 text_pos2(12, text_pos.y);
		text_pos2.y += size.y - 12;
		int size_y = 0;

		if(!box_text_small.empty())
		{
			INT2 size_small = GUI.fSmall->CalculateSize(box_text_small, size.x-24);
			box_small.left = 0;
			box_small.right = size_small.x;
			box_small.top = 0;
			box_small.bottom = size_small.y;
			size_y = size_small.y;
			size.y += size_y + 12;
		}

		if(pos2.x + size.x >= GUI.wnd_size.x)
			pos2.x = GUI.wnd_size.x - size.x - 1;
		if(pos2.y + size.y >= GUI.wnd_size.y)
			pos2.y = GUI.wnd_size.y - size.y - 1;

		box_img_pos = INT2(pos2.x+12, pos2.y+12);
		box_big.left = text_pos.x + pos2.x;
		box_big.right = box_big.left + text_size.x;
		box_big.top = text_pos.y + pos2.y;
		box_big.bottom = box_big.top + text_size.y;

		box_small.left += pos2.x + text_pos2.x;
		box_small.right += pos2.x + text_pos2.x;
		box_small.top += pos2.y + text_pos2.y;
		box_small.bottom += pos2.y + text_pos2.y;
		box_small.right = box_small.left + box_size.x-24;

		box_size = size;
		box_pos = pos2;
	}
}
Beispiel #11
0
void CCheckBox::Draw() 
{
	////////// Gee: janwas, this is just temp to see it
	glDisable(GL_TEXTURE_2D);
	//////////

	float square_side, buffer_zone;
	CStrW font_name;
	bool checked;
	int cell_id;
	GUI<float>::GetSetting(this, "square_side", square_side);
	GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
	GUI<CStrW>::GetSetting(this, "font", font_name);
	GUI<bool>::GetSetting(this, "checked", checked);
	GUI<int>::GetSetting(this, "cell_id", cell_id);

	// Get line height
	CFont font (font_name);
	float line_height = (float)font.GetHeight();

	float bz = GetBufferedZ();

	// Get square
	CRect rect;

	rect.left =		m_CachedActualSize.left;
	rect.right =	rect.left + square_side;

	if (square_side >= line_height)
		rect.top =	m_CachedActualSize.top;
	else
		rect.top =	m_CachedActualSize.top + line_height/2.f - square_side/2.f;

	rect.bottom =	rect.top + square_side;

	CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled;

	if (checked)
	{
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2", sprite);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite_over);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite_pressed);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite_disabled);
	}
	else
	{
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_over", sprite_over);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_pressed", sprite_pressed);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_disabled", sprite_disabled);
	}

	DrawButton(rect, 
			   bz,
			   *sprite,
			   *sprite_over,
			   *sprite_pressed,
			   *sprite_disabled,
			   cell_id);

	CColor color = ChooseColor();

	CPos text_pos(m_CachedActualSize.left + square_side + buffer_zone, m_CachedActualSize.top);

	if (square_side > line_height)
		text_pos.y += square_side/2.f - line_height/2.f;

	IGUITextOwner::Draw(0, color, text_pos, bz+0.1f, m_CachedActualSize);
}