コード例 #1
0
ファイル: widgets.c プロジェクト: Magister/cndrvcups-capt
void HideDialog(const char *dlg_name, const gboolean flag)
{
	GtkWidget *widget;
	GtkWidget *top;
	char *text;
	SpecialInfo* special = NULL;

	if(g_config_file_data != NULL){
		special = g_config_file_data->special_list;
	}
	while(special != NULL){
		if(0 == strcasecmp(special->name, dlg_name)){
			break;
		}
		special = special->next;
	}
	widget = glade_xml_get_widget(g_cngplp_xml, dlg_name);
	if(NULL == widget){
		return;
	}
	InitUpdateOption(g_cngplp_data);
	if(FALSE == flag){
		special->print = 0;
		RestoreTopWidgetData(dlg_name);
	}else{
		if(special->print == 1){
			if(0 == strcasecmp(dlg_name, "IdPassWdDlg")){
				const char *ps = NULL;
				const char *usr = NULL;

				ps = GetTextEntry("PassWd_entry");
				usr = GetTextEntry("ID_entry");
				if((0 == (strlen(ps))) || (0 == (strlen(usr)))){
					return;
				}
			}
			if(0 == strcasecmp(dlg_name, "JobAccountDlg")){
				const char *jobusr = NULL;
				jobusr = GetTextEntry("JobAccountID_entry");
				if(0 == strlen(jobusr)){
					return;
				}
			}
		}
	}
	FreeTopWidgetSaveData(dlg_name);
	text = ExitUpdateOption(g_cngplp_data);
	UpdateWidget(ID_CNSKIPBLANK, text);

	top = gtk_widget_get_toplevel(widget);
	gtk_widget_hide(top);
	gtk_main_quit();
}
コード例 #2
0
void
wxNumValidatorBase::GetCurrentValueAndInsertionPoint(wxString& val,
                                                             int& pos) const
{
    wxTextEntry * const control = GetTextEntry();
    if ( !control )
        return;

    val = control->GetValue();
    pos = control->GetInsertionPoint();

    long selFrom, selTo;
    control->GetSelection(&selFrom, &selTo);

    const long selLen = selTo - selFrom;
    if ( selLen )
    {
        // Remove selected text because pressing a key would make it disappear.
        val.erase(selFrom, selLen);

        // And adjust the insertion point to have correct position in the new
        // string.
        if ( pos > selFrom )
        {
            if ( pos >= selTo )
                pos -= selLen;
            else
                pos = selFrom;
        }
    }
}
コード例 #3
0
bool SPICE_VALIDATOR::Validate( wxWindow* aParent )
{
    wxTextEntry* const text = GetTextEntry();

    if( !text )
        return false;

    if( text->IsEmpty() )
    {
        if( m_emptyAllowed )
            return true;

        DisplayError( aParent, wxString::Format( wxT( "Fill required fields" ) ) );
        return false;
    }

    try
    {
        // If SPICE_VALUE can be constructed, then it is a valid Spice value
        SPICE_VALUE val( text->GetValue() );
    }
    catch( ... )
    {
        DisplayError( aParent,
                wxString::Format( wxT( "'%s' is not a valid Spice value" ), text->GetValue() ) );

        return false;
    }

    return true;
}
コード例 #4
0
bool FloatingPointValidatorBase::DoValidateNumber(wxString * errMsg) const
{
   wxTextEntry * const control = GetTextEntry();
   if ( !control )
      return false;

   wxString s(control->GetValue());
   wxChar thousandsSep;
   if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
      s.Replace(wxString(thousandsSep), wxString());

   if ( s.empty() )
   {
      if ( HasFlag(NUM_VAL_ZERO_AS_BLANK) )
         return true; //Is blank, but allowed. Stop here
      else
      {
         *errMsg = _("Empty value");
         return false; //We can't do any checks with an empty string
      }
   }

   LongestValueType value;
   bool res = FromString(s, &value); // Can it be converted to a value?
   if ( !res )
      *errMsg = _("Value overflow");
   else
   {
      res = ValidatePrecision(s);
      if ( !res )
         *errMsg = _("Too many decimal digits");
      else
      {
         res = IsInRange(value);
         if ( !res )
         {
            wxString strMin = wxString::Format(wxT("%f"), m_min);
            wxString strMax = wxString::Format(wxT("%f"), m_max);
            NumberFormatter::RemoveTrailingZeroes(strMin);
            NumberFormatter::RemoveTrailingZeroes(strMax);

            if (m_minSet && m_maxSet)
            {
               errMsg->Printf(_("Value not in range: %s to %s"),
                              strMin, strMax);
            }
            else if (m_minSet)
            {
               errMsg->Printf(_("Value must not be less than %s"), strMin);
            }
            else if (m_maxSet)
            {
               errMsg->Printf(_("Value must not be greather than %s"), strMax);
            }
         }
      }
   }

   return res;
}
コード例 #5
0
ファイル: valnum.cpp プロジェクト: MindFy/audacity
void NumValidatorBase::OnPaste(wxClipboardTextEvent& event)
{
   event.Skip(false);

   wxTextEntry * const control = GetTextEntry();
   if ( !control )
   {
      return;
   }

   wxClipboardLocker cb;
//    if (!wxClipboard::Get()->IsSupported(wxDataFormat(wxDF_TEXT)))
   if (!wxClipboard::Get()->IsSupported(wxDF_TEXT))
   {
      return;
   }

   wxTextDataObject data;
   if (!wxClipboard::Get()->GetData( data ))
   {
      return;
   }

   wxString toPaste = data.GetText();
   wxString val;
   int pos;
   GetCurrentValueAndInsertionPoint(val, pos);

   for (size_t i = 0, cnt = toPaste.Length(); i < cnt; i++)
   {
      const wxChar ch = toPaste[i];

      // Check if this character is allowed in the current state.
      if ( IsCharOk(val, pos, ch) )
      {
         val = GetValueAfterInsertingChar(val, pos++, ch);
      }
      else if ( !wxValidator::IsSilent() )
      {
               wxBell();
      }
   }

   // When we change the control value below, its "modified" status is reset
   // so we need to explicitly keep it marked as modified if it was so in the
   // first place.
   //
   // Notice that only wxTextCtrl (and not wxTextEntry) has
   // IsModified()/MarkDirty() methods hence the need for dynamic cast.
   wxTextCtrl * const text = wxDynamicCast(m_validatorWindow, wxTextCtrl);
   const bool wasModified = text ? text->IsModified() : false;

   // Use SetValue because effect still needs EVT_TEXT (bug 1357)
   control->SetValue(NormalizeString(val));

   if ( wasModified )
   {
      text->MarkDirty();
   }
}
コード例 #6
0
ファイル: widgets.c プロジェクト: Magister/cndrvcups-capt
void UpdateEntryWidget(const int id, const char *entry_name)
{
	const gchar *text;
	text = GetTextEntry(entry_name);
	if((text != NULL) && (strcmp(text, "")) != 0){
		cngplpSetData(g_cngplp_data, id, (char*)text);
	}
}
コード例 #7
0
ファイル: entry.c プロジェクト: Magister/cndrvcups-capt
void CheckEnter(const char *entry_name, const char *digit, int length)
{
	gchar id[ENTRY_TEXT_MAX];
	const gchar* tmp = NULL;
	int num = 0, cnt = 0, i;
	int code = 0;
	int check_digit = 0;
	int flag = 0;

	if(entry_name == NULL){
		return;
	}

	code = UTF8;
	if((digit != NULL) && (0 == strcmp(digit, "True"))){
		check_digit = TRUE;
	}

	tmp = GetTextEntry(entry_name);
	num = strlen(tmp);
	for(i = 0; i < num; i++, cnt++){
		guchar ch = tmp[i];
		if(cnt >= length){
			break;
		}
		if((ch & ASCII_FLAG) != 0){
			flag = TRUE;
			cnt++;
			if(cnt >= length){
				break;
			}
			switch(code){
			case EUC:
				if(ch == TWO_BYTE_WORD){
					i += TWO_BYTE;
				}else{
					i++;
				}
				break;
			case UTF8:
				if((ch & THREE_BYTE_WORD) != 0){
					if((ch & (THREE_BYTE_WORD >> 1)) != 0){
						if((ch & (THREE_BYTE_WORD >> 2)) != 0){
							i += THREE_BYTE;
						}else{
							i += TWO_BYTE;
						}
					}else{
						i++;
					}
				}
				break;
			default:
				break;
			}
コード例 #8
0
ファイル: valtext.cpp プロジェクト: 0ryuO/dolphin-avsync
// Called to transfer data to the window
bool wxTextValidator::TransferFromWindow()
{
    if ( m_stringValue )
    {
        wxTextEntry * const text = GetTextEntry();
        if ( !text )
            return false;

        *m_stringValue = text->GetValue();
    }

    return true;
}
コード例 #9
0
ファイル: entry.c プロジェクト: Magister/cndrvcups-capt
void CheckDigit(const char *entry_name)
{
	int num = 0;
	const gchar *tmp = NULL;

	if(entry_name != NULL){
		tmp = GetTextEntry(entry_name);
		num = strlen(tmp);

		if(num > 0){
			tmp += num - 1;
			if((tmp != NULL) && (0 == isdigit(*tmp))){
				num = num - 1;
			}
		}
		SetCursolPosition(entry_name, num);
	}
}
コード例 #10
0
bool IntegerValidatorBase::DoValidateNumber(wxString * errMsg) const
{
   wxTextEntry * const control = GetTextEntry();
   if ( !control )
      return false;

   wxString s(control->GetValue());
   wxChar thousandsSep;
   if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
      s.Replace(wxString(thousandsSep), wxString());

   if ( s.empty() )
   {
      // Is blank, but allowed. Stop here
      if ( HasFlag(NUM_VAL_ZERO_AS_BLANK) )
      {
         return true;
      }
      // We can't do any check with an empty string
      else
      {
         *errMsg = _("Empty value");
         return false;
      }
   }

   // Can it be converted to a value?
   LongestValueType value;
   bool res = FromString(s, &value);
   if ( !res )
      *errMsg = _("Malformed number");
   else
   {
      res = IsInRange(value);
      if ( !res )
         errMsg->Printf(_("Not in range %d to %d"),
                        (int) m_min, (int) m_max);
   }

   return res;
}
コード例 #11
0
ファイル: valtext.cpp プロジェクト: chromylei/third_party
// Called when the value in the window must be validated.
// This function can pop up an error message.
bool wxTextValidator::Validate(wxWindow *parent)
{
    // If window is disabled, simply return
    if ( !m_validatorWindow->IsEnabled() )
        return true;

    wxTextEntry * const text = GetTextEntry();
    if ( !text )
        return false;

    wxString val(text->GetValue());

    wxString errormsg;

    // We can only do some kinds of validation once the input is complete, so
    // check for them here:
    if ( HasFlag(wxFILTER_EMPTY) && val.empty() )
        errormsg = _("Required information entry is empty.");
    else if ( HasFlag(wxFILTER_INCLUDE_LIST) && m_includes.Index(val) == wxNOT_FOUND )
        errormsg = wxString::Format(_("'%s' is invalid"), val);
    else if ( HasFlag(wxFILTER_EXCLUDE_LIST) && m_excludes.Index(val) != wxNOT_FOUND )
        errormsg = wxString::Format(_("'%s' is invalid"), val);
    else if ( !(errormsg = IsValid(val)).empty() )
    {
        // NB: this format string should always contain exactly one '%s'
        wxString buf;
        buf.Printf(errormsg, val.c_str());
        errormsg = buf;
    }

    if ( !errormsg.empty() )
    {
        m_validatorWindow->SetFocus();
        wxMessageBox(errormsg, _("Validation conflict"),
                     wxOK | wxICON_EXCLAMATION, parent);

        return false;
    }

    return true;
}
コード例 #12
0
void wxNumValidatorBase::OnKillFocus(wxFocusEvent& event)
{
    wxTextEntry * const control = GetTextEntry();
    if ( !control )
        return;

    // When we change the control value below, its "modified" status is reset
    // so we need to explicitly keep it marked as modified if it was so in the
    // first place.
    //
    // Notice that only wxTextCtrl (and not wxTextEntry) has
    // IsModified()/MarkDirty() methods hence the need for dynamic cast.
    wxTextCtrl * const text = wxDynamicCast(m_validatorWindow, wxTextCtrl);
    const bool wasModified = text ? text->IsModified() : false;

    control->ChangeValue(NormalizeString(control->GetValue()));

    if ( wasModified )
        text->MarkDirty();

    event.Skip();
}
コード例 #13
0
bool NumValidatorBase::Validate(wxWindow *parent)
{
   // If window is disabled, simply return
   if ( !m_validatorWindow->IsEnabled() )
      return true;

   wxString errmsg;
   bool res = DoValidateNumber(&errmsg);

   if ( !res )
   {
      wxMessageBox(errmsg, _("Validation error"),
                  wxOK | wxICON_ERROR, parent);
      wxTextEntry *te = GetTextEntry();
      if ( te )
      {
         te->SelectAll();
         te->SetFocus();
      }
      return false;
   }

   return true;
}
コード例 #14
0
ファイル: valtext.cpp プロジェクト: 0ryuO/dolphin-avsync
// Called when the value in the window must be validated.
// This function can pop up an error message.
bool wxTextValidator::Validate(wxWindow *parent)
{
    // If window is disabled, simply return
    if ( !m_validatorWindow->IsEnabled() )
        return true;

    wxTextEntry * const text = GetTextEntry();
    if ( !text )
        return false;

    wxString val(text->GetValue());

    wxString errormsg;
    if ( HasFlag(wxFILTER_EMPTY) && val.empty() )
    {
        errormsg = _("Required information entry is empty.");
    }
    else if ( !(errormsg = IsValid(val)).empty() )
    {
        // NB: this format string should always contain exactly one '%s'
        wxString buf;
        buf.Printf(errormsg, val.c_str());
        errormsg = buf;
    }

    if ( !errormsg.empty() )
    {
        m_validatorWindow->SetFocus();
        wxMessageBox(errormsg, _("Validation conflict"),
                     wxOK | wxICON_EXCLAMATION, parent);

        return false;
    }

    return true;
}