• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ap_UnixDialog_Columns.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA.
00018  */
00019 
00020 #ifndef AP_UnixDialog_Columns_H
00021 #define AP_UnixDialog_Columns_H
00022 
00023 #include "ap_Dialog_Columns.h"
00024 
00025 #include "ut_types.h"
00026 #include "ut_string.h"
00027 
00028 
00029 /*****************************************************************
00030 ******************************************************************
00031 ** Here we begin a little CPP magic to load all of the icons.
00032 ** It is important that all of the ..._Icon_*.{h,xpm} files
00033 ** allow themselves to be included more than one time.
00034 ******************************************************************
00035 *****************************************************************/
00036 // This comes from ap_Toolbar_Icons.cpp
00037 #include "xap_Toolbar_Icons.h"
00038 
00039 #include "ap_Toolbar_Icons_All.h"
00040 
00041 class GR_UnixCairoGraphics;
00042 /*****************************************************************
00043 ******************************************************************
00044 ** Here we begin a little CPP magic to construct a table of
00045 ** the icon names and pointer to the data.
00046 ******************************************************************
00047 *****************************************************************/
00048 
00049 struct _it
00050 {
00051     const char *                m_name;
00052     const char **               m_staticVariable;
00053     UT_uint32                   m_sizeofVariable;
00054 };
00055 
00056 #define DefineToolbarIcon(name)     { #name, (const char **) name, sizeof(name)/sizeof(name[0]) },
00057 
00058 static struct _it s_itTable[] =
00059 {
00060 
00061 #include "ap_Toolbar_Icons_All.h"
00062 
00063 };
00064 
00065 #undef DefineToolbarIcon
00066 
00067 
00068 // Some convience functions to make Abi's pixmaps easily available to unix
00069 // dialogs
00070 
00071 static bool findIconDataByName(const char * szName, const char *** pIconData, UT_uint32 * pSizeofData) ;
00072 
00073 static bool label_button_with_abi_pixmap( GtkWidget * button, const char * szIconName);
00074 
00075 
00076 //
00077 //--------------------------------------------------------------------------
00078 //
00079 // Code to make pixmaps for gtk buttons
00080 //
00081 // findIconDataByName stolen from ap_Toolbar_Icons.cpp
00082 //
00083 static bool findIconDataByName(const char * szName, const char *** pIconData, UT_uint32 * pSizeofData)
00084 {
00085     // This is a static function.
00086 
00087     if (!szName || !*szName || (g_ascii_strcasecmp(szName,"NoIcon")==0))
00088         return false;
00089 
00090     UT_uint32 kLimit = G_N_ELEMENTS(s_itTable);
00091     UT_uint32 k;
00092     UT_DEBUGMSG(("SEVIOR: Looking for %s \n",szName));
00093     for (k=0; k < kLimit; k++)
00094     {
00095         UT_DEBUGMSG(("SEVIOR: examining %s \n",s_itTable[k].m_name));
00096         if (g_ascii_strcasecmp(szName,s_itTable[k].m_name) == 0)
00097         {
00098             *pIconData = s_itTable[k].m_staticVariable;
00099             *pSizeofData = s_itTable[k].m_sizeofVariable;
00100             return true;
00101         }
00102     }
00103     return false;
00104 }
00105 
00106 static inline bool label_button_with_abi_pixmap( GtkWidget * button, const char * szIconName)
00107 {
00108         const char ** pIconData = NULL;
00109     UT_uint32 sizeofIconData = 0;       // number of cells in the array
00110     bool bFound = findIconDataByName(szIconName, &pIconData, &sizeofIconData);
00111     if (!bFound)
00112     {
00113         UT_DEBUGMSG(("Could not find icon %s \n",szIconName));
00114         return false;
00115     }
00116     UT_DEBUGMSG(("SEVIOR: found icon name %s \n",szIconName));
00117     GdkBitmap * mask;
00118     GdkColormap * colormap =  gtk_widget_get_colormap (button);
00119     GdkPixmap * pixmap
00120         = gdk_pixmap_colormap_create_from_xpm_d(button->window,colormap,
00121                             &mask, NULL,
00122                             (char **)pIconData);
00123     if (!pixmap)
00124         return false;
00125     GtkWidget * wpixmap = gtk_image_new_from_pixmap(pixmap,mask);
00126     if (!wpixmap)
00127         return false;
00128     gtk_widget_show(wpixmap);
00129     UT_DEBUGMSG(("SEVIOR: Adding pixmap to button now \n"));
00130     gtk_container_add (GTK_CONTAINER (button), wpixmap);
00131     return true;
00132 }
00133 //----------------------------------------------------------------
00134 
00135 class XAP_UnixFrame;
00136 
00137 /*****************************************************************/
00138 
00139 class AP_UnixDialog_Columns: public AP_Dialog_Columns
00140 {
00141 public:
00142     AP_UnixDialog_Columns(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00143     virtual ~AP_UnixDialog_Columns(void);
00144 
00145     virtual void            runModal(XAP_Frame * pFrame);
00146     virtual void            enableLineBetweenControl(bool bState = true);
00147 
00148     static XAP_Dialog *     static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id);
00149 
00150     // callbacks can fire these events
00151     void                            doSpaceAfterEntry(void);
00152     void                            doMaxHeightEntry(void);
00153     void                            doHeightSpin(void);
00154     void                            doSpaceAfterSpin(void);
00155     void                            checkLineBetween(void);
00156     void                            readSpin(void);
00157     void                            event_Toggle( UT_uint32 icolumns);
00158     void                            event_previewExposed(void);
00159     virtual void            event_OK(void);
00160     virtual void            event_Cancel(void);
00161 
00162 protected:
00163 
00164     typedef enum
00165         {
00166             BUTTON_OK = GTK_RESPONSE_OK,
00167             BUTTON_CANCEL = GTK_RESPONSE_CANCEL
00168         } ResponseId ;
00169 
00170     // private construction functions
00171     virtual GtkWidget * _constructWindow(void);
00172     void            _constructWindowContents( GtkWidget * windowColumns);
00173     void        _populateWindowData(void);
00174     void        _storeWindowData(void);
00175     void            _connectsignals(void);
00176 
00177     GR_UnixCairoGraphics    *       m_pPreviewWidget;
00178 
00179     // pointers to widgets we need to query/set
00180     GtkWidget * m_windowMain;
00181 
00182     GtkWidget * m_wlineBetween;
00183     GtkWidget * m_wtoggleOne;
00184     GtkWidget * m_wtoggleTwo;
00185     GtkWidget * m_wtoggleThree;
00186     GtkWidget * m_wpreviewArea;
00187     GtkWidget * m_wSpin;
00188 
00189     guint m_oneHandlerID;
00190     guint m_twoHandlerID;
00191     guint m_threeHandlerID;
00192     guint m_spinHandlerID;
00193     UT_sint32 m_iSpaceAfter;
00194     guint m_iSpaceAfterID;
00195     GtkWidget * m_wSpaceAfterSpin;
00196     GtkWidget * m_wSpaceAfterEntry;
00197     GtkObject * m_oSpaceAfter_adj;
00198     UT_sint32 m_iMaxColumnHeight;
00199     guint m_iMaxColumnHeightID;
00200     GtkWidget * m_wMaxColumnHeightSpin;
00201     GtkWidget * m_wMaxColumnHeightEntry;
00202     GtkObject * m_oSpinSize_adj;
00203     UT_sint32 m_iSizeHeight;
00204     GtkWidget * m_checkOrder;
00205 };
00206 
00207 #endif /* AP_UnixDialog_Columns_H */
00208 
00209 
00210 
00211 
00212 
00213 

Generated on Sat Dec 3 2011 for AbiWord by  doxygen 1.7.1