2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fdialog.h - Widget FDialog *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2019-01-21 03:42:18 +01:00
|
|
|
* Copyright 2012-2019 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/>. *
|
|
|
|
***********************************************************************/
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
/* Inheritance diagram
|
|
|
|
* ═══════════════════
|
|
|
|
*
|
2017-10-29 14:27:50 +01:00
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTerm ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
2017-10-02 07:32:33 +02:00
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
2017-10-29 14:27:50 +01:00
|
|
|
* ▕ FVTerm ▏ ▕ FObject ▏
|
2017-10-02 07:32:33 +02:00
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲ ▲
|
|
|
|
* │ │
|
|
|
|
* └─────┬─────┘
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FWidget ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FWindow ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FDialog ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FDIALOG_H
|
|
|
|
#define FDIALOG_H
|
2017-10-31 00:41:59 +01:00
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fmenu.h"
|
|
|
|
#include "final/fwindow.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2019-07-21 23:31:21 +02:00
|
|
|
// class forward declaration
|
|
|
|
class FToolTip;
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FDialog
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FDialog : public FWindow
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Using-declaration
|
|
|
|
using FWindow::setResizeable;
|
|
|
|
|
|
|
|
// Enumeration
|
|
|
|
enum DialogCode
|
|
|
|
{
|
|
|
|
Reject = 0,
|
|
|
|
Accept = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constructors
|
2018-12-10 01:48:26 +01:00
|
|
|
explicit FDialog (FWidget* = nullptr);
|
|
|
|
explicit FDialog (const FString&, FWidget* = nullptr);
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2018-12-09 22:04:55 +01:00
|
|
|
// Disable copy constructor
|
|
|
|
FDialog (const FDialog&) = delete;
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Destructor
|
|
|
|
virtual ~FDialog();
|
|
|
|
|
2018-12-09 22:04:55 +01:00
|
|
|
// Disable assignment operator (=)
|
|
|
|
FDialog& operator = (const FDialog&) = delete;
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Accessors
|
2019-08-06 23:45:28 +02:00
|
|
|
const char* getClassName() const override;
|
2017-09-11 03:06:02 +02:00
|
|
|
FString getText() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
bool setDialogWidget (bool);
|
|
|
|
bool setDialogWidget();
|
|
|
|
bool unsetDialogWidget();
|
|
|
|
bool setModal (bool);
|
|
|
|
bool setModal();
|
|
|
|
bool unsetModal();
|
2019-08-06 23:45:28 +02:00
|
|
|
bool setResizeable (bool) override;
|
2017-09-11 03:06:02 +02:00
|
|
|
bool setScrollable (bool);
|
|
|
|
bool setScrollable();
|
|
|
|
bool unsetScrollable();
|
|
|
|
void setText (const FString&);
|
|
|
|
|
|
|
|
// Inquiries
|
2019-09-01 23:29:27 +02:00
|
|
|
bool isModal() const;
|
|
|
|
bool isScrollable() const;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Methods
|
2019-08-06 23:45:28 +02:00
|
|
|
void show() override;
|
|
|
|
void hide() override;
|
2018-12-09 18:24:31 +01:00
|
|
|
int exec();
|
2019-08-06 23:45:28 +02:00
|
|
|
void setPos (const FPoint&, bool = true) override;
|
|
|
|
void move (const FPoint&) override;
|
2017-12-27 01:38:28 +01:00
|
|
|
bool moveUp (int);
|
|
|
|
bool moveDown (int);
|
|
|
|
bool moveLeft (int);
|
|
|
|
bool moveRight (int);
|
2019-08-06 23:45:28 +02:00
|
|
|
void setSize (const FSize&, bool = true) override;
|
2017-12-27 01:38:28 +01:00
|
|
|
bool reduceHeight (int);
|
|
|
|
bool expandHeight (int);
|
|
|
|
bool reduceWidth (int);
|
|
|
|
bool expandWidth (int);
|
2017-09-11 03:06:02 +02:00
|
|
|
void activateDialog();
|
|
|
|
|
|
|
|
// Event handlers
|
2019-08-06 23:45:28 +02:00
|
|
|
void onKeyPress (FKeyEvent*) override;
|
|
|
|
void onMouseDown (FMouseEvent*) override;
|
|
|
|
void onMouseUp (FMouseEvent*) override;
|
|
|
|
void onMouseMove (FMouseEvent*) override;
|
|
|
|
void onMouseDoubleClick (FMouseEvent*) override;
|
|
|
|
void onAccel (FAccelEvent*) override;
|
|
|
|
void onWindowActive (FEvent*) override;
|
|
|
|
void onWindowInactive (FEvent*) override;
|
|
|
|
void onWindowRaised (FEvent*) override;
|
|
|
|
void onWindowLowered (FEvent*) override;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Methods
|
2018-12-09 18:24:31 +01:00
|
|
|
virtual void done (int);
|
2019-08-06 23:45:28 +02:00
|
|
|
void draw() override;
|
2017-09-11 03:06:02 +02:00
|
|
|
void drawDialogShadow();
|
|
|
|
|
|
|
|
// Event handlers
|
2019-08-06 23:45:28 +02:00
|
|
|
void onShow (FShowEvent*) override;
|
|
|
|
void onHide (FHideEvent*) override;
|
|
|
|
void onClose (FCloseEvent*) override;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
private:
|
2017-12-29 02:10:05 +01:00
|
|
|
// Typedef
|
|
|
|
typedef struct
|
|
|
|
{
|
2018-10-14 06:25:33 +02:00
|
|
|
int mouse_x;
|
|
|
|
int mouse_y;
|
|
|
|
FPoint termPos;
|
|
|
|
std::size_t zoom_btn;
|
|
|
|
bool mouse_over_menu;
|
2017-12-29 02:10:05 +01:00
|
|
|
} mouseStates;
|
|
|
|
|
2017-12-27 01:38:28 +01:00
|
|
|
// Constant
|
2018-12-26 23:41:49 +01:00
|
|
|
static constexpr std::size_t MENU_BTN = 3;
|
|
|
|
static constexpr bool PRINT_WIN_NUMBER = false; // Only for debug
|
2017-12-27 01:38:28 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Methods
|
|
|
|
void init();
|
2018-01-21 16:21:41 +01:00
|
|
|
void initDialogMenu();
|
2018-02-18 22:45:49 +01:00
|
|
|
void initMoveSizeMenuItem (FMenu*);
|
|
|
|
void initZoomMenuItem (FMenu*);
|
|
|
|
void initCloseMenuItem (FMenu*);
|
2019-08-06 23:45:28 +02:00
|
|
|
void drawBorder() override;
|
2017-09-11 03:06:02 +02:00
|
|
|
void drawTitleBar();
|
2017-12-27 01:38:28 +01:00
|
|
|
void drawBarButton();
|
|
|
|
void drawZoomButton();
|
2018-02-24 19:19:28 +01:00
|
|
|
void drawRestoreSizeButton();
|
|
|
|
void drawZoomedButton();
|
2017-12-27 01:38:28 +01:00
|
|
|
void drawTextBar();
|
2018-01-31 00:17:00 +01:00
|
|
|
void restoreOverlaidWindows();
|
|
|
|
void setCursorToFocusWidget();
|
2017-09-11 03:06:02 +02:00
|
|
|
void leaveMenu();
|
|
|
|
void openMenu();
|
|
|
|
void selectFirstMenuItem();
|
|
|
|
void setZoomItem();
|
2018-10-14 06:25:33 +02:00
|
|
|
std::size_t getZoomButtonWidth();
|
2018-12-28 22:57:43 +01:00
|
|
|
void activateZoomButton (const mouseStates&);
|
2017-12-29 02:10:05 +01:00
|
|
|
void deactivateZoomButton();
|
2018-12-28 22:57:43 +01:00
|
|
|
void leaveZoomButton (const mouseStates&);
|
|
|
|
void pressZoomButton (const mouseStates&);
|
2017-12-29 02:10:05 +01:00
|
|
|
bool isMouseOverMenu (const FPoint&);
|
2018-12-28 22:57:43 +01:00
|
|
|
void passEventToSubMenu (const mouseStates&, FMouseEvent*);
|
2017-12-27 01:38:28 +01:00
|
|
|
void moveSizeKey (FKeyEvent*);
|
2017-12-29 02:10:05 +01:00
|
|
|
void raiseActivateDialog();
|
|
|
|
void lowerActivateDialog();
|
2019-01-24 00:23:00 +01:00
|
|
|
bool isOutsideTerminal (const FPoint&);
|
2018-12-28 22:57:43 +01:00
|
|
|
bool isLowerRightResizeCorner (const mouseStates&);
|
|
|
|
void resizeMouseDown (const mouseStates&);
|
|
|
|
void resizeMouseUpMove (const mouseStates&, bool = false);
|
2017-12-29 02:10:05 +01:00
|
|
|
void cancelMouseResize();
|
2017-12-27 01:38:28 +01:00
|
|
|
void acceptMoveSize();
|
|
|
|
void cancelMoveSize();
|
2017-09-11 03:06:02 +02:00
|
|
|
static void addDialog (FWidget*);
|
|
|
|
static void delDialog (FWidget*);
|
|
|
|
|
|
|
|
// Callback methods
|
2018-12-27 00:14:46 +01:00
|
|
|
void cb_move (FWidget*, FDataPtr);
|
|
|
|
void cb_zoom (FWidget*, FDataPtr);
|
|
|
|
void cb_close (FWidget*, FDataPtr);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2018-12-03 03:22:36 +01:00
|
|
|
FString tb_text{}; // title bar text
|
2018-12-09 18:24:31 +01:00
|
|
|
int result_code{FDialog::Reject};
|
2018-12-03 03:22:36 +01:00
|
|
|
bool zoom_button_pressed{false};
|
|
|
|
bool zoom_button_active{false};
|
|
|
|
bool setPos_error{false};
|
|
|
|
bool setSize_error{false};
|
|
|
|
FPoint titlebar_click_pos{};
|
|
|
|
FPoint resize_click_pos{};
|
|
|
|
FRect save_geometry{}; // required by keyboard move/size
|
2018-12-10 01:48:26 +01:00
|
|
|
FMenu* dialog_menu{nullptr};
|
|
|
|
FMenuItem* dgl_menuitem{nullptr};
|
|
|
|
FMenuItem* move_size_item{nullptr};
|
|
|
|
FMenuItem* zoom_item{nullptr};
|
|
|
|
FMenuItem* close_item{nullptr};
|
|
|
|
FToolTip* tooltip{nullptr};
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Friend function from FMenu
|
|
|
|
friend void FMenu::hideSuperMenus();
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// FDialog inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FDialog::getClassName() const
|
|
|
|
{ return "FDialog"; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FDialog::getText() const
|
|
|
|
{ return tb_text; }
|
|
|
|
|
2016-09-25 23:53:48 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::setDialogWidget()
|
|
|
|
{ return setDialogWidget(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::unsetDialogWidget()
|
|
|
|
{ return setDialogWidget(false); }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::setModal()
|
|
|
|
{ return setModal(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::unsetModal()
|
|
|
|
{ return setModal(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::setScrollable()
|
|
|
|
{ return setScrollable(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::unsetScrollable()
|
|
|
|
{ return setScrollable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline void FDialog::setText (const FString& txt)
|
2019-08-25 22:16:00 +02:00
|
|
|
{ tb_text.setString(txt); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-09-01 23:29:27 +02:00
|
|
|
inline bool FDialog::isModal() const
|
|
|
|
{ return getFlags().modal; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-09-01 23:29:27 +02:00
|
|
|
inline bool FDialog::isScrollable() const
|
|
|
|
{ return getFlags().scrollable; }
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FDIALOG_H
|