1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/*
Simple GUI & Network demo application,
Copyright (c) 2000 by Magnus Norddahl and Kenneth Gangstoe.
*/
#include "userlist_component.h"
#include "document.h"
#include <ClanLib/display.h>
#include <ClanLib/gui.h>
/////////////////////////////////////////////////////////////////////////////
// Construction:
UserListComponent::UserListComponent(CL_Component *_parent)
: CL_Frame(CL_Rect(0,0,0,0), _parent), parent(_parent)
{
list = new CL_ListBox(CL_Rect(0,0,100,100), this);
// Connect events to signals:
slots.connect(sig_paint(), this, &UserListComponent::on_paint);
slots.connect(sig_resize(), this, &UserListComponent::on_resize);
// slots.connect(parent->get_document()->sig_user_added, this, &UserListComponent::on_user_added);
// slots.connect(parent->get_document()->sig_user_removed, this, &UserListComponent::on_user_removed);
// Document is not done yet, so add some dummy data instead:
on_user_added("Sphair");
on_user_added("Mbn");
}
UserListComponent::~UserListComponent()
{
}
/////////////////////////////////////////////////////////////////////////////
// Attributes:
/////////////////////////////////////////////////////////////////////////////
// Operations:
/////////////////////////////////////////////////////////////////////////////
// Events:
void UserListComponent::on_paint()
{
CL_Display::fill_rect(0, 0, get_width(), get_height(), 0.46f, 0.82f, 0.65f);
}
void UserListComponent::on_resize(int old_width, int old_height)
{
list->set_size(get_width(), get_height());
}
void UserListComponent::on_user_added(const std::string &user)
{
list->insert_item(user);
}
void UserListComponent::on_user_removed(const std::string &user)
{
}
|