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>
|
||||
* More individual arithmetic operations methods in
|
||||
the implementation of the calculator example
|
||||
|
|
|
@ -1037,7 +1037,8 @@ void Calc::onKeyPress (FKeyEvent* ev)
|
|||
else
|
||||
input = input.left(input.getLength() - 1);
|
||||
|
||||
a = lDouble(std::atof(input.c_str()));
|
||||
lDouble& x = getValue();
|
||||
x = lDouble(std::atof(input.c_str()));
|
||||
drawDispay();
|
||||
updateTerminal();
|
||||
}
|
||||
|
|
|
@ -333,6 +333,29 @@ class MyDialog : public FDialog
|
|||
//----------------------------------------------------------------------
|
||||
MyDialog::MyDialog (FWidget* 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()
|
||||
, myList()
|
||||
, clipboard()
|
||||
|
|
|
@ -111,7 +111,11 @@ class FApplication : public FWidget
|
|||
static bool eventInQueue();
|
||||
static bool removeQueuedEvent (const FObject*);
|
||||
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*);
|
||||
|
||||
// Callback method
|
||||
|
|
|
@ -122,6 +122,21 @@ class FMenu : public FWindow, public FMenuList
|
|||
void cb_menuitem_toggled (FWidget*, data_ptr);
|
||||
|
||||
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
|
||||
FMenu (const FMenu&);
|
||||
|
||||
|
@ -140,15 +155,28 @@ class FMenu : public FWindow, public FMenuList
|
|||
bool isMenu (FWidget*) const;
|
||||
bool isRadioMenuItem (FWidget*) const;
|
||||
bool isSubMenu() const;
|
||||
bool isMouseOverMenu (const FPoint&);
|
||||
bool isMouseOverSubmenu (const FPoint&);
|
||||
bool isMouseOverSuperMenu (const FPoint&);
|
||||
bool isMouseOverMenuBar (const FPoint&);
|
||||
|
||||
// Methods
|
||||
void init(FWidget*);
|
||||
void calculateDimensions();
|
||||
void adjustItems();
|
||||
int adjustX(int);
|
||||
void openSubMenu (FMenu*);
|
||||
void openSubMenu (FMenu*, bool = false);
|
||||
void closeOpenedSubMenu();
|
||||
void hideSubMenus();
|
||||
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 (int, int);
|
||||
FMenu* superMenuAt (const FPoint&);
|
||||
|
@ -174,7 +202,8 @@ class FMenu : public FWindow, public FMenuList
|
|||
// Data Members
|
||||
FMenuItem* item;
|
||||
FWidget* super_menu;
|
||||
FMenu* open_sub_menu;
|
||||
FMenu* opened_sub_menu;
|
||||
FMenu* shown_sub_menu;
|
||||
uInt max_item_width;
|
||||
bool mouse_down;
|
||||
bool has_checkable_items;
|
||||
|
|
|
@ -329,8 +329,11 @@ class FTerm
|
|||
static FPoint& getMousePos();
|
||||
static void setMousePos (const FPoint&);
|
||||
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
|
||||
static int stdin_no;
|
||||
static int stdout_no;
|
||||
|
@ -352,17 +355,15 @@ class FTerm
|
|||
static struct initializationValues
|
||||
{
|
||||
public:
|
||||
initializationValues()
|
||||
: terminal_detection(true)
|
||||
, cursor_optimisation(true)
|
||||
, color_change(true)
|
||||
, vgafont(false)
|
||||
, newfont(false)
|
||||
, encoding(fc::UNKNOWN)
|
||||
{ }
|
||||
|
||||
~initializationValues()
|
||||
{ }
|
||||
void setDefault()
|
||||
{
|
||||
terminal_detection = true;
|
||||
cursor_optimisation = true;
|
||||
color_change = true;
|
||||
vgafont = false;
|
||||
newfont = false;
|
||||
encoding = fc::UNKNOWN;
|
||||
}
|
||||
|
||||
uInt8 terminal_detection : 1;
|
||||
uInt8 cursor_optimisation : 1;
|
||||
|
|
|
@ -318,6 +318,7 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
|||
showParameterUsage();
|
||||
}
|
||||
|
||||
init_values.setDefault();
|
||||
cmd_options (argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
@ -753,7 +754,7 @@ inline void FApplication::sendKeyboardAccelerator()
|
|||
//----------------------------------------------------------------------
|
||||
void FApplication::processKeyboardEvent()
|
||||
{
|
||||
bool isKeyPressed = false;
|
||||
bool isKeyPressed;
|
||||
FWidget* widget = findKeyboardWidget();
|
||||
keyboardBufferTimeout(widget);
|
||||
flush_out();
|
||||
|
|
|
@ -1251,12 +1251,13 @@ void FListBox::drawList()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::drawListLine ( int y, listBoxItems::iterator iter
|
||||
, bool serach_mark )
|
||||
inline void FListBox::drawListLine ( int y
|
||||
, listBoxItems::iterator iter
|
||||
, bool serach_mark )
|
||||
{
|
||||
uInt i, len;
|
||||
uInt inc_len = inc_search.getLength();
|
||||
bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current));
|
||||
bool isCurrentLine = bool(y + yoffset + 1 == current);
|
||||
FString element;
|
||||
element = getString(iter).mid ( uInt(1 + xoffset)
|
||||
, 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
|
||||
, bool serach_mark )
|
||||
inline void FListBox::drawListBracketsLine ( int y
|
||||
, listBoxItems::iterator iter
|
||||
, bool serach_mark )
|
||||
{
|
||||
int full_length;
|
||||
FString element;
|
||||
|
@ -1301,7 +1303,7 @@ inline void FListBox::drawListBracketsLine ( int y, listBoxItems::iterator iter
|
|||
, inc_len = inc_search.getLength()
|
||||
, i = 0
|
||||
, b = 0;
|
||||
bool isCurrentLine = bool(y + uInt(yoffset) + 1 == uInt(current));
|
||||
bool isCurrentLine = bool(y + yoffset + 1 == current);
|
||||
|
||||
if ( isMonochron() && isCurrentLine )
|
||||
print ('>');
|
||||
|
@ -1408,7 +1410,7 @@ inline void FListBox::setLineAttributes ( int y
|
|||
, bool& serach_mark )
|
||||
{
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
case fc::ASCII:
|
||||
default:
|
||||
case fc::UNKNOWN:
|
||||
case fc::NUM_OF_ENCODINGS:
|
||||
Fputchar = &FTerm::putchar_ASCII;
|
||||
}
|
||||
|
||||
|
@ -1913,7 +1914,7 @@ void FTerm::exitWithMessage (std::string message)
|
|||
if ( exit_message[0] )
|
||||
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
|
||||
|
||||
term_area*& vt = vterm;
|
||||
bool& ut = FTermcap::background_color_erase;
|
||||
char*& cb = TCAP(fc::t_clr_bol);
|
||||
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;
|
||||
bool normal = isNormal(first_char);
|
||||
bool& ut = FTermcap::background_color_erase;
|
||||
|
||||
for (uInt x = 1; x < uInt(vt->width); x++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue