playeroptionsdialog.cpp from FreePop at Krugle
Show playeroptionsdialog.cpp syntax highlighted
/***************************************************************************
playeroptionsdialog.cpp
-------------------
begin : Tue Nov 30 2004
copyright : (C) 2004 by Brendon Lloyd Higgins
email : bh_doc@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <playeroptionsdialog.h>
#include <client.h>
#include <playerclient.h>
#include <ClanLib/display.h>
PlayerOptionsDialog::PlayerOptionsDialog(const CL_Point& pos,
CL_Component* parent, PlayerClient* p):
CL_Window(CL_Rect(pos, CL_Size(310, 170)), "Player Options",
CL_Window::close_button, parent),
name(CL_Rect(10, 10, 100, 0), p->getName(), get_client_area()),
slotClose(sig_close().connect_virtual(this, &PlayerOptionsDialog::onClose)),
red(CL_Rect(20, 50, 200, 65), 0, 255, true, get_client_area()),
green(CL_Rect(20, 70, 200, 85), 0, 255, true, get_client_area()),
blue(CL_Rect(20, 90, 200, 105), 0, 255, true, get_client_area()),
colourBox(CL_Rect(215, 50, 270, 105), get_client_area()),
player(p) {
red.set_value(127);
green.set_value(0);
blue.set_value(0);
slotsPaintColour.connect(colourBox.sig_paint_children(), this,
&PlayerOptionsDialog::onPaintColour);
slotsPaintColour.connect(red.sig_slider_moved(), this,
&PlayerOptionsDialog::onSliderMoved);
slotsPaintColour.connect(green.sig_slider_moved(), this,
&PlayerOptionsDialog::onSliderMoved);
slotsPaintColour.connect(blue.sig_slider_moved(), this,
&PlayerOptionsDialog::onSliderMoved);
}
PlayerOptionsDialog::~PlayerOptionsDialog() {
}
std::string PlayerOptionsDialog::getName() const {
return name.get_text();
}
unsigned int PlayerOptionsDialog::getColour() const {
return CL_Color(red.get_value(), green.get_value(), blue.get_value()).color;
}
CL_Signal_v0& PlayerOptionsDialog::sigApply() {
return mSigApply;
}
void PlayerOptionsDialog::onClose(CL_SlotParent_v0 &parent_handler) {
sigApply()();
show(false);
}
void PlayerOptionsDialog::onPaintColour() {
CL_Display::fill_rect(colourBox.get_screen_rect(),
CL_Color(red.get_value(), green.get_value(),
blue.get_value()));
}
void PlayerOptionsDialog::onSliderMoved(int v) {
colourBox.paint();
}
See more files for this project here