Files
MuditaOS/module-apps/application-notes/widgets/NotesItem.cpp
Adam Dobrowolski 164b9281c8 EGD-2195 - Changed sizes for fonts in project
* changed all fonts to follow one `Style.hpp` include
* Moved title to AppWindow from all the places in code
* added logging on font selection - when not found
* minor fixes
2019-10-25 13:04:33 +02:00

76 lines
1.9 KiB
C++

/*
* @file NotesItem.cpp
* @author Robert Borzecki (robert.borzecki@mudita.com)
* @date 12 sie 2019
* @brief
* @copyright Copyright (C) 2019 mudita.com
* @details
*/
#include "NotesItem.hpp"
#include <Style.hpp>
namespace gui {
NotesItem::NotesItem(NotesModel* model, bool mode24H) : model{model}, mode24H{mode24H} {
minWidth = 436;
minHeight = 146;
maxWidth = 436;
maxHeight = 146;
setRadius( 8 );
setPenFocusWidth(3);
setPenWidth(1);
hour = new gui::Label( this, 0,0,0,0);
hour->setPenFocusWidth(0);
hour->setPenWidth(0);
hour->setFont(style::window::font::medium);
hour->setAlignement(gui::Alignment { gui::Alignment::ALIGN_HORIZONTAL_RIGHT, gui::Alignment::ALIGN_VERTICAL_TOP } );
title = new gui::Label( this, 0,0,0,0);
title->setPenFocusWidth(0);
title->setPenWidth(0);
title->setFont(style::window::font::bigbold);
title->setAlignement(gui::Alignment { gui::Alignment::ALIGN_HORIZONTAL_LEFT, gui::Alignment::ALIGN_VERTICAL_TOP } );
snippet = new gui::Label( this, 0,0,0,0);
snippet->setPenFocusWidth(0);
snippet->setPenWidth(0);
snippet->setFont(style::window::font::small);
snippet->setAlignement(gui::Alignment { gui::Alignment::ALIGN_HORIZONTAL_LEFT, gui::Alignment::ALIGN_VERTICAL_CENTER} );
}
NotesItem::~NotesItem() {
note = nullptr;
}
bool NotesItem::onDimensionChanged( const BoundingBox& oldDim, const BoundingBox& newDim) {
hour->setPosition(11, 0 );
hour->setSize(newDim.w-22, 40 );
title->setPosition(11, 0 );
title->setSize(68, 40 );
snippet->setPosition(11, 40 );
snippet->setSize(newDim.w-22, newDim.h-40 );
return true;
}
//sets copy of alarm's
void NotesItem::setNote( std::shared_ptr<NotesRecord>& note ) {
this->note = note;
//set values of the labels
title->setText( std::to_string( note->ID));
snippet->setText( note->path );
}
bool NotesItem::onActivated( void* data ) {
LOG_INFO("ITEM WAS PRESSED");
return true;
}
} /* namespace gui */