libyui-ncurses
Loading...
Searching...
No Matches
NCTablePadBase Class Reference

#include <NCTablePadBase.h>

Inheritance diagram for NCTablePadBase:
Collaboration diagram for NCTablePadBase:

Public Member Functions

void ClearTable ()
 
virtual void wRecoded ()
 
virtual wpos CurPos () const
 CurPos().L is the index of the selected item.
 
wsze tableSize ()
 
unsigned visibleLines () const
 
bool SetHeadline (const std::vector< NCstring > &head)
 
virtual void SendHead ()
 
void SetSepChar (const chtype colSepchar)
 
void SetSepWidth (const unsigned sepwidth)
 
void SetHotCol (int hcol)
 
unsigned Cols () const
 
unsigned Lines () const
 
bool empty () const
 
unsigned HotCol () const
 
void SetLines (unsigned count)
 
void SetLines (std::vector< NCTableLine * > &newItems)
 
void AddLine (unsigned idx, NCTableLine *item)
 
void Append (NCTableLine *item)
 
void Append (std::vector< NCTableCol * > &cells, int index)
 
const NCTableLineGetLine (unsigned idx) const
 
NCTableLineModifyLine (unsigned idx)
 
int findIndex (unsigned idx) const
 
NCTableLineGetCurrentLine () const
 
virtual bool handleInput (wint_t key)
 
- Public Member Functions inherited from NCPad
 NCPad (int lines, int cols, const NCWidget &p)
 
NCursesWindowDestwin ()
 
virtual void Destwin (NCursesWindow *dwin)
 
virtual void resize (wsze nsze)
 
virtual int resize (int lines, int columns)
 
virtual void setDirty ()
 
int update ()
 
virtual int setpos ()
 
int ScrlTo (const wpos &newpos)
 
int ScrlLine (int line)
 Scroll to a line, keeping the column.
 
int ScrlCol (int col)
 Scroll to a column, keeping the line.
 
int ScrlDown (int lines=1)
 
int ScrlUp (int lines=1)
 
int ScrlRight (int cols=1)
 
int ScrlLeft (int cols=1)
 
int ScrlToLastLine ()
 
- Public Member Functions inherited from NCursesPad
 NCursesPad (int lines, int cols)
 
int echochar (const chtype ch)
 
int refresh ()
 
int noutrefresh ()
 
