LCOV - code coverage report
Current view: top level - src/utils/foxtools - MFXTextFieldIcon.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 7 0
Test Date: 2024-11-22 15:46:21 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2006-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    MFXTextFieldIcon.h
      15              : /// @author  Pablo Alvarez Lopez
      16              : /// @date    Aug 2023
      17              : ///
      18              : //
      19              : /****************************************************************************/
      20              : 
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include "fxheader.h"
      25              : 
      26              : 
      27              : // ===========================================================================
      28              : // class definitions
      29              : // ===========================================================================
      30              : 
      31              : class MFXTextFieldIcon : public FXFrame {
      32              :     /// @brief FOX declaration
      33            0 :     FXDECLARE(MFXTextFieldIcon)
      34              : 
      35              : public:
      36              :     /// @brief Construct text field wide enough to display ncols columns
      37              :     MFXTextFieldIcon(FXComposite* p, FXint ncols, FXIcon* ic, FXObject* tgt = NULL, FXSelector sel = 0, FXuint opts = TEXTFIELD_NORMAL,
      38              :                      FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0,
      39              :                      FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD);
      40              : 
      41              :     /// @brief Destructor
      42              :     virtual ~MFXTextFieldIcon();
      43              : 
      44              :     /// @brief Create server-side resources
      45              :     virtual void create();
      46              : 
      47              :     /// @brief Perform layout
      48              :     virtual void layout();
      49              : 
      50              :     /// @brief Enable text field
      51              :     virtual void enable();
      52              : 
      53              :     /// @brief Disable text field
      54              :     virtual void disable();
      55              : 
      56              :     /// @brief Return default width
      57              :     virtual FXint getDefaultWidth();
      58              : 
      59              :     /// @brief Return default height
      60              :     virtual FXint getDefaultHeight();
      61              : 
      62              :     /// @brief Yes,  text field may receive focus
      63              :     virtual bool canFocus() const;
      64              : 
      65              :     /// @brief Move the focus to this window
      66              :     virtual void setFocus();
      67              : 
      68              :     /// @brief Remove the focus from this window
      69              :     virtual void killFocus();
      70              : 
      71              :     /// @brief Set editable mode
      72              :     void setEditable(FXbool edit = TRUE);
      73              : 
      74              :     /// @brief Return TRUE if text field may be edited
      75              :     FXbool isEditable() const;
      76              : 
      77              :     /// @brief Set overstrike mode
      78              :     void setOverstrike(FXbool over = TRUE);
      79              : 
      80              :     /// @brief Return TRUE if overstrike mode in effect
      81              :     FXbool isOverstrike() const;
      82              : 
      83              :     /// @brief Set cursor position
      84              :     void setCursorPos(FXint pos);
      85              : 
      86              :     /// @brief Return cursor position
      87              :     FXint getCursorPos() const {
      88              :         return cursor;
      89              :     }
      90              : 
      91              :     /// @brief Change anchor position
      92              :     void setAnchorPos(FXint pos);
      93              : 
      94              :     /// @brief Return anchor position
      95              :     FXint getAnchorPos() const {
      96              :         return anchor;
      97              :     }
      98              : 
      99              :     /// @brief Change the text and move cursor to end
     100              :     void setText(const FXString& text, FXbool notify = FALSE);
     101              : 
     102              :     /// @brief Change the icon
     103              :     void setIcon(FXIcon* ic);
     104              : 
     105              :     /// @brief Get the text for this label
     106              :     FXString getText() const {
     107            0 :         return contents;
     108              :     }
     109              : 
     110              :     /// @brief Set the text font
     111              :     void setFont(FXFont* fnt);
     112              : 
     113              :     /// @brief Get the text font
     114              :     FXFont* getFont() const {
     115              :         return font;
     116              :     }
     117              : 
     118              :     /// @brief Change text color
     119              :     void setTextColor(FXColor clr);
     120              : 
     121              :     /// @brief Return text color
     122              :     FXColor getTextColor() const {
     123            0 :         return textColor;
     124              :     }
     125              : 
     126              :     /// @brief Change selected background color
     127              :     void setSelBackColor(FXColor clr);
     128              : 
     129              :     /// @brief Return selected background color
     130              :     FXColor getSelBackColor() const {
     131              :         return selbackColor;
     132              :     }
     133              : 
     134              :     /// @brief Change selected text color
     135              :     void setSelTextColor(FXColor clr);
     136              : 
     137              :     /// @brief Return selected text color
     138              :     FXColor getSelTextColor() const {
     139              :         return seltextColor;
     140              :     }
     141              : 
     142              :     /// @brief Changes the cursor color
     143              :     void setCursorColor(FXColor clr);
     144              : 
     145              :     /// @brief Return the cursor color
     146              :     FXColor getCursorColor() const {
     147              :         return cursorColor;
     148              :     }
     149              : 
     150              :     /// @brief Change the default width of the text field
     151              :     void setNumColumns(FXint cols);
     152              : 
     153              :     /// @brief Return number of columns
     154              :     FXint getNumColumns() const {
     155              :         return columns;
     156              :     }
     157              : 
     158              :     /// @brief Change text justification mode
     159              :     void setJustify(FXuint mode);
     160              : 
     161              :     /// @brief Return text justification mode
     162              :     FXuint getJustify() const;
     163              : 
     164              :     /// @brief Change word delimiters
     165              :     void setDelimiters(const FXchar* delims = FXTextField::textDelimiters) {
     166              :         delimiters = delims;
     167              :     }
     168              : 
     169              :     /// @brief Return word delimiters
     170              :     const FXchar* getDelimiters() const {
     171              :         return delimiters;
     172              :     }
     173              : 
     174              :     /// @brief Set the status line help text for this label
     175              :     void setHelpText(const FXString& text) {
     176            0 :         help = text;
     177              :     }
     178              : 
     179              :     /// @brief Get the status line help text for this label
     180              :     const FXString& getHelpText() const {
     181            0 :         return help;
     182              :     }
     183              : 
     184              :     /// @brief Set the tool tip message for this text field
     185              :     void setTipText(const FXString& text) {
     186            0 :         tip = text;
     187              :     }
     188              : 
     189              :     /// @brief Get the tool tip message for this text field
     190              :     const FXString& getTipText() const {
     191            0 :         return tip;
     192              :     }
     193              : 
     194              :     /// @brief Change text style
     195              :     void setTextStyle(FXuint style);
     196              : 
     197              :     /// @brief Return text style
     198              :     FXuint getTextStyle() const;
     199              : 
     200              :     /// @brief Select all text
     201              :     FXbool selectAll();
     202              : 
     203              :     /// @brief Select len characters starting at given position pos
     204              :     FXbool setSelection(FXint pos, FXint len);
     205              : 
     206              :     /// @brief Extend the selection from the anchor to the given position
     207              :     FXbool extendSelection(FXint pos);
     208              : 
     209              :     /// @brief Unselect the text
     210              :     FXbool killSelection();
     211              : 
     212              :     /// @brief Return TRUE if position pos is selected
     213              :     FXbool isPosSelected(FXint pos) const;
     214              : 
     215              :     /// @brief Return TRUE if position is fully visible
     216              :     FXbool isPosVisible(FXint pos) const;
     217              : 
     218              :     /// @brief Scroll text to make the given position visible
     219              :     void makePositionVisible(FXint pos);
     220              : 
     221              :     /// @brief Save text field to a stream
     222              :     virtual void save(FXStream& store) const;
     223              : 
     224              :     /// @brief Load text field from a stream
     225              :     virtual void load(FXStream& store);
     226              : 
     227              :     /// @brief fox callbacks
     228              :     /// @{
     229              : 
     230              :     long onPaint(FXObject*, FXSelector, void*);
     231              :     long onUpdate(FXObject*, FXSelector, void*);
     232              :     long onKeyPress(FXObject*, FXSelector, void*);
     233              :     long onKeyRelease(FXObject*, FXSelector, void*);
     234              :     long onLeftBtnPress(FXObject*, FXSelector, void*);
     235              :     long onLeftBtnRelease(FXObject*, FXSelector, void*);
     236              :     long onMiddleBtnPress(FXObject*, FXSelector, void*);
     237              :     long onMiddleBtnRelease(FXObject*, FXSelector, void*);
     238              :     long onVerify(FXObject*, FXSelector, void*);
     239              :     long onMotion(FXObject*, FXSelector, void*);
     240              :     long onSelectionLost(FXObject*, FXSelector, void*);
     241              :     long onSelectionGained(FXObject*, FXSelector, void*);
     242              :     long onSelectionRequest(FXObject*, FXSelector, void* ptr);
     243              :     long onClipboardLost(FXObject*, FXSelector, void*);
     244              :     long onClipboardGained(FXObject*, FXSelector, void*);
     245              :     long onClipboardRequest(FXObject*, FXSelector, void*);
     246              :     long onFocusSelf(FXObject*, FXSelector, void*);
     247              :     long onFocusIn(FXObject*, FXSelector, void*);
     248              :     long onFocusOut(FXObject*, FXSelector, void*);
     249              :     long onBlink(FXObject*, FXSelector, void*);
     250              :     long onAutoScroll(FXObject*, FXSelector, void*);
     251              :     long onCmdSetValue(FXObject*, FXSelector, void*);
     252              :     long onCmdSetIntValue(FXObject*, FXSelector, void*);
     253              :     long onCmdSetRealValue(FXObject*, FXSelector, void*);
     254              :     long onCmdSetStringValue(FXObject*, FXSelector, void*);
     255              :     long onCmdGetIntValue(FXObject*, FXSelector, void*);
     256              :     long onCmdGetRealValue(FXObject*, FXSelector, void*);
     257              :     long onCmdGetStringValue(FXObject*, FXSelector, void*);
     258              :     long onCmdCursorHome(FXObject*, FXSelector, void*);
     259              :     long onCmdCursorEnd(FXObject*, FXSelector, void*);
     260              :     long onCmdCursorRight(FXObject*, FXSelector, void*);
     261              :     long onCmdCursorLeft(FXObject*, FXSelector, void*);
     262              :     long onCmdCursorWordLeft(FXObject*, FXSelector, void*);
     263              :     long onCmdCursorWordRight(FXObject*, FXSelector, void*);
     264              :     long onCmdCursorWordStart(FXObject*, FXSelector, void*);
     265              :     long onCmdCursorWordEnd(FXObject*, FXSelector, void*);
     266              :     long onCmdMark(FXObject*, FXSelector, void*);
     267              :     long onCmdExtend(FXObject*, FXSelector, void*);
     268              :     long onCmdSelectAll(FXObject*, FXSelector, void*);
     269              :     long onCmdDeselectAll(FXObject*, FXSelector, void*);
     270              :     long onCmdCutSel(FXObject*, FXSelector, void*);
     271              :     long onCmdCopySel(FXObject*, FXSelector, void*);
     272              :     long onCmdPasteSel(FXObject*, FXSelector, void*);
     273              :     long onCmdPasteMiddle(FXObject*, FXSelector, void*);
     274              :     long onCmdDeleteSel(FXObject*, FXSelector, void*);
     275              :     long onCmdDeleteAll(FXObject*, FXSelector, void*);
     276              :     long onCmdOverstString(FXObject*, FXSelector, void*);
     277              :     long onCmdInsertString(FXObject*, FXSelector, void*);
     278              :     long onCmdBackspace(FXObject*, FXSelector, void*);
     279              :     long onCmdDelete(FXObject*, FXSelector, void*);
     280              :     long onCmdToggleEditable(FXObject*, FXSelector, void*);
     281              :     long onUpdToggleEditable(FXObject*, FXSelector, void*);
     282              :     long onCmdToggleOverstrike(FXObject*, FXSelector, void*);
     283              :     long onUpdToggleOverstrike(FXObject*, FXSelector, void*);
     284              :     long onUpdHaveSelection(FXObject*, FXSelector, void*);
     285              :     long onUpdSelectAll(FXObject*, FXSelector, void*);
     286              :     long onCmdSetHelp(FXObject*, FXSelector, void*);
     287              :     long onCmdGetHelp(FXObject*, FXSelector, void*);
     288              :     long onCmdSetTip(FXObject*, FXSelector, void*);
     289              :     long onCmdGetTip(FXObject*, FXSelector, void*);
     290              :     long onQueryHelp(FXObject*, FXSelector, void*);
     291              :     long onQueryTip(FXObject*, FXSelector, void*);
     292              : 
     293              :     /// @}
     294              : 
     295              : protected:
     296              :     /// @brief Edited text
     297              :     FXString contents;
     298              : 
     299              :     /// @brief Set of delimiters
     300              :     const FXchar* delimiters = FXTextField::textDelimiters;
     301              : 
     302              :     /// @brief Text font
     303              :     FXFont* font;
     304              : 
     305              :     /// @brief Text color
     306              :     FXColor textColor = 0;
     307              : 
     308              :     /// @brief Selected background color
     309              :     FXColor selbackColor = 0;
     310              : 
     311              :     /// @brief Selected text color
     312              :     FXColor seltextColor = 0;
     313              : 
     314              :     /// @brief Color of the Cursor
     315              :     FXColor cursorColor = 0;
     316              : 
     317              :     /// @brief Cursor position
     318              :     FXint cursor = 0;
     319              : 
     320              :     /// @brief Anchor position
     321              :     FXint anchor = 0;
     322              : 
     323              :     /// @brief Number of columns visible
     324              :     FXint columns = 0;
     325              : 
     326              :     /// @brief Shift amount
     327              :     FXint shift = 0;
     328              : 
     329              :     /// @brief Clipped text
     330              :     FXString clipped;
     331              : 
     332              :     /// @brief Help string
     333              :     FXString help;
     334              : 
     335              :     /// @brief Tooltip
     336              :     FXString tip;
     337              : 
     338              :     /// @brief icon
     339              :     FXIcon* icon = nullptr;
     340              : 
     341              :     /// @brief FOX need this
     342              :     MFXTextFieldIcon();
     343              : 
     344              :     /// @brief index
     345              :     FXint index(FXint x) const;
     346              : 
     347              :     /// @brief coordinates
     348              :     FXint coord(FXint i) const;
     349              : 
     350              :     /// @brief draw cursor
     351              :     void drawCursor(FXuint state);
     352              : 
     353              :     /// @brief draw text range
     354              :     void drawTextRange(FXDCWindow& dc, FXint fm, FXint to);
     355              : 
     356              :     /// @brief draw text fragment
     357              :     void drawTextFragment(FXDCWindow& dc, FXint x, FXint y, FXint fm, FXint to);
     358              : 
     359              :     /// @brief draw password text fragment
     360              :     void drawPWDTextFragment(FXDCWindow& dc, FXint x, FXint y, FXint fm, FXint to);
     361              : 
     362              :     /// @brief right word
     363              :     FXint rightWord(FXint pos) const;
     364              : 
     365              :     /// @brief left word
     366              :     FXint leftWord(FXint pos) const;
     367              : 
     368              :     /// @brief word start
     369              :     FXint wordStart(FXint pos) const;
     370              : 
     371              :     /// @brief word end
     372              :     FXint wordEnd(FXint pos) const;
     373              : 
     374              : private:
     375              :     /// @brief invalidate copy constructor
     376              :     MFXTextFieldIcon(const MFXTextFieldIcon&) = delete;
     377              : 
     378              :     /// @brief invalidate assigment constructor
     379              :     MFXTextFieldIcon& operator=(const MFXTextFieldIcon&) = delete;
     380              : };
        

Generated by: LCOV version 2.0-1