[DEV] code style step 1
This commit is contained in:
@@ -27,7 +27,7 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
|
||||
m_displayText(_fontName, _fontSize),
|
||||
m_insertMode(false)
|
||||
{
|
||||
SetCanHaveFocus(true);
|
||||
setCanHaveFocus(true);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
RegisterMultiCast(ednMsgGuiCopy);
|
||||
RegisterMultiCast(ednMsgGuiPaste);
|
||||
@@ -40,7 +40,7 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
|
||||
RegisterMultiCast(ednMsgGuiFind);
|
||||
RegisterMultiCast(ednMsgGuiReplace);
|
||||
RegisterMultiCast(ednMsgGuiGotoLine);
|
||||
SetLimitScrolling(0.2);
|
||||
setLimitScrolling(0.2);
|
||||
|
||||
ShortCutAdd("ctrl+w", ednMsgGuiRm, "Line");
|
||||
ShortCutAdd("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
|
||||
@@ -57,7 +57,7 @@ appl::TextViewer::TextViewer(const etk::UString& _fontName, int32_t _fontSize) :
|
||||
APPL_ERROR("can not create buffer ... ");
|
||||
return;
|
||||
}
|
||||
m_buffer->LoadFile("./example.txt");
|
||||
m_buffer->loadFile("./example.txt");
|
||||
|
||||
}
|
||||
|
||||
@@ -67,44 +67,44 @@ appl::TextViewer::~TextViewer(void)
|
||||
}
|
||||
|
||||
|
||||
bool appl::TextViewer::CalculateMinSize(void)
|
||||
bool appl::TextViewer::calculateMinSize(void)
|
||||
{
|
||||
m_minSize.setValue(50,50);
|
||||
return true;
|
||||
}
|
||||
|
||||
void appl::TextViewer::CalculateMaxSize(void)
|
||||
void appl::TextViewer::calculateMaxSize(void)
|
||||
{
|
||||
m_maxSize.setX(256);
|
||||
m_maxSize.setY(256);
|
||||
}
|
||||
|
||||
|
||||
void appl::TextViewer::OnDraw(void)
|
||||
void appl::TextViewer::onDraw(void)
|
||||
{
|
||||
m_displayDrawing.Draw();
|
||||
m_displayText.Draw();
|
||||
WidgetScrooled::OnDraw();
|
||||
m_displayDrawing.draw();
|
||||
m_displayText.draw();
|
||||
WidgetScrooled::onDraw();
|
||||
}
|
||||
|
||||
void appl::TextViewer::OnRegenerateDisplay(void)
|
||||
void appl::TextViewer::onRegenerateDisplay(void)
|
||||
{
|
||||
if (false == NeedRedraw()) {
|
||||
if (false == needRedraw()) {
|
||||
return;
|
||||
}
|
||||
// For the scrooling windows
|
||||
CalculateMaxSize();
|
||||
m_displayDrawing.Clear();
|
||||
m_displayText.Clear();
|
||||
calculateMaxSize();
|
||||
m_displayDrawing.clear();
|
||||
m_displayText.clear();
|
||||
|
||||
// Reset the background :
|
||||
m_displayDrawing.SetPos(vec3(0, 0, 0));
|
||||
m_displayDrawing.SetColor(etk::Color<>(220, 220, 220, 256));
|
||||
m_displayDrawing.RectangleWidth(m_size);
|
||||
// reset the background :
|
||||
m_displayDrawing.setPos(vec3(0, 0, 0));
|
||||
m_displayDrawing.setColor(etk::Color<>(220, 220, 220, 256));
|
||||
m_displayDrawing.rectangleWidth(m_size);
|
||||
|
||||
if (m_buffer == NULL) {
|
||||
m_displayText.SetTextAlignement(10, m_size.x()-20, ewol::Text::alignLeft);
|
||||
m_displayText.SetRelPos(vec3(10, 0, 0));
|
||||
m_displayText.setTextAlignement(10, m_size.x()-20, ewol::Text::alignLeft);
|
||||
m_displayText.setRelPos(vec3(10, 0, 0));
|
||||
etk::UString tmpString("<br/>\n"
|
||||
"<font color=\"red\">\n"
|
||||
" <b>\n"
|
||||
@@ -118,131 +118,131 @@ void appl::TextViewer::OnRegenerateDisplay(void)
|
||||
" No Buffer Availlable to display\n"
|
||||
" </i>\n"
|
||||
"</font>\n");
|
||||
m_displayText.SetPos(vec3(0.0f, m_size.y(), 0.0f) );
|
||||
m_displayText.ForceLineReturn();
|
||||
m_displayText.PrintDecorated(tmpString);
|
||||
m_displayText.setPos(vec3(0.0f, m_size.y(), 0.0f) );
|
||||
m_displayText.forceLineReturn();
|
||||
m_displayText.printDecorated(tmpString);
|
||||
// call the herited class...
|
||||
WidgetScrooled::OnRegenerateDisplay();
|
||||
WidgetScrooled::onRegenerateDisplay();
|
||||
return;
|
||||
}
|
||||
// normal displa of the buffer :
|
||||
vec3 tmpCursorPosition(0, 0, -1);
|
||||
// real display ...
|
||||
etk::Buffer& buf = m_buffer->GetData();
|
||||
m_displayText.SetColor(etk::Color<>(0, 0, 0, 256));
|
||||
etk::Buffer& buf = m_buffer->getData();
|
||||
m_displayText.setColor(etk::Color<>(0, 0, 0, 256));
|
||||
float countNbLine = 1;
|
||||
esize_t countColomn = 0;
|
||||
vec3 tmpLetterSize = m_displayText.CalculateSize((uniChar_t)'A');
|
||||
vec3 tmpLetterSize = m_displayText.calculateSize((uniChar_t)'A');
|
||||
vec3 positionCurentDisplay(0.0f, m_size.y()-tmpLetterSize.y(), 0.0f);
|
||||
m_displayText.SetPos(positionCurentDisplay);
|
||||
m_displayText.setPos(positionCurentDisplay);
|
||||
// the siplay string :
|
||||
etk::UString stringToDisplay;
|
||||
esize_t bufferElementSize = 0;
|
||||
etk::UniChar currentValue;
|
||||
for (int32_t iii=0; iii<buf.Size(); iii+=bufferElementSize) {
|
||||
if (iii==m_buffer->m_cursorPos) {
|
||||
for (int32_t iii=0; iii<buf.size(); iii+=bufferElementSize) {
|
||||
if (iii == m_buffer->m_cursorPos) {
|
||||
// need to display the cursor :
|
||||
tmpCursorPosition = positionCurentDisplay;
|
||||
}
|
||||
bufferElementSize = m_buffer->Get(iii, currentValue);
|
||||
bufferElementSize = m_buffer->get(iii, currentValue);
|
||||
//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
|
||||
if (currentValue == etk::UniChar::Return) {
|
||||
countNbLine += 1;
|
||||
countColomn = 0;
|
||||
if (bufferElementSize ==0) {
|
||||
if (bufferElementSize == 0) {
|
||||
bufferElementSize = 1;
|
||||
}
|
||||
positionCurentDisplay.setX(0);
|
||||
positionCurentDisplay.setY(positionCurentDisplay.y()-tmpLetterSize.y());
|
||||
m_displayText.SetPos(positionCurentDisplay);
|
||||
m_displayText.setPos(positionCurentDisplay);
|
||||
continue;
|
||||
}
|
||||
m_buffer->Expand(countColomn, currentValue, stringToDisplay);
|
||||
//APPL_DEBUG("display : '" << currentValue << "' ==> '" << stringToDisplay << "'");
|
||||
//m_displayText.SetPos(positionCurentDisplay);
|
||||
for (esize_t kkk=0; kkk<stringToDisplay.Size(); ++kkk) {
|
||||
m_displayText.Print(stringToDisplay[kkk]);
|
||||
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
|
||||
//m_displayText.setPos(positionCurentDisplay);
|
||||
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
||||
m_displayText.print(stringToDisplay[kkk]);
|
||||
}
|
||||
positionCurentDisplay = m_displayText.GetPos();
|
||||
countColomn += stringToDisplay.Size();
|
||||
positionCurentDisplay = m_displayText.getPos();
|
||||
countColomn += stringToDisplay.size();
|
||||
|
||||
if (bufferElementSize ==0) {
|
||||
if (bufferElementSize == 0) {
|
||||
bufferElementSize = 1;
|
||||
}
|
||||
}
|
||||
if (tmpCursorPosition.z()!=-1) {
|
||||
// display the cursor:
|
||||
//APPL_DEBUG("display cursor at position : " << tmpCursorPosition);
|
||||
m_displayText.SetPos(tmpCursorPosition);
|
||||
m_displayText.SetColor(etk::Color<>(0xFF0000FF));
|
||||
m_displayText.SetColorBg(etk::Color<>(0xFF0000FF));
|
||||
m_displayText.PrintCursor(m_insertMode);
|
||||
m_displayText.setPos(tmpCursorPosition);
|
||||
m_displayText.setColor(etk::Color<>(0xFF0000FF));
|
||||
m_displayText.setColorBg(etk::Color<>(0xFF0000FF));
|
||||
m_displayText.printCursor(m_insertMode);
|
||||
}
|
||||
// call the herited class...
|
||||
WidgetScrooled::OnRegenerateDisplay();
|
||||
WidgetScrooled::onRegenerateDisplay();
|
||||
}
|
||||
|
||||
|
||||
bool appl::TextViewer::OnEventEntry(const ewol::EventEntry& _event)
|
||||
bool appl::TextViewer::onEventEntry(const ewol::EventEntry& _event)
|
||||
{
|
||||
if (m_buffer == NULL) {
|
||||
return false;
|
||||
}
|
||||
// just forward event ==> manage directly in the buffer
|
||||
if (m_buffer->OnEventEntry(_event) == true) {
|
||||
MarkToRedraw();
|
||||
// just forward event == > manage directly in the buffer
|
||||
if (m_buffer->onEventEntry(_event) == true) {
|
||||
markToRedraw();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool appl::TextViewer::OnEventInput(const ewol::EventInput& _event)
|
||||
bool appl::TextViewer::onEventInput(const ewol::EventInput& _event)
|
||||
{
|
||||
vec2 relativePos = RelativePosition(_event.GetPos());
|
||||
vec2 relativePos = relativePosition(_event.getPos());
|
||||
if (m_buffer != NULL) {
|
||||
|
||||
}
|
||||
KeepFocus();
|
||||
keepFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
void appl::TextViewer::OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID)
|
||||
void appl::TextViewer::onEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID)
|
||||
{
|
||||
if (m_buffer != NULL) {
|
||||
//tmpBuffer->Paste(_clipboardID);
|
||||
}
|
||||
MarkToRedraw();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void appl::TextViewer::OnReceiveMessage(const ewol::EMessage& _msg)
|
||||
void appl::TextViewer::onReceiveMessage(const ewol::EMessage& _msg)
|
||||
{
|
||||
// Force redraw of the widget
|
||||
MarkToRedraw();
|
||||
// force redraw of the widget
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void appl::TextViewer::OnGetFocus(void)
|
||||
void appl::TextViewer::onGetFocus(void)
|
||||
{
|
||||
ShowKeyboard();
|
||||
APPL_INFO("Focus - In");
|
||||
}
|
||||
|
||||
|
||||
void appl::TextViewer::OnLostFocus(void)
|
||||
void appl::TextViewer::onLostFocus(void)
|
||||
{
|
||||
HideKeyboard();
|
||||
APPL_INFO("Focus - out");
|
||||
}
|
||||
|
||||
void appl::TextViewer::SetFontSize(int32_t _size)
|
||||
void appl::TextViewer::setFontSize(int32_t _size)
|
||||
{
|
||||
m_displayText.SetFontSize(_size);
|
||||
SetScrollingSize(_size*3.0*1.46); // 1.46 is a magic number ...
|
||||
m_displayText.setFontSize(_size);
|
||||
setScrollingSize(_size*3.0*1.46); // 1.46 is a magic number ...
|
||||
}
|
||||
|
||||
void appl::TextViewer::SetFontName(const etk::UString& _fontName)
|
||||
void appl::TextViewer::setFontName(const etk::UString& _fontName)
|
||||
{
|
||||
m_displayText.SetFontName(_fontName);
|
||||
m_displayText.setFontName(_fontName);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user