Remove the need for all cControl subclasses to be friends of cDialog
(Now only cControl itself is a friend.)
This commit is contained in:
@@ -80,7 +80,7 @@ void cButton::draw(){
|
|||||||
// TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button?
|
// TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button?
|
||||||
if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default
|
if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default
|
||||||
}else{
|
}else{
|
||||||
tileImage(*inWindow,frame,bg_gworld,bg[parent->bg]);
|
tileImage(*inWindow,frame,bg_gworld,bg[parent->getBg()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ cLed::cLed(cDialog* parent) :
|
|||||||
state(led_off),
|
state(led_off),
|
||||||
textFont(FONT_BOLD),
|
textFont(FONT_BOLD),
|
||||||
textSize(10),
|
textSize(10),
|
||||||
color(parent->defTextClr) {
|
color(parent->getDefTextClr()) {
|
||||||
type = BTN_LED;
|
type = BTN_LED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,12 +246,12 @@ void cLed::draw(){
|
|||||||
to_rect = frame;
|
to_rect = frame;
|
||||||
to_rect.right = to_rect.left + 14;
|
to_rect.right = to_rect.left + 14;
|
||||||
rect_draw_some_item(buttons[btnGW[BTN_LED]],from_rect,*inWindow,to_rect);
|
rect_draw_some_item(buttons[btnGW[BTN_LED]],from_rect,*inWindow,to_rect);
|
||||||
style.colour = parent->defTextClr;
|
style.colour = parent->getDefTextClr();
|
||||||
to_rect.right = frame.right;
|
to_rect.right = frame.right;
|
||||||
to_rect.left = frame.left + 18; // Possibly could be 20
|
to_rect.left = frame.left + 18; // Possibly could be 20
|
||||||
win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_TOP,style);
|
win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_TOP,style);
|
||||||
}else{
|
}else{
|
||||||
tileImage(*inWindow,frame,bg_gworld,bg[parent->bg]);
|
tileImage(*inWindow,frame,bg_gworld,bg[parent->getBg()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -178,14 +178,18 @@ void cControl::setActive(bool active) {
|
|||||||
depressed = active;
|
depressed = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cControl::redraw() {
|
||||||
|
// If there's no parent dialog, we're not responsible for redrawing
|
||||||
|
if(parent) parent->draw();
|
||||||
|
}
|
||||||
|
|
||||||
bool cControl::handleClick(location){
|
bool cControl::handleClick(location){
|
||||||
sf::Event e;
|
sf::Event e;
|
||||||
bool done = false, clicked = false;
|
bool done = false, clicked = false;
|
||||||
inWindow->setActive();
|
inWindow->setActive();
|
||||||
depressed = true;
|
depressed = true;
|
||||||
while(!done){
|
while(!done){
|
||||||
// If there's no parent dialog, we're not responsible for redrawing
|
redraw();
|
||||||
if(parent) parent->draw();
|
|
||||||
if(!inWindow->pollEvent(e)) continue;
|
if(!inWindow->pollEvent(e)) continue;
|
||||||
if(e.type == sf::Event::MouseButtonReleased){
|
if(e.type == sf::Event::MouseButtonReleased){
|
||||||
done = true;
|
done = true;
|
||||||
@@ -202,7 +206,7 @@ bool cControl::handleClick(location){
|
|||||||
sf::sleep(time_in_ticks(6));
|
sf::sleep(time_in_ticks(6));
|
||||||
}
|
}
|
||||||
else sf::sleep(time_in_ticks(14));
|
else sf::sleep(time_in_ticks(14));
|
||||||
if(parent) parent->draw();
|
redraw();
|
||||||
return clicked;
|
return clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -111,6 +111,7 @@ protected:
|
|||||||
int frameStyle;
|
int frameStyle;
|
||||||
cKey key;
|
cKey key;
|
||||||
void drawFrame(short amt, bool med_or_lt);
|
void drawFrame(short amt, bool med_or_lt);
|
||||||
|
void redraw();
|
||||||
private:
|
private:
|
||||||
eControlType type;
|
eControlType type;
|
||||||
};
|
};
|
||||||
|
@@ -1127,6 +1127,10 @@ void cDialog::setBg(short n){
|
|||||||
bg = n;
|
bg = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short cDialog::getBg() {
|
||||||
|
return bg;
|
||||||
|
}
|
||||||
|
|
||||||
void cDialog::setDefBtn(std::string defBtn) {
|
void cDialog::setDefBtn(std::string defBtn) {
|
||||||
defaultButton = defBtn;
|
defaultButton = defBtn;
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,7 @@ public:
|
|||||||
result = val;
|
result = val;
|
||||||
}
|
}
|
||||||
void setBg(short n);
|
void setBg(short n);
|
||||||
|
short getBg();
|
||||||
void setDefTextClr(sf::Color clr);
|
void setDefTextClr(sf::Color clr);
|
||||||
void setDefBtn(std::string defBtn);
|
void setDefBtn(std::string defBtn);
|
||||||
sf::Color getDefTextClr();
|
sf::Color getDefTextClr();
|
||||||
@@ -84,14 +85,6 @@ private:
|
|||||||
boost::any result;
|
boost::any result;
|
||||||
std::string fname;
|
std::string fname;
|
||||||
friend class cControl;
|
friend class cControl;
|
||||||
friend class cButton;
|
|
||||||
friend class cLed;
|
|
||||||
friend class cLedGroup;
|
|
||||||
friend class cPict;
|
|
||||||
friend class cTextField;
|
|
||||||
friend class cTextMsg;
|
|
||||||
friend class cScrollbar;
|
|
||||||
friend class _init;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class xBadNode : std::exception {
|
class xBadNode : std::exception {
|
||||||
|
@@ -78,7 +78,7 @@ cTextMsg::cTextMsg(cDialog& parent) :
|
|||||||
drawFramed(false),
|
drawFramed(false),
|
||||||
textFont(FONT_BOLD),
|
textFont(FONT_BOLD),
|
||||||
textSize(10),
|
textSize(10),
|
||||||
color(parent.defTextClr),
|
color(parent.getDefTextClr()),
|
||||||
clickable(false),
|
clickable(false),
|
||||||
fromList("none") {}
|
fromList("none") {}
|
||||||
|
|
||||||
|
@@ -522,7 +522,7 @@ void cPict::draw(){
|
|||||||
|
|
||||||
if(!visible){ // Erase it
|
if(!visible){ // Erase it
|
||||||
rect.inset(-3, -3);
|
rect.inset(-3, -3);
|
||||||
tileImage(*inWindow,rect,bg_gworld,bg[parent->bg]);
|
tileImage(*inWindow,rect,bg_gworld,bg[parent->getBg()]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(picNum < 0) { // Just fill with black
|
if(picNum < 0) { // Just fill with black
|
||||||
|
@@ -83,8 +83,7 @@ bool cScrollbar::handleClick(location where) {
|
|||||||
else pressedPart = PART_DOWN;
|
else pressedPart = PART_DOWN;
|
||||||
int dy = where.y - thumbRect.top;
|
int dy = where.y - thumbRect.top;
|
||||||
while(!done){
|
while(!done){
|
||||||
// If there's no parent dialog, we're not responsible for redrawing
|
redraw();
|
||||||
if(parent) parent->draw();
|
|
||||||
if(!inWindow->pollEvent(e)) continue;
|
if(!inWindow->pollEvent(e)) continue;
|
||||||
if(e.type == sf::Event::MouseButtonReleased){
|
if(e.type == sf::Event::MouseButtonReleased){
|
||||||
done = true;
|
done = true;
|
||||||
@@ -127,7 +126,7 @@ bool cScrollbar::handleClick(location where) {
|
|||||||
thumbRect.top = minmax(sf::Mouse::getPosition(*inWindow).y,frame.bottom - 32,thumbRect.top);
|
thumbRect.top = minmax(sf::Mouse::getPosition(*inWindow).y,frame.bottom - 32,thumbRect.top);
|
||||||
thumbRect.height() = 16;
|
thumbRect.height() = 16;
|
||||||
}
|
}
|
||||||
if(parent) parent->draw();
|
redraw();
|
||||||
return clicked;
|
return clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user