2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fmessagebox.h - Widget FMessageBox (a text message window) *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-01-31 23:37:03 +01:00
|
|
|
* Copyright 2014-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/>. *
|
|
|
|
***********************************************************************/
|
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 ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FMessageBox ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FMESSAGEBOX_H
|
|
|
|
#define FMESSAGEBOX_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
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
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
#include <cstring>
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fbutton.h"
|
|
|
|
#include "final/fdialog.h"
|
|
|
|
#include "final/fterm.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FMessageBox
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FMessageBox : public FDialog
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Enumeration
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Reject = 0,
|
|
|
|
Ok = 1,
|
|
|
|
Cancel = 2,
|
|
|
|
Yes = 3,
|
|
|
|
No = 4,
|
|
|
|
Abort = 5,
|
|
|
|
Retry = 6,
|
|
|
|
Ignore = 7
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
explicit FMessageBox (FWidget* = 0);
|
|
|
|
FMessageBox (const FMessageBox&); // copy constructor
|
|
|
|
FMessageBox ( const FString&, const FString&
|
|
|
|
, int, int, int
|
|
|
|
, FWidget* = 0 );
|
|
|
|
// Destructor
|
2018-01-31 23:37:03 +01:00
|
|
|
~FMessageBox();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Assignment operator (=)
|
|
|
|
FMessageBox& operator = (const FMessageBox&);
|
|
|
|
|
|
|
|
// Accessor
|
|
|
|
const char* getClassName() const;
|
|
|
|
const FString getTitlebarText() const;
|
|
|
|
const FString getHeadline() const;
|
|
|
|
const FString getText() const;
|
|
|
|
|
|
|
|
// Mutator
|
|
|
|
void setTitlebarText (const FString&);
|
|
|
|
void setHeadline (const FString&);
|
|
|
|
bool setCenterText(bool);
|
|
|
|
bool setCenterText();
|
|
|
|
bool unsetCenterText();
|
|
|
|
void setText (const FString&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
static int info ( FWidget*
|
|
|
|
, const FString&
|
2016-11-02 00:37:58 +01:00
|
|
|
, const FString&
|
|
|
|
, int = FMessageBox::Ok
|
|
|
|
, int = 0
|
|
|
|
, int = 0 );
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
static int info ( FWidget*
|
|
|
|
, const FString&
|
|
|
|
, int
|
|
|
|
, int = FMessageBox::Ok
|
|
|
|
, int = 0
|
|
|
|
, int = 0 );
|
|
|
|
|
|
|
|
static int error ( FWidget*
|
|
|
|
, const FString&
|
|
|
|
, int = FMessageBox::Ok
|
|
|
|
, int = 0
|
|
|
|
, int = 0 );
|
|
|
|
protected:
|
|
|
|
// Method
|
|
|
|
void adjustSize();
|
|
|
|
|
|
|
|
// Callback method
|
|
|
|
void cb_processClick (FWidget*, data_ptr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Methods
|
|
|
|
void init (int, int, int);
|
2018-01-31 23:37:03 +01:00
|
|
|
void allocation (int, int, int);
|
|
|
|
void deallocation();
|
|
|
|
void initCallbacks();
|
2017-09-11 03:06:02 +02:00
|
|
|
void calculateDimensions();
|
|
|
|
virtual void draw();
|
|
|
|
void resizeButtons();
|
|
|
|
void adjustButtons();
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
FString headline_text;
|
|
|
|
FString text;
|
|
|
|
FString* text_components;
|
2017-09-20 16:56:20 +02:00
|
|
|
FStringList text_split;
|
2017-09-11 03:06:02 +02:00
|
|
|
uInt max_line_width;
|
|
|
|
bool center_text;
|
|
|
|
short emphasis_color;
|
|
|
|
uInt num_buttons;
|
|
|
|
uInt text_num_lines;
|
|
|
|
int button_digit[3];
|
|
|
|
FButton* button[3];
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FMessageBox inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FMessageBox::getClassName() const
|
|
|
|
{ return "FMessageBox"; }
|
|
|
|
|
2015-09-22 04:18:20 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const FString FMessageBox::getTitlebarText() const
|
|
|
|
{ return FDialog::getText(); }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const FString FMessageBox::getHeadline() const
|
|
|
|
{ return headline_text; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const FString FMessageBox::getText() const
|
|
|
|
{ return text; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMessageBox::setTitlebarText (const FString& txt)
|
|
|
|
{ return FDialog::setText(txt); }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMessageBox::setCenterText(bool on)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ return center_text = on; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMessageBox::setCenterText()
|
|
|
|
{ return setCenterText(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMessageBox::unsetCenterText()
|
|
|
|
{ return setCenterText(false); }
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FMESSAGEBOX_H
|