示例#1
0
/** Graph widget.
 * DEPRECATED, see awful.widget.graph.
 * \param L The Lua VM state.
 * \param token The key token.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lfield plot_properties_set A function to set plot properties.
 * \lfield plot_data_add A function to add data to a plot.
 * \lfield height Graph height.
 * \lfield widget Graph width.
 * \lfield bg Background color.
 * \lfield grow Direction to grow: left or right.
 */
static int
luaA_graph_index(lua_State *L, awesome_token_t token)
{
    widget_t *widget = luaA_checkudata(L, 1, &widget_class);
    graph_data_t *d = widget->data;

    switch(token)
    {
    case A_TK_PLOT_PROPERTIES_SET:
        lua_pushcfunction(L, luaA_graph_plot_properties_set);
        break;
    case A_TK_PLOT_DATA_ADD:
        lua_pushcfunction(L, luaA_graph_plot_data_add);
        break;
    case A_TK_HEIGHT:
        lua_pushnumber(L, d->height);
        break;
    case A_TK_WIDTH:
        lua_pushnumber(L, d->width);
        break;
    case A_TK_BORDER_COLOR:
        luaA_pushcolor(L, &d->border_color);
        break;
    case A_TK_BG:
        luaA_pushcolor(L, &d->bg);
        break;
    case A_TK_GROW:
        switch(d->grow)
        {
        case Left:
            lua_pushliteral(L, "left");
            break;
        case Right:
            lua_pushliteral(L, "right");
            break;
        default:
            return 0;
        }
        break;
    default:
        return 0;
    }

    return 1;
}
示例#2
0
/** Textbox widget.
 * \param L The Lua VM state.
 * \param token The key token.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lfield text The text to display.
 * \lfield width The width of the textbox. Set to 0 for auto.
 * \lfield wrap The wrap mode: word, char, word_char.
 * \lfield ellipsize The ellipsize mode: start, middle or end.
 * \lfield border_width The border width to draw around.
 * \lfield border_color The border color.
 * \lfield align Text alignment, left, center or right.
 * \lfield margin Method to pass text margin: a table with top, left, right and bottom keys.
 * \lfield bg Background color.
 * \lfield bg_image Background image.
 * \lfield bg_align Background image alignment, left, center, right, bottom, top or middle
 * \lfield bg_resize Background resize.
 */
static int
luaA_textbox_index(lua_State *L, awesome_token_t token)
{
    widget_t *widget = luaA_checkudata(L, 1, &widget_class);
    textbox_data_t *d = widget->data;

    switch(token)
    {
      case A_TK_BG_RESIZE:
        lua_pushboolean(L, d->bg_resize);
        return 1;
      case A_TK_BG_ALIGN:
        lua_pushstring(L, draw_align_tostr(d->bg_align));
        return 1;
      case A_TK_BG_IMAGE:
        return luaA_object_push(L, d->bg_image);
      case A_TK_BG:
        return luaA_pushcolor(L, &d->bg);
      case A_TK_MARGIN:
        lua_pushcfunction(L, luaA_textbox_margin);
        return 1;
      case A_TK_ALIGN:
        lua_pushstring(L, draw_align_tostr(d->align));
        return 1;
      case A_TK_VALIGN:
        lua_pushstring(L, draw_align_tostr(d->valign));
        return 1;
      case A_TK_BORDER_WIDTH:
        lua_pushnumber(L, d->border.width);
        return 1;
      case A_TK_BORDER_COLOR:
        luaA_pushcolor(L, &d->border.color);
        return 1;
      case A_TK_TEXT:
        if(d->data.len > 0)
        {
            lua_pushlstring(L, d->data.text, d->data.len);
            return 1;
        }
        return 0;
      case A_TK_WIDTH:
        lua_pushnumber(L, d->width);
        return 1;
      case A_TK_HEIGHT:
        lua_pushnumber(L, d->height);
        return 1;
      case A_TK_WRAP:
        switch(d->wrap)
        {
          default:
            lua_pushliteral(L, "word");
            break;
          case A_TK_CHAR:
            lua_pushliteral(L, "char");
            break;
          case A_TK_WORD_CHAR:
            lua_pushliteral(L, "word_char");
            break;
        }
        return 1;
      case A_TK_ELLIPSIZE:
        switch(d->ellip)
        {
          case A_TK_START:
            lua_pushliteral(L, "start");
            break;
          case A_TK_MIDDLE:
            lua_pushliteral(L, "middle");
            break;
          default:
            lua_pushliteral(L, "end");
            break;
        }
        return 1;
      default:
        return 0;
    }
}