Refactoring of the FMenu mouse event handler
This commit is contained in:
parent
a173f2bc1e
commit
fd75f5af42
|
@ -1,3 +1,6 @@
|
||||||
|
2017-12-10 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Refactoring of the FMenu mouse event handler
|
||||||
|
|
||||||
2017-12-08 Markus Gans <guru.mail@muenster.de>
|
2017-12-08 Markus Gans <guru.mail@muenster.de>
|
||||||
* More individual arithmetic operations methods in
|
* More individual arithmetic operations methods in
|
||||||
the implementation of the calculator example
|
the implementation of the calculator example
|
||||||
|
|
|
@ -1037,7 +1037,8 @@ void Calc::onKeyPress (FKeyEvent* ev)
|
||||||
else
|
else
|
||||||
input = input.left(input.getLength() - 1);
|
input = input.left(input.getLength() - 1);
|
||||||
|
|
||||||
a = lDouble(std::atof(input.c_str()));
|
lDouble& x = getValue();
|
||||||
|
x = lDouble(std::atof(input.c_str()));
|
||||||
drawDispay();
|
drawDispay();
|
||||||
updateTerminal();
|
updateTerminal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,6 +333,29 @@ class MyDialog : public FDialog
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
MyDialog::MyDialog (FWidget* parent)
|
MyDialog::MyDialog (FWidget* parent)
|
||||||
: FDialog(parent)
|
: FDialog(parent)
|
||||||
|
, Open()
|
||||||
|
, Quit()
|
||||||
|
, File1()
|
||||||
|
, File2()
|
||||||
|
, File3()
|
||||||
|
, Cut()
|
||||||
|
, Copy()
|
||||||
|
, Paste()
|
||||||
|
, Clear()
|
||||||
|
, Env()
|
||||||
|
, Drive()
|
||||||
|
, Help()
|
||||||
|
, key_F1()
|
||||||
|
, key_F2()
|
||||||
|
, key_F3()
|
||||||
|
, MyButton1()
|
||||||
|
, MyButton2()
|
||||||
|
, MyButton3()
|
||||||
|
, MyButton4()
|
||||||
|
, MyButton5()
|
||||||
|
, MyButton6()
|
||||||
|
, radio1()
|
||||||
|
, tagged_count()
|
||||||
, myLineEdit()
|
, myLineEdit()
|
||||||
, myList()
|
, myList()
|
||||||
, clipboard()
|
, clipboard()
|
||||||
|
|
|
@ -111,7 +111,11 @@ class FApplication : public FWidget
|
||||||
static bool eventInQueue();
|
static bool eventInQueue();
|
||||||
static bool removeQueuedEvent (const FObject*);
|
static bool removeQueuedEvent (const FObject*);
|
||||||
static FWidget* processParameters (const int&, char*[]);
|
static FWidget* processParameters (const int&, char*[]);
|
||||||
static void showParameterUsage ();
|
static void showParameterUsage ()
|
||||||
|
#if defined(__clang__) || defined(__GNUC__)
|
||||||
|
__attribute__((noreturn))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
static void closeConfirmationDialog (FWidget*, FCloseEvent*);
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
|
|
|
@ -122,6 +122,21 @@ class FMenu : public FWindow, public FMenuList
|
||||||
void cb_menuitem_toggled (FWidget*, data_ptr);
|
void cb_menuitem_toggled (FWidget*, data_ptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Typedef
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uChar focus_changed : 1;
|
||||||
|
uChar hide_sub_menu : 1;
|
||||||
|
uChar mouse_over_menu : 1;
|
||||||
|
uChar mouse_over_submenu : 1;
|
||||||
|
uChar mouse_over_supermenu : 1;
|
||||||
|
uChar mouse_over_menubar : 1;
|
||||||
|
uChar : 2; // padding bits
|
||||||
|
} mouseStates;
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
static const bool SELECT_ITEM = true;
|
||||||
|
|
||||||
// Disable copy constructor
|
// Disable copy constructor
|
||||||
FMenu (const FMenu&);
|
FMenu (const FMenu&);
|
||||||
|
|
||||||
|
@ -140,15 +155,28 @@ class FMenu : public FWindow, public FMenuList
|
||||||
bool isMenu (FWidget*) const;
|
bool isMenu (FWidget*) const;
|
||||||
bool isRadioMenuItem (FWidget*) const;
|
bool isRadioMenuItem (FWidget*) const;
|
||||||
bool isSubMenu() const;
|
bool isSubMenu() const;
|
||||||
|
bool isMouseOverMenu (const FPoint&);
|
||||||
|
bool isMouseOverSubmenu (const FPoint&);
|
||||||
|
bool isMouseOverSuperMenu (const FPoint&);
|
||||||
|
bool isMouseOverMenuBar (const FPoint&);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void init(FWidget*);
|
void init(FWidget*);
|
||||||
void calculateDimensions();
|
void calculateDimensions();
|
||||||
void adjustItems();
|
void adjustItems();
|
||||||
int adjustX(int);
|
int adjustX(int);
|
||||||
void openSubMenu (FMenu*);
|
void openSubMenu (FMenu*, bool = false);
|
||||||
|
void closeOpenedSubMenu();
|
||||||
void hideSubMenus();
|
void hideSubMenus();
|
||||||
void hideSuperMenus();
|
void hideSuperMenus();
|
||||||
|
bool mouseDownOverList (FPoint);
|
||||||
|
bool mouseUpOverList (FPoint);
|
||||||
|
bool mouseMoveOverList (FPoint, mouseStates&);
|
||||||
|
void mouseUpOverBorder();
|
||||||
|
void mouseMoveOverBorder (mouseStates&);
|
||||||
|
void passEventToSubMenu (FMouseEvent*& ev);
|
||||||
|
void passEventToSuperMenu (FMouseEvent*& ev);
|
||||||
|
void passEventToMenuBar (FMouseEvent*& ev);
|
||||||
bool containsMenuStructure (const FPoint&);
|
bool containsMenuStructure (const FPoint&);
|
||||||
bool containsMenuStructure (int, int);
|
bool containsMenuStructure (int, int);
|
||||||
FMenu* superMenuAt (const FPoint&);
|
FMenu* superMenuAt (const FPoint&);
|
||||||
|
@ -174,7 +202,8 @@ class FMenu : public FWindow, public FMenuList
|
||||||
// Data Members
|
// Data Members
|
||||||
FMenuItem* item;
|
FMenuItem* item;
|
||||||
FWidget* super_menu;
|
FWidget* super_menu;
|
||||||
FMenu* open_sub_menu;
|
FMenu* opened_sub_menu;
|
||||||
|
FMenu* shown_sub_menu;
|
||||||
uInt max_item_width;
|
uInt max_item_width;
|
||||||
bool mouse_down;
|
bool mouse_down;
|
||||||
bool has_checkable_items;
|
bool has_checkable_items;
|
||||||
|
|
|
@ -329,8 +329,11 @@ class FTerm
|
||||||
static FPoint& getMousePos();
|
static FPoint& getMousePos();
|
||||||
static void setMousePos (const FPoint&);
|
static void setMousePos (const FPoint&);
|
||||||
static void setMousePos (short, short);
|
static void setMousePos (short, short);
|
||||||
static void exitWithMessage (std::string);
|
static void exitWithMessage (std::string)
|
||||||
|
#if defined(__clang__) || defined(__GNUC__)
|
||||||
|
__attribute__((noreturn))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
// Data Members
|
// Data Members
|
||||||
static int stdin_no;
|
static int stdin_no;
|
||||||
static int stdout_no;
|
static int stdout_no;
|
||||||
|
@ -352,17 +355,15 @@ class FTerm
|
||||||
static struct initializationValues
|
static struct initializationValues
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
initializationValues()
|
void setDefault()
|
||||||
: terminal_detection(true)
|
{
|
||||||
, cursor_optimisation(true)
|
terminal_detection = true;
|
||||||
, color_change(true)
|
cursor_optimisation = true;
|
||||||
, vgafont(false)
|
color_change = true;
|
||||||
, newfont(false)
|
vgafont = false;
|
||||||
, encoding(fc::UNKNOWN)
|
newfont = false;
|
||||||
{ }
|
encoding = fc::UNKNOWN;
|
||||||
|
}
|
||||||
~initializationValues()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
uInt8 terminal_detection : 1;
|
uInt8 terminal_detection : 1;
|
||||||
uInt8 cursor_optimisation : 1;
|
uInt8 cursor_optimisation : 1;
|
||||||
|
|
|
@ -318,6 +318,7 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
||||||
showParameterUsage();
|
showParameterUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_values.setDefault();
|
||||||
cmd_options (argc, argv);
|
cmd_options (argc, argv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -753,7 +754,7 @@ inline void FApplication::sendKeyboardAccelerator()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::processKeyboardEvent()
|
void FApplication::processKeyboardEvent()
|
||||||
{
|
{
|
||||||
bool isKeyPressed = false;
|
bool isKeyPressed;
|
||||||
FWidget* widget = findKeyboardWidget();
|
FWidget* widget = findKeyboardWidget();
|
||||||
keyboardBufferTimeout(widget);
|
keyboardBufferTimeout(widget);
|
||||||
flush_out();
|
flush_out();
|
||||||
|
|
|
@ -1251,12 +1251,13 @@ void FListBox::drawList()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBox::drawListLine ( int y, listBoxItems::iterator iter
|
inline void FListBox::drawListLine ( int y
|
||||||
, bool serach_mark )
|
, listBoxItems::iterator iter
|
||||||
|
, bool serach_mark )
|
||||||
{
|
{
|
||||||
uInt i, len;
|
uInt i, len;
|
||||||
uInt inc_len = inc_search.getLength();
|
uInt inc_len = inc_search.getLength();
|
||||||
bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current));
|
bool isCurrentLine = bool(y + yoffset + 1 == current);
|
||||||
FString element;
|
FString element;
|
||||||
element = getString(iter).mid ( uInt(1 + xoffset)
|
element = getString(iter).mid ( uInt(1 + xoffset)
|
||||||
, uInt(getWidth() - nf_offset - 4) );
|
, uInt(getWidth() - nf_offset - 4) );
|
||||||
|
@ -1292,8 +1293,9 @@ inline void FListBox::drawListLine ( int y, listBoxItems::iterator iter
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FListBox::drawListBracketsLine ( int y, listBoxItems::iterator iter
|
inline void FListBox::drawListBracketsLine ( int y
|
||||||
, bool serach_mark )
|
, listBoxItems::iterator iter
|
||||||
|
, bool serach_mark )
|
||||||
{
|
{
|
||||||
int full_length;
|
int full_length;
|
||||||
FString element;
|
FString element;
|
||||||
|
@ -1301,7 +1303,7 @@ inline void FListBox::drawListBracketsLine ( int y, listBoxItems::iterator iter
|
||||||
, inc_len = inc_search.getLength()
|
, inc_len = inc_search.getLength()
|
||||||
, i = 0
|
, i = 0
|
||||||
, b = 0;
|
, b = 0;
|
||||||
bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current));
|
bool isCurrentLine = bool(y + yoffset + 1 == current);
|
||||||
|
|
||||||
if ( isMonochron() && isCurrentLine )
|
if ( isMonochron() && isCurrentLine )
|
||||||
print ('>');
|
print ('>');
|
||||||
|
@ -1408,7 +1410,7 @@ inline void FListBox::setLineAttributes ( int y
|
||||||
, bool& serach_mark )
|
, bool& serach_mark )
|
||||||
{
|
{
|
||||||
bool isFocus = ((flags & fc::focus) != 0)
|
bool isFocus = ((flags & fc::focus) != 0)
|
||||||
, isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current));
|
, isCurrentLine = bool(y + yoffset + 1 == current);
|
||||||
uInt inc_len = inc_search.getLength();
|
uInt inc_len = inc_search.getLength();
|
||||||
|
|
||||||
setPrintPos (2, 2 + int(y));
|
setPrintPos (2, 2 + int(y));
|
||||||
|
|
885
src/fmenu.cpp
885
src/fmenu.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1480,7 +1480,8 @@ void FTerm::setEncoding (fc::encoding enc)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case fc::ASCII:
|
case fc::ASCII:
|
||||||
default:
|
case fc::UNKNOWN:
|
||||||
|
case fc::NUM_OF_ENCODINGS:
|
||||||
Fputchar = &FTerm::putchar_ASCII;
|
Fputchar = &FTerm::putchar_ASCII;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1913,7 +1914,7 @@ void FTerm::exitWithMessage (std::string message)
|
||||||
if ( exit_message[0] )
|
if ( exit_message[0] )
|
||||||
std::fprintf (stderr, "Warning: %s\n", exit_message);
|
std::fprintf (stderr, "Warning: %s\n", exit_message);
|
||||||
|
|
||||||
exit (EXIT_FAILURE);
|
std::exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2373,7 +2373,6 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
|
||||||
// => clear from xmin to beginning of line
|
// => clear from xmin to beginning of line
|
||||||
|
|
||||||
term_area*& vt = vterm;
|
term_area*& vt = vterm;
|
||||||
bool& ut = FTermcap::background_color_erase;
|
|
||||||
char*& cb = TCAP(fc::t_clr_bol);
|
char*& cb = TCAP(fc::t_clr_bol);
|
||||||
char_data* first_char = &vt->text[y * uInt(vt->width)];
|
char_data* first_char = &vt->text[y * uInt(vt->width)];
|
||||||
|
|
||||||
|
@ -2381,6 +2380,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
|
||||||
{
|
{
|
||||||
uInt leading_whitespace = 1;
|
uInt leading_whitespace = 1;
|
||||||
bool normal = isNormal(first_char);
|
bool normal = isNormal(first_char);
|
||||||
|
bool& ut = FTermcap::background_color_erase;
|
||||||
|
|
||||||
for (uInt x = 1; x < uInt(vt->width); x++)
|
for (uInt x = 1; x < uInt(vt->width); x++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue