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

ev_CocoaMenu.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource Program Utilities
00004  * Copyright (C) 1998-2000 AbiSource, Inc.
00005  * Copyright (C) 2001-2004, 2007, 2009 Hubert Figuiere
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  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 #ifndef EV_COCOAMENU_H
00024 #define EV_COCOAMENU_H
00025 
00026 #include <stack>
00027 #import <Cocoa/Cocoa.h>
00028 
00029 #include "ut_types.h"
00030 
00031 #include "xap_CocoaAppController.h"
00032 #include "xap_Types.h"
00033 
00034 #include "ev_Menu.h"
00035 #include "ev_Menu_Layouts.h"
00036 
00037 
00038 class AV_View;
00039 
00040 class XAP_CocoaApp;
00041 
00042 class EV_CocoaMenu;
00043 class EV_CocoaMenuBar;
00044 class EV_Menu_Action;
00045 class EV_Menu_Label;
00046 
00047 class AP_CocoaFrame;
00048 
00049 /*****************************************************************/
00050 
00051 @interface EV_CocoaMenuTarget : NSObject
00052 {
00053     EV_CocoaMenu *  m_menu;
00054 }
00055 - (id)initWithMenu:(EV_CocoaMenu *)menu;
00056 - (void)menuSelected:(id)sender;
00057 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
00058 @end
00059 
00060 @interface EV_CocoaFontTarget : NSObject
00061 {
00062     NSMutableArray *    m_Fonts;
00063 }
00064 - (id)init;
00065 - (void)dealloc;
00066 - (NSMenuItem *)fontMenuItem:(NSString *)title;
00067 - (void)menuSelected:(id)sender;
00068 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
00069 @end
00070 
00071 class EV_CocoaMenu : public EV_Menu
00072 {
00073 public:
00074     EV_CocoaMenu(const char * szMenuLayoutName, const char * szMenuLabelSetName, bool bContextMenu);
00075 
00076     virtual ~EV_CocoaMenu();
00077 
00078     void                buildAppMenu();
00079 private:
00080     void                addToAppMenu(XAP_Menu_Id menuid, const EV_Menu_Action * pAction, const EV_Menu_Label * pLabel, EV_Menu_LayoutFlags flags);
00081     void                addToAppMenu(NSMenuItem * item);
00082 public:
00083     bool                menuEvent(XAP_Menu_Id menuid);
00084 
00085     void                validateMenuItem(XAP_Menu_Id menuid, bool & bEnabled, bool & bChecked, const char *& szLabel);
00086 
00087     NSString *          convertToString(const char * label, bool strip_dots = false);
00088 
00089 private:
00090     /*
00091     static NSString *   _getItemCmd (const char * mnemonic, unsigned int & modifiers, UT_uint32 * keyRefKey = 0);
00092      */
00093     EV_CocoaMenuTarget *    m_menuTarget;
00094     EV_CocoaFontTarget *    m_fontTarget;
00095     XAP_CocoaAppMenu_Id     m_AppMenuCurrent;
00096 
00097     std::stack<NSMenu*> *               m_menuStack;
00098 
00099     void                    MenuStack_clear();
00100     void                    MenuStack_push(NSMenu * menu);
00101     NSMenu *                MenuStack_pop();
00102 
00103 protected:
00104     virtual bool            _doAddMenuItem(UT_uint32 layout_pos); // does nothing, returns false
00105 
00106 private:
00107     char *                  m_buffer;
00108     UT_uint32               m_maxlen;
00109 
00110     bool                    m_bContextMenu;
00111     bool                    m_bAddSeparator;
00112     XAP_Menu_Id             m_SeparatorID;
00113 };
00114 
00115 #endif /* EV_COCOAMENU_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1