/************************************************************************* * sbItem.h - common item * * author: Konstantin Maslyuk "Kalemas" mailto:kalemas@mail.ru * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. ************************************************************************/ #ifndef SBITEM_H #define SBITEM_H #include #include #include "sbBase.h" /* sbItem should have type, content, and parameter verse verse_id (indicates its position in Bible) goVerse verse_id title no expanding_button what_to_expand text no module_select module_id book_select verse_id text_field goView view_type chapterTitle, bookTitle verse_id Examples of items: Mattew 14:11 yestarday -- Readings ----------------| V |-- 1 In the begining God created heaven and earth. 2 After all He created man and woman 3 And then they have sin... next,prev,child */ // Global directions enum sbDirection { DIRECTION_NONE = 0, DIRECTION_NEXT = 1 << 0, DIRECTION_PREV = 1 << 1, DIRECTION_LEFT = 1 << 2, DIRECTION_RIGHT = 1 << 3, DIRECTION_COUNT }; class sbItem { public: // type responds for visual appearance and work that item do // some types like LOOK_CONTAINER should create derived classes enum TYPE { DO_NONE = 0, LOOK_NORMAL = 0, TYPE_VERSE, TYPE_BUTTON_BOOKMARK, TYPE_GOTO_MODULES, TYPE_GO_HISTORY, TYPE_HISTORY, TYPE_MODULE_INSTALLER_MODULE, TYPE_MODULE_INSTALLER_UPDATE, TYPE_GO_READING, TYPE_BUTTON_SELECTION_MODULE, TYPE_BUTTON_SELECTION_BOOK, TYPE_BUTTON_SELECTION_CHAPTER, TYPE_BOOKMARK_VERSE_NUMBER, LOOK_NORMAL_COUNT, LOOK_CONTAINER, TYPE_CONTAINER_PANEL, TYPE_CONTAINER_DIALOG, TYPE_CONTAINER_MENU, LOOK_CONTAINER_COUNT, LOOK_VERSE, LOOK_SEPARATOR, TYPE_CENTRED_DESCRIPTION, LOOK_DESCRIPTION, LOOK_CAPTION, LOOK_INPUT, TYPE_TEXT_FIELD, LOOK_BUTTON, TYPE_OPEN_MODULE_INSTALLER, TYPE_SWITCH_MODULE_OPTION, TYPE_START_SEARCH, TYPE_MODULE_INSTALLER_REPO, LOOK_BUTTON_COUNT, LOOK_PANEL, DO_EXIT, DO_WIDE_CLOSE, DO_CLOSE, DO_BUTTON_OPEN_FILE, DO_OPEN_NAVIGATION, DO_OPEN_NAVIGATION_LIST, DO_OPEN_MODULE_SELECTION, DO_OPEN_BOOK_SELECTION, DO_OPEN_SEARCH, DO_OPEN_HOME, DO_OPEN_TEXT, DO_OPEN_BOOKMARKS, DO_OPEN_READINGS, DO_OPEN_HISTORY, DO_MODE_ADD_STAR, DO_MENU_CANCEL, DO_MENU_VERSE, DO_OPEN_OPTIONS, DO_INSTALLER_DISCLAIMER_ACCEPT, DO_INSTALLER_DISCLAIMER_DECLINE, LOOK_PANEL_COUNT, LOOK_MENU, DO_SEARCH_RANGE_START, DO_SEARCH_RANGE_END, LOOK_MENU_COUNT, LOOK_BANNER, TYPE_COUNT }; sbRect getRect ( bool familyMode = false ); bool putInto ( sbRect toPut ); sbItem * getItem ( sbDirection direction, bool last = false ); sbItem * getItem ( sbPoint relativeXy ); // for container-items sbItem * getItem ( TYPE type ); // hide sbItem ( sbItem::TYPE type, const TCHAR * text, int width, long index = -1 ); virtual ~sbItem (); virtual void render ( sbSurface surface, const sbRect & rect ) const; const TYPE type; char style; // remove std::wstring text; bool processed; // none, highlighted, inactive, hover, hover+highlighted bool highlighted; bool active; unsigned short height; unsigned short width; unsigned short expanding; struct LINE { LINE () { memset (this,0,sizeof(LINE)); } enum TYPE { TYPE_NONE = 0, TYPE_VERSE_NUMBER, TYPE_SPACE, TYPE_STRONG, TYPE_MORPH, TYPE_REDWORDS, TYPE_LINE, TYPE_IMAGE, TYPE_IMAGE_COUNT = TYPE_IMAGE + DIRECTION_COUNT /*alignment*/ }; unsigned short pos; unsigned short count; unsigned short width; unsigned short height; char style; TYPE type; bool ending; }; std::vector lines; void setText ( const TCHAR * text ); long index; // TODO ? make private void attach ( sbItem * item, sbDirection to ); sbItem *next; sbItem *prev; sbItem *left; sbItem *right; // TODO ? automatic item width using sbTheme // perform automatic layout and hidden derived class creation sbItem * append ( sbItem::TYPE type, const TCHAR * text, int width, long index = -1 ); static sbItem * create ( sbItem::TYPE type, const TCHAR * text, int width, long index = -1 ); }; #endif