wlmaker
Loading...
Searching...
No Matches
Functions | Variables
box.c File Reference
#include "box.h"
#include <string.h>
#include "libbase/libbase.h"
#include "rectangle.h"
Include dependency graph for box.c:

Functions

static void _wlmtk_box_container_update_layout (wlmtk_container_t *container_ptr)
 
static bs_dllist_node_t * create_margin (wlmtk_box_t *box_ptr)
 
bool wlmtk_box_init (wlmtk_box_t *box_ptr, wlmtk_box_orientation_t orientation, const wlmtk_margin_style_t *style_ptr)
 
void wlmtk_box_fini (wlmtk_box_t *box_ptr)
 
void wlmtk_box_add_element_front (wlmtk_box_t *box_ptr, wlmtk_element_t *element_ptr)
 
void wlmtk_box_add_element_back (wlmtk_box_t *box_ptr, wlmtk_element_t *element_ptr)
 
void wlmtk_box_remove_element (wlmtk_box_t *box_ptr, wlmtk_element_t *element_ptr)
 
wlmtk_element_twlmtk_box_element (wlmtk_box_t *box_ptr)
 
static void test_init_fini (bs_test_t *test_ptr)
 
static void test_layout_horizontal (bs_test_t *test_ptr)
 
static void test_layout_vertical (bs_test_t *test_ptr)
 

Variables

static const wlmtk_container_vmt_t box_container_vmt
 
const bs_test_case_t wlmtk_box_test_cases []
 
static const wlmtk_margin_style_t test_style
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ _wlmtk_box_container_update_layout()

void _wlmtk_box_container_update_layout ( wlmtk_container_t container_ptr)
static

Updates the layout of the box.

Steps through all visible elements, and sets their position to be left-to-right. Also updates and repositions all margin elements.

Parameters
container_ptr

◆ create_margin()

bs_dllist_node_t * create_margin ( wlmtk_box_t box_ptr)
static

Creates a new margin element, and returns the dlnode.

◆ test_init_fini()

void test_init_fini ( bs_test_t *  test_ptr)
static

Exercises setup and teardown.

◆ test_layout_horizontal()

void test_layout_horizontal ( bs_test_t *  test_ptr)
static

Tests layouting horizontally

◆ test_layout_vertical()

void test_layout_vertical ( bs_test_t *  test_ptr)
static

Tests layouting vertically

◆ wlmtk_box_add_element_back()

void wlmtk_box_add_element_back ( wlmtk_box_t box_ptr,
wlmtk_element_t element_ptr 
)

Adds element_ptr to the back of the box.

Parameters
box_ptr
element_ptr

◆ wlmtk_box_add_element_front()

void wlmtk_box_add_element_front ( wlmtk_box_t box_ptr,
wlmtk_element_t element_ptr 
)

Adds element_ptr to the front of the box.

Parameters
box_ptr
element_ptr

◆ wlmtk_box_element()

wlmtk_element_t * wlmtk_box_element ( wlmtk_box_t box_ptr)
Returns
Pointer to the superclass' wlmtk_element_t of box_ptr.

◆ wlmtk_box_fini()

void wlmtk_box_fini ( wlmtk_box_t box_ptr)

Un-initializes the box.

Parameters
box_ptr

◆ wlmtk_box_init()

bool wlmtk_box_init ( wlmtk_box_t box_ptr,
wlmtk_box_orientation_t  orientation,
const wlmtk_margin_style_t style_ptr 
)

Initializes the box with the provided virtual method table.

Parameters
box_ptr
orientation
style_ptr
Returns
true on success.

◆ wlmtk_box_remove_element()

void wlmtk_box_remove_element ( wlmtk_box_t box_ptr,
wlmtk_element_t element_ptr 
)

Removes element_ptr from the box.

Requires that element_ptr is an element of the box.

Parameters
box_ptr
element_ptr

Variable Documentation

◆ box_container_vmt

const wlmtk_container_vmt_t box_container_vmt
static
Initial value:
= {
}
static void _wlmtk_box_container_update_layout(wlmtk_container_t *container_ptr)
Definition box.c:139

Virtual method table: wlmtk_container_t at wlmtk_box_t level.

◆ test_style

const wlmtk_margin_style_t test_style
static
Initial value:
= {
.width = 2,
.color = 0xff000000
}

Style used for tests.

◆ wlmtk_box_test_cases

const bs_test_case_t wlmtk_box_test_cases[]
Initial value:
= {
{ 1, "init_fini", test_init_fini },
{ 1, "layout_horizontal", test_layout_horizontal },
{ 1, "layout_vertical", test_layout_vertical },
{ 0, NULL, NULL }
}
static void test_layout_horizontal(bs_test_t *test_ptr)
Definition box.c:284
static void test_init_fini(bs_test_t *test_ptr)
Definition box.c:268
static void test_layout_vertical(bs_test_t *test_ptr)
Definition box.c:347

Unit tests.