wex  v21.04.0
Public Types | Public Member Functions | List of all members
wex::data::control Class Reference

Offers user data to be used by ctrl classes (as listctrl, styledtextctrl). More...

#include <wex/control-data.h>

Public Types

enum  action_t { }
 Determine how flags value are set. More...
 

Public Member Functions

const auto & col () const
 Returns column.
 
controlcol (int col)
 Sets column. More...
 
const auto & command () const
 Returns command.
 
controlcommand (const std::string &command)
 Sets command. More...
 
const auto & find () const
 Returns find.
 
controlfind (const std::string &text, int find_flags=0)
 Sets find. More...
 
const auto find_flags () const
 Returns find flags.
 
template<std::size_t N>
controlflags (const std::bitset< N > &flags, std::bitset< N > &result, action_t action=SET)
 Sets specified flags. More...
 
bool inject (std::function< bool(void)> line=nullptr, std::function< bool(void)> col=nullptr, std::function< bool(void)> find=nullptr, std::function< bool(void)> command=nullptr) const
 injects data. More...
 
const auto is_required () const
 Returns required.
 
controlis_required (bool required)
 Sets required.
 
const auto line () const
 Returns line number.
 
controlline (int line, std::function< int(int)> valid=nullptr)
 Sets line number. More...
 
void reset ()
 Resets members to default state.
 
const auto validator () const
 Returns validator.
 
controlvalidator (wxValidator *validator)
 Sets validator.
 
const auto & window () const
 Returns window data.
 
controlwindow (const data::window &data)
 Sets window data.
 

Detailed Description

Offers user data to be used by ctrl classes (as listctrl, styledtextctrl).

First you can set the data using Col, Line, Find etc., then call inject to perform the action. You can set several items, inject prioritizes the actions.

Member Enumeration Documentation

◆ action_t

Determine how flags value are set.

Enumerator
NOT 

sets value and flips result

OR 

remove this flag

SET 

add this flag

XOR 

set value

Member Function Documentation

◆ col()

control& wex::data::control::col ( int  col)

Sets column.

Goes to column if col_number > 0

◆ command()

control& wex::data::control::command ( const std::string &  command)

Sets command.

This is a vi command to execute.

◆ find()

control& wex::data::control::find ( const std::string &  text,
int  find_flags = 0 
)

Sets find.

If not empty selects the text on that line (if line was specified) or finds text from begin (if line was 0) or end (line was -1).

Parameters
texttext to find
find_flagsfind flags to be used

◆ flags()

template<std::size_t N>
control& wex::data::control::flags ( const std::bitset< N > &  flags,
std::bitset< N > &  result,
action_t  action = SET 
)
inline

Sets specified flags.

This is used by the other data classes as generic method to operate on flags.

◆ inject()

bool wex::data::control::inject ( std::function< bool(void)>  line = nullptr,
std::function< bool(void)>  col = nullptr,
std::function< bool(void)>  find = nullptr,
std::function< bool(void)>  command = nullptr 
) const

injects data.

If there is a callback specified, injects current data in it:

  • if line available: goto line
  • if col available: goto col
  • if text not empty: finds text
  • if vi command not empty: executes vi command
  • if flags are set: sets flag on Control Returns true if data could be injected into the control.
Parameters
linecallback to inject line number
colcallback to inject column number
findcallback to inject find text
commandcallback to inject vi command

◆ line()

control& wex::data::control::line ( int  line,
std::function< int(int)>  valid = nullptr 
)

Sets line number.

Goes to the line if > 0, if -1 goes to end of file