diff --git a/ChangeLog b/ChangeLog index bab12076..12c4388b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ +2015-09-20 Markus Gans + * Some code optimizations + 2015-09-18 Markus Gans - * fixed compile error on 32-bit architectures + * Fixed compile error on 32-bit architectures 2015-08-08 Markus Gans * Bug fix in FDialog (use GlobalPos to move) diff --git a/src/Makefile.clang b/src/Makefile.clang index 8c5e63a8..33483b5f 100644 --- a/src/Makefile.clang +++ b/src/Makefile.clang @@ -85,7 +85,7 @@ endif # $@ = name of the targets # $< = the first dependency .cpp.o: - $(CXX) -c $(CCXFLAGS) -fpic -o $@ $< + $(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $< all: dep $(OBJS) $(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS) @@ -125,7 +125,7 @@ clean: $(RM) $(LIB)* $(OBJS) .depend *.gch *.plist *~ dep: - $(CXX) -MM *.cpp >.depend + $(CXX) $(INCLUDES) -MM *.cpp >.depend # # include .depend if it exists diff --git a/src/Makefile.gcc b/src/Makefile.gcc index 7463cf2d..cdae9263 100644 --- a/src/Makefile.gcc +++ b/src/Makefile.gcc @@ -85,7 +85,7 @@ endif # $@ = name of the targets # $< = the first dependency .cpp.o: - $(CXX) -c $(CCXFLAGS) -fpic -o $@ $< + $(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $< all: dep $(OBJS) $(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS) @@ -125,7 +125,7 @@ clean: $(RM) $(LIB)* $(OBJS) .depend *.prof *~ dep: - $(CXX) -MM *.cpp >.depend + $(CXX) $(INCLUDES) -MM *.cpp >.depend # # include .depend if it exists diff --git a/src/fapp.cpp b/src/fapp.cpp index e9daa1e3..0ceffec9 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -27,7 +27,7 @@ std::deque* FApplication::event_queue = 0; // constructors and destructor //---------------------------------------------------------------------- -FApplication::FApplication (int &argc, char* argv[]) +FApplication::FApplication (int &_argc, char* _argv[]) { assert ( ! rootObj && "FApplication: There should be only one application object" ); @@ -35,13 +35,13 @@ FApplication::FApplication (int &argc, char* argv[]) rootObj = this; static char* empty = const_cast(""); - if ( argc == 0 || argv == 0 ) + if ( _argc == 0 || _argv == 0 ) { - argc = 0; - argv = ∅ + _argc = 0; + _argv = ∅ } - init(argc, argv); + init(_argc, _argv); } //---------------------------------------------------------------------- @@ -57,10 +57,10 @@ FApplication::~FApplication() // destructor // private methods of FApplication //---------------------------------------------------------------------- -void FApplication::init (int argc, char* argv[]) +void FApplication::init (int _argc, char* _argv[]) { - app_argc = argc; - app_argv = argv; + app_argc = _argc; + app_argv = _argv; // init keyboard values key = 0; @@ -222,8 +222,12 @@ void FApplication::processKeyboardEvent() case mouse_event: gpmMouseEvent = true; break; + case keyboard_event: isKeyPressed = true; + + default: + break; } } else @@ -386,8 +390,8 @@ bool FApplication::parseX11Mouse() button_down = 0x61 }; - x = uChar(x11_mouse[1]) - 0x20; - y = uChar(x11_mouse[2]) - 0x20; + x = uChar(x11_mouse[1] - 0x20); + y = uChar(x11_mouse[2] - 0x20); newMousePosition.setPoint(x,y); memset(&b_state, 0x00, sizeof(b_state)); @@ -455,6 +459,9 @@ bool FApplication::parseX11Mouse() case button3_pressed_move: b_state.right_button = Released; break; + + default: + break; } break; @@ -469,6 +476,9 @@ bool FApplication::parseX11Mouse() time_mousepressed.tv_usec = 0; b_state.wheel_down = Pressed; break; + + default: + break; } if ( uChar(x11_mouse[1]) == mouse->getX() + 0x20 && uChar(x11_mouse[2]) == mouse->getY() + 0x20 @@ -601,6 +611,9 @@ bool FApplication::parseSGRMouse() time_mousepressed.tv_usec = 0; b_state.wheel_down = Pressed; break; + + default: + break; } } else // *p == released @@ -621,6 +634,9 @@ bool FApplication::parseSGRMouse() case button3_move: b_state.right_button = Released; break; + + default: + break; } } if ( *mouse == newMousePosition @@ -783,6 +799,9 @@ bool FApplication::parseUrxvtMouse() case button3_pressed_move: b_state.right_button = Released; break; + + default: + break; } break; @@ -797,6 +816,9 @@ bool FApplication::parseUrxvtMouse() time_mousepressed.tv_usec = 0; b_state.wheel_down = Pressed; break; + + default: + break; } if ( *mouse == newMousePosition && b_state.wheel_up != Pressed @@ -864,6 +886,9 @@ bool FApplication::processGpmEvent() b_state.middle_button = Released; if ( gpm_ev.buttons & GPM_B_RIGHT ) b_state.right_button = Released; + + default: + break; } mouse->setPoint(gpm_ev.x, gpm_ev.y); flush_out(); @@ -877,7 +902,7 @@ bool FApplication::processGpmEvent() //---------------------------------------------------------------------- void FApplication::processMouseEvent() { - bool event = false; + bool Event = false; #ifdef F_HAVE_LIBGPM if ( ! gpmMouseEvent @@ -898,19 +923,19 @@ void FApplication::processMouseEvent() #ifdef F_HAVE_LIBGPM if ( gpmMouseEvent ) - event = processGpmEvent(); + Event = processGpmEvent(); #endif if ( x11_mouse[0] ) - event = parseX11Mouse(); + Event = parseX11Mouse(); if ( sgr_mouse[0] ) - event = parseSGRMouse(); + Event = parseSGRMouse(); if ( urxvt_mouse[0] ) - event = parseUrxvtMouse(); + Event = parseUrxvtMouse(); - if ( ! event ) + if ( ! Event ) return; if ( ! clicked_widget @@ -1283,6 +1308,9 @@ bool FApplication::sendEvent(FObject* receiver, FEvent* event) case FocusOut_Event: case Accelerator_Event: return false; + + default: + break; } } } diff --git a/src/fapp.h b/src/fapp.h index f8769406..109d1ce6 100644 --- a/src/fapp.h +++ b/src/fapp.h @@ -24,7 +24,7 @@ class FApplication : public FWidget { public: typedef std::pair eventPair; - static std::deque* event_queue; + static std::deque* event_queue; private: int app_argc; @@ -90,7 +90,7 @@ class FApplication : public FWidget FApplication (const FApplication&); // Disabled copy constructor FApplication& operator = (const FApplication&); // and operator '=' - void init (int argc, char* argv[]); + void init (int _argc, char* _argv[]); void cmd_options(); bool KeyPressed(); ssize_t readKey(); diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 27a461f3..a10eaf6a 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -104,8 +104,8 @@ void FButton::draw() FString txt; int d, i, j, x, mono_offset, margin; int length, hotkeypos, hotkey_offset, space; - bool isActiveFocus, isActive, isFocus, isFlat; - bool isNonFlatShadow, isNoUnderline; + bool is_ActiveFocus, is_Active, is_Focus, is_Flat; + bool is_NonFlatShadow, is_NoUnderline; if ( text.isNull() || text.isEmpty() ) return; @@ -124,18 +124,18 @@ void FButton::draw() src = const_cast(txt.wc_str()); dest = const_cast(ButtonText); - isActiveFocus = (flags & (ACTIVE+FOCUS)) == (ACTIVE+FOCUS); - isActive = ((flags & ACTIVE) != 0); - isFocus = ((flags & FOCUS) != 0); - isFlat = ((flags & FLAT) != 0); - isNonFlatShadow = ((flags & (SHADOW+FLAT)) == SHADOW); - isNoUnderline = ((flags & NO_UNDERLINE) != 0); + is_ActiveFocus = (flags & (ACTIVE+FOCUS)) == (ACTIVE+FOCUS); + is_Active = ((flags & ACTIVE) != 0); + is_Focus = ((flags & FOCUS) != 0); + is_Flat = isFlat(); + is_NonFlatShadow = ((flags & (SHADOW+FLAT)) == SHADOW); + is_NoUnderline = ((flags & NO_UNDERLINE) != 0); setUpdateVTerm(false); if ( button_down && click_animation ) { // noshadow + indent one character to the right - if ( isFlat ) + if ( is_Flat ) clearFlatBorder(); clearShadow(); setColor ( parentWidget()->getForegroundColor(), @@ -150,10 +150,10 @@ void FButton::draw() else d = 0; - if ( ! isActive && isMonochron() ) + if ( ! is_Active && isMonochron() ) space = fc::MediumShade; // ▒ - if ( (isMonochron() || getMaxColor() < 16) && isActiveFocus ) + if ( (isMonochron() || getMaxColor() < 16) && is_ActiveFocus ) { txt = "<" + txt + ">"; length = int(txt.getLength()); @@ -183,10 +183,10 @@ void FButton::draw() else margin = 0; - if ( isMonochron() && (isActive || isFocus) ) + if ( isMonochron() && (is_Active || is_Focus) ) setReverse(true); - if ( isFlat ) + if ( is_Flat ) { if ( margin == 1 ) { @@ -217,7 +217,7 @@ void FButton::draw() if ( ! button_down && ! isNewFont() - && (isFlat || ! hasShadow() || isMonochron()) ) + && (is_Flat || ! hasShadow() || isMonochron()) ) { // clear the right █ from button down setColor ( parentWidget()->getForegroundColor(), @@ -257,18 +257,18 @@ void FButton::draw() setCursorPos ( xpos+xmin-1+margin+i+hotkeypos, ypos+ymin-1+j ); // hotkey - if ( isMonochron() && isActiveFocus ) + if ( isMonochron() && is_ActiveFocus ) setBold(); for (int z=0; x < i+length && z < width; z++,x++) { - if ( (z == hotkeypos) && isActive ) + if ( (z == hotkeypos) && is_Active ) { setColor (button_hotkey_fg, button_bg); - if ( ! isNoUnderline ) + if ( ! is_NoUnderline ) setUnderline(); print ( ButtonText[z] ); - if ( ! isNoUnderline ) + if ( ! is_NoUnderline ) unsetUnderline(); setColor (button_fg, button_bg); } @@ -278,7 +278,7 @@ void FButton::draw() } } - if ( isMonochron() && isActiveFocus ) + if ( isMonochron() && is_ActiveFocus ) unsetBold(); for (x=i+length; x < width-1; x++) @@ -303,7 +303,7 @@ void FButton::draw() if ( isMonochron() ) setReverse(false); - if ( isNonFlatShadow && ! button_down ) + if ( is_NonFlatShadow && ! button_down ) { setColor ( parentWidget()->getForegroundColor(), parentWidget()->getBackgroundColor() ); @@ -314,7 +314,7 @@ void FButton::draw() setUpdateVTerm(true); delete[] ButtonText; - if ( isFocus && statusBar() ) + if ( is_Focus && statusBar() ) { FString msg = getStatusbarMessage(); FString curMsg = statusBar()->getMessage(); @@ -527,14 +527,14 @@ bool FButton::setDown (bool on) } //---------------------------------------------------------------------- -void FButton::onKeyPress (FKeyEvent* event) +void FButton::onKeyPress (FKeyEvent* ev) { int key; if ( ! isEnabled() ) return; - key = event->key(); + key = ev->key(); switch ( key ) { @@ -547,15 +547,18 @@ void FButton::onKeyPress (FKeyEvent* event) addTimer(click_time); } processClick(); - event->accept(); + ev->accept(); + break; + + default: break; } } //---------------------------------------------------------------------- -void FButton::onMouseDown (FMouseEvent* event) +void FButton::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) { setUp(); return; @@ -572,32 +575,32 @@ void FButton::onMouseDown (FMouseEvent* event) if ( statusBar() ) statusBar()->drawMessage(); } - FPoint gPos = event->getGlobalPos(); + FPoint gPos = ev->getGlobalPos(); if ( getGeometryGlobal().contains(gPos) ) setDown(); } //---------------------------------------------------------------------- -void FButton::onMouseUp (FMouseEvent* event) +void FButton::onMouseUp (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( button_down ) { setUp(); - if ( getGeometryGlobal().contains(event->getGlobalPos()) ) + if ( getGeometryGlobal().contains(ev->getGlobalPos()) ) processClick(); } } //---------------------------------------------------------------------- -void FButton::onMouseMove (FMouseEvent* event) +void FButton::onMouseMove (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; - FPoint gPos = event->getGlobalPos(); + FPoint gPos = ev->getGlobalPos(); if ( click_animation ) { if ( getGeometryGlobal().contains(gPos) ) @@ -615,13 +618,13 @@ void FButton::onTimer (FTimerEvent* ev) } //---------------------------------------------------------------------- -void FButton::onAccel (FAccelEvent* event) +void FButton::onAccel (FAccelEvent* ev) { if ( isEnabled() ) { if ( ! hasFocus() ) { - FWidget* focused_widget = static_cast(event->focusedWidget()); + FWidget* focused_widget = static_cast(ev->focusedWidget()); FFocusEvent out (FocusOut_Event); FApplication::queueEvent(focused_widget, &out); setFocus(); @@ -640,7 +643,7 @@ void FButton::onAccel (FAccelEvent* event) addTimer(click_time); processClick(); - event->accept(); + ev->accept(); } } diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index d30f603e..ecd371a9 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -430,9 +430,9 @@ bool FButtonGroup::hasCheckedButton() } //---------------------------------------------------------------------- -void FButtonGroup::onMouseDown (FMouseEvent* event) +void FButtonGroup::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; directFocus(); } diff --git a/src/fcharmap.h b/src/fcharmap.h index c83d8c43..2591c277 100644 --- a/src/fcharmap.h +++ b/src/fcharmap.h @@ -108,7 +108,7 @@ static uInt character[][fc::NUM_OF_ENCODINGS] = {0x1afb, 0, 0xfb, 0} // ✓ - NF_check_mark }; -const int lastCharItem = (sizeof(character) / sizeof(character[0])) - 1; +const int lastCharItem = int(sizeof(character) / sizeof(character[0])) - 1; static int vt100_key_to_utf8[][2] = @@ -154,8 +154,8 @@ static int vt100_key_to_utf8[][2] = {fc::vt100_key_diamond , fc::Bullet} // ◆ }; -const int lastKeyItem = ( sizeof(vt100_key_to_utf8) / - sizeof(vt100_key_to_utf8[0]) ) - 1; +const int lastKeyItem = int ( sizeof(vt100_key_to_utf8) / + sizeof(vt100_key_to_utf8[0]) ) - 1; static uInt cp437_to_ucs[][2] = @@ -290,7 +290,8 @@ static uInt cp437_to_ucs[][2] = {0xff, 0x00a0} // no-break space }; -const uInt lastCP437Item = (sizeof(cp437_to_ucs) / sizeof(cp437_to_ucs[0])) - 1; +const uInt lastCP437Item = uInt ( sizeof(cp437_to_ucs) / + sizeof(cp437_to_ucs[0]) ) - 1; #endif // _FCHARMAP_H diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 84174bc9..e45fdee1 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -94,7 +94,7 @@ void FDialog::init() createArea (vwin); setGeometry (1, 1, 10, 10, false); // initialize geometry values focus_widget = 0; - this->text = ""; + this->tb_text = ""; maximized = false; ignore_padding = true; window_object = true; @@ -185,7 +185,7 @@ void FDialog::drawBorder() void FDialog::drawTitleBar() { int i,x; - uInt length = text.getLength(); + uInt length = tb_text.getLength(); // draw the title button gotoxy (xpos+xmin-1, ypos+ymin-1); @@ -215,7 +215,7 @@ void FDialog::drawTitleBar() print (' '); // the title bar text - print (text); + print (tb_text); // fill the rest of the bar for (; x+1+int(length) <= width-2; x++) @@ -369,23 +369,23 @@ void FDialog::onHide (FHideEvent*) } //---------------------------------------------------------------------- -void FDialog::onClose (FCloseEvent* event) +void FDialog::onClose (FCloseEvent* ev) { - event->accept(); + ev->accept(); result_code = FDialog::Reject; } // public methods of FDialog //---------------------------------------------------------------------- -void FDialog::onKeyPress (FKeyEvent* event) +void FDialog::onKeyPress (FKeyEvent* ev) { if ( ! isEnabled() || this == getMainWidget() ) return; - if ( event->key() == fc::Fkey_escape - || event->key() == fc::Fkey_escape_mintty ) + if ( ev->key() == fc::Fkey_escape + || ev->key() == fc::Fkey_escape_mintty ) { - event->accept(); + ev->accept(); if ( isModal() ) done (FDialog::Reject); else @@ -394,16 +394,16 @@ void FDialog::onKeyPress (FKeyEvent* event) } //---------------------------------------------------------------------- -void FDialog::onMouseDown (FMouseEvent* event) +void FDialog::onMouseDown (FMouseEvent* ev) { - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); - if ( event->getButton() == LeftButton ) + if ( ev->getButton() == LeftButton ) { // click on titlebar or window: raise + activate if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 ) - TitleBarClickPos.setPoint (event->getGlobalX(), event->getGlobalY()); + TitleBarClickPos.setPoint (ev->getGlobalX(), ev->getGlobalY()); else TitleBarClickPos.setPoint (0,0); @@ -428,7 +428,7 @@ void FDialog::onMouseDown (FMouseEvent* event) redraw(); } - if ( event->getButton() == RightButton ) + if ( ev->getButton() == RightButton ) { // click on titlebar: just activate if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 ) @@ -451,7 +451,7 @@ void FDialog::onMouseDown (FMouseEvent* event) } } - if ( event->getButton() == MiddleButton ) + if ( ev->getButton() == MiddleButton ) { // click on titlebar: lower + activate if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 ) @@ -481,12 +481,12 @@ void FDialog::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FDialog::onMouseUp (FMouseEvent* event) +void FDialog::onMouseUp (FMouseEvent* ev) { int titlebar_x = TitleBarClickPos.getX(); int titlebar_y = TitleBarClickPos.getY(); - if ( event->getButton() == LeftButton ) + if ( ev->getButton() == LeftButton ) { if ( ! TitleBarClickPos.isNull() && titlebar_x >= xpos+xmin+3 @@ -494,41 +494,41 @@ void FDialog::onMouseUp (FMouseEvent* event) && titlebar_y == ypos+ymin-1 ) { FPoint currentPos(getGeometry().getX(), getGeometry().getY()); - FPoint deltaPos = event->getGlobalPos() - TitleBarClickPos; + FPoint deltaPos = ev->getGlobalPos() - TitleBarClickPos; move (currentPos + deltaPos); - TitleBarClickPos = event->getGlobalPos(); + TitleBarClickPos = ev->getGlobalPos(); } } } //---------------------------------------------------------------------- -void FDialog::onMouseMove (FMouseEvent* event) +void FDialog::onMouseMove (FMouseEvent* ev) { - if ( event->getButton() == LeftButton ) + if ( ev->getButton() == LeftButton ) { if ( ! TitleBarClickPos.isNull() ) { FPoint currentPos(getGeometry().getX(), getGeometry().getY()); - FPoint deltaPos = event->getGlobalPos() - TitleBarClickPos; + FPoint deltaPos = ev->getGlobalPos() - TitleBarClickPos; move (currentPos + deltaPos); - TitleBarClickPos = event->getGlobalPos(); + TitleBarClickPos = ev->getGlobalPos(); } } } //---------------------------------------------------------------------- -void FDialog::onMouseDoubleClick (FMouseEvent* event) +void FDialog::onMouseDoubleClick (FMouseEvent* ev) { int x, y; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; x = xpos + xmin - 1; y = ypos + ymin - 1; FRect title_button(x, y, 3, 1); - FPoint gPos = event->getGlobalPos(); + FPoint gPos = ev->getGlobalPos(); if ( title_button.contains(gPos) ) { setClickedWidget(0); diff --git a/src/fdialog.h b/src/fdialog.h index 974ea43e..8da796ec 100644 --- a/src/fdialog.h +++ b/src/fdialog.h @@ -24,7 +24,7 @@ class FDialog : public FWindow }; private: - FString text; + FString tb_text; int result_code; bool maximized; FPoint TitleBarClickPos; @@ -181,10 +181,10 @@ inline bool FDialog::hasShadow() //---------------------------------------------------------------------- inline void FDialog::setText (FString txt) -{ this->text = txt; } +{ this->tb_text = txt; } //---------------------------------------------------------------------- inline FString FDialog::getText() const -{ return this->text; } +{ return this->tb_text; } #endif // _FDIALOG_H diff --git a/src/fevent.cpp b/src/fevent.cpp index 0b825e83..33d367c7 100644 --- a/src/fevent.cpp +++ b/src/fevent.cpp @@ -10,11 +10,15 @@ // class FKeyEvent //---------------------------------------------------------------------- -FKeyEvent::FKeyEvent(int type, int key) : FEvent(type) // constructor -{ - k = key; - accpt = false; -} +FKeyEvent::FKeyEvent(int ev_type, int key_num) // constructor + : FEvent(ev_type) + , k(key_num) + , accpt(false) +{ } + +//---------------------------------------------------------------------- +FKeyEvent::~FKeyEvent() // destructor +{ } //---------------------------------------------------------------------- int FKeyEvent::key() const @@ -37,24 +41,28 @@ void FKeyEvent::ignore() // class FMouseEvent //---------------------------------------------------------------------- -FMouseEvent::FMouseEvent (int type, // constructor - const FPoint& pos, - int button) : FEvent(type), - p(pos), - b(button) -{ -} +FMouseEvent::FMouseEvent ( int ev_type, // constructor + const FPoint& pos, + int button ) + : FEvent(ev_type) + , p(pos) + , b(button) +{ } //---------------------------------------------------------------------- -FMouseEvent::FMouseEvent (int type, // constructor - const FPoint& pos, - const FPoint& globalPos, - int button) : FEvent(type), - p(pos), - g(globalPos), - b(button) -{ -} +FMouseEvent::FMouseEvent ( int ev_type, // constructor + const FPoint& pos, + const FPoint& globalPos, + int button ) + : FEvent(ev_type) + , p(pos) + , g(globalPos) + , b(button) +{ } + +//---------------------------------------------------------------------- +FMouseEvent::~FMouseEvent() // destructor +{ } //---------------------------------------------------------------------- const FPoint& FMouseEvent::getPos() const @@ -89,24 +97,28 @@ int FMouseEvent::getButton() const // class FWheelEvent //---------------------------------------------------------------------- -FWheelEvent::FWheelEvent (int type, // constructor - const FPoint& pos, - int wheel) : FEvent(type), - p(pos), - w(wheel) -{ -} +FWheelEvent::FWheelEvent ( int ev_type, // constructor + const FPoint& pos, + int wheel ) + : FEvent(ev_type) + , p(pos) + , w(wheel) +{ } //---------------------------------------------------------------------- -FWheelEvent::FWheelEvent (int type, // constructor +FWheelEvent::FWheelEvent (int ev_type, // constructor const FPoint& pos, const FPoint& globalPos, - int wheel) : FEvent(type), - p(pos), - g(globalPos), - w(wheel) -{ -} + int wheel) + : FEvent(ev_type) + , p(pos) + , g(globalPos) + , w(wheel) +{ } + +//---------------------------------------------------------------------- +FWheelEvent::~FWheelEvent() // destructor +{ } //---------------------------------------------------------------------- const FPoint& FWheelEvent::getPos() const @@ -141,11 +153,15 @@ int FWheelEvent::getWheel() const // class FFocusEvent //---------------------------------------------------------------------- -FFocusEvent::FFocusEvent (int type) : FEvent(type) // constructor -{ - accpt = true; - focus_type = FocusDefiniteWidget; -} +FFocusEvent::FFocusEvent (int ev_type) // constructor + : FEvent(ev_type) + , accpt(true) + , focus_type(FocusDefiniteWidget) +{ } + +//---------------------------------------------------------------------- +FFocusEvent::~FFocusEvent() // destructor +{ } //---------------------------------------------------------------------- bool FFocusEvent::gotFocus() const @@ -184,11 +200,15 @@ void FFocusEvent::ignore() // class FAccelEvent //---------------------------------------------------------------------- -FAccelEvent::FAccelEvent(int type, void* focused) : FEvent(type) // constructor -{ - focus_widget = focused; - accpt = false; -} +FAccelEvent::FAccelEvent(int ev_type, void* focused) // constructor + : FEvent(ev_type) + , accpt(false) + , focus_widget(focused) +{ } + +//---------------------------------------------------------------------- +FAccelEvent::~FAccelEvent() // destructor +{ } //---------------------------------------------------------------------- void* FAccelEvent::focusedWidget() const @@ -211,8 +231,14 @@ void FAccelEvent::ignore() // class FResizeEvent //---------------------------------------------------------------------- -FResizeEvent::FResizeEvent(int type) : FEvent(type) // constructor -{ accpt = false; } +FResizeEvent::FResizeEvent(int ev_type) // constructor + : FEvent(ev_type) + , accpt(false) +{ } + +//---------------------------------------------------------------------- +FResizeEvent::~FResizeEvent() // destructor +{ } //---------------------------------------------------------------------- bool FResizeEvent::isAccepted() const @@ -231,24 +257,38 @@ void FResizeEvent::ignore() // class FShowEvent //---------------------------------------------------------------------- -FShowEvent::FShowEvent(int type) : FEvent(type) // constructor -{ -} +FShowEvent::FShowEvent(int ev_type) // constructor + : FEvent(ev_type) +{ } + +//---------------------------------------------------------------------- +FShowEvent::~FShowEvent() // destructor +{ } //---------------------------------------------------------------------- // class FHideEvent //---------------------------------------------------------------------- -FHideEvent::FHideEvent(int type) : FEvent(type) // constructor -{ -} +FHideEvent::FHideEvent(int ev_type) // constructor + : FEvent(ev_type) +{ } + +//---------------------------------------------------------------------- +FHideEvent::~FHideEvent() // destructor +{ } //---------------------------------------------------------------------- // class FCloseEvent //---------------------------------------------------------------------- -FCloseEvent::FCloseEvent(int type) : FEvent(type) // constructor -{ accpt = false; } +FCloseEvent::FCloseEvent(int ev_type) // constructor + : FEvent(ev_type) + , accpt(false) +{ } + +//---------------------------------------------------------------------- +FCloseEvent::~FCloseEvent() // destructor +{ } //---------------------------------------------------------------------- bool FCloseEvent::isAccepted() const @@ -267,8 +307,14 @@ void FCloseEvent::ignore() // class FTimerEvent //---------------------------------------------------------------------- -FTimerEvent::FTimerEvent(int type, int timer_id) : FEvent(type) // constructor -{ id = timer_id; } +FTimerEvent::FTimerEvent(int ev_type, int timer_id) // constructor + : FEvent(ev_type) + , id(timer_id) +{ } + +//---------------------------------------------------------------------- +FTimerEvent::~FTimerEvent() // destructor +{ } //---------------------------------------------------------------------- int FTimerEvent::timerId() const diff --git a/src/fevent.h b/src/fevent.h index 1426ee0b..5aad746a 100644 --- a/src/fevent.h +++ b/src/fevent.h @@ -41,7 +41,7 @@ class FEvent // event base class { public: explicit FEvent(int); - ~FEvent(); + ~FEvent(); int type() const; protected: @@ -53,12 +53,13 @@ class FEvent // event base class // FEvent inline functions //---------------------------------------------------------------------- -inline FEvent::FEvent(int type) // constructor -{ t = type; } +inline FEvent::FEvent(int ev_type) // constructor + : t(ev_type) +{ } //---------------------------------------------------------------------- inline FEvent::~FEvent() // destructor -{} +{ } //---------------------------------------------------------------------- inline int FEvent::type() const @@ -76,6 +77,8 @@ class FKeyEvent : public FEvent // keyboard event { public: FKeyEvent (int, int); + ~FKeyEvent(); + int key() const; bool isAccepted() const; void accept(); @@ -115,6 +118,7 @@ class FMouseEvent : public FEvent // mouse event public: FMouseEvent (int, const FPoint&, int); FMouseEvent (int, const FPoint&, const FPoint&, int); + ~FMouseEvent(); const FPoint& getPos() const; const FPoint& getGlobalPos() const; @@ -149,11 +153,12 @@ enum WheelState // wheel state values #pragma pack(push) #pragma pack(1) -class FWheelEvent : public FEvent // mouse event +class FWheelEvent : public FEvent // wheel event { public: FWheelEvent (int, const FPoint&, int); FWheelEvent (int, const FPoint&, const FPoint&, int); + ~FWheelEvent(); const FPoint& getPos() const; const FPoint& getGlobalPos() const; @@ -191,6 +196,8 @@ class FFocusEvent : public FEvent // focus event { public: explicit FFocusEvent (int); + ~FFocusEvent(); + bool gotFocus() const; bool lostFocus() const; FocusTypes getFocusType() const; @@ -218,14 +225,16 @@ class FAccelEvent : public FEvent // focus event { public: FAccelEvent (int, void*); + ~FAccelEvent(); + void* focusedWidget() const; bool isAccepted() const; void accept(); void ignore(); protected: + bool accpt; void* focus_widget; - bool accpt; }; #define F_ACCEL_EVENT(x) ((FAccelEvent*)x) @@ -240,6 +249,8 @@ class FResizeEvent : public FEvent // resize event { public: explicit FResizeEvent (int); + ~FResizeEvent(); + bool isAccepted() const; void accept(); void ignore(); @@ -259,6 +270,7 @@ class FShowEvent : public FEvent // show event { public: explicit FShowEvent (int); + ~FShowEvent(); }; #define F_SHOW_EVENT(x) ((FShowEvent*)x) @@ -272,6 +284,7 @@ class FHideEvent : public FEvent // hide event { public: explicit FHideEvent (int); + ~FHideEvent(); }; #define F_HIDE_EVENT(x) ((FHideEvent*)x) @@ -285,6 +298,8 @@ class FCloseEvent : public FEvent // close event { public: explicit FCloseEvent(int); + ~FCloseEvent(); + bool isAccepted() const; void accept(); void ignore(); @@ -307,6 +322,8 @@ class FTimerEvent : public FEvent // timer event { public: FTimerEvent(int, int); + ~FTimerEvent(); + int timerId() const; protected: diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index d0b810f0..efde6cbf 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -263,10 +263,12 @@ int FFileDialog::changeDir (const FString& dirname) case -1: setPath(lastdir); return -1; + case -2: setPath(lastdir); readDir(); return -2; + case 0: if ( newdir == FString("..") ) { @@ -305,20 +307,22 @@ int FFileDialog::changeDir (const FString& dirname) printPath(directory); filename->redraw(); filebrowser->redraw(); + + default: + return 0; } - return 0; } //---------------------------------------------------------------------- void FFileDialog::printPath (const FString& txt) { - FString text = txt; + FString path = txt; uInt max_width = uInt(filebrowser->getWidth()) - 4; - if ( text.getLength() > max_width ) - filebrowser->setText(".." + text.right(max_width-2)); + if ( path.getLength() > max_width ) + filebrowser->setText(".." + path.right(max_width-2)); else - filebrowser->setText(text); + filebrowser->setText(path); } //---------------------------------------------------------------------- @@ -442,23 +446,26 @@ void FFileDialog::adjustSize() // public methods of FFileDialog //---------------------------------------------------------------------- -void FFileDialog::onKeyPress (FKeyEvent* event) +void FFileDialog::onKeyPress (FKeyEvent* ev) { if ( ! isEnabled() ) return; - FDialog::onKeyPress (event); + FDialog::onKeyPress (ev); if ( ! filebrowser->hasFocus() ) return; - int key = event->key(); + int key = ev->key(); switch ( key ) { case fc::Fkey_erase: case fc::Fkey_backspace: changeDir(".."); - event->accept(); + ev->accept(); + break; + + default: break; } diff --git a/src/flabel.cpp b/src/flabel.cpp index 9f38cdeb..88de0cbb 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -130,8 +130,10 @@ int FLabel::getXOffset(int length) return width - length; else return 0; + + default: + return 0; } - return 0; } //---------------------------------------------------------------------- @@ -298,9 +300,9 @@ void FLabel::hide() } //---------------------------------------------------------------------- -void FLabel::onMouseDown (FMouseEvent* event) +void FLabel::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( ! isEnabled() || ! accel_widget ) @@ -325,14 +327,14 @@ void FLabel::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FLabel::onAccel (FAccelEvent* event) +void FLabel::onAccel (FAccelEvent* ev) { if ( ! isEnabled() || ! accel_widget ) return; if ( ! accel_widget->hasFocus() ) { - FWidget* focused_widget = static_cast(event->focusedWidget()); + FWidget* focused_widget = static_cast(ev->focusedWidget()); FFocusEvent out (FocusOut_Event); FApplication::queueEvent(focused_widget, &out); accel_widget->setFocus(); @@ -346,7 +348,7 @@ void FLabel::onAccel (FAccelEvent* event) flush_out(); } } - event->accept(); + ev->accept(); } //---------------------------------------------------------------------- diff --git a/src/flineedit.cpp b/src/flineedit.cpp index c1a0a107..2e00d154 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -224,6 +224,7 @@ void FLineEdit::adjustLabel() case label_above: label->setGeometry(xpos, ypos-1, label_length, 1); break; + case label_left: label->setGeometry(xpos-label_length, ypos, label_length, 1); break; @@ -275,6 +276,7 @@ void FLineEdit::hide() case label_above: gotoxy (xpos+xmin-1, ypos+ymin-2); break; + case label_left: gotoxy (xpos+xmin-int(lable_Length)-1, ypos+ymin-1); break; @@ -364,10 +366,10 @@ bool FLineEdit::setShadow (bool on) } //---------------------------------------------------------------------- -void FLineEdit::onKeyPress (FKeyEvent* event) +void FLineEdit::onKeyPress (FKeyEvent* ev) { int len = int(text.getLength()); - int key = event->key(); + int key = ev->key(); switch ( key ) { @@ -377,7 +379,7 @@ void FLineEdit::onKeyPress (FKeyEvent* event) cursor_pos=0; if ( cursor_pos < offset ) offset--; - event->accept(); + ev->accept(); break; case fc::Fkey_right: @@ -386,20 +388,20 @@ void FLineEdit::onKeyPress (FKeyEvent* event) cursor_pos=len; if ( cursor_pos-offset >= width-2 && offset < len-width+2 ) offset++; - event->accept(); + ev->accept(); break; case fc::Fkey_home: cursor_pos=0; offset=0; - event->accept(); + ev->accept(); break; case fc::Fkey_end: cursor_pos=len; if ( cursor_pos > width-2 ) offset=len-width+2; - event->accept(); + ev->accept(); break; case fc::Fkey_dc: // del key @@ -414,7 +416,7 @@ void FLineEdit::onKeyPress (FKeyEvent* event) cursor_pos=0; if ( offset > 0 && len-offset <= width-2 ) offset--; - event->accept(); + ev->accept(); break; case fc::Fkey_erase: @@ -427,7 +429,7 @@ void FLineEdit::onKeyPress (FKeyEvent* event) if ( offset > 0 ) offset--; } - event->accept(); + ev->accept(); break; case fc::Fkey_ic: // insert key @@ -448,17 +450,17 @@ void FLineEdit::onKeyPress (FKeyEvent* event) if ( isUrxvtTerminal() ) setXTermCursor("rgb:0000/0000/0000"); } - event->accept(); + ev->accept(); break; case fc::Fkey_return: case fc::Fkey_enter: processActivate(); - event->accept(); + ev->accept(); break; case fc::Fkey_tab: - event->ignore(); + ev->ignore(); break; default: @@ -485,14 +487,14 @@ void FLineEdit::onKeyPress (FKeyEvent* event) cursor_pos++; if ( cursor_pos > width-2 ) offset++; - event->accept(); + ev->accept(); } else - event->ignore(); + ev->ignore(); } // end of switch - if ( event->isAccepted() + if ( ev->isAccepted() && key != fc::Fkey_return && key != fc::Fkey_enter ) { @@ -502,11 +504,11 @@ void FLineEdit::onKeyPress (FKeyEvent* event) } //---------------------------------------------------------------------- -void FLineEdit::onMouseDown (FMouseEvent* event) +void FLineEdit::onMouseDown (FMouseEvent* ev) { int mouse_x, mouse_y; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( ! hasFocus() ) @@ -522,8 +524,8 @@ void FLineEdit::onMouseDown (FMouseEvent* event) statusBar()->drawMessage(); } - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 ) { @@ -548,16 +550,16 @@ void FLineEdit::onMouseUp (FMouseEvent*) } //---------------------------------------------------------------------- -void FLineEdit::onMouseMove (FMouseEvent* event) +void FLineEdit::onMouseMove (FMouseEvent* ev) { int len, mouse_x, mouse_y; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; len = int(text.getLength()); - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= 2 && mouse_x <= width && mouse_y == 1 ) { @@ -646,6 +648,9 @@ void FLineEdit::onTimer (FTimerEvent*) cursor_pos++; if ( cursor_pos > len ) cursor_pos = len; + + default: + break; } drawInputField(); @@ -653,13 +658,13 @@ void FLineEdit::onTimer (FTimerEvent*) } //---------------------------------------------------------------------- -void FLineEdit::onAccel (FAccelEvent* event) +void FLineEdit::onAccel (FAccelEvent* ev) { if ( isEnabled() ) { if ( ! hasFocus() ) { - FWidget* focused_widget = static_cast(event->focusedWidget()); + FWidget* focused_widget = static_cast(ev->focusedWidget()); FFocusEvent out (FocusOut_Event); FApplication::queueEvent(focused_widget, &out); this->setFocus(); @@ -673,7 +678,7 @@ void FLineEdit::onAccel (FAccelEvent* event) flush_out(); } } - event->accept(); + ev->accept(); } } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index de103b97..73deedb6 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -636,13 +636,13 @@ bool FListBox::setShadow (bool on) } //---------------------------------------------------------------------- -void FListBox::onKeyPress (FKeyEvent* event) +void FListBox::onKeyPress (FKeyEvent* ev) { int element_count = int(count()); int current_before = current; int xoffset_before = xoffset; int yoffset_before = yoffset; - int key = event->key(); + int key = ev->key(); switch ( key ) { @@ -650,7 +650,7 @@ void FListBox::onKeyPress (FKeyEvent* event) case fc::Fkey_enter: processClick(); inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_up: @@ -660,7 +660,7 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( current <= yoffset ) yoffset--; inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_down: @@ -670,7 +670,7 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( current-yoffset > height - 2 ) yoffset++; inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_left: @@ -678,7 +678,7 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( xoffset < 0 ) xoffset = 0; inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_right: @@ -688,7 +688,7 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( xoffset < 0 ) xoffset = 0; inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_ppage: @@ -702,7 +702,7 @@ void FListBox::onKeyPress (FKeyEvent* event) yoffset=0; } inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_npage: @@ -716,14 +716,14 @@ void FListBox::onKeyPress (FKeyEvent* event) yoffset = element_count - height + 2; } inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_home: current = 1; yoffset = 0; inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_end: @@ -731,7 +731,7 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( current > height - 2 ) yoffset = element_count - height + 2; inc_search.clear(); - event->accept(); + ev->accept(); break; case fc::Fkey_ic: // insert key @@ -747,7 +747,7 @@ void FListBox::onKeyPress (FKeyEvent* event) current = element_count; if ( current-yoffset > height - 2 ) yoffset++; - event->accept(); + ev->accept(); } inc_search.clear(); break; @@ -774,10 +774,10 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( ! inc_found ) { inc_search.remove(inc_len, 1); - event->ignore(); + ev->ignore(); } else - event->accept(); + ev->accept(); } else if ( isMultiSelection() ) { @@ -787,7 +787,7 @@ void FListBox::onKeyPress (FKeyEvent* event) selectItem(current); processSelect(); inc_search.clear(); - event->accept(); + ev->accept(); } } break; @@ -813,10 +813,10 @@ void FListBox::onKeyPress (FKeyEvent* event) } } } - event->accept(); + ev->accept(); } else - event->ignore(); + ev->ignore(); } break; @@ -825,7 +825,7 @@ void FListBox::onKeyPress (FKeyEvent* event) if ( inc_search.getLength() > 0 ) { inc_search.clear(); - event->accept(); + ev->accept(); } break; @@ -855,15 +855,15 @@ void FListBox::onKeyPress (FKeyEvent* event) { inc_search.remove(inc_len-1, 1); if ( inc_len == 1 ) - event->ignore(); + ev->ignore(); else - event->accept(); + ev->accept(); } else - event->accept(); + ev->accept(); } else - event->ignore(); + ev->ignore(); } if ( current_before != current ) @@ -873,7 +873,7 @@ void FListBox::onKeyPress (FKeyEvent* event) processSelect(); } - if ( event->isAccepted() ) + if ( ev->isAccepted() ) { if ( isVisible() ) drawList(); @@ -890,16 +890,16 @@ void FListBox::onKeyPress (FKeyEvent* event) } //---------------------------------------------------------------------- -void FListBox::onMouseDown (FMouseEvent* event) +void FListBox::onMouseDown (FMouseEvent* ev) { int yoffset_before, mouse_x, mouse_y; - if ( event->getButton() != LeftButton - && event->getButton() != RightButton ) + if ( ev->getButton() != LeftButton + && ev->getButton() != RightButton ) { return; } - if ( event->getButton() == RightButton && ! isMultiSelection() ) + if ( ev->getButton() == RightButton && ! isMultiSelection() ) return; if ( ! hasFocus() ) @@ -915,8 +915,8 @@ void FListBox::onMouseDown (FMouseEvent* event) } yoffset_before = yoffset; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= 2 && mouse_x <= width-1 && mouse_y >= 2 && mouse_y <= height-1 ) { @@ -924,7 +924,7 @@ void FListBox::onMouseDown (FMouseEvent* event) if ( current > int(count()) ) current = int(count()); inc_search.clear(); - if ( event->getButton() == RightButton ) + if ( ev->getButton() == RightButton ) { if ( isMultiSelection() ) { @@ -954,7 +954,7 @@ void FListBox::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FListBox::onMouseUp (FMouseEvent* event) +void FListBox::onMouseUp (FMouseEvent* ev) { if ( dragScroll != FListBox::noScroll ) { @@ -964,10 +964,10 @@ void FListBox::onMouseUp (FMouseEvent* event) scrollTimer = false; } - if ( event->getButton() == LeftButton ) + if ( ev->getButton() == LeftButton ) { - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x >= 2 && mouse_x <= width-1 && mouse_y >= 2 && mouse_y <= height-1 ) { @@ -979,22 +979,22 @@ void FListBox::onMouseUp (FMouseEvent* event) } //---------------------------------------------------------------------- -void FListBox::onMouseMove (FMouseEvent* event) +void FListBox::onMouseMove (FMouseEvent* ev) { int current_before, yoffset_before, mouse_x, mouse_y; - if ( event->getButton() != LeftButton - && event->getButton() != RightButton ) + if ( ev->getButton() != LeftButton + && ev->getButton() != RightButton ) { return; } - if ( event->getButton() == RightButton && ! isMultiSelection() ) + if ( ev->getButton() == RightButton && ! isMultiSelection() ) return; current_before = current; yoffset_before = yoffset; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= 2 && mouse_x <= width-1 && mouse_y >= 2 && mouse_y <= height-1 ) @@ -1005,7 +1005,7 @@ void FListBox::onMouseMove (FMouseEvent* event) inc_search.clear(); // handle multiple selections - if ( event->getButton() == RightButton + if ( ev->getButton() == RightButton && isMultiSelection() && current_before != current ) { @@ -1056,7 +1056,7 @@ void FListBox::onMouseMove (FMouseEvent* event) { scrollTimer = true; addTimer(scrollRepeat); - if ( event->getButton() == RightButton ) + if ( ev->getButton() == RightButton ) dragScroll = FListBox::scrollUpSelect; else dragScroll = FListBox::scrollUp; @@ -1076,7 +1076,7 @@ void FListBox::onMouseMove (FMouseEvent* event) { scrollTimer = true; addTimer(scrollRepeat); - if ( event->getButton() == RightButton ) + if ( ev->getButton() == RightButton ) dragScroll = FListBox::scrollDownSelect; else dragScroll = FListBox::scrollDown; @@ -1098,15 +1098,15 @@ void FListBox::onMouseMove (FMouseEvent* event) } //---------------------------------------------------------------------- -void FListBox::onMouseDoubleClick (FMouseEvent* event) +void FListBox::onMouseDoubleClick (FMouseEvent* ev) { int mouse_x, mouse_y; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= 2 && mouse_x <= width-1 && mouse_y >= 2 && mouse_y <= height-1 ) @@ -1159,6 +1159,9 @@ void FListBox::onTimer (FTimerEvent*) yoffset += scrollDistance; if ( yoffset > element_count - height + 2 ) yoffset = element_count - height + 2; + + default: + break; } // handle multiple selections @@ -1206,7 +1209,7 @@ void FListBox::onTimer (FTimerEvent*) } //---------------------------------------------------------------------- -void FListBox::onWheel (FWheelEvent* event) +void FListBox::onWheel (FWheelEvent* ev) { int element_count, current_before, yoffset_before, yoffset_end, wheel; @@ -1218,7 +1221,7 @@ void FListBox::onWheel (FWheelEvent* event) if ( yoffset_end < 0 ) yoffset_end = 0; - wheel = event->getWheel(); + wheel = ev->getWheel(); if ( dragScroll != FListBox::noScroll ) { @@ -1261,6 +1264,9 @@ void FListBox::onWheel (FWheelEvent* event) current = element_count; inc_search.clear(); break; + + default: + break; } if ( current_before != current ) @@ -1357,15 +1363,18 @@ void FListBox::cb_VBarChange (FWidget*, void*) { FWheelEvent wheel_ev (MouseWheel_Event, FPoint(2,2), WheelUp); onWheel(&wheel_ev); - break; } + break; case FScrollbar::scrollWheelDown: { FWheelEvent wheel_ev (MouseWheel_Event, FPoint(2,2), WheelDown); onWheel(&wheel_ev); - break; } + break; + + default: + break; } if ( isVisible() ) @@ -1438,6 +1447,9 @@ void FListBox::cb_HBarChange (FWidget*, void*) if ( xoffset > xoffset_end ) xoffset = xoffset_end; break; + + default: + break; } if ( isVisible() ) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 85df3f6a..2d9a8a6d 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -115,7 +115,7 @@ void FMenu::menu_dimension() ++iter; } - setGeometry (xpos, ypos, maxItemWidth + 4, count() + 2); + setGeometry (xpos, ypos, int(maxItemWidth + 4), int(count() + 2)); } //---------------------------------------------------------------------- @@ -262,13 +262,13 @@ void FMenu::drawItems() FString txt; uInt txt_length; int hotkeypos, to_char; - bool isActive = (*iter)->isActivated(); - bool isSelected = (*iter)->isSelected(); - bool isNoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); + bool is_Active = (*iter)->isActivated(); + bool is_Selected = (*iter)->isSelected(); + bool is_NoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); - if ( isActive ) + if ( is_Active ) { - if ( isSelected ) + if ( is_Selected ) { foregroundColor = wc.menu_active_focus_fg; backgroundColor = wc.menu_active_focus_bg; @@ -291,7 +291,7 @@ void FMenu::drawItems() print (' '); txt = (*iter)->getText(); - txt_length = int(txt.getLength()); + txt_length = uInt(txt.getLength()); item_text = new wchar_t[txt_length+1]; src = const_cast(txt.wc_str()); dest = const_cast(item_text); @@ -308,13 +308,13 @@ void FMenu::drawItems() { if ( ! iswprint(wint_t(item_text[z])) ) item_text[z] = L' '; - if ( (z == hotkeypos) && isActive && ! isSelected ) + if ( (z == hotkeypos) && is_Active && ! is_Selected ) { setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); - if ( ! isNoUnderline ) + if ( ! is_NoUnderline ) setUnderline(); print (item_text[z]); - if ( ! isNoUnderline ) + if ( ! is_NoUnderline ) unsetUnderline(); setColor (foregroundColor, backgroundColor); } @@ -322,13 +322,13 @@ void FMenu::drawItems() print (item_text[z]); } - if ( isSelected ) + if ( is_Selected ) { - for (uInt i=to_char; i <= maxItemWidth; i++) + for (uInt i=uInt(to_char); i <= maxItemWidth; i++) print (' '); } - if ( isActive && isSelected ) + if ( is_Active && is_Selected ) setReverse(false); delete[] item_text; @@ -345,9 +345,9 @@ void FMenu::processActivate() // public methods of FMenu //---------------------------------------------------------------------- -void FMenu::onMouseDown (FMouseEvent* event) +void FMenu::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) { mouse_down = false; if ( ! itemlist.empty() ) @@ -384,8 +384,8 @@ void FMenu::onMouseDown (FMouseEvent* event) x1 = X; txt_length = int((*iter)->getText().getLength()); x2 = x1 + txt_length + 1; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 @@ -402,9 +402,9 @@ void FMenu::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FMenu::onMouseUp (FMouseEvent* event) +void FMenu::onMouseUp (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( mouse_down ) @@ -426,8 +426,8 @@ void FMenu::onMouseUp (FMouseEvent* event) if ( (*iter)->isSelected() ) { - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x < x1 || mouse_x > x2 || mouse_y != 1 ) (*iter)->unsetSelected(); this->redraw(); @@ -440,9 +440,9 @@ void FMenu::onMouseUp (FMouseEvent* event) } //---------------------------------------------------------------------- -void FMenu::onMouseMove (FMouseEvent* event) +void FMenu::onMouseMove (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( mouse_down && ! itemlist.empty() ) @@ -460,8 +460,8 @@ void FMenu::onMouseMove (FMouseEvent* event) int txt_length = int((*iter)->getText().getLength()); int x2 = x1 + txt_length + 1; - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 ) @@ -504,15 +504,15 @@ void FMenu::setGeometry (int xx, int yy, int ww, int hh, bool adjust) } //---------------------------------------------------------------------- -void FMenu::insert (FMenuItem* item) +void FMenu::insert (FMenuItem* i) { - FMenuList::insert(item); + FMenuList::insert(i); } //---------------------------------------------------------------------- -void FMenu::remove (FMenuItem* item) +void FMenu::remove (FMenuItem* i) { - FMenuList::remove(item); + FMenuList::remove(i); } //---------------------------------------------------------------------- diff --git a/src/fmenu.h b/src/fmenu.h index 5ea1e86a..60eb9e71 100644 --- a/src/fmenu.h +++ b/src/fmenu.h @@ -81,8 +81,8 @@ inline const char* FMenu::getClassName() const { return "FMenu"; } //---------------------------------------------------------------------- -inline void FMenu::onAccel (FAccelEvent* event) -{ item->onAccel(event); } +inline void FMenu::onAccel (FAccelEvent* ev) +{ item->onAccel(ev); } //---------------------------------------------------------------------- inline FMenuItem* FMenu::getItem() const diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index aa3e0238..fc086992 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -89,9 +89,9 @@ void FMenuBar::draw() //---------------------------------------------------------------------- void FMenuBar::drawItems() { - bool isActive; - bool isSelected; - bool isNoUnderline; + bool is_Active; + bool is_Selected; + bool is_NoUnderline; std::vector::const_iterator iter, end; int screenWidth; @@ -118,13 +118,13 @@ void FMenuBar::drawItems() uInt txt_length; int hotkeypos, to_char; - isActive = (*iter)->isActivated(); - isSelected = (*iter)->isSelected(); - isNoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); + is_Active = (*iter)->isActivated(); + is_Selected = (*iter)->isSelected(); + is_NoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); - if ( isActive ) + if ( is_Active ) { - if ( isSelected ) + if ( is_Selected ) { foregroundColor = wc.menu_active_focus_fg; backgroundColor = wc.menu_active_focus_bg; @@ -147,7 +147,7 @@ void FMenuBar::drawItems() print (vmenubar, ' '); txt = (*iter)->getText(); - txt_length = int(txt.getLength()); + txt_length = uInt(txt.getLength()); item_text = new wchar_t[txt_length+1]; src = const_cast(txt.wc_str()); dest = const_cast(item_text); @@ -155,7 +155,7 @@ void FMenuBar::drawItems() if ( x-1 <= screenWidth ) to_char = int(txt_length); else - to_char = txt_length - (screenWidth-x-1); + to_char = int(txt_length) - (screenWidth-x-1); hotkeypos = getHotkeyPos (src, dest, txt_length); @@ -164,19 +164,19 @@ void FMenuBar::drawItems() txt_length--; to_char--; } - x += txt_length; + x += int(txt_length); for (int z=0; z < to_char; z++) { if ( ! iswprint(wint_t(item_text[z])) ) item_text[z] = L' '; - if ( (z == hotkeypos) && isActive && ! isSelected ) + if ( (z == hotkeypos) && is_Active && ! is_Selected ) { setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); - if ( ! isNoUnderline ) + if ( ! is_NoUnderline ) setUnderline(); print (vmenubar, item_text[z]); - if ( ! isNoUnderline ) + if ( ! is_NoUnderline ) unsetUnderline(); setColor (foregroundColor, backgroundColor); } @@ -187,7 +187,7 @@ void FMenuBar::drawItems() if ( x > screenWidth ) { print ( vmenubar, - txt.left(uInt(txt_length+screenWidth-x-1)) ); + txt.left(uInt(int(txt_length)+screenWidth-x-1)) ); print ( vmenubar, ".." ); } else @@ -196,7 +196,7 @@ void FMenuBar::drawItems() print (vmenubar, ' '); } - if ( isActive && isSelected ) + if ( is_Active && is_Selected ) setReverse(false); delete[] item_text; @@ -221,9 +221,9 @@ void FMenuBar::adjustSize() // public methods of FMenuBar //---------------------------------------------------------------------- -void FMenuBar::onMouseDown (FMouseEvent* event) +void FMenuBar::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) { mouse_down = false; if ( ! itemlist.empty() ) @@ -262,8 +262,8 @@ void FMenuBar::onMouseDown (FMouseEvent* event) if ( (*iter)->hasHotkey() ) txt_length--; x2 = x1 + txt_length; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 @@ -285,9 +285,9 @@ void FMenuBar::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FMenuBar::onMouseUp (FMouseEvent* event) +void FMenuBar::onMouseUp (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( mouse_down ) @@ -311,8 +311,8 @@ void FMenuBar::onMouseUp (FMouseEvent* event) if ( (*iter)->isSelected() ) { - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x < x1 || mouse_x > x2 || mouse_y != 1 ) (*iter)->unsetSelected(); else @@ -329,9 +329,9 @@ void FMenuBar::onMouseUp (FMouseEvent* event) } //---------------------------------------------------------------------- -void FMenuBar::onMouseMove (FMouseEvent* event) +void FMenuBar::onMouseMove (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( mouse_down && ! itemlist.empty() ) @@ -351,8 +351,8 @@ void FMenuBar::onMouseMove (FMouseEvent* event) txt_length--; int x2 = x1 + txt_length; - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 ) diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 38fda3fc..73864495 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -147,7 +147,7 @@ void FMenuItem::processClicked() // public methods of FMenuItem //---------------------------------------------------------------------- -void FMenuItem::onAccel (FAccelEvent* event) +void FMenuItem::onAccel (FAccelEvent* ev) { if ( isSelected() ) { @@ -155,7 +155,7 @@ void FMenuItem::onAccel (FAccelEvent* event) FWidget* w = reinterpret_cast(superMenu()); if ( isMenuBar(w) ) w->redraw(); - event->accept(); + ev->accept(); } } diff --git a/src/fmenulist.cpp b/src/fmenulist.cpp index eaaefcc4..59dd2d6d 100644 --- a/src/fmenulist.cpp +++ b/src/fmenulist.cpp @@ -58,17 +58,17 @@ bool FMenuList::hasSelectedItem() } //---------------------------------------------------------------------- -void FMenuList::insert (FMenuItem* item) +void FMenuList::insert (FMenuItem* i) { - itemlist.push_back(item); + itemlist.push_back(i); } //---------------------------------------------------------------------- -void FMenuList::remove (FMenuItem* item) +void FMenuList::remove (FMenuItem* i) { std::vector::iterator iter; - //delAccelerator (item); + //delAccelerator (i); if ( itemlist.empty() ) return; @@ -76,10 +76,10 @@ void FMenuList::remove (FMenuItem* item) iter = itemlist.begin(); while ( iter != itemlist.end() ) { - if ( (*iter) == item ) + if ( (*iter) == i ) { iter = itemlist.erase(iter); - item->setSuperMenu(0); + i->setSuperMenu(0); break; } else diff --git a/src/fobject.cpp b/src/fobject.cpp index d5d92885..8369e7b0 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -47,7 +47,7 @@ FObject::~FObject() // destructor } // delete children objects - FObject::object_list children = this->children(); + FObject::object_list children = this->getChildren(); if ( ! children.empty() ) { FObject::object_list::const_iterator iter; diff --git a/src/fobject.h b/src/fobject.h index ccb9b3c0..4c4854fd 100644 --- a/src/fobject.h +++ b/src/fobject.h @@ -64,10 +64,10 @@ class FObject virtual ~FObject(); virtual const char* getClassName() const; - FObject* parent() const; + FObject* getParent() const; bool hasParent() const; void removeParent(); - object_list children() const; + object_list getChildren() const; bool hasChildren() const; void addChild (FObject*); void delChild (FObject*); @@ -93,7 +93,7 @@ inline const char* FObject::getClassName() const { return "FObject"; } //---------------------------------------------------------------------- -inline FObject* FObject::parent() const +inline FObject* FObject::getParent() const { return parentObj; } //---------------------------------------------------------------------- @@ -105,7 +105,7 @@ inline void FObject::removeParent() { parentObj = 0; } //---------------------------------------------------------------------- -inline FObject::object_list FObject::children() const +inline FObject::object_list FObject::getChildren() const { return children_list; } //---------------------------------------------------------------------- diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 25b41e04..b64ecd86 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -93,7 +93,7 @@ int FOptiMove::cap_duration (char*& cap, int affcnt) ms += num * 10; } else - ms += char_duration; + ms += float(char_duration); } return int(ms); } @@ -611,6 +611,9 @@ char* FOptiMove::cursor_move (int xold, int yold, int xnew, int ynew) move_ptr += strlen(move_buf); relative_move (move_ptr, screen_width-1, yold-1, xnew, ynew); break; + + default: + break; } } if ( move_time < LONG_DURATION ) diff --git a/src/fpoint.cpp b/src/fpoint.cpp index b91bd3d0..cd4bd6ed 100644 --- a/src/fpoint.cpp +++ b/src/fpoint.cpp @@ -49,15 +49,15 @@ FPoint& FPoint::operator = (const FPoint& p) //---------------------------------------------------------------------- FPoint& FPoint::operator += (const FPoint& p) { - xpos += p.xpos; - ypos += p.ypos; + xpos = short(xpos + p.xpos); + ypos = short(ypos + p.ypos); return *this; } //---------------------------------------------------------------------- FPoint& FPoint::operator -= (const FPoint& p) { - xpos -= p.xpos; - ypos -= p.ypos; + xpos = short(xpos - p.xpos); + ypos = short(ypos - p.ypos); return *this; } diff --git a/src/fpoint.h b/src/fpoint.h index 6086d8ea..cda75072 100644 --- a/src/fpoint.h +++ b/src/fpoint.h @@ -48,14 +48,15 @@ class FPoint // FPoint inline functions //---------------------------------------------------------------------- inline FPoint::FPoint() -{ xpos = ypos = 0; } + : xpos(0) + , ypos(0) +{ } //---------------------------------------------------------------------- inline FPoint::FPoint (int x, int y) -{ - xpos = short(x); - ypos = short(y); -} + : xpos(short(x)) + , ypos(short(y)) +{ } //---------------------------------------------------------------------- inline const char* FPoint::getClassName() diff --git a/src/frect.cpp b/src/frect.cpp index 3b715c10..9a49f9fa 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -10,12 +10,11 @@ // constructor and destructor //---------------------------------------------------------------------- FRect::FRect (const FPoint& p1, const FPoint& p2) -{ - X1 = short(p1.getX()); - Y1 = short(p1.getY()); - X2 = short(p2.getX()); - Y2 = short(p2.getY()); -} + : X1(short(p1.getX())) + , Y1(short(p1.getY())) + , X2(short(p2.getX())) + , Y2(short(p2.getY())) +{ } //---------------------------------------------------------------------- FRect::~FRect() // destructor @@ -56,7 +55,7 @@ void FRect::setY2 (int n) //---------------------------------------------------------------------- void FRect::setX (int n) { - short dX = X2 - X1; + short dX = short(X2 - X1); X1 = short(n); X2 = short(X1 + dX); } @@ -64,7 +63,7 @@ void FRect::setX (int n) //---------------------------------------------------------------------- void FRect::setY (int n) { - short dY = Y2 - Y1; + short dY = short(Y2 - Y1); Y1 = short(n); Y2 = short(Y1 + dY); } @@ -99,19 +98,19 @@ void FRect::setRect (int x, int y, int width, int height) //---------------------------------------------------------------------- void FRect::move (int dx, int dy) { - X1 += short(dx); - Y1 += short(dy); - X2 += short(dx); - Y2 += short(dy); + X1 = short(X1 + dx); + Y1 = short(Y1 + dy); + X2 = short(X2 + dx); + Y2 = short(Y2 + dy); } //---------------------------------------------------------------------- void FRect::move (const FPoint& d) { - X1 += short(d.getX()); - Y1 += short(d.getY()); - X2 += short(d.getX()); - Y2 += short(d.getY()); + X1 = short(X1 + d.getX()); + Y1 = short(Y1 + d.getY()); + X2 = short(X2 + d.getX()); + Y2 = short(Y2 + d.getY()); } //---------------------------------------------------------------------- diff --git a/src/frect.h b/src/frect.h index 7f637bd5..b8f67058 100644 --- a/src/frect.h +++ b/src/frect.h @@ -71,19 +71,19 @@ class FRect // FRect inline functions //---------------------------------------------------------------------- inline FRect::FRect() -{ - X1 = Y1 = 0; - X2 = Y2 = -1; -} + : X1(0) + , Y1(0) + , X2(-1) + , Y2(-1) +{ } //---------------------------------------------------------------------- inline FRect::FRect (int x, int y, int width, int height) -{ - X1 = short(x); - Y1 = short(y); - X2 = short(x+width-1); - Y2 = short(y+height-1); -} + : X1(short(x)) + , Y1(short(y)) + , X2(short(x+width-1)) + , Y2(short(y+height-1)) +{ } //---------------------------------------------------------------------- inline const char* FRect::getClassName() diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index 08dc7e49..772d99ec 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -143,7 +143,7 @@ void FScrollbar::processMiddleButton (int x, int y) { if ( y >1 && y < height ) { - new_val = int( round ( float(max-min) * (y-2-(SliderLength/2)) + new_val = int( round ( float(max-min) * (y-2.0-(SliderLength/2)) / float(BarLength-SliderLength) ) ); } else @@ -154,7 +154,7 @@ void FScrollbar::processMiddleButton (int x, int y) int nf = isNewFont() ? 1 : 0; if ( x > 1+nf && x < width-nf ) { - new_val = int( round ( float(max-min) * (x-2-nf-(SliderLength/2)) + new_val = int( round ( float(max-min) * (x-2.0-nf-(SliderLength/2)) / float(BarLength-SliderLength) ) ); } else @@ -180,21 +180,21 @@ void FScrollbar::processScroll() // public methods of FScrollbar //---------------------------------------------------------------------- -void FScrollbar::onMouseDown (FMouseEvent* event) +void FScrollbar::onMouseDown (FMouseEvent* ev) { int mouse_x, mouse_y; - if ( event->getButton() != LeftButton - && event->getButton() != MiddleButton ) + if ( ev->getButton() != LeftButton + && ev->getButton() != MiddleButton ) return; if ( min == max ) return; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); - if ( event->getButton() == MiddleButton ) + if ( ev->getButton() == MiddleButton ) { processMiddleButton (mouse_x, mouse_y); return; @@ -249,10 +249,10 @@ void FScrollbar::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FScrollbar::onMouseUp (FMouseEvent* event) +void FScrollbar::onMouseUp (FMouseEvent* ev) { - if ( event->getButton() != LeftButton - && event->getButton() != MiddleButton ) + if ( ev->getButton() != LeftButton + && ev->getButton() != MiddleButton ) return; SliderClickPos = -1; @@ -265,18 +265,18 @@ void FScrollbar::onMouseUp (FMouseEvent* event) } //---------------------------------------------------------------------- -void FScrollbar::onMouseMove (FMouseEvent* event) +void FScrollbar::onMouseMove (FMouseEvent* ev) { int mouse_x, mouse_y, newScrollType; - if ( event->getButton() != LeftButton - && event->getButton() != MiddleButton ) + if ( ev->getButton() != LeftButton + && ev->getButton() != MiddleButton ) return; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); - if ( event->getButton() == MiddleButton ) + if ( ev->getButton() == MiddleButton ) { processMiddleButton (mouse_x, mouse_y); return; @@ -293,7 +293,7 @@ void FScrollbar::onMouseMove (FMouseEvent* event) int dy = mouse_y - SliderClickPos; SliderClickPos = mouse_y; - new_val = int( round ( float(max-min) * (SliderPos + dy) + new_val = int( round ( float((max-min) * (SliderPos + dy)) / float(BarLength-SliderLength) ) ); } else // horizontal @@ -301,7 +301,7 @@ void FScrollbar::onMouseMove (FMouseEvent* event) int dx = mouse_x - SliderClickPos; SliderClickPos = mouse_x; - new_val = int( round ( float(max-min) * (SliderPos + dx) + new_val = int( round ( float((max-min) * (SliderPos + dx)) / float(BarLength-SliderLength) ) ); } if ( new_val != val ) @@ -330,9 +330,9 @@ void FScrollbar::onMouseMove (FMouseEvent* event) } //---------------------------------------------------------------------- -void FScrollbar::onWheel (FWheelEvent* event) +void FScrollbar::onWheel (FWheelEvent* ev) { - int wheel = event->getWheel(); + int wheel = ev->getWheel(); if ( scrollType != FScrollbar::noScroll ) { @@ -425,7 +425,7 @@ void FScrollbar::setSteps (float st) else steps = st; if ( pageSize == 0 ) - pageSize = int(max/steps); + pageSize = int(float(max)/steps); } //---------------------------------------------------------------------- @@ -450,7 +450,7 @@ void FScrollbar::calculateSliderValues() BarLength = length - 4; else BarLength = length - 2; - SliderLength = int(float(BarLength / steps)); + SliderLength = int(float(BarLength) / steps); if ( SliderLength < 1 ) SliderLength = 1; diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index f1dcdb11..1e6498e7 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -77,13 +77,13 @@ void FStatusKey::processActivate() } //---------------------------------------------------------------------- -void FStatusKey::onAccel (FAccelEvent* event) +void FStatusKey::onAccel (FAccelEvent* ev) { if ( ! isActivated() ) { setActive(); statusbar()->redraw(); - event->accept(); + ev->accept(); } } @@ -329,11 +329,11 @@ void FStatusBar::adjustSize() // public methods of FStatusBar //---------------------------------------------------------------------- -void FStatusBar::onMouseDown (FMouseEvent* event) +void FStatusBar::onMouseDown (FMouseEvent* ev) { if ( hasActivatedKey() ) return; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) { mouse_down = false; if ( ! keylist.empty() ) @@ -371,8 +371,8 @@ void FStatusBar::onMouseDown (FMouseEvent* event) kname_len = int(getKeyName((*iter)->getKey()).getLength()); txt_length = int((*iter)->getText().getLength()); x2 = x1 + kname_len + txt_length + 1; - mouse_x = event->getX(); - mouse_y = event->getY(); + mouse_x = ev->getX(); + mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 @@ -389,11 +389,11 @@ void FStatusBar::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FStatusBar::onMouseUp (FMouseEvent* event) +void FStatusBar::onMouseUp (FMouseEvent* ev) { if ( hasActivatedKey() ) return; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( mouse_down ) @@ -417,8 +417,8 @@ void FStatusBar::onMouseUp (FMouseEvent* event) if ( (*iter)->hasMouseFocus() ) { (*iter)->unsetMouseFocus(); - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 ) (*iter)->setActive(); this->redraw(); @@ -431,11 +431,11 @@ void FStatusBar::onMouseUp (FMouseEvent* event) } //---------------------------------------------------------------------- -void FStatusBar::onMouseMove (FMouseEvent* event) +void FStatusBar::onMouseMove (FMouseEvent* ev) { if ( hasActivatedKey() ) return; - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( mouse_down && ! keylist.empty() ) @@ -454,8 +454,8 @@ void FStatusBar::onMouseMove (FMouseEvent* event) int txt_length = int((*iter)->getText().getLength()); int x2 = x1 + kname_len + txt_length + 1; - int mouse_x = event->getX(); - int mouse_y = event->getY(); + int mouse_x = ev->getX(); + int mouse_y = ev->getY(); if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 ) diff --git a/src/fstring.cpp b/src/fstring.cpp index c3dfa9a3..a14b43ee 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -11,15 +11,18 @@ // constructors and destructor //---------------------------------------------------------------------- FString::FString() -{ - length = 0; - bufsize = 0; - string = 0; - c_string = 0; -} + : string(0) + , length(0) + , bufsize(0) + , c_string(0) +{ } //---------------------------------------------------------------------- FString::FString (int len) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { if ( len >= 0 ) initLength(uInt(len)); @@ -29,18 +32,21 @@ FString::FString (int len) //---------------------------------------------------------------------- FString::FString (uInt len) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { initLength(len); } //---------------------------------------------------------------------- FString::FString (int len, wchar_t c) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - length = 0; - bufsize = 0; - c_string = 0; - if ( len >= 0 ) _replace ( FString(uInt(len), c).string ); else @@ -49,6 +55,10 @@ FString::FString (int len, wchar_t c) //---------------------------------------------------------------------- FString::FString (uInt len, wchar_t c) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { register wchar_t* ps; register wchar_t* pe; @@ -63,6 +73,10 @@ FString::FString (uInt len, wchar_t c) //---------------------------------------------------------------------- FString::FString (int len, char c) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { string = 0; length = 0; @@ -77,6 +91,10 @@ FString::FString (int len, char c) //---------------------------------------------------------------------- FString::FString (uInt len, char c) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { register wchar_t* ps; register wchar_t* pe; @@ -91,84 +109,83 @@ FString::FString (uInt len, char c) //---------------------------------------------------------------------- FString::FString (const FString& s) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - length = 0; - bufsize = 0; - c_string = 0; if ( s.string ) _replace (s.string); } //---------------------------------------------------------------------- FString::FString (const std::wstring& s) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - length = 0; - bufsize = 0; - c_string = 0; if ( ! s.empty() ) _replace ( s.c_str() ); } //---------------------------------------------------------------------- FString::FString (const wchar_t* s) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - length = 0; - bufsize = 0; - c_string = 0; if ( s ) _replace (s); } //---------------------------------------------------------------------- FString::FString (const std::string& s) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - length = 0; - bufsize = 0; - c_string = 0; - if ( ! s.empty() ) { - const wchar_t* wc_str; - wc_str = c_to_wc_str(s.c_str()); + const wchar_t* wc_string; + wc_string = c_to_wc_str(s.c_str()); - if ( wc_str ) + if ( wc_string ) { - _replace( wc_str ); - if ( *wc_str ) - delete[] wc_str; + _replace( wc_string ); + if ( *wc_string ) + delete[] wc_string; } } } //---------------------------------------------------------------------- FString::FString (const char* s) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - const wchar_t* wc_str; + const wchar_t* wc_string; + wc_string = c_to_wc_str(s); - string = 0; - length = 0; - bufsize = 0; - c_string = 0; - - wc_str = c_to_wc_str(s); - - if ( wc_str ) + if ( wc_string ) { - _replace( wc_str ); - if ( *wc_str ) - delete[] wc_str; + _replace( wc_string ); + if ( *wc_string ) + delete[] wc_string; } } //---------------------------------------------------------------------- FString::FString (const wchar_t c) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - c_string = 0; wchar_t s[2]; s[0] = c; s[1] = L'\0'; @@ -177,9 +194,11 @@ FString::FString (const wchar_t c) //---------------------------------------------------------------------- FString::FString (const char c) + : string(0) + , length(0) + , bufsize(0) + , c_string(0) { - string = 0; - c_string = 0; wchar_t s[2]; s[0] = wchar_t(c & 0xff); s[1] = L'\0'; @@ -207,13 +226,6 @@ inline void FString::initLength (uInt len) string = new wchar_t[bufsize]; wmemset(string, L'\0', bufsize); } - else - { - length = 0; - bufsize = 0; - string = 0; - } - c_string = 0; } //---------------------------------------------------------------------- @@ -270,8 +282,8 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s) if ( (length + len + 1) <= bufsize ) { // output string <= bufsize - for (x = length+1; x >= pos+1; x--) - string[x+len-1] = string[x-1]; + for (x = length; x > pos-1; x--) + string[x+len] = string[x]; for (x=0; x < len; x++) string[x+pos] = s[x]; length += len; @@ -293,10 +305,10 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s) } uInt y = 0; for (x=0; x < pos; x++) - sptr[y++] = string[x]; + sptr[y++] = string[x]; for (x=0; x < len; x++) sptr[y++] = s[x]; - for (x=pos; x <= length; x++) + for (x=pos; x < length+1; x++) sptr[y++] = string[x]; length += len; delete[](string); @@ -310,7 +322,7 @@ inline void FString::_remove (uInt pos, uInt len) { if ( (bufsize - length - 1 + len) <= FWDBUFFER ) { - for (uInt i=pos; (i+len) <= length; i++) + for (uInt i=pos; (i+len) < length+1; i++) string[i] = string[i+len]; length -= len; } @@ -331,7 +343,7 @@ inline void FString::_remove (uInt pos, uInt len) uInt x, y = 0; for (x=0; x < pos; x++) sptr[y++] = string[x]; - for (x=pos+len; x <= length; x++) + for (x=pos+len; x < length+1; x++) sptr[y++] = string[x]; delete[](string); string = sptr; @@ -534,12 +546,12 @@ const FString& FString::operator = (const wchar_t* s) //---------------------------------------------------------------------- FString& FString::operator = (const std::string& s) { - const wchar_t* wc_str = c_to_wc_str(s.c_str()); - if ( wc_str ) + const wchar_t* wc_string = c_to_wc_str(s.c_str()); + if ( wc_string ) { - _replace( wc_str ); - if ( *wc_str ) - delete[] wc_str; + _replace( wc_string ); + if ( *wc_string ) + delete[] wc_string; } else length = bufsize = 0, string = 0; @@ -549,12 +561,12 @@ FString& FString::operator = (const std::string& s) //---------------------------------------------------------------------- const FString& FString::operator = (const char* s) { - const wchar_t* wc_str = c_to_wc_str(s); - if ( wc_str ) + const wchar_t* wc_string = c_to_wc_str(s); + if ( wc_string ) { - _replace( wc_str ); - if ( *wc_str ) - delete[] wc_str; + _replace( wc_string ); + if ( *wc_string ) + delete[] wc_string; } else length = bufsize = 0, string = 0; @@ -605,12 +617,12 @@ const FString& FString::operator += (const wchar_t* s) //---------------------------------------------------------------------- const FString& FString::operator += (const std::string& s) { - const wchar_t* wc_str = c_to_wc_str(s.c_str()); - if ( wc_str ) + const wchar_t* wc_string = c_to_wc_str(s.c_str()); + if ( wc_string ) { - _insert (length, uInt(s.length()), wc_str); - if ( *wc_str ) - delete[] wc_str; + _insert (length, uInt(s.length()), wc_string); + if ( *wc_string ) + delete[] wc_string; } return (*this); } @@ -618,12 +630,12 @@ const FString& FString::operator += (const std::string& s) //---------------------------------------------------------------------- const FString& FString::operator += (const char* s) { - const wchar_t* wc_str = c_to_wc_str(s); - if ( wc_str ) + const wchar_t* wc_string = c_to_wc_str(s); + if ( wc_string ) { - _insert (length, uInt(strlen(s)), wc_str); - if ( *wc_str ) - delete[] wc_str; + _insert (length, uInt(strlen(s)), wc_string); + if ( *wc_string ) + delete[] wc_string; } return (*this); } @@ -671,12 +683,12 @@ const FString FString::operator + (const wchar_t* s) const FString FString::operator + (const std::string& s) { FString tmp(string); - wchar_t* wc_str = c_to_wc_str(s.c_str()); - if ( ! wc_str ) + wchar_t* wc_string = c_to_wc_str(s.c_str()); + if ( ! wc_string ) return (tmp); - tmp._insert (length, uInt(wcslen(wc_str)), wc_str); - if ( *wc_str ) - delete[] wc_str; + tmp._insert (length, uInt(wcslen(wc_string)), wc_string); + if ( *wc_string ) + delete[] wc_string; return (tmp); } @@ -684,12 +696,12 @@ const FString FString::operator + (const std::string& s) const FString FString::operator + (const char* s) { FString tmp(string); - wchar_t* wc_str = c_to_wc_str(s); - if ( ! wc_str ) + wchar_t* wc_string = c_to_wc_str(s); + if ( ! wc_string ) return (tmp); - tmp._insert (length, uInt(wcslen(wc_str)), wc_str); - if ( *wc_str ) - delete[] wc_str; + tmp._insert (length, uInt(wcslen(wc_string)), wc_string); + if ( *wc_string ) + delete[] wc_string; return (tmp); } @@ -853,7 +865,7 @@ FString& FString::sprintf (const wchar_t* format, ...) //---------------------------------------------------------------------- FString& FString::sprintf (const char* format, ...) { - const wchar_t* wc_str; + const wchar_t* wc_string; char buf[1024]; char* buffer; int len; @@ -872,12 +884,12 @@ FString& FString::sprintf (const char* format, ...) va_end (args); } - wc_str = c_to_wc_str(buffer); - if ( wc_str ) + wc_string = c_to_wc_str(buffer); + if ( wc_string ) { - this->_replace(wc_str); - if ( *wc_str ) - delete[] wc_str; + this->_replace(wc_string); + if ( *wc_string ) + delete[] wc_string; } if ( buffer != buf ) delete[] buffer; @@ -1126,7 +1138,7 @@ double FString::toDouble() const { if ( ret >= HUGE_VAL || ret <= -HUGE_VAL ) throw std::overflow_error ("overflow"); - if ( ret == 0.0l ) + if ( fabs(ret) < DBL_EPSILON ) // ret == 0.0l throw std::underflow_error ("underflow"); } return ret; @@ -1266,12 +1278,12 @@ FString& FString::setString (const wchar_t* s) //---------------------------------------------------------------------- FString& FString::setString (const char* s) { - const wchar_t* wc_str = c_to_wc_str(s); - if ( wc_str ) + const wchar_t* wc_string = c_to_wc_str(s); + if ( wc_string ) { - _replace (wc_str); - if ( *wc_str ) - delete[] wc_str; + _replace (wc_string); + if ( *wc_string ) + delete[] wc_string; } return (*this); } @@ -1985,13 +1997,13 @@ FString FString::replaceControlCodes() const //---------------------------------------------------------------------- FString FString::expandTabs (uInt tabstop) const { - uLong end; + uLong last; FString instr(this->string); FString outstr(""); std::vector tab_split = instr.split("\t"); - end = tab_split.size(); - for (uInt i=0; i < end; i++) + last = tab_split.size(); + for (uInt i=0; i < last; i++) { uInt len = tab_split[i].getLength(); outstr += tab_split[i] + FString(tabstop - len % tabstop, L' '); @@ -2130,12 +2142,12 @@ bool FString::includes (const wchar_t* s) bool FString::includes (const char* s) { bool ret; - const wchar_t* wc_str = c_to_wc_str(s); - if ( ! wc_str ) + const wchar_t* wc_string = c_to_wc_str(s); + if ( ! wc_string ) return false; - ret = bool(wcsstr(string, wc_str) != 0); - if ( *wc_str ) - delete[] wc_str; + ret = bool(wcsstr(string, wc_string) != 0); + if ( *wc_string ) + delete[] wc_string; return (ret); } diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 7669e78e..47114291 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -119,35 +119,38 @@ void FSwitch::setText (FString txt) } //---------------------------------------------------------------------- -void FSwitch::onKeyPress (FKeyEvent* event) +void FSwitch::onKeyPress (FKeyEvent* ev) { - switch ( event->key() ) + switch ( ev->key() ) { case fc::Fkey_home: case fc::Fkey_left: setChecked(); - event->accept(); + ev->accept(); break; case fc::Fkey_end: case fc::Fkey_right: unsetChecked(); - event->accept(); + ev->accept(); + break; + + default: break; } - if ( event->isAccepted() ) + if ( ev->isAccepted() ) draw(); else - FToggleButton::onKeyPress(event); + FToggleButton::onKeyPress(ev); } //---------------------------------------------------------------------- -void FSwitch::onMouseDown (FMouseEvent* event) +void FSwitch::onMouseDown (FMouseEvent* ev) { - FToggleButton::onMouseDown(event); + FToggleButton::onMouseDown(ev); - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; button_pressed = true; @@ -155,11 +158,11 @@ void FSwitch::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FSwitch::onMouseUp (FMouseEvent* event) +void FSwitch::onMouseUp (FMouseEvent* ev) { - FToggleButton::onMouseUp(event); + FToggleButton::onMouseUp(ev); - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; button_pressed = false; diff --git a/src/fterm.cpp b/src/fterm.cpp index 0ab80a4d..f3e0c744 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -171,7 +171,7 @@ void FTerm::outb_Attribute_Controller (int index, int data) outb (index & 0x1F, AttrC_Index); outb (uChar(data), AttrC_DataW); inb (AttrC_DataSwitch); - outb ((index & 0x1F) | 0x20, AttrC_Index); + outb (uChar((index & 0x1F) | 0x20), AttrC_Index); outb (uChar(data), AttrC_DataW); } @@ -183,7 +183,7 @@ int FTerm::inb_Attribute_Controller (int index) outb (index & 0x1F, AttrC_Index); res = inb (AttrC_DataR); inb (AttrC_DataSwitch); - outb ((index & 0x1F) | 0x20, AttrC_Index); + outb (uChar((index & 0x1F) | 0x20), AttrC_Index); inb (AttrC_DataR); return res; } @@ -912,6 +912,7 @@ void FTerm::signal_handler (int signum) // initialize a resize event to the root element resize_term = true; break; + case SIGTERM: case SIGQUIT: case SIGINT: @@ -1167,6 +1168,9 @@ void FTerm::init() termtype = const_cast("rxvt"); } break; + + default: + break; } } // end of terminal detection @@ -1949,8 +1953,7 @@ void FTerm::getArea (int ax, int ay, FTerm::term_area* area) { ac = &area->text[y * area->width]; tc = &vterm->text[(ay+y) * vterm->width + ax]; - - memcpy (ac, tc, sizeof(FTerm::char_data) * uLong(length)); + memcpy (ac, tc, sizeof(FTerm::char_data) * unsigned(length)); if ( short(area->changes[y].xmin) > 0 ) area->changes[y].xmin = 0; @@ -2003,7 +2006,7 @@ void FTerm::getArea (int x, int y, int w, int h, FTerm::term_area* area) tc = &vterm->text[(y+_y-1) * vterm->width + x-1]; ac = &area->text[(dy+_y) * line_len + dx]; - memcpy (ac, tc, sizeof(FTerm::char_data) * uLong(length)); + memcpy (ac, tc, sizeof(FTerm::char_data) * unsigned(length)); if ( short(area->changes[dy+_y].xmin) > dx ) area->changes[dy+_y].xmin = uInt(dx); @@ -2068,7 +2071,7 @@ void FTerm::putArea (int ax, int ay, FTerm::term_area* area) tc = &vterm->text[(ay+y) * vterm->width + ax]; ac = &area->text[y * line_len + ol]; - memcpy (tc, ac, sizeof(FTerm::char_data) * uLong(length)); + memcpy (tc, ac, sizeof(FTerm::char_data) * unsigned(length)); if ( ax < short(vterm->changes[ay+y].xmin) ) vterm->changes[ay+y].xmin = uInt(ax); @@ -2177,7 +2180,8 @@ bool FTerm::setVGAFont() VGAFont = false; // unicode character mapping struct unimapdesc unimap; - unimap.entry_ct = sizeof(unicode_cp437_pairs) / sizeof(unipair); + unimap.entry_ct = uChar ( sizeof(unicode_cp437_pairs) / + sizeof(unipair) ); unimap.entries = &unicode_cp437_pairs[0]; setUnicodeMap(&unimap); } @@ -2231,7 +2235,8 @@ bool FTerm::setNewFont() if ( ret != 0 ) NewFont = false; // unicode character mapping - unimap.entry_ct = sizeof(unicode_cp437_pairs) / sizeof(unipair); + unimap.entry_ct = uInt16 ( sizeof(unicode_cp437_pairs) / + sizeof(unipair) ); unimap.entries = &unicode_cp437_pairs[0]; setUnicodeMap(&unimap); } @@ -2789,8 +2794,12 @@ void FTerm::setPalette (int index, int r, int g, int b) case 0: ::printf ("\033]11;#%2.2x%2.2x%2.2x\033\\", r, g, b); break; + case 7: ::printf ("\033]10;#%2.2x%2.2x%2.2x\033\\", r, g, b); + + default: + break; } } else @@ -2948,9 +2957,13 @@ bool FTerm::gpmMouse (bool on) { case -1: return false; + case -2: Gpm_Close(); return false; + + default: + break; } } else @@ -3575,7 +3588,11 @@ int FTerm::print (FTerm::term_area* area, FString& s) break; case '\t': - cursor->x_ref() += tabstop - uInt(cursor->x_ref()) + 1 % tabstop; + cursor->x_ref() = short ( uInt(cursor->x_ref()) + + tabstop + - uInt(cursor->x_ref()) + + 1 + % tabstop ); break; case '\b': @@ -3784,6 +3801,10 @@ inline void FTerm::appendAttributes (char_data*& screen_attr) case fc::NF_rev_menu_button3: case fc::NF_rev_border_line_right_and_left: setTermColor (screen_attr->bg_color, screen_attr->fg_color); + break; + + default: + break; } } } diff --git a/src/ftextview.cpp b/src/ftextview.cpp index a409e9c5..fd781dc9 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -188,42 +188,42 @@ void FTextView::hide() } //---------------------------------------------------------------------- -void FTextView::onKeyPress (FKeyEvent* event) +void FTextView::onKeyPress (FKeyEvent* ev) { int last_line = int(getRows()); - int key = event->key(); + int key = ev->key(); switch ( key ) { case fc::Fkey_up: if ( yoffset > 0 ) yoffset--; - event->accept(); + ev->accept(); break; case fc::Fkey_down: if ( yoffset+height+nf_offset-2 < last_line ) yoffset++; - event->accept(); + ev->accept(); break; case fc::Fkey_right: if ( xoffset+width-nf_offset-2 < int(maxLineWidth) ) xoffset++; - event->accept(); + ev->accept(); break; case fc::Fkey_left: if ( xoffset > 0 ) xoffset--; - event->accept(); + ev->accept(); break; case fc::Fkey_ppage: yoffset -= height-2; if ( yoffset < 0 ) yoffset = 0; - event->accept(); + ev->accept(); break; case fc::Fkey_npage: @@ -233,22 +233,25 @@ void FTextView::onKeyPress (FKeyEvent* event) yoffset = last_line - height - nf_offset + 2; if ( yoffset < 0 ) yoffset = 0; - event->accept(); + ev->accept(); break; case fc::Fkey_home: yoffset = 0; - event->accept(); + ev->accept(); break; case fc::Fkey_end: if ( last_line >= height ) yoffset = last_line - height - nf_offset + 2; - event->accept(); + ev->accept(); + break; + + default: break; } - if ( event->isAccepted() ) + if ( ev->isAccepted() ) { if ( isVisible() ) drawText(); @@ -264,9 +267,9 @@ void FTextView::onKeyPress (FKeyEvent* event) } //---------------------------------------------------------------------- -void FTextView::onMouseDown (FMouseEvent* event) +void FTextView::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( ! hasFocus() ) @@ -283,10 +286,10 @@ void FTextView::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FTextView::onWheel (FWheelEvent* event) +void FTextView::onWheel (FWheelEvent* ev) { int last_line = int(getRows()); - int wheel = event->getWheel(); + int wheel = ev->getWheel(); switch ( wheel ) { @@ -299,14 +302,19 @@ void FTextView::onWheel (FWheelEvent* event) break; case WheelDown: - int yoffset_end = last_line - height - nf_offset + 2; - if ( yoffset_end < 0 ) - yoffset_end = 0; - if ( yoffset == yoffset_end ) - break; - yoffset += 4; - if ( yoffset > yoffset_end ) - yoffset = yoffset_end; + { + int yoffset_end = last_line - height - nf_offset + 2; + if ( yoffset_end < 0 ) + yoffset_end = 0; + if ( yoffset == yoffset_end ) + break; + yoffset += 4; + if ( yoffset > yoffset_end ) + yoffset = yoffset_end; + } + break; + + default: break; } @@ -391,6 +399,9 @@ void FTextView::cb_VBarChange (FWidget*, void*) onWheel(&wheel_ev); break; } + + default: + break; } if ( isVisible() ) @@ -465,6 +476,9 @@ void FTextView::cb_HBarChange (FWidget*, void*) if ( xoffset > xoffset_end ) xoffset = xoffset_end; break; + + default: + break; } if ( isVisible() ) diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 30553920..e24b69dc 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -264,14 +264,14 @@ bool FToggleButton::isCheckboxButton() const } //---------------------------------------------------------------------- -void FToggleButton::onKeyPress (FKeyEvent* event) +void FToggleButton::onKeyPress (FKeyEvent* ev) { int key; if ( ! isEnabled() ) return; - key = event->key(); + key = ev->key(); switch ( key ) { @@ -292,25 +292,28 @@ void FToggleButton::onKeyPress (FKeyEvent* event) processToggle(); } processClick(); - event->accept(); + ev->accept(); break; case fc::Fkey_down: case fc::Fkey_right: focus_inside_group = true; focusNextChild(); - event->accept(); + ev->accept(); break; case fc::Fkey_up: case fc::Fkey_left: focus_inside_group = true; focusPrevChild(); - event->accept(); + ev->accept(); + break; + + default: break; } - if ( event->isAccepted() ) + if ( ev->isAccepted() ) { draw(); updateTerminal(); @@ -436,9 +439,9 @@ bool FToggleButton::setFocus(bool on) } //---------------------------------------------------------------------- -void FToggleButton::onMouseDown (FMouseEvent* event) +void FToggleButton::onMouseDown (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; if ( ! hasFocus() ) @@ -460,12 +463,12 @@ void FToggleButton::onMouseDown (FMouseEvent* event) } //---------------------------------------------------------------------- -void FToggleButton::onMouseUp (FMouseEvent* event) +void FToggleButton::onMouseUp (FMouseEvent* ev) { - if ( event->getButton() != LeftButton ) + if ( ev->getButton() != LeftButton ) return; - if ( getGeometryGlobal().contains(event->getGlobalPos()) ) + if ( getGeometryGlobal().contains(ev->getGlobalPos()) ) { if ( isRadioButton() ) { @@ -486,13 +489,13 @@ void FToggleButton::onMouseUp (FMouseEvent* event) } //---------------------------------------------------------------------- -void FToggleButton::onAccel (FAccelEvent* event) +void FToggleButton::onAccel (FAccelEvent* ev) { if ( isEnabled() ) { if ( ! hasFocus() ) { - FWidget* focused_widget = static_cast(event->focusedWidget()); + FWidget* focused_widget = static_cast(ev->focusedWidget()); FFocusEvent out (FocusOut_Event); FApplication::queueEvent(focused_widget, &out); setFocus(); @@ -521,7 +524,7 @@ void FToggleButton::onAccel (FAccelEvent* event) flush_out(); } processClick(); - event->accept(); + ev->accept(); } } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 96152c13..e1c74c9a 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -428,7 +428,7 @@ void FWidget::adjustSize() FObject::object_list children; FObject::object_list::const_iterator iter, end; - children = this->children(); + children = this->getChildren(); iter = children.begin(); end = children.end(); @@ -633,7 +633,7 @@ void FWidget::onAccel (FAccelEvent*) } //---------------------------------------------------------------------- -void FWidget::onResize (FResizeEvent* event) +void FWidget::onResize (FResizeEvent* ev) { if ( openConsole() == 0 ) { @@ -642,7 +642,7 @@ void FWidget::onResize (FResizeEvent* event) } rootObject->resize(); rootObject->redraw(); - event->accept(); + ev->accept(); } //---------------------------------------------------------------------- @@ -656,9 +656,9 @@ void FWidget::onHide (FHideEvent*) } //---------------------------------------------------------------------- -void FWidget::onClose (FCloseEvent* event) +void FWidget::onClose (FCloseEvent* ev) { - event->accept(); + ev->accept(); } //---------------------------------------------------------------------- @@ -666,12 +666,12 @@ bool FWidget::focusNextChild(void) { if ( hasParent() ) { - if ( parent()->hasChildren() ) + if ( getParent()->hasChildren() ) { FObject::object_list children; FObject::object_list::iterator iter, end; - children = parent()->children(); + children = getParent()->getChildren(); iter = children.begin(); end = children.end(); @@ -727,12 +727,12 @@ bool FWidget::focusPrevChild(void) { if ( hasParent() ) { - if ( parent()->hasChildren() ) + if ( getParent()->hasChildren() ) { FObject::object_list children; FObject::object_list::iterator iter, begin; - children = parent()->children(); + children = getParent()->getChildren(); iter = children.end(); begin = children.begin(); do @@ -826,7 +826,7 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) FObject::object_list children; FObject::object_list::const_iterator iter, end; - children = p->children(); + children = p->getChildren(); iter = children.begin(); end = children.end(); @@ -884,7 +884,7 @@ int FWidget::numOfFocusableChildren() int num = 0; - children = this->children(); + children = this->getChildren(); iter = children.begin(); end = children.end(); @@ -901,10 +901,10 @@ int FWidget::numOfFocusableChildren() //---------------------------------------------------------------------- bool FWidget::close() { - FCloseEvent event(Close_Event); - FApplication::sendEvent(this, &event); + FCloseEvent ev(Close_Event); + FApplication::sendEvent(this, &ev); - if ( event.isAccepted() ) + if ( ev.isAccepted() ) { if ( this == getMainWidget() ) quit(); @@ -1165,7 +1165,7 @@ void FWidget::redraw() FObject::object_list children; FObject::object_list::const_iterator iter, end; - children = this->children(); + children = this->getChildren(); iter = children.begin(); end = children.end(); @@ -1256,7 +1256,7 @@ void FWidget::show() FObject::object_list children; FObject::object_list::const_iterator iter, end; - children = this->children(); + children = this->getChildren(); iter = children.begin(); end = children.end(); @@ -1276,8 +1276,8 @@ void FWidget::show() show_root_widget = 0; } - FShowEvent show (Show_Event); - FApplication::sendEvent( this, &show ); + FShowEvent show_ev (Show_Event); + FApplication::sendEvent(this, &show_ev); } //---------------------------------------------------------------------- @@ -1296,8 +1296,8 @@ void FWidget::hide() FWidget::setFocusWidget(parentWidget()); } } - FHideEvent hide (Hide_Event); - FApplication::sendEvent( this, &hide ); + FHideEvent hide_ev (Hide_Event); + FApplication::sendEvent(this, &hide_ev); } } @@ -1322,7 +1322,7 @@ bool FWidget::focusFirstChild (void) if ( ! this->hasChildren() ) return false; - children = this->children(); + children = this->getChildren(); iter = children.begin(); end = children.end(); @@ -1358,7 +1358,7 @@ bool FWidget::focusLastChild (void) if ( ! this->hasChildren() ) return false; - children = this->children(); + children = this->getChildren(); iter = children.end(); begin = children.begin(); @@ -2051,6 +2051,9 @@ void FWidget::setDoubleFlatLine(int side, bool bit) size = double_flatline_mask.left.size(); double_flatline_mask.left.assign(size, bit); break; + + default: + break; } } diff --git a/src/fwidget.h b/src/fwidget.h index 083f39fd..45725023 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -152,6 +152,7 @@ class FWidget : public FObject, public FTerm struct dbl_line_mask { + ~dbl_line_mask() {} std::vector top; std::vector right; std::vector bottom; @@ -391,7 +392,7 @@ inline const char* FWidget::getClassName() const //---------------------------------------------------------------------- inline FWidget* FWidget::parentWidget() const -{ return static_cast(parent()); } +{ return static_cast(getParent()); } //---------------------------------------------------------------------- inline bool FWidget::isRootWidget() const diff --git a/test/calculator.cpp b/test/calculator.cpp index 46eb68d4..a06f4913 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -35,10 +35,10 @@ private: #pragma pack(pop) //---------------------------------------------------------------------- -Button::Button (FWidget* parent) : FButton(parent) -{ - checked = false; -} +Button::Button (FWidget* parent) + : FButton(parent) + , checked(false) +{ } //---------------------------------------------------------------------- void Button::setChecked(bool on) @@ -64,15 +64,15 @@ void Button::setChecked(bool on) } //---------------------------------------------------------------------- -void Button::onKeyPress (FKeyEvent* event) +void Button::onKeyPress (FKeyEvent* ev) { - int key = event->key(); + int key = ev->key(); // catch the enter key if ( key == fc::Fkey_return || key == fc::Fkey_enter ) return; - FButton::onKeyPress(event); + FButton::onKeyPress(ev); } @@ -170,17 +170,22 @@ class Calc : public FDialog #pragma pack(pop) //---------------------------------------------------------------------- -Calc::Calc (FWidget* parent) : FDialog(parent) +Calc::Calc (FWidget* parent) + : FDialog(parent) + , error(false) + , arcus_mode(false) + , hyperbolic_mode(false) + , a(0.0L) + , b(0.0L) + , max_char(32) + , last_key(-1) + , infix_operator('\0') + , last_infix_operator('\0') + , input("") + , bracket_stack() + , calculator_buttons() { - error = false; - arcus_mode = false; - hyperbolic_mode = false; - input = ""; clearInfixOperator(); - last_infix_operator = '\0'; - max_char = 32; - last_key = -1; - a = b = 0.0L; const wchar_t* button_text[Calc::NUM_OF_BUTTONS] = { @@ -428,7 +433,7 @@ void Calc::calcInfixOperator() switch ( infix_operator ) { case '*': - if ( a != 0.0L ) + if ( fabs(a) > LDBL_EPSILON ) // a != 0.0L { // ln(a * b) = ln(a) + ln(b) if ( log(abs(a)) + log(abs(b)) <= log(LDBL_MAX) ) @@ -441,14 +446,14 @@ void Calc::calcInfixOperator() break; case '/': - if ( b != 0.0L ) + if ( fabs(b) > LDBL_EPSILON ) // b != 0.0L a /= b; else error = true; break; case '+': - if ( a != 0.0L ) + if ( fabs(a) > LDBL_EPSILON ) // a != 0.0L { if ( log(abs(a)) + log(abs(1 + b/a)) <= log(LDBL_MAX) ) a += b; @@ -460,7 +465,7 @@ void Calc::calcInfixOperator() break; case '-': - if ( a != 0.0L ) + if ( fabs(b) > LDBL_EPSILON ) // b != 0.0L { if ( log(abs(a)) + log(abs(1 - b/a)) <= log(LDBL_MAX) ) a -= b; @@ -476,15 +481,18 @@ void Calc::calcInfixOperator() if ( errno == EDOM || errno == ERANGE ) error = true; break; + + default: + break; } clearInfixOperator(); } //---------------------------------------------------------------------- -void Calc::onKeyPress (FKeyEvent* event) +void Calc::onKeyPress (FKeyEvent* ev) { int len = int(input.getLength()); - int key = event->key(); + int key = ev->key(); switch ( key ) { @@ -500,14 +508,19 @@ void Calc::onKeyPress (FKeyEvent* event) drawDispay(); updateTerminal(); } - event->accept(); + ev->accept(); break; case fc::Fkey_escape: case fc::Fkey_escape_mintty: - FAccelEvent a_ev(Accelerator_Event, getFocusWidget()); - calculator_buttons[On]->onAccel(&a_ev); - event->accept(); + { + FAccelEvent a_ev(Accelerator_Event, getFocusWidget()); + calculator_buttons[On]->onAccel(&a_ev); + } + ev->accept(); + break; + + default: break; } } @@ -520,7 +533,7 @@ void Calc::onAccel (FAccelEvent* ev) } //---------------------------------------------------------------------- -void Calc::onClose (FCloseEvent* event) +void Calc::onClose (FCloseEvent* ev) { int ret = FMessageBox::info ( this, "Quit", "Do you really want\n" @@ -528,7 +541,7 @@ void Calc::onClose (FCloseEvent* event) FMessageBox::Yes, FMessageBox::No ); - (ret == FMessageBox::Yes) ? event->accept() : event->ignore(); + (ret == FMessageBox::Yes) ? ev->accept() : ev->ignore(); } //---------------------------------------------------------------------- @@ -566,7 +579,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) { if ( arcus_mode ) *x = asin(*x) * 180.0L/PI; - else if ( fmod(*x,180.0L) == 0.0L ) + else if ( fmod(*x,180.0L) < LDBL_EPSILON ) // x/180 = 0 *x = 0.0L; else *x = sin(*x * PI/180.0L); @@ -598,7 +611,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) { if ( arcus_mode ) *x = acos(*x) * 180.0L/PI; - else if ( fmod(*x - 90.0L,180.0L) == 0.0L ) + else if ( fmod(*x - 90.0L,180.0L) < LDBL_EPSILON ) // (x - 90)/180 == 0 *x = 0.0L; else *x = cos(*x * PI/180.0L); @@ -632,9 +645,10 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) if ( arcus_mode ) *x = atan(*x) * 180.0L/PI; else - if ( fmod(*x,180.0L) != 0.0L && fmod(*x,90.0L) == 0.0L ) + // Test if (x/180) != 0 and x/90 == 0 + if ( fmod(*x,180.0L) > LDBL_EPSILON && fmod(*x,90.0L) < LDBL_EPSILON ) error = true; - else if ( fmod(*x,180.0L) == 0.0L ) + else if ( fmod(*x,180.0L) < LDBL_EPSILON ) // x/180 == 0 *x = 0.0L; else *x = tan(*x * PI/180.0L); @@ -649,7 +663,7 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) break; case Reciprocal: // 1/x - if ( *x == 0.0L ) + if ( fabs(*x) < LDBL_EPSILON ) // x == 0 error = true; else { @@ -902,6 +916,9 @@ void Calc::cb_buttonClicked (FWidget*, void* data_ptr) calcInfixOperator(); setDisplay(a); break; + + default: + break; } // end of switch if ( ! input.isEmpty() ) diff --git a/test/mandelbrot.cpp b/test/mandelbrot.cpp index 626459f9..a6e50d0c 100644 --- a/test/mandelbrot.cpp +++ b/test/mandelbrot.cpp @@ -103,7 +103,7 @@ void Mandelbrot::onAccel (FAccelEvent* ev) } //---------------------------------------------------------------------- -void Mandelbrot::onClose (FCloseEvent* event) +void Mandelbrot::onClose (FCloseEvent* ev) { int ret = FMessageBox::info ( this, "Quit", "Do you really want\n" @@ -111,9 +111,9 @@ void Mandelbrot::onClose (FCloseEvent* event) FMessageBox::Yes, FMessageBox::No ); if ( ret == FMessageBox::Yes ) - event->accept(); + ev->accept(); else - event->ignore(); + ev->ignore(); } //---------------------------------------------------------------------- diff --git a/test/watch.cpp b/test/watch.cpp index 1c8d1494..3d307b36 100644 --- a/test/watch.cpp +++ b/test/watch.cpp @@ -64,9 +64,9 @@ watch::watch (FWidget* parent) : FDialog(parent) sec = seconds_sw->setChecked(); // Create button - FButton* quit = new FButton(L"&Quit", this); - quit->setGeometry(6, 9, 9, 1); - quit->setShadow(); + FButton* quit_btn = new FButton(L"&Quit", this); + quit_btn->setGeometry(6, 9, 9, 1); + quit_btn->setShadow(); // Connect switch signal "toggled" with a callback member function @@ -88,7 +88,7 @@ watch::watch (FWidget* parent) : FDialog(parent) ); // Connect button signal "clicked" with a callback member function - quit->addCallback + quit_btn->addCallback ( "clicked", this, @@ -129,7 +129,7 @@ void watch::onTimer (FTimerEvent*) } //---------------------------------------------------------------------- -void watch::onClose (FCloseEvent* event) +void watch::onClose (FCloseEvent* ev) { int ret = FMessageBox::info ( this, "Quit", "Do you really want\n" @@ -137,9 +137,9 @@ void watch::onClose (FCloseEvent* event) FMessageBox::Yes, FMessageBox::No ); if ( ret == FMessageBox::Yes ) - event->accept(); + ev->accept(); else - event->ignore(); + ev->ignore(); } //----------------------------------------------------------------------