2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fdialog.h - Widget FDialog *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
|
|
|
* Copyright 2012-2017 Markus Gans *
|
|
|
|
* *
|
|
|
|
* 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/fmenuitem.h"
|
|
|
|
#include "final/ftooltip.h"
|
|
|
|
#include "final/fwindow.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FDialog
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FDialog : public FWindow
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Using-declaration
|
|
|
|
using FWindow::setResizeable;
|
|
|
|
using FWindow::move;
|
|
|
|
using FWindow::setPos;
|
|
|
|
|
|
|
|
// Enumeration
|
|
|
|
enum DialogCode
|
|
|
|
{
|
|
|
|
Reject = 0,
|
|
|
|
Accept = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
explicit FDialog (FWidget* = 0);
|
|
|
|
FDialog (const FString&, FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FDialog();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
FString getText() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
bool setDialogWidget (bool);
|
|
|
|
bool setDialogWidget();
|
|
|
|
bool unsetDialogWidget();
|
|
|
|
bool setModal (bool);
|
|
|
|
bool setModal();
|
|
|
|
bool unsetModal();
|
|
|
|
bool setResizeable (bool);
|
|
|
|
bool setScrollable (bool);
|
|
|
|
bool setScrollable();
|
|
|
|
bool unsetScrollable();
|
|
|
|
void setText (const FString&);
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isModal();
|
|
|
|
bool isScrollable();
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
int exec();
|
|
|
|
void setPos (int, int, bool = true);
|
|
|
|
void move (int, int);
|
2017-12-27 01:38:28 +01:00
|
|
|
bool moveUp (int);
|
|
|
|
bool moveDown (int);
|
|
|
|
bool moveLeft (int);
|
|
|
|
bool moveRight (int);
|
2017-09-11 03:06:02 +02:00
|
|
|
void setSize (int, int, bool = true);
|
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
|
|
|
|
void onKeyPress (FKeyEvent*);
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
void onMouseDoubleClick (FMouseEvent*);
|
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
void onWindowActive (FEvent*);
|
|
|
|
void onWindowInactive (FEvent*);
|
|
|
|
void onWindowRaised (FEvent*);
|
|
|
|
void onWindowLowered (FEvent*);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Methods
|
|
|
|
virtual void done (int);
|
|
|
|
virtual void draw();
|
|
|
|
void drawDialogShadow();
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
virtual void onShow (FShowEvent*);
|
|
|
|
virtual void onHide (FHideEvent*);
|
|
|
|
virtual void onClose (FCloseEvent*);
|
|
|
|
|
|
|
|
private:
|
2017-12-29 02:10:05 +01:00
|
|
|
// Typedef
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int mouse_x;
|
|
|
|
int mouse_y;
|
|
|
|
FPoint termPos;
|
|
|
|
int zoom_btn;
|
|
|
|
bool mouse_over_menu;
|
|
|
|
} mouseStates;
|
|
|
|
|
2017-12-27 01:38:28 +01:00
|
|
|
// Constant
|
|
|
|
static const int MENU_BTN = 3;
|
|
|
|
static const bool PRINT_WIN_NUMBER = false; // Only for debug
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Using-declaration
|
2017-09-11 03:06:02 +02:00
|
|
|
using FWidget::drawBorder;
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FDialog (const FDialog&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FDialog& operator = (const FDialog&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init();
|
2018-01-21 16:21:41 +01:00
|
|
|
void initDialogMenu();
|
2017-09-11 03:06:02 +02:00
|
|
|
virtual void drawBorder();
|
|
|
|
void drawTitleBar();
|
2017-12-27 01:38:28 +01:00
|
|
|
void drawBarButton();
|
|
|
|
void drawZoomButton();
|
|
|
|
void drawTextBar();
|
2017-09-11 03:06:02 +02:00
|
|
|
void leaveMenu();
|
|
|
|
void openMenu();
|
|
|
|
void selectFirstMenuItem();
|
|
|
|
void setZoomItem();
|
2017-12-29 02:10:05 +01:00
|
|
|
int getZoomButtonWidth();
|
|
|
|
void activateZoomButton (mouseStates&);
|
|
|
|
void deactivateZoomButton();
|
|
|
|
void leaveZoomButton (mouseStates&);
|
|
|
|
void pressZoomButton (mouseStates&);
|
|
|
|
bool isMouseOverMenu (const FPoint&);
|
|
|
|
void passEventToSubMenu (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();
|
|
|
|
void resizeMouseDown (mouseStates&);
|
|
|
|
void resizeMouseUpMove (mouseStates&, bool = false);
|
|
|
|
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
|
|
|
|
void cb_move (FWidget*, data_ptr);
|
|
|
|
void cb_zoom (FWidget*, data_ptr);
|
|
|
|
void cb_close (FWidget*, data_ptr);
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
FString tb_text; // title bar text
|
|
|
|
int result_code;
|
|
|
|
bool zoom_button_pressed;
|
|
|
|
bool zoom_button_active;
|
2017-12-27 01:38:28 +01:00
|
|
|
bool setPos_error;
|
|
|
|
bool setSize_error;
|
2017-09-11 03:06:02 +02:00
|
|
|
FPoint titlebar_click_pos;
|
|
|
|
FPoint resize_click_pos;
|
|
|
|
FRect save_geometry; // required by keyboard move/size
|
|
|
|
FMenu* dialog_menu;
|
|
|
|
FMenuItem* dgl_menuitem;
|
|
|
|
FMenuItem* move_size_item;
|
|
|
|
FMenuItem* zoom_item;
|
|
|
|
FMenuItem* close_item;
|
|
|
|
FToolTip* tooltip;
|
|
|
|
|
|
|
|
// Friend function from FMenu
|
|
|
|
friend void FMenu::hideSuperMenus();
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{ tb_text = txt; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FDialog::isModal()
|
|
|
|
{ return ((flags & fc::modal) != 0); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FDialog::isScrollable()
|
|
|
|
{ return ((flags & fc::scrollable) != 0); }
|
|
|
|
|
2015-09-22 04:18:20 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FDIALOG_H
|