На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
msm.ru
! Правила раздела "Программирование под PalmOS"
Правила раздела просты:
1. Будьте вежливыми.
2. Задавате вопросы только по теме. Пользовательские вопросы (у меня не работает пальм) являются оффтопиком. Пользуйтесь конференциями palmz.in, hpc.ru, ihand.ru .
3. Поиск вареза запрещен.
4. Пользуйтесь поиском. Не надейтесь, что кому-то доставляет удовольствие отвечать в сотый раз на один и тот же вопрос.
  
> Где я лажанулся
    После запуска рисуется поле с розовыми кргугами. После тыканья в один из них он должен перекраситься, однако перекрашивается вся строка.
    где я промазал?

    #include <PalmTypes>
    #include <PalmCompatibility>
    #include <Event>
    #include <Field>
    #include <form>
    #include <menu>
    #include <DataMgr>
    #include <SystemMgr>
    #include <SoundMgr>
    #include <StringMgr>
    #include <ErrorMgr>
    #include <SysUtils>
    #include "Callback.h"
    #include "grid.h"

    UInt8 cells[7,7]; // cells. values is a color indexes.

    void initCells()
    {
           Coord x,y,i;
           i=0;
           for(x=0;x<7;x++) for(y=0;y<7;y++) cells[x,y]= 2;
    }

    void startDrawing()
    {
           WinHandle win,scr_win;
           Coord x,y;
           RectangleType cell_rect,scr_rect;

           win=WinCreateOffscreenWindow(159,159,genericFormat,&error);
           scr_win=WinGetDrawWindow();
           WinGetWindowBounds(&scr_rect);
           if(win) WinSetDrawWindow(win);
           WinSetForeColor(color_black);
           for(x=0; x<8; x++)
                   WinDrawLine(x*width,0,x*width,6*height);
           for(y=0; y<7; y++)
                   WinDrawLine(0,y*height,7*width,y*height);
           cell_rect.extent.x=width-1;
           cell_rect.extent.y=height-1;
           for(y=0;y<6;y++)
           {
                   cell_rect.topLeft.y=y*height+1;
                   for(x=0;x<7;x++)
                   {
                           cell_rect.topLeft.x=x*width+1;
                           WinSetForeColor(cells[x,y]);
                           prev_color=cells[x,y];
                           WinPaintRectangle(&cell_rect,7);
                   }
           }
           if(win)
           {
                   WinCopyRectangle(NULL, scr_win,&scr_rect,0,0,winPaint);
                   WinDeleteWindow(win,false);
           }
    }
    static Err StartApplication(void)
    {
           initCells();
           startDrawing();
           return 0;
    }

    static void StopApplication(void)
    {
    }



    void touchScreen(Int16 scr_x, Int16 scr_y)
    {
           Int16 x,y;
           RectangleType cell_rect;
           x=scr_x/width;
           y=scr_y/height;
           if(x<7 && y<6) cells[x,y]=5;
           startDrawing();
    }

    static Boolean appHandleEvent(EventPtr event)
    {
           Boolean    handled = false;
           Int16 formId;
           FormPtr frm;
           char str_curs[6];

    #ifdef __GNUC__
           CALLBACK_PROLOGUE
    #endif
                   switch(event->eType)
                   {
                           case frmLoadEvent:
                                   {

                                           formId = event->data.frmLoad.formID;
                                           frm = FrmInitForm(formId);
                                           FrmSetActiveForm(frm);
                                           handled = true;
                                           FrmDrawForm(frm);

                                   }
                           case frmOpenEvent:
                                   {
                                           FrmDrawForm(FrmGetActiveForm());
                                           handled=true;
                                           break;
                                   }
                           case  penDownEvent:
                                   {
                                           touchScreen(event->screenX,event->screenY);
                                           handled=true;
                                           break;
                                   }
                   }
                   return handled;
    }
    static void EventLoop(void)
    {
           EventType  event;
           Word      error;

           do {
                   EvtGetEvent(&event, evtWaitForever);
                   if (! SysHandleEvent(&event))
                           if (! MenuHandleEvent(0, &event, &error))
                                   if (! appHandleEvent(&event))
                                           FrmDispatchEvent(&event);
           } while (event.eType != appStopEvent);
    }
    DWord PilotMain(Word launchCode, Ptr cmdPBP, Word launchFlags)
    {
           Err err;
           width=20;
           height=20;

           if (launchCode == sysAppLaunchCmdNormalLaunch) {
                   if ((err = StartApplication()) == 0) {
                           EventLoop();
                           StopApplication();
                   }
           }
           return err;
    }
    1 пользователей читают эту тему (1 гостей и 0 скрытых пользователей)
    0 пользователей:


    Рейтинг@Mail.ru
    [ Script execution time: 0,0435 ]   [ 14 queries used ]   [ Generated: 15.05.24, 00:38 GMT ]