diff --git a/src/utils/foxtools/MFXTextFieldIcon.cpp b/src/utils/foxtools/MFXTextFieldIcon.cpp index 30a61b5e1d8..7a1a5791c17 100644 --- a/src/utils/foxtools/MFXTextFieldIcon.cpp +++ b/src/utils/foxtools/MFXTextFieldIcon.cpp @@ -1,178 +1,132 @@ -/******************************************************************************** -* * -* T e x t F i e l d O b j e c t * -* * -********************************************************************************* -* Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. * -********************************************************************************* -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Lesser General Public * -* License as published by the Free Software Foundation; either * -* version 2.1 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -* Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public * -* License along with this library; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * -********************************************************************************* -* $Id: FXTextField.cpp,v 1.171.2.3 2008/09/22 20:46:59 fox Exp $ * -********************************************************************************/ -#include "xincs.h" -#include "fxver.h" -#include "fxdefs.h" -#include "fxkeys.h" -#include "fxascii.h" -#include "fxunicode.h" -#include "FXHash.h" -#include "FXThread.h" -#include "FXStream.h" -#include "FXString.h" -#include "FXSize.h" -#include "FXPoint.h" -#include "FXRectangle.h" -#include "FXRegistry.h" -#include "FXApp.h" -#include "FXDCWindow.h" -#include "FXFont.h" -#include "FXCursor.h" -#include "FXTextField.h" -#include "FX88591Codec.h" -#include "FXCP1252Codec.h" -#include "FXUTF16Codec.h" -#include "FXComposeContext.h" - - -/* - Notes: - - - TextField passes string ptr in the SEL_COMMAND callback. - - Double-click should select word, triple click all of text field. - - TextField should return 0 for all unhandled keys! - - Pressing mouse button will set the focus w/o claiming selection! - - Change of cursor only implies makePositionVisible() if done by user. - - Input verify and input verify callback operation: - - 1) The input is tested to see if it qualifies as an integer or - real number. - 2) The target is allowed to raise an objection: if a target does NOT - handle the message, or handles the message and returns 0, then the - new input is accepted. - 3) If none of the above applies the input is simply accepted; - this is the default mode for generic text type-in. - - Note that the target callback is called AFTER already having verified that - the entry is a number, so a target can simply assume that this has been checked - already and just perform additional checks [e.g. numeric range]. - - Also note that verify callbacks should allow for partially complete inputs, - and that these inputs could be built up a character at a time, and in no - particular order. - - - Option to grow/shrink textfield to fit text. - - Perhaps need selstartpos,selendpos member variables to keep track of selection. - - Maybe also send SEL_SELECTED, SEL_DESELECTED? - - Need block cursor when in overstrike mode. -*/ - +/****************************************************************************/ +// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo +// Copyright (C) 2006-2023 German Aerospace Center (DLR) and others. +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0/ +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License 2.0 are satisfied: GNU General Public License, version 2 +// or later which is available at +// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later +/****************************************************************************/ +/// @file MFXTextFieldIcon.cpp +/// @author Pablo Alvarez Lopez +/// @date Aug 2023 +/// +// +/****************************************************************************/ + +// =========================================================================== +// included modules +// =========================================================================== + + +#include "MFXTextFieldIcon.h" + +#include +#include +#include +#include +#include + + +// =========================================================================== +// Macross +// =========================================================================== #define JUSTIFY_MASK (JUSTIFY_HZ_APART|JUSTIFY_VT_APART) #define TEXTFIELD_MASK (TEXTFIELD_PASSWD|TEXTFIELD_INTEGER|TEXTFIELD_REAL|TEXTFIELD_READONLY|TEXTFIELD_ENTER_ONLY|TEXTFIELD_LIMITED|TEXTFIELD_OVERSTRIKE|TEXTFIELD_AUTOHIDE|TEXTFIELD_AUTOGRAY) -using namespace FX; - -/*******************************************************************************/ +// =========================================================================== +// FOX callback mapping +// =========================================================================== -namespace FX { // Map -FXDEFMAP(FXTextField) FXTextFieldMap[]={ - FXMAPFUNC(SEL_PAINT,0,FXTextField::onPaint), - FXMAPFUNC(SEL_UPDATE,0,FXTextField::onUpdate), - FXMAPFUNC(SEL_MOTION,0,FXTextField::onMotion), - FXMAPFUNC(SEL_TIMEOUT,FXTextField::ID_BLINK,FXTextField::onBlink), - FXMAPFUNC(SEL_TIMEOUT,FXTextField::ID_AUTOSCROLL,FXTextField::onAutoScroll), - FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,FXTextField::onLeftBtnPress), - FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,FXTextField::onLeftBtnRelease), - FXMAPFUNC(SEL_MIDDLEBUTTONPRESS,0,FXTextField::onMiddleBtnPress), - FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE,0,FXTextField::onMiddleBtnRelease), - FXMAPFUNC(SEL_KEYPRESS,0,FXTextField::onKeyPress), - FXMAPFUNC(SEL_KEYRELEASE,0,FXTextField::onKeyRelease), - FXMAPFUNC(SEL_VERIFY,0,FXTextField::onVerify), - FXMAPFUNC(SEL_SELECTION_LOST,0,FXTextField::onSelectionLost), - FXMAPFUNC(SEL_SELECTION_GAINED,0,FXTextField::onSelectionGained), - FXMAPFUNC(SEL_SELECTION_REQUEST,0,FXTextField::onSelectionRequest), - FXMAPFUNC(SEL_CLIPBOARD_LOST,0,FXTextField::onClipboardLost), - FXMAPFUNC(SEL_CLIPBOARD_GAINED,0,FXTextField::onClipboardGained), - FXMAPFUNC(SEL_CLIPBOARD_REQUEST,0,FXTextField::onClipboardRequest), - FXMAPFUNC(SEL_FOCUSIN,0,FXTextField::onFocusIn), - FXMAPFUNC(SEL_FOCUSOUT,0,FXTextField::onFocusOut), - FXMAPFUNC(SEL_FOCUS_SELF,0,FXTextField::onFocusSelf), - FXMAPFUNC(SEL_QUERY_TIP,0,FXTextField::onQueryTip), - FXMAPFUNC(SEL_QUERY_HELP,0,FXTextField::onQueryHelp), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_TOGGLE_EDITABLE,FXTextField::onUpdToggleEditable), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_TOGGLE_OVERSTRIKE,FXTextField::onUpdToggleOverstrike), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_CUT_SEL,FXTextField::onUpdHaveSelection), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_COPY_SEL,FXTextField::onUpdHaveSelection), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_PASTE_SEL,FXTextField::onUpdYes), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_DELETE_SEL,FXTextField::onUpdHaveSelection), - FXMAPFUNC(SEL_UPDATE,FXTextField::ID_SELECT_ALL,FXTextField::onUpdSelectAll), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETVALUE,FXTextField::onCmdSetValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETINTVALUE,FXTextField::onCmdSetIntValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETREALVALUE,FXTextField::onCmdSetRealValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETSTRINGVALUE,FXTextField::onCmdSetStringValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETINTVALUE,FXTextField::onCmdGetIntValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETREALVALUE,FXTextField::onCmdGetRealValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETSTRINGVALUE,FXTextField::onCmdGetStringValue), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_HOME,FXTextField::onCmdCursorHome), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_END,FXTextField::onCmdCursorEnd), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_RIGHT,FXTextField::onCmdCursorRight), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_LEFT,FXTextField::onCmdCursorLeft), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_LEFT,FXTextField::onCmdCursorWordLeft), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_RIGHT,FXTextField::onCmdCursorWordRight), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_START,FXTextField::onCmdCursorWordStart), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_END,FXTextField::onCmdCursorWordEnd), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_MARK,FXTextField::onCmdMark), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_EXTEND,FXTextField::onCmdExtend), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SELECT_ALL,FXTextField::onCmdSelectAll), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DESELECT_ALL,FXTextField::onCmdDeselectAll), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CUT_SEL,FXTextField::onCmdCutSel), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_COPY_SEL,FXTextField::onCmdCopySel), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_PASTE_SEL,FXTextField::onCmdPasteSel), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_PASTE_MIDDLE,FXTextField::onCmdPasteMiddle), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DELETE_SEL,FXTextField::onCmdDeleteSel), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DELETE_ALL,FXTextField::onCmdDeleteAll), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_OVERST_STRING,FXTextField::onCmdOverstString), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_INSERT_STRING,FXTextField::onCmdInsertString), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_BACKSPACE,FXTextField::onCmdBackspace), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DELETE,FXTextField::onCmdDelete), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_TOGGLE_EDITABLE,FXTextField::onCmdToggleEditable), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_TOGGLE_OVERSTRIKE,FXTextField::onCmdToggleOverstrike), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETHELPSTRING,FXTextField::onCmdSetHelp), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETHELPSTRING,FXTextField::onCmdGetHelp), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETTIPSTRING,FXTextField::onCmdSetTip), - FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETTIPSTRING,FXTextField::onCmdGetTip), +FXDEFMAP(MFXTextFieldIcon) MFXTextFieldIconMap[]={ + FXMAPFUNC(SEL_PAINT,0,MFXTextFieldIcon::onPaint), + FXMAPFUNC(SEL_UPDATE,0,MFXTextFieldIcon::onUpdate), + FXMAPFUNC(SEL_MOTION,0,MFXTextFieldIcon::onMotion), + FXMAPFUNC(SEL_TIMEOUT,FXTextField::ID_BLINK,MFXTextFieldIcon::onBlink), + FXMAPFUNC(SEL_TIMEOUT,FXTextField::ID_AUTOSCROLL,MFXTextFieldIcon::onAutoScroll), + FXMAPFUNC(SEL_LEFTBUTTONPRESS,0,MFXTextFieldIcon::onLeftBtnPress), + FXMAPFUNC(SEL_LEFTBUTTONRELEASE,0,MFXTextFieldIcon::onLeftBtnRelease), + FXMAPFUNC(SEL_MIDDLEBUTTONPRESS,0,MFXTextFieldIcon::onMiddleBtnPress), + FXMAPFUNC(SEL_MIDDLEBUTTONRELEASE,0,MFXTextFieldIcon::onMiddleBtnRelease), + FXMAPFUNC(SEL_KEYPRESS,0,MFXTextFieldIcon::onKeyPress), + FXMAPFUNC(SEL_KEYRELEASE,0,MFXTextFieldIcon::onKeyRelease), + FXMAPFUNC(SEL_VERIFY,0,MFXTextFieldIcon::onVerify), + FXMAPFUNC(SEL_SELECTION_LOST,0,MFXTextFieldIcon::onSelectionLost), + FXMAPFUNC(SEL_SELECTION_GAINED,0,MFXTextFieldIcon::onSelectionGained), + FXMAPFUNC(SEL_SELECTION_REQUEST,0,MFXTextFieldIcon::onSelectionRequest), + FXMAPFUNC(SEL_CLIPBOARD_LOST,0,MFXTextFieldIcon::onClipboardLost), + FXMAPFUNC(SEL_CLIPBOARD_GAINED,0,MFXTextFieldIcon::onClipboardGained), + FXMAPFUNC(SEL_CLIPBOARD_REQUEST,0,MFXTextFieldIcon::onClipboardRequest), + FXMAPFUNC(SEL_FOCUSIN,0,MFXTextFieldIcon::onFocusIn), + FXMAPFUNC(SEL_FOCUSOUT,0,MFXTextFieldIcon::onFocusOut), + FXMAPFUNC(SEL_FOCUS_SELF,0,MFXTextFieldIcon::onFocusSelf), + FXMAPFUNC(SEL_QUERY_TIP,0,MFXTextFieldIcon::onQueryTip), + FXMAPFUNC(SEL_QUERY_HELP,0,MFXTextFieldIcon::onQueryHelp), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_TOGGLE_EDITABLE,MFXTextFieldIcon::onUpdToggleEditable), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_TOGGLE_OVERSTRIKE,MFXTextFieldIcon::onUpdToggleOverstrike), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_CUT_SEL,MFXTextFieldIcon::onUpdHaveSelection), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_COPY_SEL,MFXTextFieldIcon::onUpdHaveSelection), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_PASTE_SEL,MFXTextFieldIcon::onUpdYes), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_DELETE_SEL,MFXTextFieldIcon::onUpdHaveSelection), + FXMAPFUNC(SEL_UPDATE,FXTextField::ID_SELECT_ALL,MFXTextFieldIcon::onUpdSelectAll), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETVALUE,MFXTextFieldIcon::onCmdSetValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETINTVALUE,MFXTextFieldIcon::onCmdSetIntValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETREALVALUE,MFXTextFieldIcon::onCmdSetRealValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETSTRINGVALUE,MFXTextFieldIcon::onCmdSetStringValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETINTVALUE,MFXTextFieldIcon::onCmdGetIntValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETREALVALUE,MFXTextFieldIcon::onCmdGetRealValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETSTRINGVALUE,MFXTextFieldIcon::onCmdGetStringValue), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_HOME,MFXTextFieldIcon::onCmdCursorHome), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_END,MFXTextFieldIcon::onCmdCursorEnd), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_RIGHT,MFXTextFieldIcon::onCmdCursorRight), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_LEFT,MFXTextFieldIcon::onCmdCursorLeft), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_LEFT,MFXTextFieldIcon::onCmdCursorWordLeft), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_RIGHT,MFXTextFieldIcon::onCmdCursorWordRight), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_START,MFXTextFieldIcon::onCmdCursorWordStart), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_END,MFXTextFieldIcon::onCmdCursorWordEnd), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_MARK,MFXTextFieldIcon::onCmdMark), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_EXTEND,MFXTextFieldIcon::onCmdExtend), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SELECT_ALL,MFXTextFieldIcon::onCmdSelectAll), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DESELECT_ALL,MFXTextFieldIcon::onCmdDeselectAll), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_CUT_SEL,MFXTextFieldIcon::onCmdCutSel), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_COPY_SEL,MFXTextFieldIcon::onCmdCopySel), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_PASTE_SEL,MFXTextFieldIcon::onCmdPasteSel), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_PASTE_MIDDLE,MFXTextFieldIcon::onCmdPasteMiddle), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DELETE_SEL,MFXTextFieldIcon::onCmdDeleteSel), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DELETE_ALL,MFXTextFieldIcon::onCmdDeleteAll), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_OVERST_STRING,MFXTextFieldIcon::onCmdOverstString), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_INSERT_STRING,MFXTextFieldIcon::onCmdInsertString), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_BACKSPACE,MFXTextFieldIcon::onCmdBackspace), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_DELETE,MFXTextFieldIcon::onCmdDelete), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_TOGGLE_EDITABLE,MFXTextFieldIcon::onCmdToggleEditable), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_TOGGLE_OVERSTRIKE,MFXTextFieldIcon::onCmdToggleOverstrike), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETHELPSTRING,MFXTextFieldIcon::onCmdSetHelp), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETHELPSTRING,MFXTextFieldIcon::onCmdGetHelp), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_SETTIPSTRING,MFXTextFieldIcon::onCmdSetTip), + FXMAPFUNC(SEL_COMMAND,FXTextField::ID_GETTIPSTRING,MFXTextFieldIcon::onCmdGetTip), }; // Object implementation -FXIMPLEMENT(FXTextField,FXFrame,FXTextFieldMap,ARRAYNUMBER(FXTextFieldMap)) - +FXIMPLEMENT(MFXTextFieldIcon,FXFrame,MFXTextFieldIconMap,ARRAYNUMBER(MFXTextFieldIconMap)) -// Delimiters -const FXchar FXTextField::textDelimiters[]="~.,/\\`'!@#$%^&*()-=+{}|[]\":;<>?"; - -/*******************************************************************************/ +// =========================================================================== +// member method definitions +// =========================================================================== // For serialization -FXTextField::FXTextField(){ +MFXTextFieldIcon::MFXTextFieldIcon(){ flags|=FLAG_ENABLED; - delimiters=textDelimiters; + delimiters=FXTextField::textDelimiters; font=(FXFont*)-1L; textColor=0; selbackColor=0; @@ -186,7 +140,7 @@ FXTextField::FXTextField(){ // Construct and init -FXTextField::FXTextField(FXComposite* p,FXint ncols,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb): +MFXTextFieldIcon::MFXTextFieldIcon(FXComposite* p,FXint ncols,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb): FXFrame(p,opts,x,y,w,h,pl,pr,pt,pb){ if(ncols<0) ncols=0; flags|=FLAG_ENABLED; @@ -195,7 +149,7 @@ FXTextField::FXTextField(FXComposite* p,FXint ncols,FXObject* tgt,FXSelector sel if(!(options&JUSTIFY_RIGHT)) options|=JUSTIFY_LEFT; defaultCursor=getApp()->getDefaultCursor(DEF_TEXT_CURSOR); dragCursor=getApp()->getDefaultCursor(DEF_TEXT_CURSOR); - delimiters=textDelimiters; + delimiters=FXTextField::textDelimiters; font=getApp()->getNormalFont(); backColor=getApp()->getBackColor(); textColor=getApp()->getForeColor(); @@ -210,7 +164,7 @@ FXTextField::FXTextField(FXComposite* p,FXint ncols,FXObject* tgt,FXSelector sel // Create X window -void FXTextField::create(){ +void MFXTextFieldIcon::create(){ FXFrame::create(); if(!textType){ textType=getApp()->registerDragType(textTypeName); } if(!utf8Type){ utf8Type=getApp()->registerDragType(utf8TypeName); } @@ -220,7 +174,7 @@ void FXTextField::create(){ // Change the font -void FXTextField::setFont(FXFont* fnt){ +void MFXTextFieldIcon::setFont(FXFont* fnt){ if(!fnt){ fxerror("%s::setFont: NULL font specified.\n",getClassName()); } if(font!=fnt){ font=fnt; @@ -231,7 +185,7 @@ void FXTextField::setFont(FXFont* fnt){ // Enable the window -void FXTextField::enable(){ +void MFXTextFieldIcon::enable(){ if(!(flags&FLAG_ENABLED)){ FXFrame::enable(); update(); @@ -240,7 +194,7 @@ void FXTextField::enable(){ // Disable the window -void FXTextField::disable(){ +void MFXTextFieldIcon::disable(){ if(flags&FLAG_ENABLED){ FXFrame::disable(); update(); @@ -249,19 +203,19 @@ void FXTextField::disable(){ // Get default width -FXint FXTextField::getDefaultWidth(){ +FXint MFXTextFieldIcon::getDefaultWidth(){ return padleft+padright+(border<<1)+columns*font->getTextWidth("8",1); } // Get default height -FXint FXTextField::getDefaultHeight(){ +FXint MFXTextFieldIcon::getDefaultHeight(){ return padtop+padbottom+(border<<1)+font->getFontHeight(); } // Implement auto-hide or auto-gray modes -long FXTextField::onUpdate(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onUpdate(FXObject* sender,FXSelector sel,void* ptr){ if(!FXFrame::onUpdate(sender,sel,ptr)){ if(options&TEXTFIELD_AUTOHIDE){if(shown()){hide();recalc();}} if(options&TEXTFIELD_AUTOGRAY){disable();} @@ -271,7 +225,7 @@ long FXTextField::onUpdate(FXObject* sender,FXSelector sel,void* ptr){ // We now really do have the selection; repaint the text field -long FXTextField::onSelectionGained(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onSelectionGained(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onSelectionGained(sender,sel,ptr); update(); return 1; @@ -279,7 +233,7 @@ long FXTextField::onSelectionGained(FXObject* sender,FXSelector sel,void* ptr){ // We lost the selection somehow; repaint the text field -long FXTextField::onSelectionLost(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onSelectionLost(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onSelectionLost(sender,sel,ptr); update(); return 1; @@ -287,7 +241,7 @@ long FXTextField::onSelectionLost(FXObject* sender,FXSelector sel,void* ptr){ // Somebody wants our selection; the text field will furnish it if the target doesn't -long FXTextField::onSelectionRequest(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onSelectionRequest(FXObject* sender,FXSelector sel,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXString string; FXuint start; @@ -340,14 +294,14 @@ long FXTextField::onSelectionRequest(FXObject* sender,FXSelector sel,void* ptr){ // We now really do have the clipboard, keep clipped text -long FXTextField::onClipboardGained(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onClipboardGained(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onClipboardGained(sender,sel,ptr); return 1; } // We lost the clipboard, free clipped text -long FXTextField::onClipboardLost(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onClipboardLost(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onClipboardLost(sender,sel,ptr); clipped.clear(); return 1; @@ -355,7 +309,7 @@ long FXTextField::onClipboardLost(FXObject* sender,FXSelector sel,void* ptr){ // Somebody wants our clipped text -long FXTextField::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr){ FXEvent *event=(FXEvent*)ptr; FXString string; @@ -399,18 +353,18 @@ long FXTextField::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr){ // Blink the cursor -long FXTextField::onBlink(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onBlink(FXObject*,FXSelector,void*){ drawCursor(flags^FLAG_CARET); - getApp()->addTimeout(this,ID_BLINK,getApp()->getBlinkSpeed()); + getApp()->addTimeout(this,FXTextField::ID_BLINK,getApp()->getBlinkSpeed()); return 0; } // Gained focus -long FXTextField::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onFocusIn(sender,sel,ptr); if(isEditable()){ - getApp()->addTimeout(this,ID_BLINK,getApp()->getBlinkSpeed()); + getApp()->addTimeout(this,FXTextField::ID_BLINK,getApp()->getBlinkSpeed()); drawCursor(FLAG_CARET); } if(hasSelection()){ @@ -421,9 +375,9 @@ long FXTextField::onFocusIn(FXObject* sender,FXSelector sel,void* ptr){ // Lost focus -long FXTextField::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ FXFrame::onFocusOut(sender,sel,ptr); - getApp()->removeTimeout(this,ID_BLINK); + getApp()->removeTimeout(this,FXTextField::ID_BLINK); drawCursor(0); if(hasSelection()){ update(border,border,width-(border<<1),height-(border<<1)); @@ -433,11 +387,11 @@ long FXTextField::onFocusOut(FXObject* sender,FXSelector sel,void* ptr){ // Focus on widget itself -long FXTextField::onFocusSelf(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onFocusSelf(FXObject* sender,FXSelector sel,void* ptr){ if(FXFrame::onFocusSelf(sender,sel,ptr)){ FXEvent *event=(FXEvent*)ptr; if(event->type==SEL_KEYPRESS || event->type==SEL_KEYRELEASE){ - handle(this,FXSEL(SEL_COMMAND,ID_SELECT_ALL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_SELECT_ALL),NULL); } return 1; } @@ -446,11 +400,11 @@ long FXTextField::onFocusSelf(FXObject* sender,FXSelector sel,void* ptr){ // If window can have focus -bool FXTextField::canFocus() const { return true; } +bool MFXTextFieldIcon::canFocus() const { return true; } // Into focus chain -void FXTextField::setFocus(){ +void MFXTextFieldIcon::setFocus(){ FXFrame::setFocus(); setDefault(TRUE); flags&=~FLAG_UPDATE; @@ -461,7 +415,7 @@ void FXTextField::setFocus(){ // Out of focus chain -void FXTextField::killFocus(){ +void MFXTextFieldIcon::killFocus(){ FXFrame::killFocus(); setDefault(MAYBE); flags|=FLAG_UPDATE; @@ -478,35 +432,35 @@ void FXTextField::killFocus(){ // Set help using a message -long FXTextField::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdSetHelp(FXObject*,FXSelector,void* ptr){ setHelpText(*((FXString*)ptr)); return 1; } // Get help using a message -long FXTextField::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdGetHelp(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getHelpText(); return 1; } // Set tip using a message -long FXTextField::onCmdSetTip(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdSetTip(FXObject*,FXSelector,void* ptr){ setTipText(*((FXString*)ptr)); return 1; } // Get tip using a message -long FXTextField::onCmdGetTip(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdGetTip(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getTipText(); return 1; } // We were asked about tip text -long FXTextField::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ if(FXWindow::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); @@ -517,7 +471,7 @@ long FXTextField::onQueryTip(FXObject* sender,FXSelector sel,void* ptr){ // We were asked about status text -long FXTextField::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ +long MFXTextFieldIcon::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ if(FXWindow::onQueryHelp(sender,sel,ptr)) return 1; if((flags&FLAG_HELP) && !help.empty()){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&help); @@ -528,56 +482,56 @@ long FXTextField::onQueryHelp(FXObject* sender,FXSelector sel,void* ptr){ // Update value from a message -long FXTextField::onCmdSetValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdSetValue(FXObject*,FXSelector,void* ptr){ setText((const FXchar*)ptr); return 1; } // Update value from a message -long FXTextField::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdSetIntValue(FXObject*,FXSelector,void* ptr){ setText(FXStringVal(*((FXint*)ptr))); return 1; } // Update value from a message -long FXTextField::onCmdSetRealValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdSetRealValue(FXObject*,FXSelector,void* ptr){ setText(FXStringVal(*((FXdouble*)ptr))); return 1; } // Update value from a message -long FXTextField::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdSetStringValue(FXObject*,FXSelector,void* ptr){ setText(*((FXString*)ptr)); return 1; } // Obtain value from text field -long FXTextField::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdGetIntValue(FXObject*,FXSelector,void* ptr){ *((FXint*)ptr)=FXIntVal(contents); return 1; } // Obtain value from text field -long FXTextField::onCmdGetRealValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdGetRealValue(FXObject*,FXSelector,void* ptr){ *((FXdouble*)ptr)=FXDoubleVal(contents); return 1; } // Obtain value from text field -long FXTextField::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onCmdGetStringValue(FXObject*,FXSelector,void* ptr){ *((FXString*)ptr)=getText(); return 1; } // Pressed left button -long FXTextField::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); @@ -610,7 +564,7 @@ long FXTextField::onLeftBtnPress(FXObject*,FXSelector,void* ptr){ // Released left button -long FXTextField::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled()){ ungrab(); flags&=~FLAG_PRESSED; @@ -622,7 +576,7 @@ long FXTextField::onLeftBtnRelease(FXObject*,FXSelector,void* ptr){ // Pressed middle button to paste -long FXTextField::onMiddleBtnPress(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onMiddleBtnPress(FXObject*,FXSelector,void* ptr){ FXEvent* ev=(FXEvent*)ptr; flags&=~FLAG_TIP; handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); @@ -641,18 +595,18 @@ long FXTextField::onMiddleBtnPress(FXObject*,FXSelector,void* ptr){ // Released middle button causes paste of selection -long FXTextField::onMiddleBtnRelease(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onMiddleBtnRelease(FXObject*,FXSelector,void* ptr){ if(isEnabled()){ ungrab(); if(target && target->tryHandle(this,FXSEL(SEL_MIDDLEBUTTONRELEASE,message),ptr)) return 1; - handle(this,FXSEL(SEL_COMMAND,ID_PASTE_MIDDLE),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_PASTE_MIDDLE),NULL); } return 0; } // Moved -long FXTextField::onMotion(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onMotion(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; FXint t; if(flags&FLAG_PRESSED){ @@ -677,7 +631,7 @@ long FXTextField::onMotion(FXObject*,FXSelector,void* ptr){ // Automatic scroll -long FXTextField::onAutoScroll(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onAutoScroll(FXObject*,FXSelector,void* ptr){ register FXEvent* event=(FXEvent*)ptr; if(flags&FLAG_PRESSED){ register FXint newcursor=cursor; @@ -787,14 +741,14 @@ long FXTextField::onAutoScroll(FXObject*,FXSelector,void* ptr){ // Overstrike toggle -long FXTextField::onCmdToggleOverstrike(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onCmdToggleOverstrike(FXObject*,FXSelector,void*){ setOverstrike(!isOverstrike()); return 1; } // Update overstrike toggle -long FXTextField::onUpdToggleOverstrike(FXObject* sender,FXSelector,void*){ +long MFXTextFieldIcon::onUpdToggleOverstrike(FXObject* sender,FXSelector,void*){ sender->handle(this,isOverstrike()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),NULL); sender->handle(this,FXSEL(SEL_COMMAND,ID_SHOW),NULL); sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),NULL); @@ -804,14 +758,14 @@ long FXTextField::onUpdToggleOverstrike(FXObject* sender,FXSelector,void*){ // Editable toggle -long FXTextField::onCmdToggleEditable(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onCmdToggleEditable(FXObject*,FXSelector,void*){ setEditable(!isEditable()); return 1; } // Update editable toggle -long FXTextField::onUpdToggleEditable(FXObject* sender,FXSelector,void*){ +long MFXTextFieldIcon::onUpdToggleEditable(FXObject* sender,FXSelector,void*){ sender->handle(this,isEditable()?FXSEL(SEL_COMMAND,ID_CHECK):FXSEL(SEL_COMMAND,ID_UNCHECK),NULL); sender->handle(this,FXSEL(SEL_COMMAND,ID_SHOW),NULL); sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),NULL); @@ -820,21 +774,21 @@ long FXTextField::onUpdToggleEditable(FXObject* sender,FXSelector,void*){ // Update somebody who works on the selection -long FXTextField::onUpdHaveSelection(FXObject* sender,FXSelector,void* ptr){ +long MFXTextFieldIcon::onUpdHaveSelection(FXObject* sender,FXSelector,void* ptr){ sender->handle(this,hasSelection()?FXSEL(SEL_COMMAND,ID_ENABLE):FXSEL(SEL_COMMAND,ID_DISABLE),ptr); return 1; } // Update somebody who works on the selection -long FXTextField::onUpdSelectAll(FXObject* sender,FXSelector,void* ptr){ +long MFXTextFieldIcon::onUpdSelectAll(FXObject* sender,FXSelector,void* ptr){ sender->handle(this,contents.empty()?FXSEL(SEL_COMMAND,ID_DISABLE):FXSEL(SEL_COMMAND,ID_ENABLE),ptr); return 1; } // Move the cursor to new valid position -void FXTextField::setCursorPos(FXint pos){ +void MFXTextFieldIcon::setCursorPos(FXint pos){ pos=contents.validate(FXCLAMP(0,pos,contents.length())); if(cursor!=pos){ drawCursor(0); @@ -845,7 +799,7 @@ void FXTextField::setCursorPos(FXint pos){ // Set anchor position to valid position -void FXTextField::setAnchorPos(FXint pos){ +void MFXTextFieldIcon::setAnchorPos(FXint pos){ anchor=contents.validate(FXCLAMP(0,pos,contents.length())); } @@ -854,7 +808,7 @@ void FXTextField::setAnchorPos(FXint pos){ // due to possible overhanging in certain fonts. Also, need to // completely erase and redraw because of ClearType. // Kudos to Bill Baxter for help with this code. -void FXTextField::drawCursor(FXuint state){ +void MFXTextFieldIcon::drawCursor(FXuint state){ FXint cl,ch,xx,xlo,xhi; if((state^flags)&FLAG_CARET){ if(xid){ @@ -910,7 +864,7 @@ void FXTextField::drawCursor(FXuint state){ // Fix scroll amount after text changes or widget resize -void FXTextField::layout(){ +void MFXTextFieldIcon::layout(){ register FXint rr=width-border-padright; register FXint ll=border+padleft; register FXint ww=rr-ll; @@ -951,7 +905,7 @@ void FXTextField::layout(){ // Force position to become fully visible; we assume layout is correct -void FXTextField::makePositionVisible(FXint pos){ +void MFXTextFieldIcon::makePositionVisible(FXint pos){ register FXint rr=width-border-padright; register FXint ll=border+padleft; register FXint ww=rr-ll; @@ -990,7 +944,7 @@ void FXTextField::makePositionVisible(FXint pos){ // Find index from coord -FXint FXTextField::index(FXint x) const { +FXint MFXTextFieldIcon::index(FXint x) const { register FXint rr=width-border-padright; register FXint ll=border+padleft; register FXint mm=(ll+rr)/2; @@ -1021,7 +975,7 @@ FXint FXTextField::index(FXint x) const { // Find coordinate from index -FXint FXTextField::coord(FXint i) const { +FXint MFXTextFieldIcon::coord(FXint i) const { register FXint rr=width-border-padright; register FXint ll=border+padleft; register FXint mm=(ll+rr)/2; @@ -1056,7 +1010,7 @@ FXint FXTextField::coord(FXint i) const { // Return TRUE if position is visible -FXbool FXTextField::isPosVisible(FXint pos) const { +FXbool MFXTextFieldIcon::isPosVisible(FXint pos) const { if(0<=pos && pos<=contents.length()){ register FXint x=coord(contents.validate(pos)); return border+padleft<=x && x<=width-border-padright; @@ -1066,13 +1020,13 @@ FXbool FXTextField::isPosVisible(FXint pos) const { // Return TRUE if position pos is selected -FXbool FXTextField::isPosSelected(FXint pos) const { +FXbool MFXTextFieldIcon::isPosSelected(FXint pos) const { return hasSelection() && FXMIN(anchor,cursor)<=pos && pos<=FXMAX(anchor,cursor); } // Draw text fragment -void FXTextField::drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to){ +void MFXTextFieldIcon::drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to){ x+=font->getTextWidth(contents.text(),fm); y+=font->getFontAscent(); dc.drawText(x,y,&contents[fm],to-fm); @@ -1080,7 +1034,7 @@ void FXTextField::drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint // Draw text fragment in password mode -void FXTextField::drawPWDTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to){ +void MFXTextFieldIcon::drawPWDTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to){ register FXint cw=font->getTextWidth("*",1); register FXint i; y+=font->getFontAscent(); @@ -1090,7 +1044,7 @@ void FXTextField::drawPWDTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FX // Draw range of text -void FXTextField::drawTextRange(FXDCWindow& dc,FXint fm,FXint to){ +void MFXTextFieldIcon::drawTextRange(FXDCWindow& dc,FXint fm,FXint to){ register FXint sx,ex,xx,yy,cw,hh,ww,si,ei,lx,rx,t; register FXint rr=width-border-padright; register FXint ll=border+padleft; @@ -1281,7 +1235,7 @@ void FXTextField::drawTextRange(FXDCWindow& dc,FXint fm,FXint to){ // Handle repaint -long FXTextField::onPaint(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onPaint(FXObject*,FXSelector,void* ptr){ FXEvent *ev=(FXEvent*)ptr; FXDCWindow dc(this,ev); @@ -1314,7 +1268,7 @@ long FXTextField::onPaint(FXObject*,FXSelector,void* ptr){ // Move cursor to begin of line -long FXTextField::onCmdCursorHome(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onCmdCursorHome(FXObject*,FXSelector,void*){ setCursorPos(0); makePositionVisible(0); return 1; @@ -1322,7 +1276,7 @@ long FXTextField::onCmdCursorHome(FXObject*,FXSelector,void*){ // Move cursor to end of line -long FXTextField::onCmdCursorEnd(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onCmdCursorEnd(FXObject*,FXSelector,void*){ setCursorPos(contents.length()); makePositionVisible(cursor); return 1; @@ -1330,7 +1284,7 @@ long FXTextField::onCmdCursorEnd(FXObject*,FXSelector,void*){ // Move cursor right -long FXTextField::onCmdCursorRight(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onCmdCursorRight(FXObject*,FXSelector,void*){ setCursorPos(contents.inc(cursor)); makePositionVisible(cursor); return 1; @@ -1338,7 +1292,7 @@ long FXTextField::onCmdCursorRight(FXObject*,FXSelector,void*){ // Move cursor left -long FXTextField::onCmdCursorLeft(FXObject*,FXSelector,void*){ +long MFXTextFieldIcon::onCmdCursorLeft(FXObject*,FXSelector,void*){ setCursorPos(contents.dec(cursor)); makePositionVisible(cursor); return 1; @@ -1352,7 +1306,7 @@ static FXbool isdelimiter(const FXchar *delimiters,FXwchar w){ // Find end of previous word -FXint FXTextField::leftWord(FXint pos) const { +FXint MFXTextFieldIcon::leftWord(FXint pos) const { register FXint pp=pos,p; // Ensure input is valid @@ -1372,7 +1326,7 @@ FXint FXTextField::leftWord(FXint pos) const { // Find begin of next word -FXint FXTextField::rightWord(FXint pos) const { +FXint MFXTextFieldIcon::rightWord(FXint pos) const { register FXint pp=pos; // Ensure input is valid @@ -1392,7 +1346,7 @@ FXint FXTextField::rightWord(FXint pos) const { // Find begin of a word -FXint FXTextField::wordStart(FXint pos) const { +FXint MFXTextFieldIcon::wordStart(FXint pos) const { register FXint p; FXASSERT(0<=pos && pos<=contents.length()); if(pos==contents.length() || Unicode::isSpace(contents.wc(pos))){ @@ -1409,7 +1363,7 @@ FXint FXTextField::wordStart(FXint pos) const { // Find end of word -FXint FXTextField::wordEnd(FXint pos) const { +FXint MFXTextFieldIcon::wordEnd(FXint pos) const { FXASSERT(0<=pos && pos<=contents.length()); if(pos==contents.length() || Unicode::isSpace(contents.wc(pos))){ while(posstate&SHIFTMASK)){ - handle(this,FXSEL(SEL_COMMAND,ID_DESELECT_ALL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DESELECT_ALL),NULL); } if(event->state&CONTROLMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_CURSOR_WORD_RIGHT),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_RIGHT),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_CURSOR_RIGHT),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CURSOR_RIGHT),NULL); } if(event->state&SHIFTMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_EXTEND),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_EXTEND),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_MARK),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_MARK),NULL); } return 1; case KEY_Left: case KEY_KP_Left: if(!(event->state&SHIFTMASK)){ - handle(this,FXSEL(SEL_COMMAND,ID_DESELECT_ALL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DESELECT_ALL),NULL); } if(event->state&CONTROLMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_CURSOR_WORD_LEFT),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CURSOR_WORD_LEFT),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_CURSOR_LEFT),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CURSOR_LEFT),NULL); } if(event->state&SHIFTMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_EXTEND),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_EXTEND),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_MARK),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_MARK),NULL); } return 1; case KEY_Home: case KEY_KP_Home: if(!(event->state&SHIFTMASK)){ - handle(this,FXSEL(SEL_COMMAND,ID_DESELECT_ALL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DESELECT_ALL),NULL); } - handle(this,FXSEL(SEL_COMMAND,ID_CURSOR_HOME),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CURSOR_HOME),NULL); if(event->state&SHIFTMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_EXTEND),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_EXTEND),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_MARK),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_MARK),NULL); } return 1; case KEY_End: case KEY_KP_End: if(!(event->state&SHIFTMASK)){ - handle(this,FXSEL(SEL_COMMAND,ID_DESELECT_ALL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DESELECT_ALL),NULL); } - handle(this,FXSEL(SEL_COMMAND,ID_CURSOR_END),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CURSOR_END),NULL); if(event->state&SHIFTMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_EXTEND),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_EXTEND),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_MARK),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_MARK),NULL); } return 1; case KEY_Insert: case KEY_KP_Insert: if(event->state&CONTROLMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_COPY_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_COPY_SEL),NULL); return 1; } else if(event->state&SHIFTMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_PASTE_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_PASTE_SEL),NULL); return 1; } else{ - handle(this,FXSEL(SEL_COMMAND,ID_TOGGLE_OVERSTRIKE),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_TOGGLE_OVERSTRIKE),NULL); } return 1; case KEY_Delete: case KEY_KP_Delete: if(hasSelection()){ if(event->state&SHIFTMASK){ - handle(this,FXSEL(SEL_COMMAND,ID_CUT_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CUT_SEL),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_DELETE_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DELETE_SEL),NULL); } } else{ - handle(this,FXSEL(SEL_COMMAND,ID_DELETE),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DELETE),NULL); } return 1; case KEY_BackSpace: if(hasSelection()){ - handle(this,FXSEL(SEL_COMMAND,ID_DELETE_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_DELETE_SEL),NULL); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_BACKSPACE),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_BACKSPACE),NULL); } return 1; case KEY_Return: @@ -1909,30 +1863,30 @@ long FXTextField::onKeyPress(FXObject*,FXSelector,void* ptr){ return 1; case KEY_a: if(!(event->state&CONTROLMASK)) goto ins; - handle(this,FXSEL(SEL_COMMAND,ID_SELECT_ALL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_SELECT_ALL),NULL); return 1; case KEY_x: if(!(event->state&CONTROLMASK)) goto ins; case KEY_F20: // Sun Cut key - handle(this,FXSEL(SEL_COMMAND,ID_CUT_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_CUT_SEL),NULL); return 1; case KEY_c: if(!(event->state&CONTROLMASK)) goto ins; case KEY_F16: // Sun Copy key - handle(this,FXSEL(SEL_COMMAND,ID_COPY_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_COPY_SEL),NULL); return 1; case KEY_v: if(!(event->state&CONTROLMASK)) goto ins; case KEY_F18: // Sun Paste key - handle(this,FXSEL(SEL_COMMAND,ID_PASTE_SEL),NULL); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_PASTE_SEL),NULL); return 1; default: ins: if((event->state&(CONTROLMASK|ALTMASK)) || ((FXuchar)event->text[0]<32)) return 0; if(isOverstrike()){ - handle(this,FXSEL(SEL_COMMAND,ID_OVERST_STRING),(void*)event->text.text()); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_OVERST_STRING),(void*)event->text.text()); } else{ - handle(this,FXSEL(SEL_COMMAND,ID_INSERT_STRING),(void*)event->text.text()); + handle(this,FXSEL(SEL_COMMAND,FXTextField::ID_INSERT_STRING),(void*)event->text.text()); } return 1; } @@ -1942,7 +1896,7 @@ ins: if((event->state&(CONTROLMASK|ALTMASK)) || ((FXuchar)event->text[0]<32)) // Key Release -long FXTextField::onKeyRelease(FXObject*,FXSelector,void* ptr){ +long MFXTextFieldIcon::onKeyRelease(FXObject*,FXSelector,void* ptr){ FXEvent* event=(FXEvent*)ptr; if(isEnabled()){ FXTRACE((200,"%s::onKeyRelease keysym=0x%04x state=%04x\n",getClassName(),((FXEvent*)ptr)->code,((FXEvent*)ptr)->state)); @@ -1981,7 +1935,7 @@ long FXTextField::onKeyRelease(FXObject*,FXSelector,void* ptr){ // Kill the selection -FXbool FXTextField::killSelection(){ +FXbool MFXTextFieldIcon::killSelection(){ if(hasSelection()){ releaseSelection(); update(border,border,width-(border<<1),height-(border<<1)); @@ -1992,7 +1946,7 @@ FXbool FXTextField::killSelection(){ // Select all text -FXbool FXTextField::selectAll(){ +FXbool MFXTextFieldIcon::selectAll(){ setAnchorPos(0); setCursorPos(contents.length()); extendSelection(cursor); @@ -2001,7 +1955,7 @@ FXbool FXTextField::selectAll(){ // Set selection -FXbool FXTextField::setSelection(FXint pos,FXint len){ +FXbool MFXTextFieldIcon::setSelection(FXint pos,FXint len){ setAnchorPos(pos); setCursorPos(pos+len); extendSelection(cursor); @@ -2010,7 +1964,7 @@ FXbool FXTextField::setSelection(FXint pos,FXint len){ // Extend selection -FXbool FXTextField::extendSelection(FXint pos){ +FXbool MFXTextFieldIcon::extendSelection(FXint pos){ FXDragType types[4]; // Validate position to start of character @@ -2038,7 +1992,7 @@ FXbool FXTextField::extendSelection(FXint pos){ // Change the text and move cursor to end -void FXTextField::setText(const FXString& text,FXbool notify){ +void MFXTextFieldIcon::setText(const FXString& text,FXbool notify){ killSelection(); if(contents!=text){ contents=text; @@ -2051,7 +2005,7 @@ void FXTextField::setText(const FXString& text,FXbool notify){ // Set text color -void FXTextField::setTextColor(FXColor clr){ +void MFXTextFieldIcon::setTextColor(FXColor clr){ if(textColor!=clr){ textColor=clr; update(); @@ -2060,7 +2014,7 @@ void FXTextField::setTextColor(FXColor clr){ // Set select background color -void FXTextField::setSelBackColor(FXColor clr){ +void MFXTextFieldIcon::setSelBackColor(FXColor clr){ if(selbackColor!=clr){ selbackColor=clr; update(); @@ -2069,7 +2023,7 @@ void FXTextField::setSelBackColor(FXColor clr){ // Set selected text color -void FXTextField::setSelTextColor(FXColor clr){ +void MFXTextFieldIcon::setSelTextColor(FXColor clr){ if(seltextColor!=clr){ seltextColor=clr; update(); @@ -2078,7 +2032,7 @@ void FXTextField::setSelTextColor(FXColor clr){ // Set cursor color -void FXTextField::setCursorColor(FXColor clr){ +void MFXTextFieldIcon::setCursorColor(FXColor clr){ if(clr!=cursorColor){ cursorColor=clr; update(); @@ -2087,7 +2041,7 @@ void FXTextField::setCursorColor(FXColor clr){ // Change number of columns -void FXTextField::setNumColumns(FXint ncols){ +void MFXTextFieldIcon::setNumColumns(FXint ncols){ if(ncols<0) ncols=0; if(columns!=ncols){ shift=0; @@ -2100,31 +2054,31 @@ void FXTextField::setNumColumns(FXint ncols){ // Return true if editable -FXbool FXTextField::isEditable() const { +FXbool MFXTextFieldIcon::isEditable() const { return (options&TEXTFIELD_READONLY)==0; } // Set editable mode -void FXTextField::setEditable(FXbool edit){ +void MFXTextFieldIcon::setEditable(FXbool edit){ if(edit) options&=~TEXTFIELD_READONLY; else options|=TEXTFIELD_READONLY; } // Return TRUE if overstrike mode in effect -FXbool FXTextField::isOverstrike() const { +FXbool MFXTextFieldIcon::isOverstrike() const { return (options&TEXTFIELD_OVERSTRIKE)!=0; } // Set overstrike mode -void FXTextField::setOverstrike(FXbool over){ +void MFXTextFieldIcon::setOverstrike(FXbool over){ if(over) options|=TEXTFIELD_OVERSTRIKE; else options&=~TEXTFIELD_OVERSTRIKE; } // Change text style -void FXTextField::setTextStyle(FXuint style){ +void MFXTextFieldIcon::setTextStyle(FXuint style){ FXuint opts=(options&~TEXTFIELD_MASK) | (style&TEXTFIELD_MASK); if(options!=opts){ shift=0; @@ -2136,13 +2090,13 @@ void FXTextField::setTextStyle(FXuint style){ // Get text style -FXuint FXTextField::getTextStyle() const { +FXuint MFXTextFieldIcon::getTextStyle() const { return (options&TEXTFIELD_MASK); } // Set text justify style -void FXTextField::setJustify(FXuint style){ +void MFXTextFieldIcon::setJustify(FXuint style){ FXuint opts=(options&~JUSTIFY_MASK) | (style&JUSTIFY_MASK); if(options!=opts){ shift=0; @@ -2154,13 +2108,13 @@ void FXTextField::setJustify(FXuint style){ // Get text justify style -FXuint FXTextField::getJustify() const { +FXuint MFXTextFieldIcon::getJustify() const { return (options&JUSTIFY_MASK); } // Save object to stream -void FXTextField::save(FXStream& store) const { +void MFXTextFieldIcon::save(FXStream& store) const { FXFrame::save(store); store << contents; store << font; @@ -2175,7 +2129,7 @@ void FXTextField::save(FXStream& store) const { // Load object from stream -void FXTextField::load(FXStream& store){ +void MFXTextFieldIcon::load(FXStream& store){ FXFrame::load(store); store >> contents; store >> font; @@ -2190,10 +2144,8 @@ void FXTextField::load(FXStream& store){ // Clean up -FXTextField::~FXTextField(){ - getApp()->removeTimeout(this,ID_BLINK); +MFXTextFieldIcon::~MFXTextFieldIcon(){ + getApp()->removeTimeout(this,FXTextField::ID_BLINK); getApp()->removeTimeout(this,ID_AUTOSCROLL); font=(FXFont*)-1L; - } - -} + } \ No newline at end of file diff --git a/src/utils/foxtools/MFXTextFieldIcon.h b/src/utils/foxtools/MFXTextFieldIcon.h index 4a4708ab84c..89af6e4b72a 100644 --- a/src/utils/foxtools/MFXTextFieldIcon.h +++ b/src/utils/foxtools/MFXTextFieldIcon.h @@ -1,367 +1,296 @@ -/******************************************************************************** -* * -* T e x t F i e l d W i d g e t * -* * -********************************************************************************* -* Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. * -********************************************************************************* -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Lesser General Public * -* License as published by the Free Software Foundation; either * -* version 2.1 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -* Lesser General Public License for more details. * -* * -* You should have received a copy of the GNU Lesser General Public * -* License along with this library; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * -********************************************************************************* -* $Id: FXTextField.h,v 1.62 2006/01/22 17:58:11 fox Exp $ * -********************************************************************************/ -#ifndef FXTEXTFIELD_H -#define FXTEXTFIELD_H - -#ifndef FXFRAME_H -#include "FXFrame.h" -#endif - -namespace FX { - - -/// Textfield styles -enum { - TEXTFIELD_PASSWD = 0x00080000, /// Password mode - TEXTFIELD_INTEGER = 0x00100000, /// Integer mode - TEXTFIELD_REAL = 0x00200000, /// Real mode - TEXTFIELD_READONLY = 0x00400000, /// NOT editable - TEXTFIELD_ENTER_ONLY = 0x00800000, /// Only callback when enter hit - TEXTFIELD_LIMITED = 0x01000000, /// Limit entry to given number of columns - TEXTFIELD_OVERSTRIKE = 0x02000000, /// Overstrike mode - TEXTFIELD_AUTOGRAY = 0x04000000, /// Automatically gray out text field when not updated - TEXTFIELD_AUTOHIDE = 0x08000000, /// Automatically hide text field when not updated - TEXTFIELD_NORMAL = FRAME_SUNKEN|FRAME_THICK - }; - - -/** -* A text field is a single-line text entry widget. -* The text field widget supports clipboard for cut-and-paste -* operations. -* Text input may be constrained to a certain format; the built-in -* capabilities support integer and real number entry constraints; -* additional constraints on the input may be implemented by intercepting -* the SEL_VERIFY message; a custom handler should examine the tentative -* input string passed as type const FXchar* in the message data, and return -* a value of "0" if the new input is accepted. -* During text entry, the text field sends a SEL_CHANGED message to its target, -* with the message data set to the current text value of type const FXchar*. -* When the text is accepted by hitting ENTER, the SEL_COMMAND message is sent. -* The text field also sends SEL_COMMAND when the focus moves to another control. -* TEXTFIELD_ENTER_ONLY can be passed to suppress this feature. Typically, this -* flag is used in dialogs that close when ENTER is hit in a text field. -*/ -class FXAPI FXTextField : public FXFrame { - FXDECLARE(FXTextField) -protected: - FXString contents; // Edited text - const FXchar *delimiters; // Set of delimiters - FXFont *font; // Text font - FXColor textColor; // Text color - FXColor selbackColor; // Selected background color - FXColor seltextColor; // Selected text color - FXColor cursorColor; // Color of the Cursor - FXint cursor; // Cursor position - FXint anchor; // Anchor position - FXint columns; // Number of columns visible - FXint shift; // Shift amount - FXString clipped; // Clipped text - FXString help; // Help string - FXString tip; // Tooltip -protected: - FXTextField(); - FXint index(FXint x) const; - FXint coord(FXint i) const; - void drawCursor(FXuint state); - void drawTextRange(FXDCWindow& dc,FXint fm,FXint to); - void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to); - void drawPWDTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to); - FXint rightWord(FXint pos) const; - FXint leftWord(FXint pos) const; - FXint wordStart(FXint pos) const; - FXint wordEnd(FXint pos) const; -private: - FXTextField(const FXTextField&); - FXTextField& operator=(const FXTextField&); -public: - long onPaint(FXObject*,FXSelector,void*); - long onUpdate(FXObject*,FXSelector,void*); - long onKeyPress(FXObject*,FXSelector,void*); - long onKeyRelease(FXObject*,FXSelector,void*); - long onLeftBtnPress(FXObject*,FXSelector,void*); - long onLeftBtnRelease(FXObject*,FXSelector,void*); - long onMiddleBtnPress(FXObject*,FXSelector,void*); - long onMiddleBtnRelease(FXObject*,FXSelector,void*); - long onVerify(FXObject*,FXSelector,void*); - long onMotion(FXObject*,FXSelector,void*); - long onSelectionLost(FXObject*,FXSelector,void*); - long onSelectionGained(FXObject*,FXSelector,void*); - long onSelectionRequest(FXObject*,FXSelector,void* ptr); - long onClipboardLost(FXObject*,FXSelector,void*); - long onClipboardGained(FXObject*,FXSelector,void*); - long onClipboardRequest(FXObject*,FXSelector,void*); - long onFocusSelf(FXObject*,FXSelector,void*); - long onFocusIn(FXObject*,FXSelector,void*); - long onFocusOut(FXObject*,FXSelector,void*); - long onBlink(FXObject*,FXSelector,void*); - long onAutoScroll(FXObject*,FXSelector,void*); - long onCmdSetValue(FXObject*,FXSelector,void*); - long onCmdSetIntValue(FXObject*,FXSelector,void*); - long onCmdSetRealValue(FXObject*,FXSelector,void*); - long onCmdSetStringValue(FXObject*,FXSelector,void*); - long onCmdGetIntValue(FXObject*,FXSelector,void*); - long onCmdGetRealValue(FXObject*,FXSelector,void*); - long onCmdGetStringValue(FXObject*,FXSelector,void*); - long onCmdCursorHome(FXObject*,FXSelector,void*); - long onCmdCursorEnd(FXObject*,FXSelector,void*); - long onCmdCursorRight(FXObject*,FXSelector,void*); - long onCmdCursorLeft(FXObject*,FXSelector,void*); - long onCmdCursorWordLeft(FXObject*,FXSelector,void*); - long onCmdCursorWordRight(FXObject*,FXSelector,void*); - long onCmdCursorWordStart(FXObject*,FXSelector,void*); - long onCmdCursorWordEnd(FXObject*,FXSelector,void*); - long onCmdMark(FXObject*,FXSelector,void*); - long onCmdExtend(FXObject*,FXSelector,void*); - long onCmdSelectAll(FXObject*,FXSelector,void*); - long onCmdDeselectAll(FXObject*,FXSelector,void*); - long onCmdCutSel(FXObject*,FXSelector,void*); - long onCmdCopySel(FXObject*,FXSelector,void*); - long onCmdPasteSel(FXObject*,FXSelector,void*); - long onCmdPasteMiddle(FXObject*,FXSelector,void*); - long onCmdDeleteSel(FXObject*,FXSelector,void*); - long onCmdDeleteAll(FXObject*,FXSelector,void*); - long onCmdOverstString(FXObject*,FXSelector,void*); - long onCmdInsertString(FXObject*,FXSelector,void*); - long onCmdBackspace(FXObject*,FXSelector,void*); - long onCmdDelete(FXObject*,FXSelector,void*); - long onCmdToggleEditable(FXObject*,FXSelector,void*); - long onUpdToggleEditable(FXObject*,FXSelector,void*); - long onCmdToggleOverstrike(FXObject*,FXSelector,void*); - long onUpdToggleOverstrike(FXObject*,FXSelector,void*); - long onUpdHaveSelection(FXObject*,FXSelector,void*); - long onUpdSelectAll(FXObject*,FXSelector,void*); - long onCmdSetHelp(FXObject*,FXSelector,void*); - long onCmdGetHelp(FXObject*,FXSelector,void*); - long onCmdSetTip(FXObject*,FXSelector,void*); - long onCmdGetTip(FXObject*,FXSelector,void*); - long onQueryHelp(FXObject*,FXSelector,void*); - long onQueryTip(FXObject*,FXSelector,void*); -public: - - /// Default text delimiters - static const FXchar textDelimiters[]; +/****************************************************************************/ +// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo +// Copyright (C) 2006-2023 German Aerospace Center (DLR) and others. +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0/ +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License 2.0 are satisfied: GNU General Public License, version 2 +// or later which is available at +// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later +/****************************************************************************/ +/// @file MFXTextFieldIcon.h +/// @author Pablo Alvarez Lopez +/// @date Aug 2023 +/// +// +/****************************************************************************/ + +#pragma once +#include + +#include "fxheader.h" + + +// =========================================================================== +// class definitions +// =========================================================================== + +class MFXTextFieldIcon : public FXFrame { + FXDECLARE(MFXTextFieldIcon) public: - - enum{ - ID_CURSOR_HOME=FXFrame::ID_LAST, - ID_CURSOR_END, - ID_CURSOR_RIGHT, - ID_CURSOR_LEFT, - ID_CURSOR_WORD_LEFT, - ID_CURSOR_WORD_RIGHT, - ID_CURSOR_WORD_START, - ID_CURSOR_WORD_END, - ID_MARK, - ID_EXTEND, - ID_SELECT_ALL, - ID_DESELECT_ALL, - ID_CUT_SEL, - ID_COPY_SEL, - ID_PASTE_SEL, - ID_PASTE_MIDDLE, - ID_DELETE_SEL, - ID_DELETE_ALL, - ID_OVERST_STRING, - ID_INSERT_STRING, - ID_BACKSPACE, - ID_DELETE, - ID_TOGGLE_EDITABLE, - ID_TOGGLE_OVERSTRIKE, - ID_BLINK, - ID_LAST - }; + long onPaint(FXObject*,FXSelector,void*); + long onUpdate(FXObject*,FXSelector,void*); + long onKeyPress(FXObject*,FXSelector,void*); + long onKeyRelease(FXObject*,FXSelector,void*); + long onLeftBtnPress(FXObject*,FXSelector,void*); + long onLeftBtnRelease(FXObject*,FXSelector,void*); + long onMiddleBtnPress(FXObject*,FXSelector,void*); + long onMiddleBtnRelease(FXObject*,FXSelector,void*); + long onVerify(FXObject*,FXSelector,void*); + long onMotion(FXObject*,FXSelector,void*); + long onSelectionLost(FXObject*,FXSelector,void*); + long onSelectionGained(FXObject*,FXSelector,void*); + long onSelectionRequest(FXObject*,FXSelector,void* ptr); + long onClipboardLost(FXObject*,FXSelector,void*); + long onClipboardGained(FXObject*,FXSelector,void*); + long onClipboardRequest(FXObject*,FXSelector,void*); + long onFocusSelf(FXObject*,FXSelector,void*); + long onFocusIn(FXObject*,FXSelector,void*); + long onFocusOut(FXObject*,FXSelector,void*); + long onBlink(FXObject*,FXSelector,void*); + long onAutoScroll(FXObject*,FXSelector,void*); + long onCmdSetValue(FXObject*,FXSelector,void*); + long onCmdSetIntValue(FXObject*,FXSelector,void*); + long onCmdSetRealValue(FXObject*,FXSelector,void*); + long onCmdSetStringValue(FXObject*,FXSelector,void*); + long onCmdGetIntValue(FXObject*,FXSelector,void*); + long onCmdGetRealValue(FXObject*,FXSelector,void*); + long onCmdGetStringValue(FXObject*,FXSelector,void*); + long onCmdCursorHome(FXObject*,FXSelector,void*); + long onCmdCursorEnd(FXObject*,FXSelector,void*); + long onCmdCursorRight(FXObject*,FXSelector,void*); + long onCmdCursorLeft(FXObject*,FXSelector,void*); + long onCmdCursorWordLeft(FXObject*,FXSelector,void*); + long onCmdCursorWordRight(FXObject*,FXSelector,void*); + long onCmdCursorWordStart(FXObject*,FXSelector,void*); + long onCmdCursorWordEnd(FXObject*,FXSelector,void*); + long onCmdMark(FXObject*,FXSelector,void*); + long onCmdExtend(FXObject*,FXSelector,void*); + long onCmdSelectAll(FXObject*,FXSelector,void*); + long onCmdDeselectAll(FXObject*,FXSelector,void*); + long onCmdCutSel(FXObject*,FXSelector,void*); + long onCmdCopySel(FXObject*,FXSelector,void*); + long onCmdPasteSel(FXObject*,FXSelector,void*); + long onCmdPasteMiddle(FXObject*,FXSelector,void*); + long onCmdDeleteSel(FXObject*,FXSelector,void*); + long onCmdDeleteAll(FXObject*,FXSelector,void*); + long onCmdOverstString(FXObject*,FXSelector,void*); + long onCmdInsertString(FXObject*,FXSelector,void*); + long onCmdBackspace(FXObject*,FXSelector,void*); + long onCmdDelete(FXObject*,FXSelector,void*); + long onCmdToggleEditable(FXObject*,FXSelector,void*); + long onUpdToggleEditable(FXObject*,FXSelector,void*); + long onCmdToggleOverstrike(FXObject*,FXSelector,void*); + long onUpdToggleOverstrike(FXObject*,FXSelector,void*); + long onUpdHaveSelection(FXObject*,FXSelector,void*); + long onUpdSelectAll(FXObject*,FXSelector,void*); + long onCmdSetHelp(FXObject*,FXSelector,void*); + long onCmdGetHelp(FXObject*,FXSelector,void*); + long onCmdSetTip(FXObject*,FXSelector,void*); + long onCmdGetTip(FXObject*,FXSelector,void*); + long onQueryHelp(FXObject*,FXSelector,void*); + long onQueryTip(FXObject*,FXSelector,void*); public: - /// Construct text field wide enough to display ncols columns - FXTextField(FXComposite* p,FXint ncols,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=TEXTFIELD_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); + /// Construct text field wide enough to display ncols columns + MFXTextFieldIcon(FXComposite* p,FXint ncols,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=TEXTFIELD_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); - /// Create server-side resources - virtual void create(); + /// Create server-side resources + virtual void create(); - /// Perform layout - virtual void layout(); + /// Perform layout + virtual void layout(); - /// Enable text field - virtual void enable(); + /// Enable text field + virtual void enable(); - /// Disable text field - virtual void disable(); + /// Disable text field + virtual void disable(); - /// Return default width - virtual FXint getDefaultWidth(); + /// Return default width + virtual FXint getDefaultWidth(); - /// Return default height - virtual FXint getDefaultHeight(); + /// Return default height + virtual FXint getDefaultHeight(); - /// Yes, text field may receive focus - virtual bool canFocus() const; + /// Yes, text field may receive focus + virtual bool canFocus() const; - /// Move the focus to this window - virtual void setFocus(); + /// Move the focus to this window + virtual void setFocus(); - /// Remove the focus from this window - virtual void killFocus(); + /// Remove the focus from this window + virtual void killFocus(); - /// Set editable mode - void setEditable(FXbool edit=TRUE); + /// Set editable mode + void setEditable(FXbool edit=TRUE); - /// Return TRUE if text field may be edited - FXbool isEditable() const; + /// Return TRUE if text field may be edited + FXbool isEditable() const; - /// Set overstrike mode - void setOverstrike(FXbool over=TRUE); + /// Set overstrike mode + void setOverstrike(FXbool over=TRUE); - /// Return TRUE if overstrike mode in effect - FXbool isOverstrike() const; + /// Return TRUE if overstrike mode in effect + FXbool isOverstrike() const; - /// Set cursor position - void setCursorPos(FXint pos); + /// Set cursor position + void setCursorPos(FXint pos); - /// Return cursor position - FXint getCursorPos() const { return cursor; } + /// Return cursor position + FXint getCursorPos() const { return cursor; } - /// Change anchor position - void setAnchorPos(FXint pos); + /// Change anchor position + void setAnchorPos(FXint pos); - /// Return anchor position - FXint getAnchorPos() const { return anchor; } + /// Return anchor position + FXint getAnchorPos() const { return anchor; } - /// Change the text and move cursor to end - void setText(const FXString& text,FXbool notify=FALSE); + /// Change the text and move cursor to end + void setText(const FXString& text,FXbool notify=FALSE); - /// Get the text for this label - FXString getText() const { return contents; } + /// Get the text for this label + FXString getText() const { return contents; } - /// Set the text font - void setFont(FXFont* fnt); + /// Set the text font + void setFont(FXFont* fnt); - /// Get the text font - FXFont* getFont() const { return font; } + /// Get the text font + FXFont* getFont() const { return font; } - /// Change text color - void setTextColor(FXColor clr); + /// Change text color + void setTextColor(FXColor clr); - /// Return text color - FXColor getTextColor() const { return textColor; } + /// Return text color + FXColor getTextColor() const { return textColor; } - /// Change selected background color - void setSelBackColor(FXColor clr); + /// Change selected background color + void setSelBackColor(FXColor clr); - /// Return selected background color - FXColor getSelBackColor() const { return selbackColor; } + /// Return selected background color + FXColor getSelBackColor() const { return selbackColor; } - /// Change selected text color - void setSelTextColor(FXColor clr); + /// Change selected text color + void setSelTextColor(FXColor clr); - /// Return selected text color - FXColor getSelTextColor() const { return seltextColor; } + /// Return selected text color + FXColor getSelTextColor() const { return seltextColor; } - /// Changes the cursor color - void setCursorColor(FXColor clr); + /// Changes the cursor color + void setCursorColor(FXColor clr); - /// Return the cursor color - FXColor getCursorColor() const { return cursorColor; } + /// Return the cursor color + FXColor getCursorColor() const { return cursorColor; } - /** - * Change the default width of the text field in terms of a number - * of columns times the width of the numeral '8'. - */ - void setNumColumns(FXint cols); + /** + * Change the default width of the text field in terms of a number + * of columns times the width of the numeral '8'. + */ + void setNumColumns(FXint cols); - /// Return number of columns - FXint getNumColumns() const { return columns; } + /// Return number of columns + FXint getNumColumns() const { return columns; } - /** - * Change text justification mode. The justify mode is a combination of - * horizontal justification (JUSTIFY_LEFT, JUSTIFY_RIGHT, or JUSTIFY_CENTER_X), - * and vertical justification (JUSTIFY_TOP, JUSTIFY_BOTTOM, JUSTIFY_CENTER_Y). - * Note that JUSTIFY_CENTER_X can not be set from the constructor since by - * default text fields are left-justified. - */ - void setJustify(FXuint mode); + /** + * Change text justification mode. The justify mode is a combination of + * horizontal justification (JUSTIFY_LEFT, JUSTIFY_RIGHT, or JUSTIFY_CENTER_X), + * and vertical justification (JUSTIFY_TOP, JUSTIFY_BOTTOM, JUSTIFY_CENTER_Y). + * Note that JUSTIFY_CENTER_X can not be set from the constructor since by + * default text fields are left-justified. + */ + void setJustify(FXuint mode); - /// Return text justification mode - FXuint getJustify() const; + /// Return text justification mode + FXuint getJustify() const; - /// Change word delimiters - void setDelimiters(const FXchar* delims=textDelimiters){ delimiters=delims; } + /// Change word delimiters + void setDelimiters(const FXchar* delims=FXTextField::textDelimiters){ delimiters=delims; } - /// Return word delimiters - const FXchar* getDelimiters() const { return delimiters; } + /// Return word delimiters + const FXchar* getDelimiters() const { return delimiters; } - /// Set the status line help text for this label - void setHelpText(const FXString& text){ help=text; } + /// Set the status line help text for this label + void setHelpText(const FXString& text){ help=text; } - /// Get the status line help text for this label - const FXString& getHelpText() const { return help; } + /// Get the status line help text for this label + const FXString& getHelpText() const { return help; } - /// Set the tool tip message for this text field - void setTipText(const FXString& text){ tip=text; } + /// Set the tool tip message for this text field + void setTipText(const FXString& text){ tip=text; } - /// Get the tool tip message for this text field - const FXString& getTipText() const { return tip; } + /// Get the tool tip message for this text field + const FXString& getTipText() const { return tip; } - /// Change text style - void setTextStyle(FXuint style); + /// Change text style + void setTextStyle(FXuint style); - /// Return text style - FXuint getTextStyle() const; + /// Return text style + FXuint getTextStyle() const; - /// Select all text - FXbool selectAll(); + /// Select all text + FXbool selectAll(); - /// Select len characters starting at given position pos - FXbool setSelection(FXint pos,FXint len); + /// Select len characters starting at given position pos + FXbool setSelection(FXint pos,FXint len); - /// Extend the selection from the anchor to the given position - FXbool extendSelection(FXint pos); + /// Extend the selection from the anchor to the given position + FXbool extendSelection(FXint pos); - /// Unselect the text - FXbool killSelection(); + /// Unselect the text + FXbool killSelection(); - /// Return TRUE if position pos is selected - FXbool isPosSelected(FXint pos) const; + /// Return TRUE if position pos is selected + FXbool isPosSelected(FXint pos) const; - /// Return TRUE if position is fully visible - FXbool isPosVisible(FXint pos) const; + /// Return TRUE if position is fully visible + FXbool isPosVisible(FXint pos) const; - /// Scroll text to make the given position visible - void makePositionVisible(FXint pos); + /// Scroll text to make the given position visible + void makePositionVisible(FXint pos); - /// Save text field to a stream - virtual void save(FXStream& store) const; + /// Save text field to a stream + virtual void save(FXStream& store) const; - /// Load text field from a stream - virtual void load(FXStream& store); + /// Load text field from a stream + virtual void load(FXStream& store); - /// Destructor - virtual ~FXTextField(); - }; + /// Destructor + virtual ~MFXTextFieldIcon(); -} +protected: + FXString contents; // Edited text + const FXchar *delimiters; // Set of delimiters + FXFont *font; // Text font + FXColor textColor; // Text color + FXColor selbackColor; // Selected background color + FXColor seltextColor; // Selected text color + FXColor cursorColor; // Color of the Cursor + FXint cursor; // Cursor position + FXint anchor; // Anchor position + FXint columns; // Number of columns visible + FXint shift; // Shift amount + FXString clipped; // Clipped text + FXString help; // Help string + FXString tip; // Tooltip + + MFXTextFieldIcon(); + FXint index(FXint x) const; + FXint coord(FXint i) const; + void drawCursor(FXuint state); + void drawTextRange(FXDCWindow& dc,FXint fm,FXint to); + void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to); + void drawPWDTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint fm,FXint to); + FXint rightWord(FXint pos) const; + FXint leftWord(FXint pos) const; + FXint wordStart(FXint pos) const; + FXint wordEnd(FXint pos) const; -#endif +private: + MFXTextFieldIcon(const MFXTextFieldIcon&) = delete; + MFXTextFieldIcon& operator=(const MFXTextFieldIcon&) = delete; +}; \ No newline at end of file