Ticket #8217: EditTextWidget_long.diff

File EditTextWidget_long.diff, 1.8 KB (added by wjp, 21 years ago)

EditTextWidget_long.diff

  • newgui.h

    old new  
    135135        void drawChar(byte c, int x, int y, NewGuiColor color);
    136136        int getStringWidth(const String &str);
    137137        int getCharWidth(byte c);
    138         void drawString(const String &str, int x, int y, int w, NewGuiColor color, int align = kTextAlignLeft);
     138        void drawString(const String &str, int x, int y, int w, NewGuiColor color, int align = kTextAlignLeft, int deltax = 0);
    139139
    140140        void blitFromBuffer(int x, int y, int w, int h, const byte *buf, int pitch);
    141141        void blitToBuffer(int x, int y, int w, int h, byte *buf, int pitch);
  • newgui.cpp

    old new  
    429429        return guifont[c+6];
    430430}
    431431
    432 void NewGui::drawString(const String &str, int x, int y, int w, NewGuiColor color, int align) {
     432void NewGui::drawString(const String &str, int x, int y, int w, NewGuiColor color, int align, int deltax) {
    433433        const int leftX = x, rightX = x + w;
    434434        int width = getStringWidth(str);
    435435        if (align == kTextAlignCenter)
    436436                x = x + (w - width - 1)/2;
    437437        else if (align == kTextAlignRight)
    438438                x = x + w - width;
     439        x += deltax;
    439440
    440441        for (int i = 0; i < str.size(); ++i) {
    441442                w = getCharWidth(str[i]);
  • EditTextWidget.h

    old new  
    3434        bool                    _caretVisible;
    3535        uint32          _caretTime;
    3636        int                             _pos;
     37        int                             _labelOffset;
    3738public:
    3839        EditTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text);
    3940
     
    4748        void drawWidget(bool hilite);
    4849        void drawCaret(bool erase);
    4950        void lostFocusWidget() { _backupString = _label; drawCaret(true); }
     51
     52        int getCaretPos();
     53        bool adjustOffset();
    5054};
    5155
    5256#endif