Skip to content

Commit

Permalink
errore: 'eRect eListbox::getPadding()' contrassegnato come 'override',
Browse files Browse the repository at this point in the history
ma non esegue l'override
  • Loading branch information
formiano committed Dec 12, 2024
1 parent bb2387e commit 493197e
Show file tree
Hide file tree
Showing 13 changed files with 514 additions and 150 deletions.
90 changes: 65 additions & 25 deletions lib/gui/elabel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <lib/gui/elabel.h>
#include <lib/gdi/font.h>
#include <lib/gui/ewindowstyleskinned.h>

eLabel::eLabel(eWidget *parent, int markedPos) : eWidget(parent)
{
Expand All @@ -12,14 +13,6 @@ eLabel::eLabel(eWidget *parent, int markedPos) : eWidget(parent)
/* default to topleft alignment */
m_valign = alignTop;
m_halign = alignBidi;

m_have_foreground_color = 0;
m_have_shadow_color = 0;

m_wrap = 1;
m_border_size = 0;

m_text_offset = 0;
}

int eLabel::event(int event, void *data, void *data2)
Expand Down Expand Up @@ -66,6 +59,12 @@ int eLabel::event(int event, void *data, void *data2)
else if (m_wrap == 2)
flags |= gPainter::RT_ELLIPSIS;

if (m_underline)
flags |= gPainter::RT_UNDERLINE;

if (isGradientSet() || m_blend)
flags |= gPainter::RT_BLEND;

int x = m_padding.x();
int y = m_padding.y();

Expand All @@ -75,16 +74,19 @@ int eLabel::event(int event, void *data, void *data2)
auto position = eRect(x, y, w, h);
/* if we don't have shadow, m_shadow_offset will be 0,0 */
auto shadowposition = eRect(position.x() - m_shadow_offset.x(), position.y() - m_shadow_offset.y(), position.width() - m_shadow_offset.x(), position.height() - m_shadow_offset.y());
painter.renderText(shadowposition, m_text, flags, m_border_color, m_border_size, m_pos, &m_text_offset);
painter.renderText(shadowposition, m_text, flags, m_text_border_color, m_text_border_width, m_pos, &m_text_offset, m_tab_width);

if (m_have_shadow_color)
{
if (!m_have_foreground_color)
style->setStyle(painter, eWindowStyle::styleLabel);
else
painter.setForegroundColor(m_foreground_color);

painter.setBackgroundColor(m_shadow_color);
painter.renderText(position, m_text, flags, gRGB(), 0, m_pos);

painter.renderText(position, m_text, flags, gRGB(), 0, m_pos, &m_text_shaddowoffset, m_tab_width);

}

return 0;
Expand Down Expand Up @@ -120,11 +122,6 @@ void eLabel::setFont(gFont *font)
event(evtChangedFont);
}

gFont *eLabel::getFont()
{
return m_font;
}

void eLabel::setVAlign(int align)
{
m_valign = align;
Expand All @@ -147,6 +144,25 @@ void eLabel::setForegroundColor(const gRGB &col)
}
}

gRGB eLabel::getForegroundColor(int styleID)
{
if (m_have_foreground_color)
return m_foreground_color;

ePtr<eWindowStyleManager> mgr;
eWindowStyleManager::getInstance(mgr);

if (mgr) {
ePtr<eWindowStyle> style;
mgr->getStyle(styleID, style);
if(style)
{
return style->getColor(eWindowStyleSkinned::colForeground);
}
}
return gRGB(0xFFFFFF);
}

void eLabel::setShadowColor(const gRGB &col)
{
if ((!m_have_shadow_color) || (m_shadow_color != col))
Expand All @@ -157,30 +173,39 @@ void eLabel::setShadowColor(const gRGB &col)
}
}

void eLabel::setShadowOffset(const ePoint &offset)
void eLabel::setTextBorderColor(const gRGB &col)
{
m_shadow_offset = offset;
if (m_text_border_color != col)
{
m_text_border_color = col;
invalidate();
}
}

