2015-09-25 21:37:19 +02:00
|
|
|
// File: fdialog.h
|
|
|
|
// Provides: class FDialog
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
2016-10-11 04:57:36 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWindow ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FDialog ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#ifndef _FDIALOG_H
|
|
|
|
#define _FDIALOG_H
|
|
|
|
|
2016-06-12 23:06:58 +02:00
|
|
|
#include "fmenu.h"
|
|
|
|
#include "fmenuitem.h"
|
2016-10-01 23:18:49 +02:00
|
|
|
#include "ftooltip.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
#include "fwindow.h"
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FDialog
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FDialog : public FWindow
|
|
|
|
{
|
|
|
|
public:
|
2016-11-02 00:37:58 +01:00
|
|
|
// Using-declaration
|
|
|
|
using FWindow::setResizeable;
|
|
|
|
using FWindow::move;
|
|
|
|
using FWindow::setPos;
|
|
|
|
|
|
|
|
// Enumeration
|
2015-05-23 13:35:12 +02:00
|
|
|
enum DialogCode
|
|
|
|
{
|
|
|
|
Reject = 0,
|
|
|
|
Accept = 1
|
|
|
|
};
|
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Constructors
|
|
|
|
explicit FDialog (FWidget* = 0);
|
|
|
|
FDialog (const FString&, FWidget* = 0);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Destructor
|
|
|
|
virtual ~FDialog();
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Accessors
|
2015-05-23 13:35:12 +02:00
|
|
|
virtual const char* getClassName() const;
|
2016-11-02 00:37:58 +01:00
|
|
|
FString getText() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
bool setFocus (bool);
|
|
|
|
bool setFocus();
|
|
|
|
bool unsetFocus();
|
|
|
|
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);
|
|
|
|
void setSize (int, int, bool = true);
|
|
|
|
void activateDialog();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Event handlers
|
2016-11-02 00:37:58 +01:00
|
|
|
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*);
|
2016-06-13 22:44:15 +02:00
|
|
|
|
|
|
|
private:
|
2016-11-02 00:37:58 +01:00
|
|
|
// Using-declaration
|
|
|
|
using FWidget::drawBorder;
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FDialog (const FDialog&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FDialog& operator = (const FDialog&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init();
|
|
|
|
virtual void drawBorder();
|
|
|
|
void drawTitleBar();
|
|
|
|
void leaveMenu();
|
|
|
|
void openMenu();
|
|
|
|
void selectFirstMenuItem();
|
|
|
|
void setZoomItem();
|
|
|
|
static void addDialog (FWidget*);
|
|
|
|
static void delDialog (FWidget*);
|
|
|
|
|
|
|
|
// Callback methods
|
2017-02-24 00:30:07 +01:00
|
|
|
void cb_move (FWidget*, data_ptr);
|
|
|
|
void cb_zoom (FWidget*, data_ptr);
|
|
|
|
void cb_close (FWidget*, data_ptr);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// Data Members
|
|
|
|
FString tb_text; // title bar text
|
|
|
|
int result_code;
|
|
|
|
bool zoom_button_pressed;
|
|
|
|
bool zoom_button_active;
|
|
|
|
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;
|
|
|
|
|
2016-10-01 23:18:49 +02:00
|
|
|
// 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; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::setFocus()
|
|
|
|
{ return setFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FDialog::unsetFocus()
|
|
|
|
{ return setFocus(false); }
|
|
|
|
|
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
|
|
|
|
|
|
|
#endif // _FDIALOG_H
|