void DLcdPowerHandler::HandleMsg(TMessageBase* aMsg)
{
  if(aMsg->iValue)
	DisplayOn();
  else
	DisplayOff();
  aMsg->Complete(KErrNone,ETrue);
}
void DLcdPowerHandler::SwitchDisplay(TBool aSecure)
 {
   if(aSecure)
	 {
	   if(!iSecureDisplay)
		 {
		   DisplayOff();
		   iSecureDisplay = ETrue;
		   DisplayOn();
		 }
	 }
   else
	 {
	   if(iSecureDisplay)
		 {
		   DisplayOff();
		   iSecureDisplay = EFalse;
		   DisplayOn();
		 }
	 }
 }
Exemple #3
0
BOOL CALLBACK FileDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    SHINITDLGINFO idi;
    OPENFILENAME of;
    const LPTSTR pszOpenFilter = L"Text Documents (*.txt)\0*.txt\0\0";
    int nParameter = 5;
    DWORD dwThreadID = 0;
    TCHAR szFilePos[FL_MAX_TEXTLEN];
    TCHAR *x;
    int i;
    float nfilepos;
    HWND hwndvox;

    switch (msg)
    {
    case WM_INITDIALOG:
        idi.dwMask = SHIDIM_FLAGS;
        idi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIZEDLGFULLSCREEN;
        idi.hDlg = hwnd;
        SHInitDialog (&idi);

        if (fl_filename[0] != '\0')
        {
            SetDlgItemText(hwnd, FL_FILENAME, fl_filename);
            flowm_file_pos = 0;
            SetDlgItemText(hwnd, FL_FILEPOS, L"0");
        }

        for (i=0; flowm_voice_name(i); i++)
        {   /* Add regestered voices to the voice dropdown */
            SendDlgItemMessage(hwnd, FL_VOXLIST, CB_ADDSTRING, 
                               0, (LPARAM)flowm_voice_name(i));
        }
        /* Position cursor at start, selecting first voice */
        SendDlgItemMessage(hwnd, FL_VOXLIST, CB_SETCURSEL, 0, 0);

        return TRUE;
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case FL_PUSHSELECT:
            /* Find a file to synthesize */
            fl_filename[0] = '\0';
            ZeroMemory(&of,sizeof(of));
            of.lStructSize = sizeof(of);
            of.lpstrFile = fl_filename;
            of.nMaxFile = 256;
            of.lpstrFilter = pszOpenFilter;
            of.Flags = 0;
            of.lpstrTitle = L"Flowm Open";

            if (GetOpenFileName(&of) != 0)
            {
                flowm_play_status = FLOWM_STOP;
                SetDlgItemText(hwnd, FL_FILENAME, fl_filename);

                flowm_file_pos = 0;
                flowm_file_size = flowm_find_filesize(fl_filename);
                flowm_utt_pos_pos = 0;
                flowm_prev_utt_pos[flowm_utt_pos_pos] = 0;
                SetDlgItemText(hwnd, FL_FILEPOS, L"0");
                SetDlgItemText(hwnd, FL_SYNTHTEXT, L"");
                if (flowm_file_size == -1)
                {
                    wsprintf(fl_fp_msg,L"File not found: %s",fl_filename);
                    MessageBox(hwnd, fl_fp_msg,AppName, MB_OK);
                    fl_filename[0] = '\0';
                }
            }
            return TRUE;
        case FL_PUSHTTS:
            /* Synthesize the selected file from the specified position */
            /* with the selected voice */
            if ((flowm_play_status != FLOWM_PLAY) &&
                (fl_filename[0] != '\0'))
            {
                flowm_play_status = FLOWM_PLAY;
                TTSWindow = hwnd;
                /* Find out what voice we want */
                hwndvox = GetDlgItem(hwnd,FL_VOXLIST);
                flowm_selected_voice = ComboBox_GetCurSel(hwndvox);

                /* Update file position, in case user changed it */
                GetDlgItemText(hwnd, FL_FILEPOS, szFilePos, FL_MAX_TEXTLEN);
                nfilepos = wcstod(szFilePos,&x);
                /* Be a little careful we don't reset file position */
                /* when we have an accuracy problem: filepos is an int */
                /* but the display field is the % */
                if (nfilepos > 100) nfilepos = 100.0;
                if (nfilepos < 0) nfilepos = 0.0;
                if (((nfilepos - flowm_find_file_percentage()) > 0.001) ||
                    ((nfilepos - flowm_find_file_percentage()) < -0.001))
                    flowm_file_pos = (int)((nfilepos*flowm_file_size)/100.0);
                
                /* Do the synthesis in a new thread, so we can still process */
                /* button pushes */
                tts_thread = CreateThread(NULL, 0, tts_thread_function, 
                                          (PVOID)nParameter, 0, &dwThreadID);
                CloseHandle(tts_thread);
            }
            return TRUE;
        case FL_PUSHBACK:
            /* Move back to previous utterance */
            if (flowm_utt_pos_pos > 0)
            {   /* Jump back to beginning of previous utt (we know about) */
                flowm_utt_pos_pos--;
                flowm_file_pos = flowm_prev_utt_pos[flowm_utt_pos_pos];
            }
            else if (flowm_file_pos > 1)
                /* Not got any previous -- we never payed that bit get */
                /* so just jump back 100 chars */
                flowm_file_pos -= 100;
            else /* At start of file already */
                flowm_file_pos = 0;
            wsprintf(fl_fp_msg,L"%2.3f",flowm_find_file_percentage());
            SetDlgItemText(TTSWindow, FL_FILEPOS, fl_fp_msg);
            flowm_play_status = FLOWM_BACKSKIP;
            return TRUE;
        case FL_PUSHFORWARD:
            /* Skip forward to next utterances now */
            if ((flowm_play_status == FLOWM_PLAY) ||
                (flowm_play_status == FLOWM_SKIP))
                flowm_play_status = FLOWM_SKIP; /* already playing/skipping */
            else
            {   /* No playing so just jump forward 100 chars */
                flowm_file_pos += 100;
                wsprintf(fl_fp_msg,L"%2.3f",flowm_find_file_percentage());
                SetDlgItemText(TTSWindow, FL_FILEPOS, fl_fp_msg);
            }
            return TRUE;
        case FL_PUSHSTOP:
            flowm_play_status = FLOWM_STOP;

            return TRUE;
        case FL_SCREENOFF:
            /* turn off the screen */
            DisplayOff();
            return TRUE;  
        case IDOK:
            if (flowm_play_status == FLOWM_STOP)
            {   /* Only end if we are in stop mode */
                TTSWindow = 0;  /* just in case there is a race condition */
                EndDialog(hwnd,0);
            }
            return TRUE;  /* you need to press end to end */
        case FL_PUSHEND:
        case IDCANCEL:
            flowm_play_status = FLOWM_STOP;
            TTSWindow = 0;  /* just in case there is a race condition */
            EndDialog(hwnd,0);
            return TRUE;
        }
    break;
    }
    return FALSE;
}
void DLcdPowerHandler::PowerDownDfc()
{
  DisplayOff();

  PowerDownDone();
}