pub struct Field {Show 26 fields
pub field_name: String,
pub field_type: FieldType,
pub size: usize,
pub scale: u8,
pub rounding: Rounding,
pub display_label: String,
pub display_width: f32,
pub display_format: String,
pub edit_format: String,
pub alignment: Option<TextAlign>,
pub required: bool,
pub read_only: bool,
pub visible: bool,
pub min: Option<f64>,
pub max: Option<f64>,
pub default_value: String,
pub display_values: String,
pub char_case: CharCase,
pub kind: FieldKind,
pub expression: String,
pub lookup_data_set: Option<ComponentId>,
pub key_fields: String,
pub lookup_key_fields: String,
pub lookup_result_field: String,
pub edit_mask: String,
pub sensitive: bool,
/* private fields */
}Expand description
Definição de um campo.
ui.add(Field::new("limite", FieldType::Currency).label("Limite").format("R$ #,##0.00").min(0.0), cds);Fields§
§field_name: StringNome da coluna. Vazio = usa o nome do componente.
field_type: FieldTypeO tipo do valor: string, memo, integer, float, currency, boolean, date,
time, datetime, blob, auto_inc ou timestamp.
size: usizeTamanho máximo (texto). 0 = sem limite.
scale: u8Casas decimais de currency.
rounding: RoundingComo um valor com mais casas é arredondado para scale (ao gravar, vindo da tela, do
backend ou de uma expressão, e ao mostrar): metade para cima (o padrão), bancário,
truncar ou para cima.
display_label: StringO título do campo nas grades e nos rótulos; vazio: o nome do campo.
display_width: f32Largura sugerida para grids, em unidades lógicas. 0 = automática.
display_format: StringComo o valor aparece (R$ #,##0.00, dd/mm/yyyy); vazio: o padrão do tipo e do idioma.
edit_format: StringComo um número aparece durante a edição; vazio: o display_format.
alignment: Option<TextAlign>None = conforme o tipo (números à direita).
required: boolNão aceita gravar o registro com o campo vazio.
read_only: boolOs controles ligados mostram, mas não deixam editar.
visible: boolAparece nas grades; desligado, a coluna some (o valor continua no registro).
min: Option<f64>O menor valor aceito (números); vazio: sem limite.
max: Option<f64>O maior valor aceito (números); vazio: sem limite.
default_value: StringValor inicial de registros novos, em texto (lido com as regras do tipo).
display_values: StringTextos para verdadeiro;falso (campos lógicos), como DisplayValues.
char_case: CharCaseMaiúsculas (upper) ou minúsculas (lower) forçadas no valor; normal: como digitado.
kind: FieldKindDe onde vem o valor: data (do registro), calculated (a expression) ou lookup
(procurado em outro dataset).
expression: StringCampo calculado: a expressão (quantidade * preco, ver crate::expr).
lookup_data_set: Option<ComponentId>Lookup: o dataset onde procurar.
key_fields: StringLookup: campo(s) deste dataset com a chave (cliente_id).
lookup_key_fields: StringLookup: campo(s) do outro dataset que correspondem (id).
lookup_result_field: StringLookup: o campo trazido (nome).
edit_mask: StringMáscara de edição (000.000.000-00;0, ver crate::mask).
sensitive: boolDado pessoal (LGPD): os controles ligados ao campo contam como sensitive (as
gravações do EventRecorder mascaram o que é digitado neles).
Implementations§
Source§impl Field
impl Field
pub fn new(name: impl Into<String>, field_type: FieldType) -> Self
pub fn label(self, label: impl Into<String>) -> Self
pub fn size(self, size: usize) -> Self
pub fn format(self, display_format: impl Into<String>) -> Self
Sourcepub fn align(self, alignment: TextAlign) -> Self
pub fn align(self, alignment: TextAlign) -> Self
Alinhamento do texto (o padrão é pelo tipo: números à direita).
pub fn required(self) -> Self
pub fn read_only(self) -> Self
pub fn min(self, min: f64) -> Self
pub fn max(self, max: f64) -> Self
pub fn default_value(self, text: impl Into<String>) -> Self
pub fn display_values(self, values: impl Into<String>) -> Self
pub fn char_case(self, char_case: CharCase) -> Self
Sourcepub fn on_get_text(self, f: impl Fn(&Value, bool) -> String + 'static) -> Self
pub fn on_get_text(self, f: impl Fn(&Value, bool) -> String + 'static) -> Self
Como o OnGetText: valor → texto. display é true para exibir e false para
editar.
Sourcepub fn on_set_text(
self,
f: impl Fn(&str) -> Result<Value, String> + 'static,
) -> Self
pub fn on_set_text( self, f: impl Fn(&str) -> Result<Value, String> + 'static, ) -> Self
Como o OnSetText: texto digitado → valor (ou mensagem de erro).
Sourcepub fn on_validate(
self,
f: impl Fn(&Value) -> Result<(), String> + 'static,
) -> Self
pub fn on_validate( self, f: impl Fn(&Value) -> Result<(), String> + 'static, ) -> Self
Como o OnValidate: recusa um valor com uma mensagem.
Sourcepub fn calculated(self, expression: impl Into<String>) -> Self
pub fn calculated(self, expression: impl Into<String>) -> Self
Nome para mensagens e cabeçalhos: o display_label ou o nome da coluna.
Campo calculado por expressão.
Sourcepub fn on_calculate(
self,
f: impl Fn(&dyn Fn(&str) -> Value) -> Value + 'static,
) -> Self
pub fn on_calculate( self, f: impl Fn(&dyn Fn(&str) -> Value) -> Value + 'static, ) -> Self
Campo calculado em Rust: get("quantidade") lê os outros campos do registro.
Sourcepub fn lookup(
self,
data_set: ComponentId,
key_field: &str,
lookup_key: &str,
result: &str,
) -> Self
pub fn lookup( self, data_set: ComponentId, key_field: &str, lookup_key: &str, result: &str, ) -> Self
Campo lookup: procura key_field deste registro no lookup_key de data_set e
mostra o result.
Sourcepub fn compute(&self, get: &dyn Fn(&str) -> Option<Value>) -> Value
pub fn compute(&self, get: &dyn Fn(&str) -> Option<Value>) -> Value
Calcula o valor de um campo calculado (get lê os outros campos).
Sourcepub fn expression_error(&self) -> Option<String>
pub fn expression_error(&self) -> Option<String>
Erro da expressão do campo calculado, se houver (para mostrar no designer).
pub fn caption(&self) -> &str
pub fn alignment(&self) -> TextAlign
pub fn is_read_only(&self) -> bool
Sourcepub fn clear_texts(&self)
pub fn clear_texts(&self)
Esquece os textos recebidos (o backend mudou a regra): serão pedidos de novo.
Sourcepub fn text_of(
&self,
value: &Value,
display: bool,
locale: &LocaleInfo,
) -> String
pub fn text_of( &self, value: &Value, display: bool, locale: &LocaleInfo, ) -> String
Texto para exibir (display = true) ou para editar (false).
Sourcepub fn parse_text(
&self,
text: &str,
locale: &LocaleInfo,
) -> Result<Value, String>
pub fn parse_text( &self, text: &str, locale: &LocaleInfo, ) -> Result<Value, String>
Lê o texto digitado. Texto vazio vira Null.
Sourcepub fn coerce(&self, value: Value) -> Result<Value, String>
pub fn coerce(&self, value: Value) -> Result<Value, String>
Ajusta o tipo do valor ao do campo (por exemplo inteiro num campo float), ou
recusa.
Sourcepub fn check(&self, value: &Value) -> Result<(), String>
pub fn check(&self, value: &Value) -> Result<(), String>
Restrições do valor (tamanho, mínimo, máximo e on_validate). required é
conferido no post.
Sourcepub fn initial_value(&self, locale: &LocaleInfo) -> Value
pub fn initial_value(&self, locale: &LocaleInfo) -> Value
Valor inicial de um registro novo.
Trait Implementations§
Source§impl Component for Field
impl Component for Field
Source§fn property_changed(&mut self, ctx: &mut EventCtx<'_>, name: &str)
fn property_changed(&mut self, ctx: &mut EventCtx<'_>, name: &str)
Mudou como o campo aparece (largura, título, visível, alinhamento, formato): os
controles ligados ao dataset refazem (a grade, as colunas). Antes o display_width em
execução não mudava a coluna. Vai por post: durante esta chamada o campo está
emprestado, e a grade o lê ao refazer.
Source§fn class_name(&self) -> &'static str
fn class_name(&self) -> &'static str
Source§fn notification(&mut self, freed: ComponentId)
fn notification(&mut self, freed: ComponentId)
Notification(AComponent, opRemove)).
Quem guarda referências para outros componentes deve limpá-las aqui.Source§fn props(&self) -> &'static [PropInfo]
fn props(&self) -> &'static [PropInfo]
inner) e as do
ControlBase são incluídas automaticamente pelo Ui.Source§fn get_prop(&self, name: &str) -> Option<PropValue>
fn get_prop(&self, name: &str) -> Option<PropValue>
None se não for dela.Source§fn set_prop(&mut self, name: &str, value: PropValue) -> Result<()>
fn set_prop(&mut self, name: &str, value: PropValue) -> Result<()>
Error::UnknownProperty se não for
dela (o Ui então tenta a camada base).Source§fn inner(&self) -> Option<&(dyn Component + 'static)>
fn inner(&self) -> Option<&(dyn Component + 'static)>
fn inner_mut(&mut self) -> Option<&mut (dyn Component + 'static)>
Source§fn class_chain(&self, out: &mut Vec<&'static str>)
fn class_chain(&self, out: &mut Vec<&'static str>)
GlowButton sem estilo próprio usa o estilo de Button.Source§fn control(&self) -> Option<&ControlBase>
fn control(&self) -> Option<&ControlBase>
None.fn control_mut(&mut self) -> Option<&mut ControlBase>
Source§fn default_event(&self) -> Option<&'static str>
fn default_event(&self) -> Option<&'static str>
None: a IDE escolhe pelo nome (o on_change da classe, o
on_timer… ou o on_click).Source§fn paint(&self, canvas: &mut dyn Canvas, ctx: &PaintCtx<'_>)
fn paint(&self, canvas: &mut dyn Canvas, ctx: &PaintCtx<'_>)
ctx.rect é a área dele.Source§fn transparent_background(&self) -> bool
fn transparent_background(&self) -> bool
fill
próprio, o Ui pinta o fundo dele inteiro. Os que têm
fundo usam o fill no desenho deles.Source§fn opaque(&self, style: &ResolvedStyle) -> bool
fn opaque(&self, style: &ResolvedStyle) -> bool
paint deste estilo cobre o retângulo inteiro do controle com cor opaca (um painel
de fundo sólido sem cantos arredondados, um form). Com true, o que fica inteiro atrás
dele (um irmão pintado antes) não é pintado: um medidor animando embaixo de uma tela que
o cobre não pede quadros. Na dúvida, false (o padrão): só se perde a economia.Source§fn clip_shape(&self) -> Option<ClipShape>
fn clip_shape(&self) -> Option<ClipShape>
None (o padrão): o retângulo, com o
raio do estilo no fundo.Source§fn paint_after(&self, canvas: &mut dyn Canvas, ctx: &PaintCtx<'_>)
fn paint_after(&self, canvas: &mut dyn Canvas, ctx: &PaintCtx<'_>)
Source§fn paint_is_pure(&self) -> bool
fn paint_is_pure(&self) -> bool
paint e paint_after) só lê: sem efeito colateral (nada de evento, de
cache que avança, de quadro de vídeo consumido) e o mesmo desenho para o mesmo estado,
estilo e propriedades. Com true, o Ui pode ensaiar o desenho fora do quadro e não
repintar o controle quando ele não mudou (o fundo de um contêiner quando o mouse entra
nele). Os contêineres simples dizem true; o padrão é false, mesmo com inner
(quem herda de um contêiner e pinta por cima precisa dizer de novo).Source§fn provided(&self) -> Option<Provided<'_>>
fn provided(&self) -> Option<Provided<'_>>
provider (veja crate::providers). O padrão: nada.Source§fn resized(&mut self, ctx: &mut EventCtx<'_>)
fn resized(&mut self, ctx: &mut EventCtx<'_>)
bounds) mudou depois de um layout (como o Resize).Source§fn click(&mut self, ctx: &mut EventCtx<'_>)
fn click(&mut self, ctx: &mut EventCtx<'_>)
Click). O padrão dispara o evento on_click.fn pointer_down(&mut self, ctx: &mut EventCtx<'_>, event: &PointerEvent)
fn pointer_up(&mut self, ctx: &mut EventCtx<'_>, event: &PointerEvent)
fn pointer_move(&mut self, ctx: &mut EventCtx<'_>, event: &PointerEvent)
fn pointer_enter(&mut self, ctx: &mut EventCtx<'_>)
fn pointer_leave(&mut self, ctx: &mut EventCtx<'_>)
fn wheel(&mut self, ctx: &mut EventCtx<'_>, event: &WheelEvent)
Source§fn gesture(&mut self, ctx: &mut EventCtx<'_>, event: &GestureEvent)
fn gesture(&mut self, ctx: &mut EventCtx<'_>, event: &GestureEvent)
ctx.set_handled()) para não subir
para os pais.Source§fn swipe(&mut self, ctx: &mut EventCtx<'_>, event: &SwipeEvent)
fn swipe(&mut self, ctx: &mut EventCtx<'_>, event: &SwipeEvent)
Carousel troca de item, o TabControl de página). Marque
como tratado (ctx.set_handled()) para não subir para os pais.Source§fn touch_end(&mut self, ctx: &mut EventCtx<'_>)
fn touch_end(&mut self, ctx: &mut EventCtx<'_>)
Source§fn edge_swipe(&mut self, ctx: &mut EventCtx<'_>, event: &SwipeEvent) -> bool
fn edge_swipe(&mut self, ctx: &mut EventCtx<'_>, event: &SwipeEvent) -> bool
event.start nas coordenadas do form) e que
ninguém tratou: a NavigationDrawer abre. true se tratou.Edit e do Memo: Recortar,
Copiar, Colar, Selecionar tudo). O Ui chama no botão direito e no toque longo
(touch), subindo do controle tocado pelos pais, só quando nem ele nem um pai tem
popup_menu (o menu do app vence). at é o ponto local. true se abriu um menu.fn key_down(&mut self, ctx: &mut EventCtx<'_>, event: &KeyEvent)
fn key_up(&mut self, ctx: &mut EventCtx<'_>, event: &KeyEvent)
Source§fn shortcut(&mut self, ctx: &mut EventCtx<'_>, event: &KeyEvent)
fn shortcut(&mut self, ctx: &mut EventCtx<'_>, event: &KeyEvent)
Ui
oferece a todos os componentes do form. Marque como tratado
(EventCtx::set_handled) se for sua.Source§fn platform_hooks(&self) -> Option<&dyn PlatformHooks>
fn platform_hooks(&self) -> Option<&dyn PlatformHooks>
Some(self) e implemente PlatformHooks.fn platform_hooks_mut(&mut self) -> Option<&mut dyn PlatformHooks>
Source§fn design_hooks(&self) -> Option<&dyn DesignHooks>
fn design_hooks(&self) -> Option<&dyn DesignHooks>
Some(self) e implemente DesignHooks.fn design_hooks_mut(&mut self) -> Option<&mut dyn DesignHooks>
Source§fn contains_point(&self, local: PointF, size: SizeF) -> bool
fn contains_point(&self, local: PointF, size: SizeF) -> bool
Source§fn hit_slop(&self) -> f32
fn hit_slop(&self) -> f32
contains_point (que recebe o ponto fora dele). Padrão: 0.Source§fn scroll_axes(&self) -> (bool, bool)
fn scroll_axes(&self) -> (bool, bool)
Ui::reveal
rola estes contêineres para mostrar um controle de dentro (o campo sob o teclado).Source§fn drag_drop(&self) -> Option<&dyn DragDrop>
fn drag_drop(&self) -> Option<&dyn DragDrop>
DragDrop). None (o padrão):
o componente não usa.fn drag_drop_mut(&mut self) -> Option<&mut dyn DragDrop>
fn accepts_text(&self) -> bool
Source§fn captures_key(&self, event: &KeyEvent) -> bool
fn captures_key(&self, event: &KeyEvent) -> bool
tab_keys).Source§fn mnemonic_text(&self) -> Option<&str>
fn mnemonic_text(&self) -> Option<&str>
& da letra do atalho ("&Salvar": Alt+S), para os controles que
aceitam (botões, caixas de marcar, rótulos, grupos).Source§fn mnemonic_focuses_child(&self) -> bool
fn mnemonic_focuses_child(&self) -> bool
Source§fn text_input(&mut self, ctx: &mut EventCtx<'_>, text: &str)
fn text_input(&mut self, ctx: &mut EventCtx<'_>, text: &str)
fn focus_enter(&mut self, ctx: &mut EventCtx<'_>)
fn focus_exit(&mut self, ctx: &mut EventCtx<'_>)
Source§fn checked_state(&self) -> Option<bool>
fn checked_state(&self) -> Option<bool>
checked), lida pelo núcleo na pintura: o tema reflete a
marca mesmo quando o campo muda direto, sem o set_prop (C02 do Tabernáculo).Source§fn change_args(&self, name: &str, value: &PropValue) -> Option<EventArgs>
fn change_args(&self, name: &str, value: &PropValue) -> Option<EventArgs>
on_change quando a propriedade de valor name muda pelo código
(Ui::set_prop: o acesso tipado, o protocolo);
value é o valor novo. O padrão é EventArgs::Value(value): o controle que dispara
outro argumento quando o usuário muda (o texto do item, numa ComboBox) devolve o mesmo
aqui, e None não dispara. Quais propriedades contam: is_value_property.Source§fn paint_only_property(&self, name: &str) -> bool
fn paint_only_property(&self, name: &str) -> bool
name só muda a pintura (o valor de um medidor, o giro de um 3D): o
set_prop dela repinta sem refazer o layout da tela. As do controle (cores, opacidade,
giro, deslocamento, cursor, dica) o Ui já conhece; aqui vão as do componente. Na
dúvida, false (refazer o layout nunca está errado, só custa).Source§fn timed(&self) -> Option<&dyn Timed>
fn timed(&self) -> Option<&dyn Timed>
Timed). O padrão: o do componente de dentro.fn timed_mut(&mut self) -> Option<&mut dyn Timed>
Source§fn layout_hooks(&self) -> Option<&dyn LayoutHooks>
fn layout_hooks(&self) -> Option<&dyn LayoutHooks>
LayoutHooks). O padrão: o do componente de
dentro.Source§fn child_pointer_mut(&mut self) -> Option<&mut dyn ChildPointer>
fn child_pointer_mut(&mut self) -> Option<&mut dyn ChildPointer>
ChildPointer). O padrão: o do componente de
dentro.Source§fn popup(&self) -> Option<&dyn Popup>
fn popup(&self) -> Option<&dyn Popup>
Popup). O padrão: o do componente
de dentro.fn popup_mut(&mut self) -> Option<&mut dyn Popup>
Source§fn accessible_items(&self) -> Option<&dyn AccessibleItems>
fn accessible_items(&self) -> Option<&dyn AccessibleItems>
AccessibleItems). O padrão: o do
componente de dentro.fn accessible_items_mut(&mut self) -> Option<&mut dyn AccessibleItems>
Source§fn attach(&self) -> Option<(ComponentId, f32, f32)>
fn attach(&self) -> Option<(ComponentId, f32, f32)>
0..1 na largura e na altura: (1, 0) é o canto de
cima à direita). É o que deixa um Badge no canto de um botão.Source§fn event_info(&self, event: &str) -> Vec<(&'static str, String)>
fn event_info(&self, event: &str) -> Vec<(&'static str, String)>
info do evento (o on_message do
WebView manda a URL de quem mandou).Source§fn message(&mut self, ctx: &mut EventCtx<'_>, message: &(dyn Any + 'static))
fn message(&mut self, ctx: &mut EventCtx<'_>, message: &(dyn Any + 'static))
Ui::send_message.
O tipo da mensagem é livre: cada camada
(por exemplo a de dados) define as suas e o componente faz downcast_ref.Source§fn methods(&self) -> &'static [MethodInfo]
fn methods(&self) -> &'static [MethodInfo]
invoke atende, com os tipos (o catálogo do
acesso tipado nas linguagens: frmPaint.pcDesenho.Undo).Source§fn invoke(
&mut self,
ctx: &mut EventCtx<'_>,
method: &str,
args: &[PropValue],
) -> Result<PropValue, String>
fn invoke( &mut self, ctx: &mut EventCtx<'_>, method: &str, args: &[PropValue], ) -> Result<PropValue, String>
Ui::invoke, o comando invoke do
protocolo): o que não é propriedade, como undo, clear ou save. Funciona igual
em Rust e nas outras linguagens (pelo protocolo). Devolve o resultado ou o erro.