本文整理汇总了C++中Widget::GetMask方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::GetMask方法的具体用法?C++ Widget::GetMask怎么用?C++ Widget::GetMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::GetMask方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddOption
/**\brief Append an option to this Dropdown
* \note Tables of strings will be flattened and added
*/
int UI_Lua::AddOption(lua_State *L){
int n = lua_gettop(L); // Number of arguments
if (n < 2)
return luaL_error(L, "Got %d arguments expected at least 2 (self OPTION [OPTION ...])", n);
Widget *widget = checkWidget(L, 1);
luaL_argcheck(L, widget->GetMask() & WIDGET_DROPDOWN, 1, "`Dropdown' expected.");
Dropdown *dropdown = (Dropdown*)widget;
// Add the options
for(int arg = 2; arg <= n; ++arg){
if( lua_istable(L, arg) ) {
// Tables can be lists of strings
list<string>::iterator i;
list<string> values = Lua::getStringListField( arg );
for(i = values.begin(); i != values.end(); ++i) {
dropdown->AddOption( (*i) );
}
} else {
// Everything else is converted into a string
string option = lua_tostring(L, arg);
dropdown->AddOption( option );
}
}
return 0;
}
示例2: GetAbsX
/**\brief Tests if point is within a rectangle.
*/
int Widget::GetAbsX( void ) {
int absx = GetX();
Widget* theParent = parent;
while( theParent != NULL ) {
assert( theParent->GetMask() & WIDGET_CONTAINER );
absx += theParent->GetX();
theParent = theParent->parent;
}
return absx;
}
示例3: setText
/** \brief Set Widget Text
* \todo This should support more widget types.
*/
int UI_Lua::setText(lua_State *L){
int n = lua_gettop(L); // Number of arguments
if (n != 2)
return luaL_error(L, "Got %d arguments expected 2 (self, text)", n);
Widget *widget = checkWidget(L,1);
string text = luaL_checkstring(L, 2);
int mask = widget->GetMask();
mask &= ~WIDGET_CONTAINER; // Turn off the Container flag.
switch( mask ) {
// These Widget types currently support setText
case WIDGET_LABEL:
((Label*)(widget))->SetText( text );
break;
case WIDGET_TEXTBOX:
((Textbox*)(widget))->SetText( text );
break;
case WIDGET_BUTTON:
((Button*)(widget))->SetText( text );
break;
case WIDGET_DROPDOWN:
((Dropdown*)(widget))->SetText( text );
break;
// TODO These Widget Types do not currently accept setText, but they should.
case WIDGET_TAB:
case WIDGET_WINDOW:
return luaL_error(L, "Epiar does not currently calling setText on Widgets of type '%s'.", (widget)->GetType().c_str() );
break;
// These Widget Types can't accept setText.
case WIDGET_TABS:
case WIDGET_FRAME:
case WIDGET_SLIDER:
case WIDGET_PICTURE:
case WIDGET_CHECKBOX:
case WIDGET_SCROLLBAR:
case WIDGET_CONTAINER:
default:
return luaL_error(L, "Cannot setText to Widget of type '%s'.", (widget)->GetType().c_str() );
}
return 0;
}