Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsinputcontrol.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #include "mmsgui/additional/mmsinputcontrol.h"
00034 #include "mmsinfo/mmsinfo.h"
00035 
00036 #define INPUTCONTROL_TEXTWIN    "inputcontrol_textwin"
00037 #define INPUTCONTROL_TEXT       "inputcontrol_text"
00038 #define INPUTCONTROL_SPRITE     "inputcontrol_sprite"
00039 #define INPUTCONTROL_STEXT      "inputcontrol_stext"
00040 
00041 MMSInputControl::MMSInputControl(MMSWindow *window) {
00042 }
00043 
00044 MMSInputControl::~MMSInputControl() {
00045 }
00046 
00047 bool MMSInputControl::load(MMSWindow *parent, string dialogfile, MMSTheme *theme) {
00048     if (!MMSGUIControl::load(parent, dialogfile, theme)) {
00049         // base class has failed to load...
00050         if (parent) {
00051             // load the default dialog file which includes a child window
00052             // do this only if a parent window is given!!!
00053             this->window = this->dm->loadChildDialog((string)getPrefix() + "/share/disko/mmsgui/mmsinputcontrol.xml", theme);
00054         }
00055     }
00056 
00057     if (!this->window)
00058         return false;
00059 
00060     // get access to the widgets
00061     this->inputcontrol_textwin  = dynamic_cast<MMSWindow*>(this->window->findWindow(INPUTCONTROL_TEXTWIN));
00062     this->inputcontrol_text     = dynamic_cast<MMSInputWidget*>(this->window->findWidget(INPUTCONTROL_TEXT));
00063     this->inputcontrol_sprite   = dynamic_cast<MMSWindow*>(this->window->findWindow(INPUTCONTROL_SPRITE));
00064     this->inputcontrol_stext    = dynamic_cast<MMSLabelWidget*>(this->window->findWidget(INPUTCONTROL_STEXT));
00065 
00066     // check something and/or connect callbacks if widgets does exist
00067     if (this->inputcontrol_text) {
00068         this->inputcontrol_text->onBeforeChange->connect(sigc::mem_fun(this,&MMSInputControl::onBeforeChange));
00069     }
00070 
00071     return true;
00072 }
00073 
00074 bool MMSInputControl::onBeforeChange(MMSWidget *widget, string text, bool add, MMSFBRectangle rect) {
00075     if (add) {
00076         MMSFBRectangle r = this->inputcontrol_textwin->getGeometry();
00077         MMSFBRectangle rs = this->inputcontrol_sprite->getGeometry();
00078         this->inputcontrol_stext->setText(text);
00079         this->inputcontrol_sprite->moveTo(r.x + rect.x - rs.w / 2 + rect.w / 2, r.y + rect.y - rs.h / 2 + rect.h / 2);
00080         this->inputcontrol_sprite->show();
00081     }
00082 //  printf("'%s':%d,%d,%d,%d\n", text.c_str(),rect.x, rect.y, rect.w, rect.h);
00083     return true;
00084 }

Generated by doxygen