00001 /* AbiSource Program Utilities 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., 51 Franklin Street, Fifth Floor, Boston, MA 00017 * 02110-1301 USA. 00018 */ 00019 00020 #ifndef EV_MENU_LABELS_H 00021 #define EV_MENU_LABELS_H 00022 00023 #include "xap_Types.h" 00024 #include "ut_vector.h" 00025 #include "ut_string_class.h" 00026 00027 /***************************************************************** 00028 ****************************************************************** 00029 ** This file defines a framework for the string labels which 00030 ** are used with menus. This binding allows us to localize 00031 ** menus in a platform-independent manner. 00032 ** 00033 ** We create one EV_Menu_Label per menu-item (such as "File|Open") 00034 ** per language per application (not per window or actual menu). 00035 ** 00036 ** We create one EV_Menu_LabelSet per language per application. 00037 ** 00038 ****************************************************************** 00039 *****************************************************************/ 00040 00041 // TODO decide if we should make all labels Unicode 00042 00043 class ABI_EXPORT EV_Menu_Label 00044 { 00045 friend class XAP_Menu_Factory; 00046 public: 00047 EV_Menu_Label(XAP_Menu_Id id, 00048 const char* szMenuLabel, /* label on the actual menu itself */ 00049 const char* szStatusMsg); /* status bar message */ 00050 ~EV_Menu_Label(); 00051 00052 XAP_Menu_Id getMenuId() const; 00053 const char* getMenuLabel() const; 00054 const char* getMenuStatusMessage() const; 00055 00056 private: 00057 XAP_Menu_Id m_id; 00058 UT_String m_stMenuLabel; 00059 UT_String m_stStatusMsg; 00060 }; 00061 00062 /*****************************************************************/ 00063 00064 class ABI_EXPORT EV_Menu_LabelSet /* a glorified array with bounds checking */ 00065 { 00066 friend class XAP_Menu_Factory; 00067 public: 00068 EV_Menu_LabelSet(const char * szLanguage, 00069 XAP_Menu_Id first, XAP_Menu_Id last); 00070 EV_Menu_LabelSet(EV_Menu_LabelSet * pLabelSet); 00071 ~EV_Menu_LabelSet(); 00072 00073 bool setLabel(XAP_Menu_Id id, 00074 const char * szMenuLabel, 00075 const char * szStatusMsg); 00076 bool addLabel(EV_Menu_Label *pLabel); 00077 EV_Menu_Label * getLabel(XAP_Menu_Id id) const; 00078 XAP_Menu_Id getFirst(void) { return m_first;} 00079 const char * getLanguage() const; 00080 void setLanguage(const char *szLanguage); 00081 #if 0 00082 // we really do not need this, the way it was used it 00083 // was causing stack overflows on my machine (took me hours to 00084 // track), yet, there was no single call that would require to make 00085 // a temporary copy of this table on the stack, so I have done 00086 // away with this (Tomas) 00087 inline const UT_GenericVector<EV_Menu_Label *>& getAllLabels() const { return m_labelTable; } 00088 #else 00089 const UT_GenericVector<EV_Menu_Label *> * getAllLabels() const { return &m_labelTable;} 00090 #endif 00091 00092 private: 00093 UT_GenericVector<EV_Menu_Label *> m_labelTable; 00094 XAP_Menu_Id m_first; 00095 UT_String m_stLanguage; /* for the convenience of the app only */ 00096 }; 00097 00098 #endif /* EV_MENU_LABELS_H */