2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* menu.cpp - A menu example *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-01-21 16:25:19 +01:00
|
|
|
* Copyright 2015-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The 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. *
|
|
|
|
* *
|
|
|
|
* The 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 *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2017-10-31 00:41:59 +01:00
|
|
|
#include <final/final.h>
|
2015-12-18 21:48:27 +01:00
|
|
|
|
2015-12-08 21:05:00 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class Menu
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
class Menu : public finalcut::FDialog
|
2015-12-08 21:05:00 +01:00
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
2018-09-20 23:59:01 +02:00
|
|
|
explicit Menu (finalcut::FWidget* = 0);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Destructor
|
|
|
|
~Menu();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
Menu (const Menu&);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Disable assignment operator (=)
|
|
|
|
Menu& operator = (const Menu&);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Methods
|
2018-09-20 23:59:01 +02:00
|
|
|
void createFileMenuItems (finalcut::FMenu*);
|
|
|
|
void createEditMenuItems (finalcut::FMenu*);
|
|
|
|
void createChoiceMenuItems (finalcut::FMenu*);
|
|
|
|
void createColorMenuItems (finalcut::FMenu*);
|
|
|
|
void createStyleMenuItems (finalcut::FMenu*);
|
|
|
|
void createBorderMenuItems (finalcut::FMenu*);
|
|
|
|
void createBorderColorMenuItems (finalcut::FMenu*);
|
|
|
|
void createBorderStyleMenuItems (finalcut::FMenu*);
|
|
|
|
void defaultCallback (finalcut::FMenuList*);
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual void adjustSize();
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Event handler
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual void onClose (finalcut::FCloseEvent*);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2017-10-29 18:27:38 +01:00
|
|
|
// Callback method
|
2018-09-20 23:59:01 +02:00
|
|
|
void cb_message (finalcut::FWidget*, data_ptr);
|
2015-12-08 21:05:00 +01:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
Menu::Menu (finalcut::FWidget* parent)
|
|
|
|
: finalcut::FDialog(parent)
|
2015-12-08 21:05:00 +01:00
|
|
|
{
|
2018-01-21 16:21:41 +01:00
|
|
|
// Menu bar
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuBar* Menubar = new finalcut::FMenuBar(this);
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
// Menu bar items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* File = \
|
|
|
|
new finalcut::FMenu ("&File", Menubar);
|
2015-12-08 21:05:00 +01:00
|
|
|
File->setStatusbarMessage ("File management commands");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* Edit = \
|
|
|
|
new finalcut::FMenu ("&Edit", Menubar);
|
2015-12-08 21:05:00 +01:00
|
|
|
Edit->setStatusbarMessage ("Cut-and-paste editing commands");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* Choice = \
|
|
|
|
new finalcut::FMenu ("&Choice", Menubar);
|
2015-12-08 21:05:00 +01:00
|
|
|
Choice->setStatusbarMessage ("Choice menu");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Window = \
|
|
|
|
new finalcut::FMenuItem ("&Window", Menubar);
|
2015-12-08 21:05:00 +01:00
|
|
|
Window->setDisable();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Help = \
|
|
|
|
new finalcut::FMenuItem ("&Help", Menubar);
|
2015-12-08 21:05:00 +01:00
|
|
|
Help->setStatusbarMessage ("Show version and copyright information");
|
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
// Menu items
|
|
|
|
createFileMenuItems (File);
|
|
|
|
createEditMenuItems (Edit);
|
|
|
|
createChoiceMenuItems (Choice);
|
|
|
|
|
|
|
|
// Add default menu item callback
|
|
|
|
defaultCallback (Menubar);
|
|
|
|
|
|
|
|
// Statusbar at the bottom
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FStatusBar* Statusbar = \
|
|
|
|
new finalcut::FStatusBar (this);
|
2018-09-02 03:57:57 +02:00
|
|
|
Statusbar->setMessage("Status bar message");
|
2018-01-21 16:21:41 +01:00
|
|
|
|
|
|
|
// Headline labels
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FLabel* Headline1 = \
|
|
|
|
new finalcut::FLabel(" Key ", this);
|
2018-01-21 16:21:41 +01:00
|
|
|
Headline1->ignorePadding();
|
|
|
|
Headline1->setGeometry(3, 2, 5, 1);
|
|
|
|
Headline1->setEmphasis();
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FLabel* Headline2 = \
|
|
|
|
new finalcut::FLabel(" Function ", this);
|
2018-01-21 16:21:41 +01:00
|
|
|
Headline2->ignorePadding();
|
|
|
|
Headline2->setGeometry(19, 2, 10, 1);
|
|
|
|
Headline2->setEmphasis();
|
|
|
|
|
|
|
|
// Info label
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FLabel* Info = \
|
|
|
|
new finalcut::FLabel( "<F10> Activate menu bar\n"
|
2018-01-21 16:21:41 +01:00
|
|
|
"<Ctrl>+<Space> Activate menu bar\n"
|
2018-09-20 23:59:01 +02:00
|
|
|
"<Meta>+<X> Exit", this );
|
2018-01-21 16:21:41 +01:00
|
|
|
Info->setGeometry(2, 1, 36, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
Menu::~Menu()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createFileMenuItems (finalcut::FMenu* File)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "File" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* New = \
|
|
|
|
new finalcut::FMenuItem ("&New", File);
|
|
|
|
New->addAccelerator (finalcut::fc::Fckey_n); // Ctrl + N
|
2015-12-08 21:05:00 +01:00
|
|
|
New->setStatusbarMessage ("Create a new file");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Open = \
|
|
|
|
new finalcut::FMenuItem ("&Open...", File);
|
|
|
|
Open->addAccelerator (finalcut::fc::Fckey_o); // Ctrl + O
|
2015-12-08 21:05:00 +01:00
|
|
|
Open->setStatusbarMessage ("Locate and open a text file");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Save = \
|
|
|
|
new finalcut::FMenuItem ("&Save", File);
|
|
|
|
Save->addAccelerator (finalcut::fc::Fckey_s); // Ctrl + S
|
2015-12-08 21:05:00 +01:00
|
|
|
Save->setStatusbarMessage ("Save the file");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* SaveAs = \
|
|
|
|
new finalcut::FMenuItem ("&Save as...", File);
|
2015-12-08 21:05:00 +01:00
|
|
|
SaveAs->setStatusbarMessage ("Save the current file under a different name");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Close = \
|
|
|
|
new finalcut::FMenuItem ("&Close", File);
|
|
|
|
Close->addAccelerator (finalcut::fc::Fckey_w); // Ctrl + W
|
2015-12-08 21:05:00 +01:00
|
|
|
Close->setStatusbarMessage ("Close the current file");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Line1 = \
|
|
|
|
new finalcut::FMenuItem (File);
|
2015-12-08 21:05:00 +01:00
|
|
|
Line1->setSeparator();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Print = \
|
|
|
|
new finalcut::FMenuItem ("&Print", File);
|
|
|
|
Print->addAccelerator (finalcut::fc::Fckey_p); // Ctrl + P
|
2015-12-08 21:05:00 +01:00
|
|
|
Print->setStatusbarMessage ("Print the current file");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Line2 = \
|
|
|
|
new finalcut::FMenuItem (File);
|
2015-12-08 21:05:00 +01:00
|
|
|
Line2->setSeparator();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Quit = \
|
|
|
|
new finalcut::FMenuItem ("&Quit", File);
|
|
|
|
Quit->addAccelerator (finalcut::fc::Fmkey_x); // Meta/Alt + X
|
2015-12-08 21:05:00 +01:00
|
|
|
Quit->setStatusbarMessage ("Exit the program");
|
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
// Add quit menu item callback
|
|
|
|
Quit->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2018-09-20 23:59:01 +02:00
|
|
|
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp)
|
2018-01-21 16:21:41 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createEditMenuItems (finalcut::FMenu* Edit)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "Edit" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Undo = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_z, "&Undo", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Undo->setStatusbarMessage ("Undo the previous operation");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Redo = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_y, "&Redo", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Redo->setDisable();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Line3 = \
|
|
|
|
new finalcut::FMenuItem (Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Line3->setSeparator();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Cut = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_x, "Cu&t", Edit);
|
2017-09-11 03:06:02 +02:00
|
|
|
Cut->setStatusbarMessage ( "Remove the input text "
|
|
|
|
"and put it in the clipboard" );
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Copy = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_c, "&Copy", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Paste = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_v, "&Paste", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Paste->setStatusbarMessage ("Insert text form clipboard");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Line4 = \
|
|
|
|
new finalcut::FMenuItem (Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Line4->setSeparator();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Search = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_f, "&Search", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Search->setStatusbarMessage ("Search for text");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Next = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fkey_f3, "Search &next", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Next->setStatusbarMessage ("Repeat the last search command");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* Line5 = \
|
|
|
|
new finalcut::FMenuItem (Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
Line5->setSeparator();
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* SelectAll = \
|
|
|
|
new finalcut::FMenuItem (finalcut::fc::Fckey_a, "Select &all", Edit);
|
2015-12-08 21:05:00 +01:00
|
|
|
SelectAll->setStatusbarMessage ("Select the whole text");
|
2018-01-21 16:21:41 +01:00
|
|
|
}
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createChoiceMenuItems (finalcut::FMenu* Choice)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "Choice" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* Color = new finalcut::FMenu ("&Color", Choice);
|
2015-12-08 21:05:00 +01:00
|
|
|
Color->setStatusbarMessage ("Choose a color");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* Style = new finalcut::FMenu ("&Style", Choice);
|
2015-12-08 21:05:00 +01:00
|
|
|
Style->setStatusbarMessage ("Choose a Style");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* Border = new finalcut::FMenu ("&Border", Choice);
|
2015-12-08 21:05:00 +01:00
|
|
|
Border->setStatusbarMessage ("Choose Border");
|
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
createColorMenuItems (Color);
|
|
|
|
createStyleMenuItems (Style);
|
|
|
|
createBorderMenuItems (Border);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createColorMenuItems (finalcut::FMenu* Color)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "Color" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* Color1 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Red", Color);
|
2015-12-08 21:05:00 +01:00
|
|
|
Color1->setStatusbarMessage ("Set text red");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* Color2 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Green", Color);
|
2015-12-08 21:05:00 +01:00
|
|
|
Color2->setStatusbarMessage ("Set text green");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* Color3 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Yellow", Color);
|
2015-12-08 21:05:00 +01:00
|
|
|
Color3->setStatusbarMessage ("Set text yellow");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* Color4 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Brue", Color);
|
2015-12-08 21:05:00 +01:00
|
|
|
Color4->setStatusbarMessage ("Set text brue");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* Color5 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Black", Color);
|
2015-12-08 21:05:00 +01:00
|
|
|
Color5->setStatusbarMessage ("Set text black");
|
|
|
|
Color5->setChecked();
|
2018-01-21 16:21:41 +01:00
|
|
|
}
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createStyleMenuItems (finalcut::FMenu* Style)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "Style" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FCheckMenuItem* Bold = \
|
|
|
|
new finalcut::FCheckMenuItem ("Bold", Style);
|
2015-12-08 21:05:00 +01:00
|
|
|
Bold->setStatusbarMessage ("Set text bold");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FCheckMenuItem* Italic = \
|
|
|
|
new finalcut::FCheckMenuItem ("Italic", Style);
|
2015-12-08 21:05:00 +01:00
|
|
|
Italic->setStatusbarMessage ("Set text italic");
|
2018-01-21 16:21:41 +01:00
|
|
|
}
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createBorderMenuItems (finalcut::FMenu* Border)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "Border" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* BColor = new finalcut::FMenu ("&Color", Border);
|
2015-12-08 21:05:00 +01:00
|
|
|
BColor->setStatusbarMessage ("Choose the border color");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenu* BStyle = new finalcut::FMenu ("&Style", Border);
|
2015-12-08 21:05:00 +01:00
|
|
|
BStyle->setStatusbarMessage ("Choose the border Style");
|
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
createBorderColorMenuItems (BColor);
|
|
|
|
createBorderStyleMenuItems (BStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createBorderColorMenuItems (finalcut::FMenu* BColor)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "BColor" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* BColor1 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Red", BColor);
|
2015-12-08 21:05:00 +01:00
|
|
|
BColor1->setStatusbarMessage ("Set red border");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* BColor2 = \
|
|
|
|
new finalcut::FRadioMenuItem ("Blue", BColor);
|
2015-12-08 21:05:00 +01:00
|
|
|
BColor2->setStatusbarMessage ("Set blue border");
|
2018-01-21 16:21:41 +01:00
|
|
|
}
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2018-01-21 16:21:41 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::createBorderStyleMenuItems (finalcut::FMenu* BStyle)
|
2018-01-21 16:21:41 +01:00
|
|
|
{
|
2015-12-08 21:05:00 +01:00
|
|
|
// "BStyle" menu items
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FString line(13, wchar_t(finalcut::fc::BoxDrawingsHorizontal));
|
|
|
|
finalcut::FRadioMenuItem* BStyle1 = \
|
|
|
|
new finalcut::FRadioMenuItem (line, BStyle);
|
2015-12-08 21:05:00 +01:00
|
|
|
BStyle1->setChecked();
|
|
|
|
BStyle1->setStatusbarMessage ("Set border 1");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* BStyle2 = \
|
|
|
|
new finalcut::FRadioMenuItem ("-------------", BStyle);
|
2015-12-08 21:05:00 +01:00
|
|
|
BStyle2->setStatusbarMessage ("Set border 2");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* BStyle3 = \
|
|
|
|
new finalcut::FRadioMenuItem ("- - - - - - -", BStyle);
|
2015-12-08 21:05:00 +01:00
|
|
|
BStyle3->setStatusbarMessage ("Set border 3");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FRadioMenuItem* BStyle4 = \
|
|
|
|
new finalcut::FRadioMenuItem ("- - - - -", BStyle);
|
2015-12-08 21:05:00 +01:00
|
|
|
BStyle4->setStatusbarMessage ("Set border 4");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::defaultCallback (finalcut::FMenuList* mb)
|
2015-12-18 21:48:27 +01:00
|
|
|
{
|
2017-08-27 09:50:30 +02:00
|
|
|
for (uInt i = 1; i <= mb->getCount(); i++)
|
2015-12-18 21:48:27 +01:00
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* item = mb->getItem(int(i));
|
2015-12-18 21:48:27 +01:00
|
|
|
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( item
|
2017-11-26 22:37:18 +01:00
|
|
|
&& item->isEnabled()
|
|
|
|
&& item->acceptFocus()
|
|
|
|
&& item->isVisible()
|
|
|
|
&& ! item->isSeparator()
|
|
|
|
&& item->getText() != "&Quit" )
|
2015-12-18 21:48:27 +01:00
|
|
|
{
|
|
|
|
// Add the callback function
|
|
|
|
item->addCallback
|
|
|
|
(
|
|
|
|
"clicked",
|
2017-04-09 20:08:53 +02:00
|
|
|
F_METHOD_CALLBACK (this, &Menu::cb_message)
|
2015-12-18 21:48:27 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// Call sub-menu
|
|
|
|
if ( item->hasMenu() )
|
|
|
|
defaultCallback (item->getMenu());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void Menu::adjustSize()
|
|
|
|
{
|
|
|
|
int pw = getParentWidget()->getWidth();
|
|
|
|
int ph = getParentWidget()->getHeight();
|
|
|
|
setX (1 + (pw - getWidth()) / 2, false);
|
|
|
|
setY (1 + (ph - getHeight()) / 4, false);
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FDialog::adjustSize();
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
2015-12-08 21:05:00 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::onClose (finalcut::FCloseEvent* ev)
|
2015-12-08 21:05:00 +01:00
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
2015-12-08 21:05:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void Menu::cb_message (finalcut::FWidget* widget, data_ptr)
|
2015-12-08 21:05:00 +01:00
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMenuItem* menuitem = \
|
|
|
|
static_cast<finalcut::FMenuItem*>(widget);
|
|
|
|
finalcut::FString text = menuitem->getText();
|
2015-12-08 21:05:00 +01:00
|
|
|
text = text.replace('&', "");
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FMessageBox::info ( this
|
|
|
|
, "Info"
|
|
|
|
, "You have chosen \"" + text + "\"" );
|
2015-12-08 21:05:00 +01:00
|
|
|
}
|
|
|
|
|
2015-12-18 21:48:27 +01:00
|
|
|
|
2015-12-08 21:05:00 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// main part
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
2017-09-19 06:18:03 +02:00
|
|
|
// Create the application object
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FApplication app (argc, argv);
|
2015-12-08 21:05:00 +01:00
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Create main dialog object
|
2015-12-08 21:05:00 +01:00
|
|
|
Menu main_dlg (&app);
|
|
|
|
main_dlg.setText ("Menu example");
|
2017-08-27 09:50:30 +02:00
|
|
|
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6);
|
2015-12-08 21:05:00 +01:00
|
|
|
main_dlg.setShadow();
|
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Set dialog main_dlg as main widget
|
2015-12-08 21:05:00 +01:00
|
|
|
app.setMainWidget (&main_dlg);
|
2017-09-19 06:18:03 +02:00
|
|
|
|
|
|
|
// Show and start the application
|
2015-12-08 21:05:00 +01:00
|
|
|
main_dlg.show();
|
|
|
|
return app.exec();
|
|
|
|
}
|