Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

vdkcustombutton.h

00001 /*
00002  * ===========================
00003  * VDK Visual Develeopment Kit
00004  * Version 0.6.2
00005  * May 1999
00006  * ===========================
00007  *
00008  * Copyright (C) 1998, Mario Motta
00009  * Developed by Mario Motta <mmotta@guest.net>
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Library General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Library General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Library General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00024  * 02111-1307, USA.
00025  */
00026 
00027 #ifndef _vdkcustombutton_h
00028 #define _vdkcustombutton_h
00029 #include <vdk/vdkobj.h>
00030 #include <vdk/boxes.h>
00031 #include <vdk/label.h>
00032 #include <vdk/image.h>
00033 #include <vdk/menu.h>
00034 // #include <vdk/gtkcombobutton.h>
00047 class VDKCustomButton: public VDKObject
00048 {
00049  protected:
00050   void ConnectButtonSignals();
00051   static void ToggleEvent(GtkWidget *wid, gpointer gp);
00052  public:
00053 // properties
00059   VDKReadOnlyValueProp<VDKCustomButton,  VDKBox*> ButtonBox;
00072   VDKReadOnlyValueProp<VDKCustomButton,  VDKLabel*> Label;
00077   VDKReadOnlyValueProp<VDKCustomButton,  VDKImage*> Pixmap;
00081   VDKReadWriteValueProp<VDKCustomButton, const char*> Caption;
00085   VDKReadWriteValueProp<VDKCustomButton, bool> CaptionWrap;
00086   /*
00087     !
00088     Permits to set/get checked state (meaningless if isn't
00089     a toggle button
00090   */
00091   VDKReadWriteValueProp<VDKCustomButton, bool> Checked;
00092   /*
00093     !
00094     Permits to set/get button relief (meaningless if is
00095     a toggle button
00096   */
00097   VDKReadWriteValueProp<VDKCustomButton, GtkReliefStyle> Relief;
00121   VDKCustomButton(VDKForm* owner, 
00122                   const char* label,
00123                   unsigned int type = 
00124                   VDK_CBUTTON_UNTOGGLED |  VDK_CBUTTON_NORMAL);
00132   VDKCustomButton(VDKForm* owner, 
00133                   const char* pixfile, 
00134                   const char* label,
00135                   unsigned int type = 
00136                   VDK_CBUTTON_UNTOGGLED |  VDK_CBUTTON_NORMAL,
00137                   GtkPositionType position = GTK_POS_RIGHT);
00141   VDKCustomButton(VDKForm* owner, 
00142                   const char** pixdata, 
00143                   const char* label,
00144                   unsigned int type = 
00145                   VDK_CBUTTON_UNTOGGLED |  VDK_CBUTTON_NORMAL,
00146                   GtkPositionType position = GTK_POS_RIGHT);
00147 
00148   ~VDKCustomButton();
00154   void SetComboMenu(VDKMenu* menu);
00155 
00156   /*
00157    */
00158   virtual void SetForeground(VDKRgb color, 
00159                              GtkStateType state = GTK_STATE_NORMAL) 
00160     {
00161       VDKLabel *label = Label;
00162       if( label)
00163         _setForeground_(label->Widget(),
00164                         color.red,
00165                         color.green,
00166                         color.blue, 
00167                         state);
00168     }
00169   /*
00170    */
00171   virtual void SetFont(VDKFont* font) 
00172     {
00173       VDKLabel *label = Label;
00174       if( label)
00175         _setFont_(label->Widget(),font);
00176     }
00177   /*
00178    */
00179   void SetCaption(const char* str) 
00180     {
00181       VDKLabel *label = Label;
00182       if( label)
00183         label->Caption = str;
00184     }
00185   /*
00186    */
00187   const char* GetCaption () 
00188     {
00189       VDKLabel *label = Label;
00190       if( label)
00191         return label->Caption;
00192       else
00193         return (const char*) NULL;
00194     }
00195   /*
00196    */
00197   void SetCaptionWrap (bool flag) 
00198     {
00199       VDKLabel *label = Label;
00200       if( label)
00201         gtk_label_set_line_wrap (GTK_LABEL (label->Widget()), flag);
00202     }
00203   /*
00204    */
00205   bool GetCaptionWrap () 
00206     {
00207       VDKLabel *label = Label;
00208       if( label)
00209         return GTK_LABEL (label->Widget())->wrap;
00210       else
00211         return false;
00212     }
00213   /*
00214    */
00215   void SetRelief(GtkReliefStyle style) 
00216     {
00217       if(GTK_IS_BUTTON(widget))
00218         gtk_button_set_relief(GTK_BUTTON(widget), style);
00219     }
00220   /*
00221    */
00222   GtkReliefStyle GetRelief() 
00223     {
00224       if(GTK_IS_BUTTON(widget))
00225         return gtk_button_get_relief(GTK_BUTTON(widget));
00226       else
00227         return GTK_RELIEF_NORMAL;
00228     }
00229   /*
00230    */
00231   void Toggle() { 
00232     if(GTK_IS_TOGGLE_BUTTON(widget))
00233       Checked = Checked ? false : true; 
00234   }
00235   /*
00236    */
00237   void SetChecked(bool flag)
00238     {
00239       if(GTK_IS_TOGGLE_BUTTON(widget))
00240         gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(widget),flag);
00241     }
00242   /*
00243    */
00244   bool GetChecked()
00245     { 
00246       if(GTK_IS_TOGGLE_BUTTON(widget))
00247         return GTK_TOGGLE_BUTTON(widget)->active ? true : false; 
00248       else
00249         return false;
00250     }
00251   /*
00252    */
00253   virtual void Enable(bool flag = true);
00254 #ifdef USE_SIGCPLUSPLUS
00255  public:
00261   VDKSignal1<void, bool> OnButtonToggled;
00266   VDKSignal0<void> OnButtonClicked;
00271   VDKSignal0<void> OnButtonPressed;
00276   VDKSignal0<void> OnButtonLeave;
00277  private:
00278   static void _handle_clicked(GtkWidget*, gpointer);
00279   static void _handle_pressed(GtkWidget*, gpointer);
00280   static void _handle_leave(GtkWidget*, gpointer);
00281 #endif /* USE_SIGCPLUSPLUS */
00282 };
00283 
00284 #endif

Generated on Sat May 4 23:45:42 2002 for vdk 2.0.1 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002