formatting
parent
2a6fd55e2e
commit
94e6cff063
|
@ -9,6 +9,7 @@
|
|||
#include "inkview.h"
|
||||
#include "eventHandler.h"
|
||||
#include "mainMenu.h"
|
||||
#include "contextMenu.h"
|
||||
#include "listView.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
@ -309,10 +310,9 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void EventHandler::DialogHandlerStatic(const int clicked)
|
||||
void EventHandler::DialogHandlerStatic(int clicked)
|
||||
{
|
||||
//TODO cannot interact with it
|
||||
// make download in different thread https://github.com/pmartin/pocketbook-demo/blob/master/demo08-pthreads/demo08.cpp
|
||||
if (clicked == 1)
|
||||
CloseProgressbar();
|
||||
CloseProgressbar();
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
* @param index int of the menu that is set
|
||||
*/
|
||||
static void mainMenuHandlerStatic(const int index);
|
||||
|
||||
|
||||
/**
|
||||
* Handles menu events and redirects them
|
||||
*
|
||||
|
@ -90,6 +90,6 @@ private:
|
|||
*
|
||||
* @param clicked button that has been clicked
|
||||
*/
|
||||
static void DialogHandlerStatic(const int clicked);
|
||||
static void DialogHandlerStatic(int clicked);
|
||||
};
|
||||
#endif
|
|
@ -34,10 +34,10 @@ ListView::ListView(const irect *contentRect, const vector<Item> &items) : _conte
|
|||
_footerFontHeight = 0.3 * _footerHeight;
|
||||
_entryFontHeight = 0.2 * entrySize;
|
||||
|
||||
_headerFont = OpenFont("LiberationMono", _headerFontHeight, 1);
|
||||
_footerFont = OpenFont("LiberationMono", _footerFontHeight, 1);
|
||||
_entryFont = OpenFont("LiberationMono", _entryFontHeight, 1);
|
||||
_entryFontBold = OpenFont("LiberationMono-Bold", _entryFontHeight, 1);
|
||||
_headerFont = OpenFont("LiberationMono", _headerFontHeight, FONT_STD);
|
||||
_footerFont = OpenFont("LiberationMono", _footerFontHeight, FONT_STD);
|
||||
_entryFont = OpenFont("LiberationMono", _entryFontHeight, FONT_STD);
|
||||
_entryFontBold = OpenFont("LiberationMono-Bold", _entryFontHeight, FONT_BOLD);
|
||||
|
||||
_page = 1;
|
||||
_shownPage = _page;
|
||||
|
@ -90,6 +90,52 @@ void ListView::drawHeader(string headerText)
|
|||
DrawLine(0, line, ScreenWidth(), line, BLACK);
|
||||
}
|
||||
|
||||
void ListView::drawEntry(int itemID)
|
||||
{
|
||||
FillAreaRect(_entries[itemID].getPosition(), WHITE);
|
||||
_entries[itemID].draw(_items->at(itemID), _entryFont, _entryFontBold, _entryFontHeight);
|
||||
}
|
||||
|
||||
void ListView::drawEntries()
|
||||
{
|
||||
for (unsigned int i = 0; i < _entries.size(); i++)
|
||||
{
|
||||
if (_entries[i].getPage() == _shownPage)
|
||||
_entries[i].draw(_items->at(i), _entryFont, _entryFontBold, _entryFontHeight);
|
||||
}
|
||||
}
|
||||
|
||||
int ListView::listClicked(int x, int y)
|
||||
{
|
||||
if (IsInRect(x, y, &_firstPageButton))
|
||||
{
|
||||
firstPage();
|
||||
}
|
||||
else if (IsInRect(x, y, &_nextPageButton))
|
||||
{
|
||||
nextPage();
|
||||
}
|
||||
else if (IsInRect(x, y, &_prevPageButton))
|
||||
{
|
||||
prevPage();
|
||||
}
|
||||
else if (IsInRect(x, y, &_lastPageButton))
|
||||
{
|
||||
actualizePage(_page);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < _entries.size(); i++)
|
||||
{
|
||||
if (_entries[i].getPage() == _shownPage && IsInRect(x, y, _entries[i].getPosition()) == 1)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ListView::drawFooter()
|
||||
{
|
||||
SetFont(_footerFont, WHITE);
|
||||
|
@ -107,19 +153,9 @@ void ListView::drawFooter()
|
|||
DrawTextRect2(&_lastPageButton, "Last");
|
||||
}
|
||||
|
||||
void ListView::drawEntry(int itemID)
|
||||
void ListView::updateEntry(int itemID)
|
||||
{
|
||||
FillAreaRect(_entries[itemID].getPosition(), WHITE);
|
||||
_entries[itemID].draw(_items->at(itemID), _entryFont, _entryFontBold, _entryFontHeight);
|
||||
}
|
||||
|
||||
void ListView::drawEntries()
|
||||
{
|
||||
for (unsigned int i = 0; i < _entries.size(); i++)
|
||||
{
|
||||
if (_entries[i].getPage() == _shownPage)
|
||||
_entries[i].draw(_items->at(i), _entryFont, _entryFontBold, _entryFontHeight);
|
||||
}
|
||||
PartialUpdate(_entries[itemID].getPosition()->x, _entries[itemID].getPosition()->y, _entries[itemID].getPosition()->w, _entries[itemID].getPosition()->h);
|
||||
}
|
||||
|
||||
void ListView::actualizePage(int pageToShown)
|
||||
|
@ -138,36 +174,6 @@ void ListView::actualizePage(int pageToShown)
|
|||
FillArea(_contentRect->x, _contentRect->y + _headerHeight, _contentRect->w, _contentRect->h, WHITE);
|
||||
drawEntries();
|
||||
drawFooter();
|
||||
PartialUpdate(_contentRect->x, _contentRect->y + _headerHeight, _contentRect->w, _contentRect->h);
|
||||
}
|
||||
}
|
||||
|
||||
int ListView::listClicked(int x, int y)
|
||||
{
|
||||
if (IsInRect(x, y, &_firstPageButton))
|
||||
{
|
||||
actualizePage(1);
|
||||
}
|
||||
else if (IsInRect(x, y, &_nextPageButton))
|
||||
{
|
||||
actualizePage(_shownPage + 1);
|
||||
}
|
||||
else if (IsInRect(x, y, &_prevPageButton))
|
||||
{
|
||||
actualizePage(_shownPage - 1);
|
||||
}
|
||||
else if (IsInRect(x, y, &_lastPageButton))
|
||||
{
|
||||
actualizePage(_page);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < _entries.size(); i++)
|
||||
{
|
||||
if (_entries[i].getPage() == _shownPage && IsInRect(x, y, _entries[i].getPosition()) == 1)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
|
@ -38,11 +38,6 @@ public:
|
|||
*/
|
||||
void drawHeader(std::string headerText);
|
||||
|
||||
/**
|
||||
* Draws the footer including a page changer
|
||||
*/
|
||||
void drawFooter();
|
||||
|
||||
/**
|
||||
* Draws an single entry to the screen
|
||||
*
|
||||
|
@ -56,11 +51,19 @@ public:
|
|||
void drawEntries();
|
||||
|
||||
/**
|
||||
* Navigates to the selected page
|
||||
*
|
||||
* @param pageToShown page that shall be shown
|
||||
* Navigates to the next page
|
||||
*/
|
||||
void actualizePage(int pageToShown);
|
||||
void nextPage() { this->actualizePage(_shownPage + 1); };
|
||||
|
||||
/**
|
||||
* Navigates to the prev page
|
||||
*/
|
||||
void prevPage() { this->actualizePage(_shownPage - 1); };
|
||||
|
||||
/**
|
||||
* Navigates to first page
|
||||
*/
|
||||
void firstPage() { this->actualizePage(1); };
|
||||
|
||||
/**
|
||||
* Checkes if the listview has been clicked and either changes the page or returns item ID
|
||||
|
@ -92,5 +95,24 @@ private:
|
|||
irect _firstPageButton;
|
||||
irect _lastPageButton;
|
||||
int _itemCount = 7;
|
||||
|
||||
/**
|
||||
* Draws the footer including a page changer
|
||||
*/
|
||||
void drawFooter();
|
||||
|
||||
/**
|
||||
* updates an entry
|
||||
*
|
||||
* @param itemID the id of the item that shall be inverted
|
||||
*/
|
||||
void updateEntry(int itemID);
|
||||
|
||||
/**
|
||||
* Navigates to the selected page
|
||||
*
|
||||
* @param pageToShown page that shall be shown
|
||||
*/
|
||||
void actualizePage(int pageToShown);
|
||||
};
|
||||
#endif
|
|
@ -30,7 +30,7 @@ LoginView::LoginView(const irect *contentRect) : _contentRect(contentRect)
|
|||
|
||||
_loginFontHeight = contents / 2;
|
||||
|
||||
_loginFont = OpenFont("LiberationMono", _loginFontHeight, 1);
|
||||
_loginFont = OpenFont("LiberationMono", _loginFontHeight, FONT_STD);
|
||||
SetFont(_loginFont, BLACK);
|
||||
FillAreaRect(_contentRect, WHITE);
|
||||
|
||||
|
|
|
@ -64,7 +64,11 @@ Item::Item(const string &localPath, FileState state, Itemtype type) : _localPath
|
|||
|
||||
void Item::open() const
|
||||
{
|
||||
if (_fileType.find("application/epub+zip") != string::npos ||
|
||||
if(_state==FileState::ICLOUD)
|
||||
{
|
||||
Message(ICON_ERROR,"File not found.","Could not find file.",1000);
|
||||
}
|
||||
else if (_fileType.find("application/epub+zip") != string::npos ||
|
||||
_fileType.find("application/pdf") != string::npos ||
|
||||
_fileType.find("application/octet-stream") != string::npos ||
|
||||
_fileType.find("text/plain") != string::npos ||
|
||||
|
|
|
@ -27,6 +27,7 @@ size_t Util::writeData(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|||
return written;
|
||||
}
|
||||
|
||||
//https://github.com/pmartin/pocketbook-demo/blob/master/devutils/wifi.cpp
|
||||
bool Util::connectToNetwork()
|
||||
{
|
||||
iv_netinfo *netinfo = NetInfo();
|
||||
|
|
|
@ -12,17 +12,10 @@
|
|||
#include "inkview.h"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
using std::ostringstream;
|
||||
|
||||
using std::string;
|
||||
|
||||
class Util
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Handles the return of curl command
|
||||
*
|
||||
|
@ -51,14 +44,15 @@ public:
|
|||
/**
|
||||
* get an XML Attribute from the buffer
|
||||
*/
|
||||
static string getXMLAttribute(const string &buffer, const string &name);
|
||||
static std::string getXMLAttribute(const std::string &buffer, const std::string &name);
|
||||
|
||||
/**
|
||||
* Decodes an URL
|
||||
*
|
||||
* @param text text that shall be converted
|
||||
*/
|
||||
static void decodeUrl(string &text);
|
||||
static void decodeUrl(std::string &text);
|
||||
|
||||
|
||||
private:
|
||||
Util() {}
|
||||
|
|
Loading…
Reference in New Issue