From 19fcd63937ef2129f361ffe16d7e6fa74e4f4512 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 23 Jun 2003 13:32:30 +0000 Subject: moved slit resources from BScreen to Slit --- src/Slit.cc | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 8 deletions(-) diff --git a/src/Slit.cc b/src/Slit.cc index c349230..c91a7b5 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.64 2003/06/22 14:17:17 fluxgen Exp $ +// $Id: Slit.cc,v 1.65 2003/06/23 13:32:30 fluxgen Exp $ #include "Slit.hh" @@ -72,6 +72,83 @@ #include using namespace std; +template<> +void FbTk::Resource::setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Slit::TOPLEFT; + else if (strcasecmp(strval, "CenterLeft")==0) + m_value = Slit::CENTERLEFT; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Slit::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Slit::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Slit::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Slit::TOPRIGHT; + else if (strcasecmp(strval, "CenterRight")==0) + m_value = Slit::CENTERRIGHT; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Slit::BOTTOMRIGHT; + else + setDefaultValue(); +} + +template<> +void FbTk::Resource::setFromString(const char *strval) { + if (strcasecmp(strval, "Vertical") == 0) + m_value = Slit::VERTICAL; + else if (strcasecmp(strval, "Horizontal") == 0) + m_value = Slit::HORIZONTAL; + else + setDefaultValue(); +} + +string FbTk::Resource::getString() { + switch (m_value) { + case Slit::TOPLEFT: + return string("TopLeft"); + break; + case Slit::CENTERLEFT: + return string("CenterLeft"); + break; + case Slit::BOTTOMLEFT: + return string("BottomLeft"); + break; + case Slit::TOPCENTER: + return string("TopCenter"); + break; + case Slit::BOTTOMCENTER: + return string("BottomCenter"); + break; + case Slit::TOPRIGHT: + return string("TopRight"); + break; + case Slit::CENTERRIGHT: + return string("CenterRight"); + break; + case Slit::BOTTOMRIGHT: + return string("BottomRight"); + break; + } + //default string + return string("BottomRight"); +} + +template<> +string FbTk::Resource::getString() { + switch (m_value) { + case Slit::VERTICAL: + return string("Vertical"); + break; + case Slit::HORIZONTAL: + return string("Horizontal"); + break; + } + // default string + return string("Vertical"); +} + namespace { class SlitClientMenuItem: public FbTk::MenuItem { @@ -275,19 +352,26 @@ void Slit::updateStrut() { int left = 0, right = 0, top = 0, bottom = 0; switch (placement()) { case TOPLEFT: - top = height(); - left = width(); + if (direction() == HORIZONTAL) + top = height(); + else + left = width(); break; case TOPCENTER: - top = height(); + if (direction() == HORIZONTAL) + top = height(); break; case TOPRIGHT: - right = width(); - top = height(); + if (direction() == HORIZONTAL) + top = height(); + else + right = width(); break; case BOTTOMLEFT: - bottom = height(); - left = width(); + if (direction() == HORIZONTAL) + bottom = height(); + else + left = width(); break; case BOTTOMCENTER: // would be strange to have it request size on vertical direction -- cgit v0.11.2