Some small cleanups.

This commit is contained in:
Mark de Wever 2008-04-30 18:28:09 +00:00
parent 06b32747ae
commit 2c3d8719f2
6 changed files with 20 additions and 34 deletions

View file

@ -783,16 +783,7 @@ void tcanvas::draw(const bool force)
variables_.add("height",variant(h_));
}
// set surface sizes (do nothing now)
#if 0
if(fixme test whether -> can be used otherwise we crash w_ != canvas_->w || h_ != canvas_->h) {
// create new
} else {
// fill current
}
#endif
// instead we overwrite the entire thing for now
// create surface
DBG_G_D << "Canvas: create new empty canvas.\n";
canvas_.assign(SDL_CreateRGBSurface(SDL_SWSURFACE, w_, h_, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000));
@ -837,7 +828,6 @@ void tcanvas::parse_cfg(const config& cfg)
void tcanvas::tshape::put_pixel(ptrdiff_t start, Uint32 colour, unsigned w, unsigned x, unsigned y)
{
// fixme the 4 is true due to Uint32..
*reinterpret_cast<Uint32*>(start + (y * w * 4) + x * 4) = colour;
}

View file

@ -16,8 +16,6 @@
//! This file contains the canvas object which is the part where the widgets
//! draw (tempory) images on.
// FIXME look at SDL_gfx it might have some nice functions that same me work.
#ifndef __GUI_WIDGETS_CANVAS_HPP_INCLUDED__
#define __GUI_WIDGETS_CANVAS_HPP_INCLUDED__

View file

@ -20,6 +20,8 @@
#include "gui/widgets/widget.hpp"
#include "tstring.hpp"
#include <cassert>
namespace gui2 {
//! Base class for all visible items.
@ -62,7 +64,8 @@ public:
const t_string& help_message() const { return help_message_; }
std::vector<tcanvas>& canvas() { return canvas_; }
tcanvas& canvas(const unsigned index) { return canvas_[index]; } // FIXME an assert would be nice
tcanvas& canvas(const unsigned index)
{ assert(index < canvas_.size()); return canvas_[index]; }
//! Inherited from twidget.
void draw(surface& surface);
@ -122,10 +125,10 @@ private:
//! The label associated with a lot of widgets to show a (non editable) text.
t_string label_;
//! When hovering a tooltip with extra information can show up. (FIXME implement)
//! When hovering a tooltip with extra information can show up.
t_string tooltip_;
//! When the user presses help a tooltip with even more info can be shown. (FIXME implement)
//! When the user presses help a tooltip with even more info can be shown.
t_string help_message_;
//! Holds all canvas objects for a control.

View file

@ -18,6 +18,8 @@
#include "gui/widgets/widget.hpp"
#include "gui/widgets/control.hpp"
#include <cassert>
namespace gui2 {
//! Base container class which needs to size children
@ -75,16 +77,22 @@ public:
void set_rows_cols(const unsigned rows, const unsigned cols);
void set_row_grow_factor(const unsigned row, const unsigned factor)
{ row_grow_factor_[row] = factor; set_dirty(); } //FIXME add assert.
{
assert(row < row_grow_factor_.size());
row_grow_factor_[row] = factor;
set_dirty();
}
void set_col_grow_factor(const unsigned col, const unsigned factor)
{ col_grow_factor_[col] = factor; set_dirty(); } //FIXME add assert.
{
assert(col< col_grow_factor_.size());
col_grow_factor_[col] = factor;
set_dirty();
}
void remove_child(const unsigned row, const unsigned col);
void remove_child(const std::string& id, const bool find_all = false);
//FIXME add the option to set the proportional growth for each row and column
//! Inherited from twidget.
tpoint get_minimum_size() const { /*FIXME IMPLEMENT*/ return tpoint(0,0); }
tpoint get_best_size() const;

View file

@ -79,9 +79,6 @@ void ttext_::mouse_left_button_down(tevent_handler& event)
{
DBG_G_E << "Text_box: left mouse button down.\n";
//FIXME place cursor
//set select mode
event.keyboard_capture(this);
event.mouse_capture();
}
@ -355,8 +352,6 @@ void ttext_::handle_key_backspace(SDLMod /*modifier*/, bool& handled)
handled = true;
if(sel_start_){
delete_char(true);
} else {
// FIXME beep
}
}
@ -384,8 +379,5 @@ void ttext_::handle_key_default(bool& handled, SDLKey /*key*/, SDLMod /*modifier
}
}
} // namespace gui2

View file

@ -77,11 +77,7 @@ int twindow::show(const bool restore, void* /*flip_function*/)
{
log_scope2(gui_draw, "Window: show.");
// Sanity
if(status_ != NEW) {
// FIXME throw an exception
}
assert(status_ == NEW);
// We cut a piece of the screen and use that, that way all coordinates
// are relative to the window.
@ -93,7 +89,6 @@ int twindow::show(const bool restore, void* /*flip_function*/)
for(status_ = SHOWING; status_ != REQUEST_CLOSE; ) {
process_events();
// fixme manual destroy
if(status_ == REQUEST_CLOSE) {
break;
}