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?
|
||||
if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default
|
||||
}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),
|
||||
textFont(FONT_BOLD),
|
||||
textSize(10),
|
||||
color(parent->defTextClr) {
|
||||
color(parent->getDefTextClr()) {
|
||||
type = BTN_LED;
|
||||
}
|
||||
|
||||
@@ -246,12 +246,12 @@ void cLed::draw(){
|
||||
to_rect = frame;
|
||||
to_rect.right = to_rect.left + 14;
|
||||
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.left = frame.left + 18; // Possibly could be 20
|
||||
win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_TOP,style);
|
||||
}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;
|
||||
}
|
||||
|
||||
void cControl::redraw() {
|
||||
// If there's no parent dialog, we're not responsible for redrawing
|
||||
if(parent) parent->draw();
|
||||
}
|
||||
|
||||
bool cControl::handleClick(location){
|
||||
sf::Event e;
|
||||
bool done = false, clicked = false;
|
||||
inWindow->setActive();
|
||||
depressed = true;
|
||||
while(!done){
|
||||
// If there's no parent dialog, we're not responsible for redrawing
|
||||
if(parent) parent->draw();
|
||||
redraw();
|
||||
if(!inWindow->pollEvent(e)) continue;
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
done = true;
|
||||
@@ -202,7 +206,7 @@ bool cControl::handleClick(location){
|
||||
sf::sleep(time_in_ticks(6));
|
||||
}
|
||||
else sf::sleep(time_in_ticks(14));
|
||||
if(parent) parent->draw();
|
||||
redraw();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
|
@@ -111,6 +111,7 @@ protected:
|
||||
int frameStyle;
|
||||
cKey key;
|
||||
void drawFrame(short amt, bool med_or_lt);
|
||||
void redraw();
|
||||
private:
|
||||
eControlType type;
|
||||
};
|
||||
|
@@ -1127,6 +1127,10 @@ void cDialog::setBg(short n){
|
||||
bg = n;
|
||||
}
|
||||
|
||||
short cDialog::getBg() {
|
||||
return bg;
|
||||
}
|
||||
|
||||
void cDialog::setDefBtn(std::string defBtn) {
|
||||
defaultButton = defBtn;
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ public:
|
||||
result = val;
|
||||
}
|
||||
void setBg(short n);
|
||||
short getBg();
|
||||
void setDefTextClr(sf::Color clr);
|
||||
void setDefBtn(std::string defBtn);
|
||||
sf::Color getDefTextClr();
|
||||
@@ -84,14 +85,6 @@ private:
|
||||
boost::any result;
|
||||
std::string fname;
|
||||
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 {
|
||||
|
@@ -78,7 +78,7 @@ cTextMsg::cTextMsg(cDialog& parent) :
|
||||
drawFramed(false),
|
||||
textFont(FONT_BOLD),
|
||||
textSize(10),
|
||||
color(parent.defTextClr),
|
||||
color(parent.getDefTextClr()),
|
||||
clickable(false),
|
||||
fromList("none") {}
|
||||
|
||||
|
@@ -522,7 +522,7 @@ void cPict::draw(){
|
||||
|
||||
if(!visible){ // Erase it
|
||||
rect.inset(-3, -3);
|
||||
tileImage(*inWindow,rect,bg_gworld,bg[parent->bg]);
|
||||
tileImage(*inWindow,rect,bg_gworld,bg[parent->getBg()]);
|
||||
return;
|
||||
}
|
||||
if(picNum < 0) { // Just fill with black
|
||||
|
@@ -83,8 +83,7 @@ bool cScrollbar::handleClick(location where) {
|
||||
else pressedPart = PART_DOWN;
|
||||
int dy = where.y - thumbRect.top;
|
||||
while(!done){
|
||||
// If there's no parent dialog, we're not responsible for redrawing
|
||||
if(parent) parent->draw();
|
||||
redraw();
|
||||
if(!inWindow->pollEvent(e)) continue;
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
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.height() = 16;
|
||||
}
|
||||
if(parent) parent->draw();
|
||||
redraw();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user