anchor.diff:  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% Local functions
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -
  -do_move(#state{solver_state=newgame}=State) ->
  -    newgame(State);
  -do_move(#state{solver_state=SState, board=Board}=State) ->
  -    {NewSState, Events, NewBoard} = solver:step(SState, Board),
  -    lists:foreach(fun(E) -> draw_event(E, State) end, Events),
  -    refresh(State),
  -    %io:format("Events: ~p~n", [Events]),
  -    {noreply, State#state{solver_state=NewSState, board=NewBoard}}.
   
   create_and_draw_board({Rows, Cols, Mines}, Bitmap) ->
       Board = board:new(Rows, Cols, Mines),
  
positive.code: newgame(#state{bitmap=Bitmap, config=Config} = State) ->
      Board = create_and_draw_board(Config, Bitmap),
      refresh(State),
      {noreply, State#state{board=Board, solver_state=flag}}.
  
  solver_event(Fun, #state{board=Board}=State) ->
      {Events, NewBoard} = solver:Fun(Board),
      lists:foreach(fun(E) -> draw_event(E, State) end, Events),
      refresh(State),
      %io:format("Events: ~p~n", [Events]),
      {noreply, State#state{board=NewBoard}}.
  
  icon_filename({empty, 0}) -> "0.gif";
  icon_filename({empty, 1}) -> "1.gif";
  
negative.code:   when X < 0; Y < 0; Rows < Y div 16; Cols < X div 16 ->
      {noreply, State};
  handle_event(#wx{event = #wxMouse{type = MouseEventType, x = X, y = Y}},
               State) ->
      Fun = case MouseEventType of
                left_up   -> step;
                right_up  -> flag;
                middle_up -> question
            end,
      {noreply, board_event(Fun, {Y div 16, X div 16}, State)};
  handle_event(#wx{event=#wxKey{keyCode=$ }}, State) ->
      {noreply, do_move(State)};
  handle_event(#wx{event=#wxKey{keyCode=$F}}, State) ->
      {noreply, solver_event(flag_apparent_mines, State)};
  handle_event(#wx{event=#wxKey{keyCode=$S}}, State) ->
      {noreply, solver_event(uncover_safe_areas, State)};
  handle_event(#wx{event=#wxKey{keyCode=$R}}, State) ->
      {noreply, solver_event(uncover_unsafe, State)};
  handle_event(#wx{event=#wxKey{keyCode=$N}}, State) ->
      {noreply, newgame(State)};
  handle_event(#wx{event=#wxKey{keyCode=_KC}}, State) ->
      {noreply, State}.
  
  %% Callbacks handled as normal gen_server callbacks
  handle_info(move, State) ->
      {noreply, do_move(State)};
  handle_info(Msg, State) ->
      io:format("Got Info ~p\n", [Msg]),
      {noreply, State}.
  