本文整理汇总了C++中StaticArray::append方法的典型用法代码示例。如果您正苦于以下问题:C++ StaticArray::append方法的具体用法?C++ StaticArray::append怎么用?C++ StaticArray::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StaticArray
的用法示例。
在下文中一共展示了StaticArray::append方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QuickMenuButtonRenderer
void
QuickMenu::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
WindowStyle grid_view_style;
grid_view_style.ControlParent();
grid_view_style.Hide();
const auto &dialog_look = UIGlobals::GetDialogLook();
const auto &font = *dialog_look.button.font;
const unsigned column_width = Layout::Scale(78u);
const unsigned row_height =
std::max(2 * (Layout::GetTextPadding() + font.GetHeight()),
Layout::GetMaximumControlHeight());
grid_view.Create(parent, dialog_look, rc, grid_view_style,
column_width, row_height);
SetWindow(&grid_view);
WindowStyle buttonStyle;
buttonStyle.TabStop();
for (unsigned i = 0; i < menu.MAX_ITEMS; ++i) {
if (buttons.full())
continue;
const auto &menuItem = menu[i];
if (!menuItem.IsDefined())
continue;
TCHAR buffer[100];
const auto expanded =
ButtonLabel::Expand(menuItem.label, buffer, ARRAY_SIZE(buffer));
if (!expanded.visible)
continue;
PixelRect button_rc;
button_rc.left = 0;
button_rc.top = 0;
button_rc.right = 80;
button_rc.bottom = 30;
auto *button = new Button(grid_view, button_rc, buttonStyle,
new QuickMenuButtonRenderer(dialog_look,
expanded.text),
*this, menuItem.event);
button->SetEnabled(expanded.enabled);
buttons.append(button);
grid_view.AddItem(*button);
}
grid_view.RefreshLayout();
UpdateCaption();
}
示例2: AddWaypoint
void AddWaypoint(const WaypointPtr &way_point, bool in_task) {
if (waypoints.full())
return;
if (!projection.WaypointInScaleFilter(*way_point) && !in_task)
return;
PixelPoint sc;
if (!projection.GeoToScreenIfVisible(way_point->location, sc))
return;
VisibleWaypoint &vwp = waypoints.append();
vwp.Set(way_point, sc, in_task);
}
示例3: WindowReference
WindowReference(const ContainerWindow &root, Window &_window)
:window(&_window) {
const ContainerWindow *parent = window->GetParent();
while (true) {
if (parent == &root)
return;
if (parent == NULL || parents.full()) {
window = NULL;
return;
}
parents.append(parent);
parent = parent->GetParent();
}
}
示例4: LookupSecondaryIndex
bool
FlarmDetails::AddSecondaryItem(FlarmId id, const TCHAR *name)
{
int index = LookupSecondaryIndex(id);
if (index != -1) {
// modify existing record
FLARM_Names[index].ID = id;
FLARM_Names[index].Name = name;
return true;
}
if (FLARM_Names.full())
return false;
// create new record
FlarmIdNameCouple &item = FLARM_Names.append();
item.ID = id;
item.Name = name;
return true;
}
示例5: fixed
void
TerrainXSRenderer::Draw(Canvas &canvas, const ChartRenderer &chart, const short *elevations) const
{
const fixed max_distance = chart.GetXMax();
StaticArray<RasterPoint, CrossSectionRenderer::NUM_SLICES + 2> points;
canvas.SelectNullPen();
RasterBuffer::TerrainType last_type = RasterBuffer::TerrainType::UNKNOWN;
fixed last_distance = fixed(0);
for (unsigned j = 0; j < CrossSectionRenderer::NUM_SLICES; ++j) {
const fixed distance_factor =
fixed(j) / (CrossSectionRenderer::NUM_SLICES - 1);
const fixed distance = distance_factor * max_distance;
short h = elevations[j];
RasterBuffer::TerrainType type = RasterBuffer::GetTerrainType(h);
if (type == RasterBuffer::TerrainType::WATER)
h = 0;
// Close and paint polygon
if (j != 0 &&
type != last_type &&
last_type != RasterBuffer::TerrainType::UNKNOWN) {
const fixed center_distance = (distance + last_distance) / 2;
points.append() = chart.ToScreen(center_distance, fixed(0));
points.append() = chart.ToScreen(center_distance, fixed(-500));
DrawPolygon(canvas, last_type, points.begin(), points.size());
}
if (type != RasterBuffer::TerrainType::UNKNOWN) {
if (j == 0) {
// Start first polygon
points.append() = chart.ToScreen(distance, fixed(-500));
points.append() = chart.ToScreen(distance, fixed(h));
} else if (type != last_type) {
// Start new polygon
points.clear();
const fixed center_distance = (distance + last_distance) / 2;
points.append() = chart.ToScreen(center_distance, fixed(-500));
points.append() = chart.ToScreen(center_distance, fixed(0));
}
if (j + 1 == CrossSectionRenderer::NUM_SLICES) {
// Close and paint last polygon
points.append() = chart.ToScreen(distance, fixed(h));
points.append() = chart.ToScreen(distance, fixed(-500));
DrawPolygon(canvas, type, points.begin(), points.size());
} else if (type == last_type && j != 0) {
// Add single point to polygon
points.append() = chart.ToScreen(distance, fixed(h));
}
}
last_type = type;
last_distance = distance;
}
}
示例6: layout
void
WaypointDetailsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
for (const auto &i : waypoint.files_embed) {
if (images.full())
break;
try {
if (!images.append().LoadFile(LocalPath(i.c_str())))
images.shrink(images.size() - 1);
} catch (const std::exception &e) {
LogFormat("Failed to load %s: %s",
(const char *)NarrowPathName(Path(i.c_str())),
e.what());
images.shrink(images.size() - 1);
}
}
const Layout layout(rc, waypoint);
WindowStyle dock_style;
dock_style.Hide();
dock_style.ControlParent();
WindowStyle button_style;
button_style.Hide();
button_style.TabStop();
if (allow_navigation)
goto_button.Create(parent, look.button, _("GoTo"), layout.goto_button,
button_style, *this, GOTO);
if (!images.empty()) {
magnify_button.Create(parent, layout.magnify_button, button_style,
new SymbolButtonRenderer(look.button, _T("+")),
*this, MAGNIFY);
shrink_button.Create(parent, layout.shrink_button, button_style,
new SymbolButtonRenderer(look.button, _T("-")),
*this, SHRINK);
}
if (allow_navigation) {
previous_button.Create(parent, layout.previous_button, button_style,
new SymbolButtonRenderer(look.button, _T("<")),
*this, PREVIOUS);
next_button.Create(parent, layout.next_button, button_style,
new SymbolButtonRenderer(look.button, _T(">")),
*this, NEXT);
}
close_button.Create(parent, look.button, _("Close"), layout.close_button,
button_style, dialog, mrOK);
info_dock.Create(parent, layout.main, dock_style);
info_dock.SetWidget(&info_widget);
details_panel.Create(parent, look, layout.main, dock_style);
details_text.Create(details_panel, layout.details_text);
details_text.SetFont(look.text_font);
details_text.SetText(waypoint.details.c_str());
#ifdef HAVE_RUN_FILE
const unsigned num_files = std::distance(waypoint.files_external.begin(),
waypoint.files_external.end());
if (num_files > 0) {
file_list.Create(details_panel, layout.file_list,
WindowStyle(), layout.file_list_item_height);
file_list.SetItemRenderer(&file_list_handler);
file_list.SetCursorHandler(&file_list_handler);
file_list.SetLength(num_files);
}
#endif
commands_dock.Create(parent, layout.main, dock_style);
commands_dock.SetWidget(&commands_widget);
if (!images.empty())
image_window.Create(parent, layout.main, dock_style,
[this](Canvas &canvas, const PixelRect &rc){
OnImagePaint(canvas, rc);
});
last_page = 2 + images.size();
}
示例7: Update
/**
* Updates filter to add sample to buffer
*
* @param x0 Input (pre-filtered) value at sample time
*
* @return True if buffer is full
*/
bool Update(const fixed x0) {
if (!x.full())
x.append(x0);
return x.full();
}
示例8:
/**
* Allocates a new FLARM_TRAFFIC object from the array.
*
* @return the FLARM_TRAFFIC pointer, NULL if the array is full
*/
FLARM_TRAFFIC *AllocateTraffic() {
return traffic.full()
? NULL
: &traffic.append();
}
示例9: LoadDialog
void
dlgWaypointDetailsShowModal(SingleWindow &parent, const Waypoint &_waypoint,
bool allow_navigation)
{
waypoint = &_waypoint;
wf = LoadDialog(CallBackTable, parent,
Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") :
_T("IDR_XML_WAYPOINTDETAILS"));
assert(wf != NULL);
LastUsedWaypoints::Add(_waypoint);
UpdateCaption(waypoint->name.c_str(), waypoint->file_num);
wf->SetKeyDownNotify(FormKeyDown);
wInfo = (DockWindow *)wf->FindByName(_T("info"));
assert(wInfo != NULL);
wInfo->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(),
_waypoint));
wCommand = (DockWindow *)wf->FindByName(_T("commands"));
assert(wCommand != NULL);
wCommand->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(),
wf, _waypoint,
protected_task_manager));
wCommand->Hide();
wDetails = wf->FindByName(_T("frmDetails"));
assert(wDetails != NULL);
ListControl *wFilesList = (ListControl *)wf->FindByName(_T("Files"));
assert(wFilesList != NULL);
EditWindow *wDetailsText = (EditWindow *)wf->FindByName(_T("Details"));
assert(wDetailsText != NULL);
wDetailsText->SetText(waypoint->details.c_str());
#ifdef ANDROID
int num_files = std::distance(waypoint->files_external.begin(),
waypoint->files_external.end());
if (num_files > 0) {
wFilesList->SetPaintItemCallback(OnFileListItemPaint);
wFilesList->SetCursorCallback(OnFileListEnter);
wFilesList->SetActivateCallback(OnFileListEnter);
unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5);
wFilesList->Resize(wFilesList->GetWidth(), list_height);
wFilesList->SetLength(num_files);
PixelRect rc = wDetailsText->GetPosition();
rc.top += list_height;
wDetailsText->Move(rc);
} else
#endif
wFilesList->Hide();
wImage = (PaintWindow *)wf->FindByName(_T("frmImage"));
assert(wImage != NULL);
wMagnify = (WndButton *)wf->FindByName(_T("cmdMagnify"));
assert(wMagnify != NULL);
wShrink = (WndButton *)wf->FindByName(_T("cmdShrink"));
assert(wShrink != NULL);
if (!allow_navigation) {
WndButton* butnav = (WndButton *)wf->FindByName(_T("cmdPrev"));
assert(butnav != NULL);
butnav->Hide();
butnav = (WndButton *)wf->FindByName(_T("cmdNext"));
assert(butnav != NULL);
butnav->Hide();
butnav = (WndButton *)wf->FindByName(_T("cmdGoto"));
assert(butnav != NULL);
butnav->Hide();
}
for (auto it = waypoint->files_embed.begin(),
it_end = waypoint->files_embed.end();
it != it_end && !images.full(); it++) {
TCHAR path[MAX_PATH];
LocalPath(path, it->c_str());
if (!images.append().LoadFile(path))
images.shrink(images.size() - 1);
}
page = 0;
NextPage(0); // JMW just to turn proper pages on/off
wf->ShowModal();
delete wf;
for (auto image = images.begin(); image < images.end(); image++)
image->Reset();
images.clear();
//.........这里部分代码省略.........
示例10: AddButton
void AddButton(const TCHAR *caption, int id) {
buttons.append({caption, id});
}
示例11: size
PixelRect
ButtonPanel::BottomLayout(PixelRect rc)
{
assert(!buttons.empty());
const unsigned n_buttons = buttons.size();
const unsigned total_width = rc.GetWidth();
/* naive button distribution algorithm: distribute as many buttons
as possible into each row; weakness: the last row may have only
one button */
struct Row {
unsigned start, end;
constexpr unsigned size() const {
return end - start;
}
};
StaticArray<Row, 8u> rows;
for (unsigned i = 0; i < n_buttons;) {
unsigned end = FitButtonRow(i, total_width);
assert(end > i);
auto &row = rows.append();
row.start = i;
row.end = i = end;
}
assert(!rows.empty());
/* optimise the naive result: try to move buttons down until we see
no further chance for improvement */
bool modified;
do {
modified = false;
for (unsigned i = rows.size() - 1; i > 0; --i) {
auto &dest_row = rows[i];
auto &src_row = rows[i - 1];
/* the upper row has many more buttons than the lower row */
if (dest_row.size() + 2 <= src_row.size()) {
unsigned max_width = RangeMaxWidth(dest_row.start - 1, dest_row.end);
unsigned row_width = (dest_row.size() + 1) * max_width;
/* yes, we can move one button down */
if (row_width <= total_width) {
--src_row.end;
--dest_row.start;
modified = true;
}
}
}
} while (modified);
/* now do the actual layout based on row metadata */
for (int i = rows.size() - 1; i >= 0; --i) {
const auto &row = rows[i];
rc = HorizontalRange(rc, row.start, row.end);
}
return rc;
}
示例12: LoadDialog
void
dlgWaypointDetailsShowModal(const Waypoint &_waypoint,
bool allow_navigation)
{
waypoint = &_waypoint;
form = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(),
Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") :
_T("IDR_XML_WAYPOINTDETAILS"));
assert(form != nullptr);
LastUsedWaypoints::Add(_waypoint);
UpdateCaption();
form->SetKeyDownFunction(FormKeyDown);
info_widget = (DockWindow *)form->FindByName(_T("info"));
assert(info_widget != nullptr);
info_widget->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(),
_waypoint));
commands_widget = (DockWindow *)form->FindByName(_T("commands"));
assert(commands_widget != nullptr);
commands_widget->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(),
form, _waypoint,
protected_task_manager));
commands_widget->Hide();
details_panel = form->FindByName(_T("frmDetails"));
assert(details_panel != nullptr);
ListControl *wFilesList = (ListControl *)form->FindByName(_T("Files"));
assert(wFilesList != nullptr);
LargeTextWindow *wDetailsText = (LargeTextWindow *)
form->FindByName(_T("Details"));
assert(wDetailsText != nullptr);
wDetailsText->SetText(waypoint->details.c_str());
#ifdef ANDROID
WaypointExternalFileListHandler handler;
int num_files = std::distance(waypoint->files_external.begin(),
waypoint->files_external.end());
if (num_files > 0) {
wFilesList->SetItemRenderer(&handler);
wFilesList->SetCursorHandler(&handler);
unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5);
wFilesList->Resize(wFilesList->GetWidth(), list_height);
wFilesList->SetLength(num_files);
PixelRect rc = wDetailsText->GetPosition();
rc.top += list_height;
wDetailsText->Move(rc);
} else
#endif
wFilesList->Hide();
image_window = (PaintWindow *)form->FindByName(_T("frmImage"));
assert(image_window != nullptr);
magnify_button = (WndButton *)form->FindByName(_T("cmdMagnify"));
assert(magnify_button != nullptr);
shrink_button = (WndButton *)form->FindByName(_T("cmdShrink"));
assert(shrink_button != nullptr);
if (!allow_navigation) {
for (const TCHAR *button_name :
{ _T("cmdPrev"), _T("cmdNext"), _T("cmdGoto") }) {
Window *button = form->FindByName(button_name);
assert(button != nullptr);
button->Hide();
}
}
for (auto it = waypoint->files_embed.begin(),
it_end = waypoint->files_embed.end();
it != it_end && !images.full(); it++) {
TCHAR path[MAX_PATH];
LocalPath(path, it->c_str());
if (!images.append().LoadFile(path))
images.shrink(images.size() - 1);
}
last_page = 2 + images.size();
page = 0;
UpdatePage();
form->ShowModal();
delete form;
for (auto image = images.begin(); image < images.end(); image++)
image->Reset();
images.clear();
}
示例13: AddPoint
virtual void AddPoint(const GeoPoint& p) {
// Add a new GeoPoint to the current TriangleFan
g.append(p);
}
示例14: Update
/**
* Updates filter to add sample to buffer
*
* @param x0 Input (pre-filtered) value at sample time
*
* @return True if buffer is full
*/
bool Update(const double x0) {
if (!x.full())
x.append(x0);
return x.full();
}