/*
File: LCDDLGS.C

Methods for dialogs
*/
#include <lcdtest.g>
#include <p_gen.h>
#include <epoc.h>
#include <hwim.h>
#include <lcddlgs.g>
#include <lcdcomm.g>
#include <lcdtest.rsg>

#define RBUFLEN         50      /* Buffer length for resource strings   */

/* Set backlight & time dialog: position/index values */
#define BACKLIGHT_OFFON     1

/* Sound test dialog: position/index values */
#define SOUND_DURATION      1
#define SOUND_PITCH         2

#pragma METHOD_CALL

METHOD VOID lcd_backlight_dl_dyn_init(PR_DLGBOX *self)
    {
    if(p_backlight(E_BACKLIGHT_QUERY))
        hDlgSetChlistOn(BACKLIGHT_OFFON);
    }

METHOD VOID lcd_backlight_dl_changed(PR_DLGBOX *self, INT pos)
    {
    p_backlight(hDlgSenseChlist(BACKLIGHT_OFFON)?
                                        E_BACKLIGHT_ON: E_BACKLIGHT_OFF);
    }

METHOD INT lcd_backlight_dl_key(PR_DLGBOX *self, INT pos, INT keycode)
    {
    lcd_backlight_dl_changed(self,pos);
    return WN_KEY_CHANGED;
    }


METHOD VOID lcd_sound_dl_dyn_init(PR_DLGBOX *self)
    {
    LCDCOMM_SOUND_INFO  *const pInfo = self->dlgbox.rbuf;

    hDlgSetNcedit(SOUND_DURATION,pInfo->duration);
    hDlgSetNcedit(SOUND_PITCH,pInfo->pitch);
    }

METHOD INT lcd_sound_dl_key(PR_DLGBOX *self, INT pos, INT keycode)
    {
    LCDCOMM_SOUND_INFO  *const pInfo = self->dlgbox.rbuf;

    pInfo->duration = hDlgSenseNcedit(SOUND_DURATION); 
    pInfo->pitch    = hDlgSenseNcedit(SOUND_PITCH);
    p_sound(pInfo->duration,pInfo->pitch);
    return WN_KEY_CHANGED;
    }
