⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fl_sys_menu_bar.cxx

📁 SRI international 发布的OAA框架软件
💻 CXX
字号:
//
// "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.1.1 2003/06/03 22:25:43 agno Exp $"
//
// MacOS system menu bar widget for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2003 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//

/**
 * This code is a quick hack! It was written as a proof of concept.
 * It has been tested on the "menubar" sample program and provides
 * basic functionality. 
 * 
 * To use the System Menu Bar, simply replace the main Fl_Menu_Bar
 * in an application with Fl_Sys_Menu_Bar.
 *
 * FLTK features not supported by the Mac System menu
 *
 * - no invisible menu items
 * - no sybolic labels
 * - embossed labels will be underlined instead
 * - no font sizes
 * - Shortcut Characters should be English alphanumeric only, no modifiers yet
 * - no disable main menus
 * - changes to menubar in run-time don't update! 
 *     (disable, etc. - toggle and readio button do!)
 *
 * No care was taken to clean up the menu bar after destruction!
 * ::menu(bar) should only be called once!
 * Many other calls of the parent class don't work.
 * Changing the menu items has no effect on the menu bar.
 */

#include <FL/X.H>
#include <FL/Fl.H>
#include <FL/Fl_Sys_Menu_Bar.H>

#include "flstring.h"
#include <stdio.h>
#include <ctype.h>

typedef const Fl_Menu_Item *pFl_Menu_Item;

/**
 * copy the text of a menuitem into a buffer.
 * Skip all '&' which would mark the shortcut in FLTK
 * Skip all Mac control characters ('(', '<', ';', '^', '!' )
 */
static void catMenuText( const char *src, char *dst )
{
  char c;
  while ( *dst ) 
    dst++;
  if ( *src == '-' ) 
    src++;
  while ( ( c = *src++ ) ) 
  {
    if ( !strchr( "&(<;^!", c )  )
      *dst++ = c;
  }
  *dst = 0;
}

/**
 * append a marker to identify the menu font style
 * <B, I, U, O, and S
 */
static void catMenuFont( const Fl_Menu_Item *m, char *dst )
{
  if ( !m->labeltype_ && !m->labelfont_ ) 
    return;
  while ( *dst ) 
    dst++;
    
  if ( m->labelfont_ & FL_BOLD )
    strcat( dst, "<B" );
  if ( m->labelfont_ & FL_ITALIC )
    strcat( dst, "<I" );
  //if ( m->labelfont_ & FL_UNDERLINE )
  //  strcat( dst, "<U" );
  
  if ( m->labeltype_ == FL_EMBOSSED_LABEL )
      strcat( dst, "<U" );
  else if ( m->labeltype_ == FL_ENGRAVED_LABEL )
      strcat( dst, "<O" );
  else if ( m->labeltype_ == FL_SHADOW_LABEL )
      strcat( dst, "<S" );
  //else if ( m->labeltype_ == FL_SYMBOL_LABEL )
      ; // not supported
}

/**
 * append a marker to identify the menu shortcut
 * <B, I, U, O, and S
enum {
排排kMenuNoModifiers排排排排= 0,
排排kMenuShiftModifier排排排= (1 << 0),
排排kMenuOptionModifier排排

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -