void SmileyType::CallSmileyService(MCONTACT hContact) { _TPattern *srvsplit = _TPattern::compile(_T("(.*)\\|(.*)\\|(.*)")); _TMatcher *m0 = srvsplit->createTMatcher(GetTriggerText()); m0->findFirstMatch(); CMString name = m0->getGroup(1); CMString par1 = m0->getGroup(2); CMString par2 = m0->getGroup(3); delete m0; delete srvsplit; char str[MAXMODULELABELLENGTH]; const char *proto = ""; if (name[0] == '/') { proto = (const char*)GetContactProto(hContact); if (proto == NULL) return; } mir_snprintf(str, "%s%s", proto, T2A_SM(name.c_str())); CallService(str, ConvertServiceParam(hContact, par1.c_str()), ConvertServiceParam(hContact, par2.c_str())); }
bool pawsShortcutWindow::OnFingering(csString string, psControl::Device device, uint button, uint32 mods) { pawsFingeringWindow* fingWnd = dynamic_cast<pawsFingeringWindow*>(PawsManager::GetSingleton().FindWidget("FingeringWindow")); if (fingWnd == NULL || !fingWnd->IsVisible()) return true; csString editedCmd; editedCmd.Format("Shortcut %d",edit+1); bool changed = false; if (string == NO_BIND) // Removing trigger { psengine->GetCharControl()->RemapTrigger(editedCmd,psControl::NONE,0,0); changed = true; } else // Changing trigger { changed = psengine->GetCharControl()->RemapTrigger(editedCmd,device,button,mods); } if (changed) { shortcutText->SetText(GetTriggerText(edit)); return true; // Hide fingering window } else // Map already exists { const psControl* other = psengine->GetCharControl()->GetMappedTrigger(device,button,mods); CS_ASSERT(other); csString name = GetDisplayName(other->name); if (name.IsEmpty()) //then not cleaned up properly from deleting a shortcut { name = other->name; //use its numeric name } else { name.AppendFmt(" (%s)", other->name.GetDataSafe()); } fingWnd->SetCollisionInfo(name); return false; } }
// bool pawsShortcutWindow::OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ) bool pawsShortcutWindow::OnButtonReleased( int mouseButton, int keyModifier, pawsWidget* widget ) { if (!subWidget) subWidget = PawsManager::GetSingleton().FindWidget("ShortcutEdit"); if (!labelBox) labelBox = dynamic_cast <pawsEditTextBox*> (subWidget->FindWidget("LabelBox")); if (!textBox) textBox = dynamic_cast <pawsMultilineEditTextBox*> (subWidget->FindWidget("CommandBox")); if (!shortcutText) shortcutText = dynamic_cast <pawsTextBox*> (subWidget->FindWidget("ShortcutText")); // These should not be NULL CS_ASSERT(subWidget); CS_ASSERT(labelBox); CS_ASSERT(textBox); CS_ASSERT(shortcutText); BringToTop(this); // Finished Configuring command button switch ( widget->GetID() ) { case DONE_BUTTON: { if (!labelBox->GetText() || *(labelBox->GetText()) == '\0') { if (textBox->GetText() && *(textBox->GetText()) != '\0') { //no name but a command was specified. psSystemMessage msg(0,MSG_ERROR,PawsManager::GetSingleton().Translate("Please specify a name when creating a shortcut.")); msg.FireEvent(); return true; } else //shortcut is empty and will be removed. Also remove possible key binding. { csString editedCmd; editedCmd.Format("Shortcut %d",edit+1); psengine->GetCharControl()->RemapTrigger(editedCmd,psControl::NONE,0,0); } } // Otherwise save the label and command as it is names[edit] = labelBox->GetText(); cmds[edit] = textBox->GetText(); CalcButtonSize(); UpdateMatrix(); LayoutMatrix(); SetWindowSizeToFitMatrix(); PawsManager::GetSingleton().SetModalWidget(NULL); PawsManager::GetSingleton().SetCurrentFocusedWidget(this); subWidget->Hide(); pawsWidget * configKeyAsWidget = PawsManager::GetSingleton().FindWidget("ConfigKeys"); pawsConfigKeys * configKey = dynamic_cast<pawsConfigKeys*> (configKeyAsWidget); if (configKey) { configKey->UpdateNicks(); } SaveCommands(); return true; } case CLEAR_BUTTON: { labelBox->Clear(); textBox->Clear(); return true; } case CANCEL_BUTTON: { PawsManager::GetSingleton().SetModalWidget(NULL); PawsManager::GetSingleton().SetCurrentFocusedWidget(this); subWidget->Hide(); return true; } case SETKEY_BUTTON: { pawsWidget * fingWndAsWidget; fingWndAsWidget = PawsManager::GetSingleton().FindWidget("FingeringWindow"); if (fingWndAsWidget == NULL) { Error1("Could not find widget FingeringWindow"); return false; } pawsFingeringWindow * fingWnd = dynamic_cast<pawsFingeringWindow *>(fingWndAsWidget); if (fingWnd == NULL) { Error1("FingeringWindow is not pawsFingeringWindow"); return false; } fingWnd->ShowDialog(this, labelBox->GetText()); return true; } } // switch( ... ) // Execute clicked on button if ( mouseButton == csmbLeft && !(keyModifier & CSMASK_CTRL)) ExecuteCommand( widget->GetID() - SHORTCUT_BUTTON_OFFSET, false ); // Configure the button that was clicked on else if ( mouseButton == csmbRight || (mouseButton == csmbLeft && (keyModifier & CSMASK_CTRL)) ) { edit = widget->GetID() - SHORTCUT_BUTTON_OFFSET; if ( edit < 0 || edit >= NUM_SHORTCUTS ) return false; if (!subWidget || !labelBox || !textBox || !shortcutText) return false; if ( names[edit] && names[edit].Length() ) labelBox->SetText( names[edit].GetData() ); else labelBox->Clear(); if ( cmds[edit] && cmds[edit].Length() ) { textBox->SetText( cmds[edit].GetData() ); shortcutText->SetText( GetTriggerText(edit) ); } else { textBox->Clear(); shortcutText->SetText(""); } subWidget->Show(); PawsManager::GetSingleton().SetCurrentFocusedWidget(textBox); } else { return false; } return true; }