Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

textBox.cpp

Go to the documentation of this file.
00001 /* *************************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
00017 ************************************************************************************* */
00018 
00019 #include "3d.h"
00020 #include "MyString.h"
00021 #include "control.h"
00022 #include "input.h"
00023 #include "controlEngine.h"
00024 #include "mylist.h"
00025 #include "text3d.h"
00026 #include "textBox.h"
00027 
00028 extern ControlEngine ce;
00029 
00030 // ********************************************************************************
00031 
00032 TextBox::TextBox()
00033 {
00034         // intitialisation des variables
00035         name="TextBox";
00036         isReadOnly=FALSE;
00037 
00038         // init du text<
00039         text.Setup(ce.fontTexture,ft_texture); 
00040         text.SetAlign(align_center,align_center);
00041         text.material.SetDS(0,0,0);
00042 
00043         // gestion des evenements
00044         onControl.mouse.left.up.connect(this,OnLButtonUp);
00045         onControl.mouse.left.down.connect(this,OnLButtonDown);
00046         onControl.over.in.connect(this,OnOverIn);
00047 }
00048 
00049 TextBox::~TextBox()
00050 {
00051 }
00052 
00053 // ********************************************************************************
00054 
00055 void TextBox::Create(double depth)
00056 {
00057         SetParent();
00058         faceNode = ce.primitive.AddBox(name,id,depth,FALSE); 
00059         faceNode->Elems(FACE_FRONT)->text=&text;
00060         if (isReadOnly) faceNode->Elems(FACE_BACK)->material.SetDS(.75,.75,.75);
00061         else faceNode->Elems(FACE_BACK)->material.SetDS(.5,.5,.5);
00062 }
00063 
00073 void TextBox::operator=(char *newText)
00074 {
00075         text.SetText(newText);
00076 }
00077 
00078 // ********************************************************************************
00079 
00080 void TextBox::SetText(char *newText)
00081 {
00082         text.SetText(newText);
00083 }
00084 
00090 int TextBox::OnLButtonDown(StateMouse *mouse,int face)
00091 {
00092         DebugMouse2("TextBox::OnLButtonDown",mouse,face);
00093         ce.cursor.ApplyTypes(cursorText,cursorArrow);
00094         if (!isReadOnly) SetCursor(mouse->pos.x,mouse->pos.y);
00095         return 0;
00096 }
00097 
00098 int TextBox::OnLButtonUp(StateMouse *mouse,int face)
00099 {
00100         DebugMouse2("TextBox::OnLButtonUp",mouse,face);
00101         ce.cursor.ApplyTypes(cursorArrow,cursorText);
00102         return 0;
00103 }
00104 
00105 int TextBox::OnOverIn(Control *oldControl,int face)
00106 {
00107         Debug2Param("TextBox::OnOverIn(oldCtlr:%s,face:%d",(char *)oldControl->name,face);
00108         ce.cursor.ApplyTypes(cursorArrow,cursorText,cursorNothing,cursorNothing);
00109         return 1;
00110 }
00111 
00113 void TextBox::SetCursor(int column,int line)
00114 {
00115         Debug2Param("TextBox::OnSetCursor(col:%d,line:%d)",column,line);
00116         onTextBox.setCursor(column,line);
00117 }
00118 
00119 void TextBox::ToString(MyString &str)
00120 {
00121         str.AddFormat("name: %s isReadOnly:%d",name,isReadOnly);
00122 }
00123 

Generated on Fri Aug 20 19:19:50 2004 for 3d Controls by doxygen 1.3.6