void eLabel::setBorderColor(const gRGB &col)
void eLabel::setWrap(int wrap)
{
if (m_border_color != col)
if (m_wrap != wrap)
{
m_border_color = col;
m_wrap = wrap;
invalidate();
}
}

void eLabel::setBorderWidth(int size)
void eLabel::setUnderline(bool underline)
{
m_border_size = size;
if (m_underline != underline)
{
m_underline = underline;
invalidate();
}
}

void eLabel::setWrap(int wrap)
void eLabel::setAlphatest(int alphatest)
{
if (m_wrap != wrap)
bool blend = (alphatest > 0); // blend if BT_ALPHATEST or BT_ALPHABLEND
if (m_blend != blend)
{
m_wrap = wrap;
m_blend = blend;
invalidate();
}
}
Expand All @@ -194,6 +219,21 @@ void eLabel::clearForegroundColor()
}
}

void eLabel::setTabWidth(int width)
{
if (width == -1)
{
eTextPara para(eRect(0, 0, 1000, 1000));
para.setFont(m_font);
para.renderString("W", 0);
m_tab_width = para.getBoundBox().size().width() * 8;
}
else
{
m_tab_width = width;
}
}

eSize eLabel::calculateSize()
{
return calculateTextSize(m_font, m_text, size(), m_wrap == 0);
Expand Down
32 changes: 20 additions & 12 deletions lib/gui/elabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class eLabel : public eWidget
void setText(const std::string &string);
void setMarkedPos(int markedPos);
void setFont(gFont *font);
gFont *getFont();
gFont *getFont() { return m_font; }

enum
{
Expand All @@ -28,16 +28,20 @@ class eLabel : public eWidget

void setForegroundColor(const gRGB &col);
void setShadowColor(const gRGB &col);
void setShadowOffset(const ePoint &offset);
void setBorderColor(const gRGB &col);
void setBorderWidth(int size);
void setShadowOffset(const ePoint &offset) { m_shadow_offset = offset; }
void setBorderColor(const gRGB &col) override { setTextBorderColor(col); } // WILL BE CHANGED !!!!
void setBorderWidth(int width) override { setTextBorderWidth(width); } // WILL BE CHANGED !!!!
void setTextBorderColor(const gRGB &col);
void setTextBorderWidth(int width) { m_text_border_width = width; }
void setWrap(int wrap);
void setNoWrap(int nowrap) { setWrap((nowrap == 1) ? 0 : 1); } // DEPRECATED
void setUnderline(bool underline);
void clearForegroundColor();
int getWrap() const { return m_wrap; }
int getNoWrap() const { return (m_wrap == 0) ? 1 : 0; } // DEPRECATED
void setTextPadding(const eRect &padding) { m_padding = padding; }

void setAlphatest(int alphatest);
void setTabWidth(int width);
gRGB getForegroundColor(int styleID = 0 );
eSize calculateSize();
static eSize calculateTextSize(gFont *font, const std::string &string, eSize targetSize, bool nowrap = false);

Expand All @@ -47,15 +51,19 @@ class eLabel : public eWidget
std::string m_text;
int event(int event, void *data = 0, void *data2 = 0);
int m_pos;
int m_text_offset;
int m_text_offset = 0;
int m_text_shaddowoffset = 0;

private:
int m_have_foreground_color, m_have_shadow_color;
gRGB m_foreground_color, m_shadow_color, m_border_color;
int m_have_foreground_color = 0;
int m_have_shadow_color = 0;
gRGB m_foreground_color, m_shadow_color, m_text_border_color;
ePoint m_shadow_offset;
eRect m_padding = eRect(0, 0, 0, 0);
int m_border_size;
int m_wrap;
int m_text_border_width = 0;
int m_wrap = 1;
bool m_blend = false;
bool m_underline = false;
int m_tab_width = -1;

enum eLabelEvent
{
Expand Down
Loading

0 comments on commit 493197e

Please sign in to comment.