/***********************************************************************
* menu.cpp - A menu example *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2021 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* . *
***********************************************************************/
#include
using FKey = finalcut::FKey;
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Menu
//----------------------------------------------------------------------
class Menu final : public finalcut::FDialog
{
public:
// Constructor
explicit Menu (finalcut::FWidget* = nullptr);
// Disable copy constructor
Menu (const Menu&) = delete;
// Destructor
~Menu() override = default;
// Disable copy assignment operator (=)
Menu& operator = (const Menu&) = delete;
private:
// Methods
void configureFileMenuItems();
void configureEditMenuItems();
void configureChoiceMenuItems();
void configureColorMenuItems();
void configureStyleMenuItems();
void configureBorderMenuItems();
void defaultCallback (const finalcut::FMenuList*);
void initLayout() override;
void adjustSize() override;
// Event handler
void onClose (finalcut::FCloseEvent*) override;
// Callback method
void cb_message (const finalcut::FMenuItem*);
// Data members
finalcut::FString line{13, finalcut::UniChar::BoxDrawingsHorizontal};
finalcut::FMenuBar Menubar{this};
finalcut::FMenu File{"&File", &Menubar};
finalcut::FMenu Edit{"&Edit", &Menubar};
finalcut::FMenu Choice{"&Choice", &Menubar};
finalcut::FMenuItem Window{"&Window", &Menubar};
finalcut::FMenuItem Help{"&Help", &Menubar};
finalcut::FMenuItem New{"&New", &File};
finalcut::FMenuItem Open{"&Open...", &File};
finalcut::FMenuItem Save{"&Save", &File};
finalcut::FMenuItem SaveAs{"&Save as...", &File};
finalcut::FMenuItem Close{"&Close", &File};
finalcut::FMenuItem Line1{&File};
finalcut::FMenuItem Print{"&Print", &File};
finalcut::FMenuItem Line2{&File};
finalcut::FMenuItem Quit{"&Quit", &File};
finalcut::FMenuItem Undo{FKey::Ctrl_z, "&Undo", &Edit};
finalcut::FMenuItem Redo{FKey::Ctrl_y, "&Redo", &Edit};
finalcut::FMenuItem Line3{&Edit};
finalcut::FMenuItem Cut{FKey::Ctrl_x, "Cu&t", &Edit};
finalcut::FMenuItem Copy{FKey::Ctrl_c, "&Copy", &Edit};
finalcut::FMenuItem Paste{FKey::Ctrl_v, "&Paste", &Edit};
finalcut::FMenuItem Line4{&Edit};
finalcut::FMenuItem Search{FKey::Ctrl_f, "&Search", &Edit};
finalcut::FMenuItem Next{FKey::F3, "Search &next", &Edit};
finalcut::FMenuItem Line5{&Edit};
finalcut::FMenuItem SelectAll{FKey::Ctrl_a, "Select &all", &Edit};
finalcut::FMenu Color{"&Color", &Choice};
finalcut::FMenu Style{"&Style", &Choice};
finalcut::FMenu Border{"&Border", &Choice};
finalcut::FRadioMenuItem Color1{"Red", &Color};
finalcut::FRadioMenuItem Color2{"Green", &Color};
finalcut::FRadioMenuItem Color3{"Yellow", &Color};
finalcut::FRadioMenuItem Color4{"Brue", &Color};
finalcut::FRadioMenuItem Color5{"Black", &Color};
finalcut::FCheckMenuItem Bold{"Bold", &Style};
finalcut::FCheckMenuItem Italic{"Italic", &Style};
finalcut::FMenu BColor{"&Color", &Border};
finalcut::FMenu BStyle{"&Style", &Border};
finalcut::FRadioMenuItem BColor1{"Red", &BColor};
finalcut::FRadioMenuItem BColor2{"Blue", &BColor};
finalcut::FRadioMenuItem BStyle1{line, &BStyle};
finalcut::FRadioMenuItem BStyle2{"-------------", &BStyle};
finalcut::FRadioMenuItem BStyle3{"- - - - - - -", &BStyle};
finalcut::FRadioMenuItem BStyle4{"- - - - -", &BStyle};
finalcut::FStatusBar Statusbar{this};
finalcut::FLabel Headline1{this};
finalcut::FLabel Headline2{this};
finalcut::FLabel Info{this};
};
//----------------------------------------------------------------------
Menu::Menu (finalcut::FWidget* parent)
: finalcut::FDialog{parent}
{
// Menu bar itms
File.setStatusbarMessage ("File management commands");
Edit.setStatusbarMessage ("Cut-and-paste editing commands");
Choice.setStatusbarMessage ("Choice menu");
Window.setDisable();
Help.setStatusbarMessage ("Show version and copyright information");
// Menu items
configureFileMenuItems();
configureEditMenuItems();
configureChoiceMenuItems();
// Add default menu item callback
defaultCallback (&Menubar);
// Statusbar at the bottom
Statusbar.setMessage("Status bar message");
// Headline labels
Headline1 << " Key ";
Headline1.ignorePadding();
Headline1.setEmphasis();
Headline2 << " Function ";
Headline2.ignorePadding();
Headline2.setEmphasis();
// Info label
Info << " Activate menu bar\n"
<< "+ Activate menu bar\n"
<< "