int refresh (int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
 
int noutrefresh (int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
 
- Public Member Functions inherited from NCursesWindow
 NCursesWindow (WINDOW *window)
 
 NCursesWindow (int lines, int cols, int begin_y, int begin_x)
 
 NCursesWindow (NCursesWindow &parent, int lines, int cols, int begin_y, int begin_x, char absrel='a')
 
virtual ~NCursesWindow ()
 
NCursesWindow Clone ()
 
int colors () const
 
int height () const
 
int width () const
 
int begx () const
 
int begy () const
 
int maxx () const
 
int maxy () const
 
wsze size () const
 
wpos begpos () const
 
wpos maxpos () const
 
wrect area () const
 
short getcolor () const
 
short foreground () const
 
short background () const
 
int setpalette (short fore, short back)
 
int setcolor (short pair)
 
virtual int mvwin (int begin_y, int begin_x)
 
int mvsubwin (NCursesWindow *sub, int begin_y, int begin_x)
 
int move (int y, int x)
 
void getyx (int &y, int &x) const
 
int mvcur (int oldrow, int oldcol, int newrow, int newcol) const
 
int nodelay (bool bf)
 
int getch ()
 
int getch (int y, int x)
 
int getstr (char *str, int n=-1)
 
int getstr (int y, int x, char *str, int n=-1)
 
int instr (char *s, int n=-1)
 
int instr (int y, int x, char *s, int n=-1)
 
int addch (const char ch)
 
int addch (const chtype ch)
 
int add_attr_char (int y, int x)
 
int add_attr_char ()
 
int add_wch (const cchar_t *cch)
 
int add_wch (int y, int x, const cchar_t *cch)
 
int addch (int y, int x, const char ch)
 
int addch (int y, int x, const chtype ch)
 
int echochar (const char ch)
 
int echochar (const chtype ch)
 
int addstr (const char *str, int n=-1)
 
int addstr (int y, int x, const char *str, int n=-1)
 
int addwstr (const wchar_t *str, int n=-1)
 
int addwstr (int y, int x, const wchar_t *str, int n=-1)
 
int printw (const char *fmt,...)
 
int printw (int y, int x, const char *fmt,...)
 
chtype inch () const
 
chtype inchar () const
 
chtype inch (int y, int x)
 
chtype inchar (int y, int x)
 
int in_wchar (cchar_t *cchar)
 
int in_wchar (int y, int x, cchar_t *cchar)
 
int insch (chtype ch)
 
int insch (int y, int x, chtype ch)
 
int ins_wch (int y, int x, const cchar_t *cchar)
 
int insertln ()
 
int insdelln (int n=1)
 
int insstr (const char *s, int n=-1)
 
int insstr (int y, int x, const char *s, int n=-1)
 
int attron (chtype at)
 
int attroff (chtype at)
 
int attrset (chtype at)
 
int chgat (int n, attr_t attr, short color, const void *opts=NULL)
 
int chgat (int y, int x, int n, attr_t attr, short color, const void *opts=NULL)
 
chtype getbkgd () const
 
int bkgd (const chtype ch)
 
void bkgdset (chtype ch)
 
int box ()
 
int border (chtype left=0, chtype right=0, chtype top=0, chtype bottom=0, chtype top_left=0, chtype top_right=0, chtype bottom_left=0, chtype bottom_right=0)
 
int hline (int len, chtype ch=0)
 
int hline (int y, int x, int len, chtype ch=0)
 
int vline (int len, chtype ch=0)
 
int vline (int y, int x, int len, chtype ch=0)
 
int box (const wrect &dim)
 
int erase ()
 
int clear ()
 
int clearok (bool bf)
 
int clrtobot ()
 
int clrtoeol ()
 
int delch ()
 
int delch (int y, int x)
 
int deleteln ()
 
int scroll (int amount=1)
 
int scrollok (bool bf)
 
int setscrreg (int from, int to)
 
int idlok (bool bf)
 
void idcok (bool bf)
 
int touchwin ()
 
int untouchwin ()
 
int touchln (int s, int cnt, bool changed=TRUE)
 
bool is_wintouched () const
 
int leaveok (bool bf)
 
int redrawln (int from, int n)
 
int redrawwin ()
 
int doupdate ()
 
void syncdown ()
 
void syncup ()
 
void cursyncup ()
 
int syncok (bool bf)
 
void immedok (bool bf)
 
int keypad (bool bf)
 
int meta (bool bf)
 
int standout ()
 
int standend ()
 
int overlay (NCursesWindow &win)
 
int overwrite (NCursesWindow &win)
 
int copywin (NCursesWindow &win, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, bool overlay=TRUE)
 
bool has_mouse () const
 
NCursesWindowchild ()
 
const NCursesWindowchild () const
 
NCursesWindowsibling ()
 
const NCursesWindowsibling () const
 
NCursesWindowparent ()
 
const NCursesWindowparent () const
 
bool isDescendant (NCursesWindow &win)
 
- Public Member Functions inherited from NCScrollHint
void SendSchrollCB (NCSchrollCB *dest)
 Set the receiver of callbacks to dest
 

Protected Member Functions

 NCTablePadBase (int lines, int cols, const NCWidget &p)
 
virtual wsze UpdateFormat ()
 
virtual bool currentItemHandleInput (wint_t key)
 
void updateVisibleItems ()
 
void setFormatDirty ()
 
virtual int dirtyPad ()
 
virtual int DoRedraw ()
 
virtual void prepareRedraw ()
 
virtual void drawContentLines ()
 
virtual void drawHeader ()
 
virtual int setpos (const wpos &newPos)
 
int currentLineNo () const
 
void setCurrentLineNo (int newVal)
 
int currentColNo () const
 
void setCurrentColNo (int newVal)
 
void assertLine (unsigned index)
 
- Protected Member Functions inherited from NCPad
int vheight () const
 
bool paging () const
 
int adjpos (const wpos &offset)
 Adjust CurPos relatively by offset
 
virtual void updateScrollHint ()
 
virtual void directDraw (NCursesWindow &w, const wrect at, unsigned lineno)
 
- Protected Member Functions inherited from NCursesWindow
void err_handler (const char *) const THROWS(NCursesException)
 
void kill_subwindows ()
 
 NCursesWindow ()
 
- Protected Member Functions inherited from NCScrollHint
virtual void SetHead (NCursesWindow &w, unsigned ccol)
 
void VSet (unsigned total, unsigned visible, unsigned start)
 
void HSet (unsigned total, unsigned visible, unsigned start)
 
virtual void SetPadSize (wsze &minsze)
 
- Protected Member Functions inherited from NCSchrollCB
virtual void HScroll (unsigned total, unsigned visible, unsigned start)
 
virtual void VScroll (unsigned total, unsigned visible, unsigned start)
 
virtual void ScrollHead (NCursesWindow &w, unsigned ccol)
 
virtual void AdjustPadSize (wsze &minsze)
 

Protected Attributes

std::vector< NCTableLine * > _items
 (owned)
 
std::vector< NCTableLine * > _visibleItems
 not owned
 
NCursesPad _headpad
 
bool _dirtyHead
 
bool _dirtyFormat
 does table format (size) need recalculating?
 
NCTableStyle _itemStyle
 
wpos _citem
 current/cursor position
 
- Protected Attributes inherited from NCPad
const NCWidgetparw
 
NCursesWindowdestwin
 Destination rectangle: (Pos is always 0, 0)
 
wrect drect
 
wrect srect
 Source rectangle: the visible part of this pad.
 
wpos maxdpos
 
wpos maxspos
 
bool dclear
 should destwin be cleared before contents is copied there
 
bool dirty
 
- Protected Attributes inherited from NCursesWindow
WINDOW * w
 
bool alloced
 
NCursesWindowpar
 
NCursesWindowsubwins
 
NCursesWindowsib
 

Friends

std::ostream & operator<< (std::ostream &str, const NCTablePadBase &obj)
 

Additional Inherited Members

- Static Public Member Functions inherited from NCursesWindow
static void useColors (void)
 
static int ripoffline (int ripoff_lines, int(*init)(NCursesWindow &win))
 
static int lines ()
 
static int cols ()
 
static int tabsize ()
 
static int NumberOfColors ()
 
static int maxcoord ()
 
- Static Protected Attributes inherited from NCursesWindow
static long count = 0L
 

Detailed Description

An NCPad for an NCTable or an NCTree.

This is an abstract base class for NCTablePad and NCTreePad.

See also https://github.com/libyui/libyui-ncurses/blob/master/doc/nctable-and-nctree.md

Notice that this class is heavily used in other selection widgets like

And the table classes from libyui-ncurses-pkg:

  • NCPkgTable
  • NCPkgLocaleTable
  • NCPkgRepoTable

So if you change anything here, make sure to test all those classes.

Constructor & Destructor Documentation

◆ NCTablePadBase()

NCTablePadBase::NCTablePadBase ( int lines,
int cols,
const NCWidget & p )
protected

Constructor. This is protected because this is an abstract base class, not meant to be instantiated on this level.

Member Function Documentation

◆ AddLine()

void NCTablePadBase::AddLine ( unsigned idx,
NCTableLine * item )

Add item at position idx, expanding if needed

Parameters
itemwe take ownership
Deprecated
Used only by Append; undefined behaviour if used after sorting

◆ Append() [1/2]

void NCTablePadBase::Append ( NCTableLine * item)
inline

Add one item to the end of _items.

◆ Append() [2/2]

void NCTablePadBase::Append ( std::vector< NCTableCol * > & cells,
int index )
inline

Create a new item from 'cells' and add it to the end of _items.

◆ assertLine()

void NCTablePadBase::assertLine ( unsigned index)
protected

Ensure that a line with the specified index exists. Enlarge or shrink if necessary.

◆ ClearTable()

void NCTablePadBase::ClearTable ( )

Clear all content.

◆ Cols()

unsigned NCTablePadBase::Cols ( ) const
inline

Return the number of table columns (logical, not screen)

◆ CurPos()

wpos NCTablePadBase::CurPos ( ) const
virtual

CurPos().L is the index of the selected item.

Reimplemented from NCPad.

◆ currentColNo()

int NCTablePadBase::currentColNo ( ) const
inlineprotected

Return the current column number (the cursor position).

◆ currentItemHandleInput()

bool NCTablePadBase::currentItemHandleInput ( wint_t key)
protectedvirtual

Call the current item's handleInput() method and return 'true' if the event is now handled, 'false' if not.

◆ currentLineNo()

int NCTablePadBase::currentLineNo ( ) const
inlineprotected

Return the current line number (the cursor position).

◆ dirtyPad()

virtual int NCTablePadBase::dirtyPad ( )
inlineprotectedvirtual

Reimplemented from NCPad.

◆ DoRedraw()

int NCTablePadBase::DoRedraw ( )
protectedvirtual

Redraw the pad.

Reimplemented from NCPad.

Reimplemented in NCTablePad, and NCTreePad.

◆ drawContentLines()

void NCTablePadBase::drawContentLines ( )
protectedvirtual

Redraw the (visible) content lines one by one.

◆ drawHeader()

void NCTablePadBase::drawHeader ( )
protectedvirtual

Redraw the table header.

◆ findIndex()

int NCTablePadBase::findIndex ( unsigned idx) const

Find the item with index 'idx' in the items and return its position. Return -1 if not found.

◆ GetCurrentLine()

NCTableLine * NCTablePadBase::GetCurrentLine ( ) const

Return the current line (the line at the cursor position) or 0 if there is none.

◆ GetLine()

const NCTableLine * NCTablePadBase::GetLine ( unsigned idx) const

Return the line at idx for read-only operations.

◆ handleInput()

bool NCTablePadBase::handleInput ( wint_t key)
virtual

Handle a keyboard input event. Return 'true' if the event is now handled, 'false' if it should be propagated to the parent widget.

Most of the keys are now handled in the individual items' handlers (NCTreeLine, NCTableLine). This method is mostly here as a stub for future extensions.

Reimplemented from NCPad.

Reimplemented from NCPad.

Reimplemented in NCTablePad, and NCTreePad.

◆ Lines()

unsigned NCTablePadBase::Lines ( ) const
inline

Return the number of table lines (logical, not screen)

◆ ModifyLine()

NCTableLine * NCTablePadBase::ModifyLine ( unsigned idx)

Return line at idx for read-write operations and mark it as modified.

◆ prepareRedraw()

void NCTablePadBase::prepareRedraw ( )
protectedvirtual

Prepare a redraw: Update the format if needed, set the background, clear the old content.

◆ SendHead()

virtual void NCTablePadBase::SendHead ( )
inlinevirtual

Reimplemented from NCScrollHint.

◆ setCurrentColNo()

void NCTablePadBase::setCurrentColNo ( int newVal)
inlineprotected

Set the current column number (the cursor position).

◆ setCurrentLineNo()

void NCTablePadBase::setCurrentLineNo ( int newVal)
inlineprotected

Set the current line number (the cursor position).

◆ SetLines()

void NCTablePadBase::SetLines ( unsigned count)

Expand or shrink to have exactly count logical lines

◆ setpos()

int NCTablePadBase::setpos ( const wpos & newPos)
protectedvirtual

Base function for scrolling: Move the cursor position to 'newPos' and redraw the old and the new current item with suitable attributes: The new current item is highlighted, the old one is not.

Reimplemented from NCPad.

Reimplemented from NCPad.

◆ updateVisibleItems()

void NCTablePadBase::updateVisibleItems ( )
protected

Update the internal _visibleItems vector with the items that are currently visible: Clear the old contents of the vector, iterate over all lines and check which ones are currently visible.

This does NOT do a screen update of the visible items!

◆ visibleLines()

unsigned NCTablePadBase::visibleLines ( ) const
inline

Return the number of lines that are currently visible. This is updated in UpdateFormat().

◆ wRecoded()

void NCTablePadBase::wRecoded ( )
virtual

Reimplemented from NCPad.


The documentation for this class was generated from the following files: