Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

control_gui_float.C

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= control_gui_float.C                                     Octubre de 2000 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definicion del Widget abstracto AQUYNZA para control de escalares       =
00005 //=-------------------------------------------------------------------------=
00006 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO   =
00007 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN   =
00008 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES,     = 
00009 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO,        =
00010 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO,  =
00011 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA   =
00012 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES       =
00013 //= ("ACTIVIDADES DE ALGO RIESGO").                                         =
00014 //=-------------------------------------------------------------------------=
00015 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00016 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00017 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00018 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00019 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
00020 //===========================================================================
00021 
00022 #include "framework/gui/control_gui.h"
00023 #include <stdio.h>
00024 #include <string.h>
00025 #include <stdlib.h>
00026 
00027 #ifdef MOTIF_ENABLED
00028     #include <Xm/PushB.h>
00029     #include <Xm/Form.h>
00030     #include <Xm/Label.h>
00031     #include <Xm/ScrollBar.h>
00032     #include <Xm/TextF.h>
00033 #endif
00034 
00035 #include "lista.cc"
00036 #include "arreglo.cc"
00037 
00038 //===========================================================================
00039 //= Contantes y macros                                                      =
00040 //===========================================================================
00041 
00042 #define ESPERO_F(tipo, msg) \
00043     if ( tipo_token != (tipo) ) { \
00044         fprintf(stderr, "<CONTROL_GUI_FLOAT> " \
00045                 "ERROR: Esperaba %s y recibi [%s].\n", \
00046           (msg), cad); fflush(stderr);  return FALSE; \
00047     }
00048 
00049 #define VERIFICAR_F(c) \
00050     if ( !(c) ) {\
00051         fprintf(stderr, \
00052             "<CONTROL_GUI_FLOAT> ERROR: No se pudo crear un objeto " \
00053                 "dinamico!\n");\
00054         fflush(stderr);\
00055         exit(1);\
00056     }
00057 
00058 #ifdef WXWINDOWS_ENABLED
00059 
00060 //===========================================================================
00061 //= Clase _WXWINDOWS_EVTMNGR_SPIN                                            =
00062 //===========================================================================
00063 
00064 BEGIN_EVENT_TABLE(_WXWINDOWS_EVTMNGR_SPIN, wxEvtHandler)
00065     EVT_SPIN_UP(-1, _WXWINDOWS_EVTMNGR_SPIN::OnSpinBtnUp)
00066     EVT_SPIN_DOWN(-1, _WXWINDOWS_EVTMNGR_SPIN::OnSpinBtnDown)
00067 END_EVENT_TABLE()
00068 
00069 _WXWINDOWS_EVTMNGR_SPIN::_WXWINDOWS_EVTMNGR_SPIN() : wxEvtHandler()
00070 {
00071     _Textbox = NULL;
00072     _Spin = NULL;
00073 }
00074 
00075 void
00076 _WXWINDOWS_EVTMNGR_SPIN::set_data(_WXWINDOWS_TEXTBOX *textbox, 
00077                                  wxSpinButton *spin)
00078 {
00079     _Textbox = textbox;
00080     _Spin = spin;
00081 }
00082 
00083 void
00084 _WXWINDOWS_EVTMNGR_SPIN::OnSpinBtnUp(wxCommandEvent& event)
00085 {
00086     double incremento = 1;
00087     double val;
00088     wxString s;
00089     char cad[30];
00090 
00091     if ( !_Textbox ) return;
00092 
00093     s = _Textbox->GetValue();
00094     val = (double)atof(s.GetData());
00095     val += incremento;
00096     sprintf(cad, "%f", val);
00097     _Textbox->SetValue(wxString(cad));
00098     _Textbox->_Control->set_valor(val);
00099 
00100     _Spin->SetValue(5);  // OJO: Esto es para controlar los limites...
00101                          //      comportamiento pendiente de programar...
00102 }
00103 
00104 void
00105 _WXWINDOWS_EVTMNGR_SPIN::OnSpinBtnDown(wxCommandEvent& event)
00106 {
00107     double incremento = 1;
00108     double val;
00109     wxString s;
00110     char cad[30];
00111 
00112     if ( !_Textbox ) return;
00113 
00114     s = _Textbox->GetValue();
00115     val = (double)atof(s.GetData());
00116     val -= incremento;
00117     sprintf(cad, "%f", val);
00118     _Textbox->SetValue(wxString(cad));
00119     _Textbox->_Control->set_valor(val);
00120 
00121     _Spin->SetValue(5);  // OJO: Esto es para controlar los limites...
00122                          //      comportamiento pendiente de programar...
00123 }
00124 
00125 //===========================================================================
00126 //= Clase _WXWINDOWS_TEXTBOX                                                 =
00127 //===========================================================================
00128 
00129 BEGIN_EVENT_TABLE(_WXWINDOWS_TEXTBOX, wxTextCtrl)
00130     EVT_CHAR(_WXWINDOWS_TEXTBOX::OnChar)
00131 /*
00132     EVT_KEY_DOWN(_WXWINDOWS_TEXTBOX::OnKeyDown)
00133     EVT_KEY_UP(_WXWINDOWS_TEXTBOX::OnKeyUp)
00134     EVT_TEXT(-1, _WXWINDOWS_TEXTBOX::OnText)
00135     EVT_TEXT_URL(-1, _WXWINDOWS_TEXTBOX::OnTextURL)
00136     EVT_TEXT_MAXLEN(-1, _WXWINDOWS_TEXTBOX::OnTextMaxLen)
00137 
00138     EVT_MOUSE_EVENTS(_WXWINDOWS_TEXTBOX::OnMouseEvent)
00139 
00140     EVT_SET_FOCUS(_WXWINDOWS_TEXTBOX::OnSetFocus)
00141     EVT_KILL_FOCUS(_WXWINDOWS_TEXTBOX::OnKillFocus)
00142 */
00143 END_EVENT_TABLE()
00144 
00145 _WXWINDOWS_TEXTBOX::_WXWINDOWS_TEXTBOX(wxWindow *parent, wxWindowID id, 
00146     const wxString &value, const wxPoint &pos, const wxSize &size, 
00147     int style) : wxTextCtrl(parent, -1, value, pos, size, style)
00148 {
00149     _Control = NULL;
00150 }
00151 
00152 void
00153 _WXWINDOWS_TEXTBOX::OnChar(wxKeyEvent& event) 
00154 
00162 {
00163     wxString s;
00164 
00165     if ( event.KeyCode() == WXK_RETURN && _Control) {
00166         s = GetValue();
00167         _Control->set_valor((double)atof(s.GetData()));
00168     }
00169     event.Skip();
00170 }
00171 
00172 void
00173 _WXWINDOWS_TEXTBOX::set_control(CONTROL_GUI_FLOAT *c)
00174 {
00175     _Control = c;
00176 }
00177 
00178 #endif // WXWINDOWS
00179 
00180 //===========================================================================
00181 //= Clase CONTROL_GUI_FLOAT                                                 =
00182 //===========================================================================
00183 
00184 CONTROL_GUI_FLOAT::CONTROL_GUI_FLOAT(JED_INTERFACE **p) : CONTROL_GUI(p)
00185 {
00186     _nombre_variable = NULL;
00187     _nombre_subvariable = NULL;
00188     estilo = 0;
00189     _valor = 0;
00190     Entidad_controlada = NULL;
00191   #ifdef MOTIF_ENABLED
00192     widget_datos = NULL;
00193   #endif
00194   #ifdef WXWINDOS_ENABLED
00195     textbox = NULL;
00196     slider = NULL;
00197   #endif
00198 }
00199 
00200 CONTROL_GUI_FLOAT::~CONTROL_GUI_FLOAT()
00201 {
00202 }
00203 
00204 BOOLEAN
00205 CONTROL_GUI_FLOAT::leer(TOKENIZADOR *Sabiondo)
00206 {
00207     char cad[1000];
00208     int tipo_token = TK_DESCONOCIDO, pos;
00209 
00210     //- Ejecute el parser especifico de la COSA_RIGIDA -----------------
00211     pos = 1;
00212     while ( tipo_token != TK_CERRAR) {
00213         tipo_token = Sabiondo->siguiente_token(cad);
00214         switch ( pos ) {
00215             case 1:
00216               ESPERO_F(TK_CADENA, "una cadena, nombre de una variable");
00217               if ( strlen(cad) > MAX_CAD-1 ) cad[MAX_CAD-1] = '\0'; 
00218               des_comille(cad);
00219               _nombre_variable = new char[strlen(cad)+1];
00220               VERIFICAR_F(_nombre_variable);
00221               strcpy(_nombre_variable, cad);
00222               pos++;
00223               break;
00224             case 2:  ESPERO_F(TK_ABRIR, "\"{\"");  pos++; break;
00225             default:
00226               if ( tipo_token == TK_CERRAR ) break;
00227               ESPERO_F(TK_IDENTIFICADOR, "un identificador (3)");
00228               if ( strcmp(cad, "etiqueta") == 0 ) {
00229                   tipo_token = Sabiondo->siguiente_token(cad);
00230                   ESPERO_F(TK_CADENA, "una cadena");
00231                   des_comille(cad);
00232                   _nombre_etiqueta = new char[strlen(cad)+1];
00233                   VERIFICAR_F(_nombre_etiqueta);
00234                   strcpy(_nombre_etiqueta, cad);
00235                 }
00236                 else if ( strcmp(cad, "estilo") == 0 ) {
00237                   tipo_token = Sabiondo->siguiente_token(cad);
00238                   ESPERO_F(TK_NUMERO, "un estilo (numero)");
00239                   estilo = atoi(cad);
00240                 }
00241               ;
00242               break;
00243         }
00244     }
00245 
00246     return TRUE;
00247 }
00248 
00249 void
00250 CONTROL_GUI_FLOAT::actualizar(ENTIDAD *Entidad)
00251 {
00252     //-----------------------------------------------------------------------
00253     double *Nuevo_valor;
00254     int tipo = T_FLOAT;
00255 
00256     if ( !Entidad || !Entidad->consultar_variable(
00257           (const char *)_nombre_subvariable,
00258           tipo, (void**)(&Nuevo_valor)) ) return;
00259 
00260     _valor = *Nuevo_valor;
00261 
00262 #ifdef MOTIF_ENABLED
00263     if ( widget_datos ) {
00264     //-----------------------------------------------------------------------
00265     char mi_valormotif[1024];
00266 
00267     sprintf(mi_valormotif, "%f", _valor);
00268     simplifique_real(mi_valormotif);
00269 
00270     switch ( estilo ) {    
00271     //- Estilo 1, barra horizontal ------------------------------------------
00272       case 1: case 2:
00273         XtVaSetValues(widget_datos, XmNsliderSize, 10, NULL);
00274         XtVaSetValues(widget_datos, XmNminimum, -100, NULL);
00275         XtVaSetValues(widget_datos, XmNmaximum, 100, NULL);
00276         XtVaSetValues(widget_datos, XmNvalue, (int)_valor*10, NULL);
00277         break;
00278     //- Estilo 0, estilo standard: CAJA DE TEXTO ----------------------------
00279       case 0: default:
00280         XmTextFieldSetString(widget_datos, mi_valormotif);
00281         break;
00282     }
00283     }
00284 #endif
00285 
00286 #ifdef WXWINDOWS_ENABLED
00287     //-----------------------------------------------------------------------
00288     if ( textbox || slider ) {
00289     char mi_valorwxw[1024];
00290 
00291     sprintf(mi_valorwxw, "%f", _valor);
00292     simplifique_real(mi_valorwxw);
00293 
00294 switch ( estilo ) {
00295     //- Estilo 1, barra horizontal, estilo 2, barra vertical ----------------
00296    case 1: case 2:
00297     if ( !slider ) return; // OJO: Aun pendiente como manejar el min-max
00298     slider->SetValue((int)_valor);
00299     break;
00300     //- Estilo 0, estilo standard: CAJA DE TEXTO ----------------------------
00301   case 0: default:
00302     if ( !textbox ) return;
00303     textbox->SetValue(wxString(mi_valorwxw));
00304     break;
00305     //-----------------------------------------------------------------------
00306 } // switch
00307     }
00308 #endif
00309 }
00310 
00311 void
00312 CONTROL_GUI_FLOAT::set_valor(double val)
00313 {
00314     _valor = val;
00315     if ( Entidad_controlada ) {
00316         Entidad_controlada->actualizar_variable(_nombre_subvariable,
00317             T_FLOAT, (void *)(&_valor));
00318         Entidad_controlada->propagar_cambios();
00319         (*_Padre)->solicitar_repintado();
00320     }
00321 }
00322 
00323 #ifdef MOTIF_ENABLED
00324 
00325 static void
00326 control_gui_float_callback(Widget text_w, XtPointer client_data, 
00327                            XtPointer /*call_data*/)
00328 /*---------------------------------------------------------------------------
00329 */
00330 {
00331     char *cad = XmTextFieldGetString(text_w);
00332     CONTROL_GUI_FLOAT *Control = (CONTROL_GUI_FLOAT *)client_data;
00333     Control->set_valor((double)atof(cad));
00334 }
00335 
00336 static void
00337 control_gui_float_callback1(Widget barra, XtPointer client_data, 
00338                            XtPointer /*call_data*/)
00339 /*---------------------------------------------------------------------------
00340 */
00341 {
00342     int valor;
00343     CONTROL_GUI_FLOAT *Control = (CONTROL_GUI_FLOAT *)client_data;
00344 
00345     XtVaGetValues(barra, XmNvalue, &valor, NULL);
00346     Control->set_valor(((double)valor)/10);
00347 }
00348 
00349 Widget
00350 CONTROL_GUI_FLOAT::crear_motif(REPOSITORIO_DE_ENTIDADES *Repositorio,
00351                                Widget padre)
00355 {
00356     //- Asocie la variable de estado con introspeccion que corresponde ------
00357     ENTIDAD *e;
00358     char entidad[1024];
00359     char *ptr;
00360 
00361     strcpy(entidad, _nombre_variable);
00362     ptr = strtok(entidad, ".");
00363 
00364     //printf("BUSCO A LA ENTIDAD [%s] en %ld repositorios\n", 
00365     //   ptr, Entidades->tam());
00366     //fflush(stdout);
00367     e = Repositorio->buscar_entidad("_default", ptr);
00368     if ( e ) {
00369         //printf("  - ENCUENTRO A LA ENTIDAD [%s]\n", ptr); fflush(stdout);
00370         Entidad_controlada = e;
00371         _nombre_subvariable = strchr(_nombre_variable, '.')+1;
00372          e->registrar_controlador(this);
00373     }
00374 
00375     //- Determine el nombre visible del control -----------------------------
00376     char nombre_defecto[] = "[SIN VARIABLE]";
00377     char *mi_nombre = nombre_defecto;
00378     XmString motif_cad;
00379 
00380     if ( _nombre_variable ) mi_nombre = _nombre_variable;
00381     if ( _nombre_etiqueta ) mi_nombre = _nombre_etiqueta;
00382     motif_cad = XmStringCreateLocalized(mi_nombre);
00383 
00384     //- Cree el control -----------------------------------------------------
00385     Widget control = NULL;
00386     Widget etiqueta, barra, texto;
00387 
00388 switch ( estilo ) {
00389     //- Estilo 1, barra horizontal ------------------------------------------
00390   case 1:
00391     control = XtVaCreateManagedWidget ("[VARIABLE_FLOAT]", xmFormWidgetClass, 
00392         padre, XmNwidth, 180, XmNheight, 20, XmNmarginWidth, 0, 
00393         XmNmarginHeight, 0, XmNresizePolicy, XmRESIZE_ANY, 
00394         XmNallowOverlap, False, NULL);
00395     etiqueta = XtVaCreateManagedWidget ("[LABEL]", xmLabelWidgetClass, control,
00396         XmNlabelString,  motif_cad, XmNx, 10, XmNy, 10, NULL);
00397 
00398     barra = XtVaCreateManagedWidget("Scroll", xmScrollBarWidgetClass, control, 
00399         XmNorientation, XmHORIZONTAL, 
00400         //XmNprocessingDirection, XmMAX_ON_BOTTOM,
00401         XmNhighlightThickness, 1, XmNhighlightOnEnter, False, XmNheight, 15,
00402         NULL);
00403     widget_datos = barra;
00404     actualizar(Entidad_controlada);
00405     XtAddCallback (barra, XmNvalueChangedCallback,control_gui_float_callback1, 
00406                    (void *)this);
00407     XtAddCallback (barra, XmNdragCallback,control_gui_float_callback1, 
00408                    (void *)this);
00409 
00410     XtVaSetValues(etiqueta, 
00411         XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0, 
00412         XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00413         XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0, NULL);
00414     XtVaSetValues(barra, 
00415         XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 0, 
00416         XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00417         XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0, 
00418         XmNleftAttachment, XmATTACH_WIDGET, XmNleftOffset, 2,
00419         XmNleftWidget, etiqueta, NULL);
00420     break;
00421     //- Estilo 2, barra vertical --------------------------------------------
00422   case 2:
00423     control = XtVaCreateManagedWidget ("[VARIABLE_FLOAT]", xmFormWidgetClass,
00424              padre, XmNwidth, 20, XmNheight, 320,
00425              XmNmarginWidth, 0, XmNmarginHeight, 0, 
00426              XmNresizePolicy, XmRESIZE_ANY,
00427              XmNallowOverlap, False, 
00428              NULL);
00429     etiqueta = XtVaCreateManagedWidget ("[LABEL]", xmLabelWidgetClass, control,
00430         XmNlabelString,  motif_cad, XmNx, 10, XmNy, 10, NULL);
00431 
00432     barra = XtVaCreateManagedWidget("Scroll", xmScrollBarWidgetClass, control, 
00433                                 XmNorientation, XmVERTICAL,
00434                                 XmNprocessingDirection, XmMAX_ON_BOTTOM,
00435                                 XmNhighlightThickness, 1,
00436                                 XmNhighlightOnEnter, False,
00437                                 XmNwidth, 15,
00438                                 NULL);
00439 
00440 /*
00441     XtVaSetValues(etiqueta, XtVaTypedArg, XmNforeground,
00442         XmRString, "#008000", 7, NULL);
00443 */
00444 
00445     widget_datos = barra;
00446     actualizar(Entidad_controlada);
00447     XtAddCallback (barra, XmNvalueChangedCallback,control_gui_float_callback1, 
00448                    (void *)this);
00449     XtAddCallback (barra, XmNdragCallback,control_gui_float_callback1, 
00450                    (void *)this);
00451 
00452     XtVaSetValues(etiqueta, 
00453                   XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0, 
00454                   XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00455                   XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 0, 
00456                   NULL);
00457     XtVaSetValues(barra, 
00458                   XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 0, 
00459                   XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0,
00460                   XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0, 
00461                   XmNtopAttachment, XmATTACH_WIDGET, XmNtopOffset, 2,
00462                   XmNtopWidget, etiqueta,
00463                   NULL);
00464     break;
00465     //- Estilo 0, estilo standard: CAJA DE TEXTO ----------------------------
00466   case 0: default:
00467     //- Creo el contenedor de este control
00468     control = XtVaCreateManagedWidget ("[VARIABLE_FLOAT]", xmFormWidgetClass,
00469         padre, XmNwidth, 120, XmNheight, 30,
00470         XmNmarginWidth, 0, XmNmarginHeight, 0, XmNresizePolicy, XmRESIZE_ANY,
00471         XmNallowOverlap, False, XmNchildType, XmFRAME_GENERIC_CHILD, NULL);
00472 
00473     //- Creo el Widget de etiqueta
00474     etiqueta = XtVaCreateManagedWidget("[LABEL]", xmLabelWidgetClass,control,
00475         XmNlabelString,  motif_cad, XmNx, 10, XmNy, 10, NULL);
00476 
00477     //- Creo el Widget de texto
00478     texto = XtVaCreateManagedWidget ("[TEXT]", xmTextFieldWidgetClass, control,
00479                         XmNx, 10, XmNy, 60, NULL);
00480 
00481     widget_datos = texto;
00482     actualizar(Entidad_controlada);
00483     XtAddCallback (texto, XmNactivateCallback, control_gui_float_callback, 
00484                    (void *)this);
00485 
00486     //- Configuracion de la administracion de geometria
00487     XtVaSetValues(etiqueta, 
00488                   XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0, 
00489                   XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00490                   XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0, 
00491                   NULL);
00492     XtVaSetValues(texto, 
00493                   XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 0, 
00494                   XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00495                   XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0, 
00496                   XmNleftAttachment, XmATTACH_WIDGET, XmNleftOffset, 2,
00497                   XmNleftWidget, etiqueta,
00498                   NULL);
00499 
00500     break;
00501     //-----------------------------------------------------------------------
00502 } // switch
00503 
00504     //-----------------------------------------------------------------------
00505     // Final (OJO: Puede cambiar)
00506     XtManageChild(control);
00507 
00508     XmStringFree(motif_cad);
00509     return control;
00510 }
00511 #endif // MOTIF_ENABLED
00512 
00513 #ifdef WXWINDOWS_ENABLED
00514 void
00515 CONTROL_GUI_FLOAT::crear_wxwindows(REPOSITORIO_DE_ENTIDADES *Repositorio,
00516                            wxPanel *padre)
00517 {
00518     //- Asocie la variable de estado con introspeccion que corresponde ------
00519     ENTIDAD *e;
00520     char entidad[1024];
00521     char *ptr;
00522 
00523     strcpy(entidad, _nombre_variable);
00524     ptr = strtok(entidad, ".");
00525     e = Repositorio->buscar_entidad("_default", ptr);
00526     if ( e ) {
00527         Entidad_controlada = e;
00528         _nombre_subvariable = strchr(_nombre_variable, '.')+1;
00529          e->registrar_controlador(this);
00530     }
00531 
00532     //- Determine el nombre visible del control -----------------------------
00533     char nombre_defecto[] = "[SIN VARIABLE]";
00534     char *mi_nombre = nombre_defecto;
00535 
00536     if ( _nombre_variable ) mi_nombre = _nombre_variable;
00537     if ( _nombre_etiqueta ) mi_nombre = _nombre_etiqueta;
00538 // OJO: La etiqueta del control debe llamarse `mi_nombre`
00539 
00540     //- Cree el control -----------------------------------------------------
00541     wxSizer *acomodador_con_etiqueta;
00542     wxStaticText *etiqueta;
00543     _WXWINDOWS_EVTMNGR_SPIN *mngr;
00544 
00545 switch ( estilo ) {
00546     //- Estilo 1, barra horizontal ------------------------------------------
00547   case 1:
00548     acomodador_con_etiqueta = new wxBoxSizer(wxHORIZONTAL);
00549     etiqueta = new wxStaticText(padre, -1, wxString(mi_nombre));
00550     acomodador_con_etiqueta->Add(etiqueta, 0, wxRIGHT, 5);
00551     slider = new wxSlider(padre, -1, 0, 0, 7, 
00552         wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL);
00553     acomodador_con_etiqueta->Add(slider, 1, wxLEFT, 5);
00554     actualizar(Entidad_controlada);
00555 
00556     acomodador_con_etiqueta->Fit(padre);
00557     padre->SetSizer(acomodador_con_etiqueta);
00558 
00559     actualizar(Entidad_controlada);
00560     break;
00561     //- Estilo 2, barra vertical --------------------------------------------
00562   case 2:
00563     acomodador_con_etiqueta = new wxBoxSizer(wxVERTICAL);
00564     etiqueta = new wxStaticText(padre, -1, wxString(mi_nombre));
00565     acomodador_con_etiqueta->Add(etiqueta, 0, wxBOTTOM, 5);
00566     slider = new wxSlider(padre, -1, 0, 0, 7, 
00567         wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL);
00568     acomodador_con_etiqueta->Add(slider, 1, wxTOP, 5);
00569     actualizar(Entidad_controlada);
00570 
00571     acomodador_con_etiqueta->Fit(padre);
00572     padre->SetSizer(acomodador_con_etiqueta);
00573 
00574     actualizar(Entidad_controlada);
00575     break;
00576     //- Estilo 0, estilo standard: CAJA DE TEXTO ----------------------------
00577   case 0: default:
00578     // Creacion de la estructura del control y su componente textbox
00579     acomodador_con_etiqueta = new wxBoxSizer(wxHORIZONTAL);
00580     etiqueta = new wxStaticText(padre, -1, wxString(mi_nombre));
00581     acomodador_con_etiqueta->Add(etiqueta, 0, wxRIGHT, 5);
00582     textbox = new _WXWINDOWS_TEXTBOX(padre, -1, _T("vacio"), 
00583         wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
00584     textbox->set_control(this);
00585     textbox->SetEditable(TRUE);
00586     acomodador_con_etiqueta->Add(textbox, 1, wxLEFT, 5);
00587 
00588     // Creacion del spin asociado al cuadro de texto
00589     spin = new wxSpinButton(padre, -1);
00590     mngr = new _WXWINDOWS_EVTMNGR_SPIN();
00591     mngr->set_data(textbox, spin);
00592     spin->PushEventHandler(mngr);
00593     spin->SetRange(0, 10);
00594     spin->SetValue(5);
00595     acomodador_con_etiqueta->Add(spin, 0, 0, 0);
00596 
00597     // Detalles finales
00598     actualizar(Entidad_controlada);
00599     acomodador_con_etiqueta->Fit(padre);
00600     padre->SetSizer(acomodador_con_etiqueta);
00601     break;
00602     //-----------------------------------------------------------------------
00603 } // switch
00604 
00605     //-----------------------------------------------------------------------
00606 }
00607 #endif // WXWINDOWS_ENABLED
00608 
00609 //===========================================================================
00610 //= EOF                                                                     =
00611 //===========================================================================
00612 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.