本文整理汇总了C++中DataFieldEnum::Sort方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFieldEnum::Sort方法的具体用法?C++ DataFieldEnum::Sort怎么用?C++ DataFieldEnum::Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFieldEnum
的用法示例。
在下文中一共展示了DataFieldEnum::Sort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
static bool
DetectSerialPorts(DataFieldEnum &df)
{
TTYEnumerator enumerator;
if (enumerator.HasFailed())
return false;
unsigned sort_start = df.Count();
bool found = false;
const char *path;
while ((path = enumerator.Next()) != nullptr) {
const char *display_string = path;
if (memcmp(path, "/dev/", 5) == 0)
display_string = path + 5;
AddPort(df, DeviceConfig::PortType::SERIAL, path, display_string);
found = true;
}
if (found)
df.Sort(sort_start);
return found;
}
示例2: GetFocused
void
InfoBoxManager::SetupFocused()
{
int i = GetFocused();
if (i < 0)
return;
const enum mode mode = GetCurrentMode();
int old_type = GetType(i, mode);
/* create a fake WndProperty for dlgComboPicker() */
/* XXX reimplement properly */
DataFieldEnum *dfe = new DataFieldEnum(old_type, NULL);
for (unsigned i = 0; i < InfoBoxFactory::NUM_TYPES; i++)
dfe->addEnumText(gettext(GetTypeDescription(i)));
dfe->Sort(0);
dfe->Set(old_type);
ComboList *list = dfe->CreateComboList();
delete dfe;
/* let the user select */
info_box_combo_list = list;
int result = ComboPicker(XCSoarInterface::main_window, _("InfoBox"), *list,
OnInfoBoxHelp);
if (result < 0) {
delete list;
return;
}
/* was there a modification? */
int new_type = (*list)[result].DataFieldIndex;
delete list;
if (new_type == old_type)
return;
/* yes: apply and save it */
SetType(i, new_type, mode);
DisplayInfoBox();
Profile::SetInfoBoxes(i, GetTypes(i));
}
示例3: opendir
static bool
DetectSerialPorts(DataFieldEnum &df)
{
DIR *dir = opendir("/dev");
if (dir == NULL)
return false;
unsigned sort_start = df.Count();
bool found = false;
struct dirent *ent;
while ((ent = readdir(dir)) != NULL) {
/* filter "/dev/tty*" */
if (memcmp(ent->d_name, "tty", 3) == 0) {
/* filter out "/dev/tty0", ... (valid integer after "tty") */
char *endptr;
strtoul(ent->d_name + 3, &endptr, 10);
if (*endptr == 0)
continue;
} else if (memcmp(ent->d_name, "rfcomm", 6) != 0)
continue;
char path[64];
snprintf(path, sizeof(path), "/dev/%s", ent->d_name);
if (access(path, R_OK|W_OK) == 0 && access(path, X_OK) < 0) {
AddPort(df, DeviceConfig::PortType::SERIAL, path);
found = true;
}
}
closedir(dir);
if (found)
df.Sort(sort_start);
return found;
}
示例4: layout
void
InfoBoxesConfigWidget::Prepare(ContainerWindow &parent,
const PixelRect &rc)
{
const Layout layout(rc, geometry);
AddText(_("Name"), nullptr,
allow_name_change ? (const TCHAR *)data.name : gettext(data.name));
SetReadOnly(NAME, !allow_name_change);
DataFieldEnum *dfe = new DataFieldEnum(this);
for (unsigned i = 0; i < layout.info_boxes.count; ++i) {
TCHAR label[32];
_stprintf(label, _T("%u"), i + 1);
dfe->addEnumText(label, i);
}
Add(_("InfoBox"), nullptr, dfe);
dfe = new DataFieldEnum(this);
for (unsigned i = InfoBoxFactory::MIN_TYPE_VAL; i < InfoBoxFactory::NUM_TYPES; i++) {
const TCHAR *name = InfoBoxFactory::GetName((InfoBoxFactory::Type) i);
const TCHAR *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type) i);
if (name != NULL)
dfe->addEnumText(gettext(name), i, desc != NULL ? gettext(desc) : NULL);
}
dfe->EnableItemHelp(true);
dfe->Sort(0);
Add(_("Content"), nullptr, dfe);
ContainerWindow &form_parent = (ContainerWindow &)RowFormWidget::GetWindow();
AddRemaining(new WndFrame(form_parent, GetLook(), rc));
WindowStyle button_style;
button_style.Hide();
button_style.TabStop();
const auto &button_look = GetLook().button;
copy_button.Create(parent, button_look, _("Copy"), layout.copy_button,
button_style, *this, COPY);
paste_button.Create(parent, button_look, _("Paste"), layout.paste_button,
button_style, *this, PASTE);
close_button.Create(parent, button_look, _("Close"), layout.close_button,
button_style, dialog, mrOK);
WindowStyle preview_style;
preview_style.EnableDoubleClicks();
preview_style.Hide();
previews.resize(layout.info_boxes.count);
for (unsigned i = 0; i < layout.info_boxes.count; ++i) {
previews[i].SetParent(*this, i);
previews[i].Create(parent, layout.info_boxes.positions[i],
preview_style);
}
current_preview = 0;
RefreshEditContent();
RefreshPasteButton();
}
示例5: switch
//.........这里部分代码省略.........
_T("1200"), _T("2400"), _T("4800"), _T("9600"),
_T("19200"), _T("38400"), _T("57600"), _T("115200"),
NULL
};
#endif
if (port_field != NULL) {
DataFieldEnum *dfe = (DataFieldEnum *)port_field->GetDataField();
for (unsigned i = 0; port_types[i].label != NULL; i++) {
dfe->addEnumText(gettext(port_types[i].label));
if (port_types[i].type == config.port_type)
dfe->Set(i);
}
#ifdef ANDROID
JNIEnv *env = Java::GetEnv();
jobjectArray bonded = BluetoothHelper::list(env);
if (bonded != NULL) {
jsize n = env->GetArrayLength(bonded) / 2;
for (jsize i = 0; i < n; ++i) {
jstring address = (jstring)env->GetObjectArrayElement(bonded, i * 2);
if (address == NULL)
continue;
const char *address2 = env->GetStringUTFChars(address, NULL);
if (address2 == NULL)
continue;
jstring name = (jstring)env->GetObjectArrayElement(bonded, i * 2 + 1);
const char *name2 = name != NULL
? env->GetStringUTFChars(name, NULL)
: NULL;
dfe->addEnumText(address2, name2);
env->ReleaseStringUTFChars(address, address2);
if (name2 != NULL)
env->ReleaseStringUTFChars(name, name2);
}
env->DeleteLocalRef(bonded);
if (config.port_type == DeviceConfig::RFCOMM &&
!config.bluetooth_mac.empty()) {
if (!dfe->Exists(config.bluetooth_mac))
dfe->addEnumText(config.bluetooth_mac);
dfe->SetAsString(config.bluetooth_mac);
}
}
#else
dfe->addEnumTexts(COMMPort);
switch (config.port_type) {
case DeviceConfig::SERIAL:
dfe->Set(config.port_index + num_port_types);
break;
case DeviceConfig::DISABLED:
case DeviceConfig::RFCOMM:
case DeviceConfig::AUTO:
case DeviceConfig::INTERNAL:
case DeviceConfig::TCP_LISTENER:
break;
}
#endif
port_field->RefreshDisplay();
}
if (speed_field != NULL) {
#ifdef ANDROID
speed_field->hide();
#else
DataFieldEnum *dfe = (DataFieldEnum *)speed_field->GetDataField();
dfe->addEnumTexts(tSpeed);
dfe->Set(config.speed_index);
speed_field->RefreshDisplay();
#endif
}
if (driver_field) {
DataFieldEnum *dfe = (DataFieldEnum *)driver_field->GetDataField();
const TCHAR *DeviceName;
for (unsigned i = 0; (DeviceName = devRegisterGetName(i)) != NULL; i++)
dfe->addEnumText(DeviceName);
dfe->Sort(1);
dfe->SetAsString(config.driver_name);
driver_field->RefreshDisplay();
}
if (setup_button != NULL)
setup_button->set_visible(config.IsVega());
UpdateDeviceControlVisibility(*port_field, *speed_field, *driver_field);
}
示例6: WndButton
bool
dlgConfigInfoboxesShowModal(SingleWindow &parent,
const DialogLook &dialog_look,
InfoBoxLayout::Geometry geometry,
InfoBoxSettings::Panel &data_r,
bool allow_name_change)
{
current_preview = 0;
data = data_r;
PixelRect rc = parent.get_client_rect();
wf = new WndForm(parent, dialog_look, rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top);
#ifdef _WIN32_WCE
if (is_altair())
wf->SetKeyDownNotify(OnKeyDown);
#endif
ContainerWindow &client_area = wf->GetClientAreaWindow();
rc = client_area.get_client_rect();
InflateRect(&rc, Layout::FastScale(-2), Layout::FastScale(-2));
info_box_layout = InfoBoxLayout::Calculate(rc, geometry);
WindowStyle preview_style;
preview_style.enable_double_clicks();
for (unsigned i = 0; i < info_box_layout.count; ++i) {
rc = info_box_layout.positions[i];
previews[i].set(client_area, rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top,
preview_style);
}
rc = info_box_layout.remaining;
WindowStyle style;
style.control_parent();
EditWindowStyle edit_style;
edit_style.tab_stop();
if (is_embedded() || Layout::scale_1024 < 2048)
/* sunken edge doesn't fit well on the tiny screen of an
embedded device */
edit_style.border();
else
edit_style.sunken_edge();
const int x = rc.left;
const unsigned width = rc.right - rc.left - Layout::FastScale(2);
const unsigned height = Layout::Scale(22);
const unsigned caption_width = Layout::Scale(60);
int y = rc.top;
ButtonWindowStyle button_style;
button_style.tab_stop();
buttonPanelName =
new WndButton(client_area, dialog_look, _T(""),
x, y, width, height, button_style, OnNameAccess);
buttonPanelName->set_enabled(allow_name_change);
UpdatePanelName();
y += height;
edit_select = new WndProperty(client_area, dialog_look, _("InfoBox"),
x, y, width, height, caption_width,
style, edit_style,
NULL);
DataFieldEnum *dfe = new DataFieldEnum(OnSelectAccess);
for (unsigned i = 0; i < info_box_layout.count; ++i) {
TCHAR label[32];
_stprintf(label, _T("%u"), i + 1);
dfe->addEnumText(label, i);
}
edit_select->SetDataField(dfe);
y += height;
edit_content = new WndProperty(client_area, dialog_look, _("Content"),
x, y, width, height, caption_width,
style, edit_style,
NULL);
dfe = new DataFieldEnum(OnContentAccess);
for (unsigned i = 0; i < InfoBoxFactory::NUM_TYPES; ++i) {
const TCHAR *name = InfoBoxFactory::GetName(i);
if (name != NULL)
dfe->addEnumText(gettext(name), i);
}
dfe->Sort(0);
edit_content->SetDataField(dfe);
edit_content->SetOnHelpCallback(OnContentHelp);
//.........这里部分代码省略.........
示例7: WndButton
bool
dlgConfigInfoboxesShowModal(SingleWindow &parent,
const DialogLook &dialog_look,
const InfoBoxLook &_look,
InfoBoxSettings::Geometry geometry,
InfoBoxSettings::Panel &data_r,
bool allow_name_change)
{
current_preview = 0;
look = &_look;
data = data_r;
PixelRect rc = parent.GetClientRect();
wf = new WndForm(parent, dialog_look, rc);
#ifdef _WIN32_WCE
if (IsAltair())
wf->SetKeyDownFunction(OnKeyDown);
#endif
ContainerWindow &client_area = wf->GetClientAreaWindow();
rc = client_area.GetClientRect();
rc.Grow(Layout::FastScale(-2));
info_box_layout = InfoBoxLayout::Calculate(rc, geometry);
WindowStyle preview_style;
preview_style.EnableDoubleClicks();
for (unsigned i = 0; i < info_box_layout.count; ++i) {
rc = info_box_layout.positions[i];
previews[i].Create(client_area, rc, preview_style);
}
rc = info_box_layout.remaining;
WindowStyle style;
style.TabStop();
PixelRect control_rc = rc;
control_rc.right -= Layout::FastScale(2);
const UPixelScalar height = Layout::Scale(22);
const UPixelScalar caption_width = Layout::Scale(60);
ButtonWindowStyle button_style;
button_style.TabStop();
control_rc.bottom = control_rc.top + height;
edit_name = new WndProperty(client_area, dialog_look, _("Name"),
control_rc, caption_width,
style);
DataFieldString *dfs = new DataFieldString(allow_name_change
? (const TCHAR *)data.name
: gettext(data.name));
edit_name->SetDataField(dfs);
edit_name->SetReadOnly(!allow_name_change);
control_rc.top = control_rc.bottom;
control_rc.bottom = control_rc.top + height;
edit_select = new WndProperty(client_area, dialog_look, _("InfoBox"),
control_rc, caption_width,
style);
DataFieldEnum *dfe = new DataFieldEnum(OnSelectAccess);
for (unsigned i = 0; i < info_box_layout.count; ++i) {
TCHAR label[32];
_stprintf(label, _T("%u"), i + 1);
dfe->addEnumText(label, i);
}
edit_select->SetDataField(dfe);
control_rc.top += height;
control_rc.bottom += height;
edit_content = new WndProperty(client_area, dialog_look, _("Content"),
control_rc, caption_width,
style);
dfe = new DataFieldEnum(OnContentAccess);
for (unsigned i = InfoBoxFactory::MIN_TYPE_VAL; i < InfoBoxFactory::NUM_TYPES; i++) {
const TCHAR *name = InfoBoxFactory::GetName((InfoBoxFactory::Type) i);
const TCHAR *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type) i);
if (name != NULL)
dfe->addEnumText(gettext(name), i, desc != NULL ? gettext(desc) : NULL);
}
dfe->EnableItemHelp(true);
dfe->Sort(0);
edit_content->SetDataField(dfe);
control_rc.top += height;
control_rc.bottom += height * 5;
edit_content_description = new WndFrame(client_area, dialog_look,
control_rc, style);
RefreshEditContent();
const UPixelScalar button_width = Layout::Scale(60);
//.........这里部分代码省略.........