Tweak button swallowing in slideouts.

Done to avoid casting Button to EObj.
This commit is contained in:
Kim Woelders 2013-06-09 20:11:08 +02:00
parent 4bded497e4
commit 1316cfb15a
3 changed files with 15 additions and 11 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2012 Kim Woelders * Copyright (C) 2004-2013 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -282,7 +282,7 @@ ButtonShow(Button * b)
EoMap(b, 0); EoMap(b, 0);
} }
void EObj *
ButtonSwallowInto(Button * b, EObj * eo) ButtonSwallowInto(Button * b, EObj * eo)
{ {
b->internal = 1; b->internal = 1;
@ -294,6 +294,7 @@ ButtonSwallowInto(Button * b, EObj * eo)
ButtonCalc(b); ButtonCalc(b);
ButtonDraw(b); ButtonDraw(b);
EMapWindow(EoGetWin(b)); EMapWindow(EoGetWin(b));
return EoObj(b);
} }
void void

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2008 Kim Woelders * Copyright (C) 2004-2013 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -44,7 +44,7 @@ void ButtonShow(Button * b);
void ButtonHide(Button * b); void ButtonHide(Button * b);
void ButtonMoveToCoord(Button * b, int x, int y); void ButtonMoveToCoord(Button * b, int x, int y);
void ButtonMoveRelative(Button * b, int dx, int dy); void ButtonMoveRelative(Button * b, int dx, int dy);
void ButtonSwallowInto(Button * b, EObj * eo); EObj *ButtonSwallowInto(Button * b, EObj * eo);
void ButtonSetCallback(Button * b, ButtonCbFunc * func, void ButtonSetCallback(Button * b, ButtonCbFunc * func,
EObj * eo); EObj * eo);
int ButtonDoShowDefault(const Button * b); int ButtonDoShowDefault(const Button * b);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2012 Kim Woelders * Copyright (C) 2004-2013 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -335,17 +335,20 @@ SlideoutButtonCallback(EObj * seo, XEvent * ev, ActionClass * ac)
} }
static void static void
SlideoutAddButton(Slideout * s, Button * b) SlideoutAddButton(Slideout * s, const char *bname)
{ {
EObj *eob = (EObj *) b; Button *b;
if (!s || !b) if (!s)
return;
b = ButtonFind(bname);
if (!b)
return; return;
s->num_objs++; s->num_objs++;
s->objs = EREALLOC(EObj *, s->objs, s->num_objs); s->objs = EREALLOC(EObj *, s->objs, s->num_objs);
s->objs[s->num_objs - 1] = eob; s->objs[s->num_objs - 1] = ButtonSwallowInto(b, EoObj(s));
ButtonSwallowInto(b, EoObj(s));
ButtonSetCallback(b, SlideoutButtonCallback, EoObj(s)); ButtonSetCallback(b, SlideoutButtonCallback, EoObj(s));
SlideoutCalcSize(s); SlideoutCalcSize(s);
} }
@ -429,7 +432,7 @@ SlideoutsConfigLoad(FILE * fs)
slideout = SlideoutCreate(name, (char)atoi(s2)); slideout = SlideoutCreate(name, (char)atoi(s2));
break; break;
case CONFIG_BUTTON: case CONFIG_BUTTON:
SlideoutAddButton(slideout, ButtonFind(s2)); SlideoutAddButton(slideout, s2);
break; break;
default: default:
ConfigParseError("Slideout", s); ConfigParseError("Slideout", s);