Back to index

gcompris  8.2.2
Defines | Functions
gtans_callbacks.c File Reference
#include "gcompris/gcompris.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "gtans_callbacks.h"
#include "gtans_interface.h"
#include "gtans.h"
#include "gtans_support.h"

Go to the source code of this file.

Defines

#define FIGGC   2848

Functions

void colselinit (int col)
void filselinit (int col)
gboolean on_wdrawareagrande_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean on_wdrawareagrande_configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
gboolean on_wdrawareagrande_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gboolean on_wdrawareagrande_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gboolean on_wdrawareagrande_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
gboolean on_wdrawareapetite_configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
gboolean on_wdrawareapetite_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean on_arrow_clicked (GnomeCanvasItem *item, GdkEvent *event, gpointer user_data)
gboolean on_show_clicked (GnomeCanvasItem *canvasitem, GdkEvent *event, gpointer user_data)
gboolean on_outline_clicked (GnomeCanvasItem *canvasitem, GdkEvent *event, gpointer user_data)
gboolean on_symetry_clicked (GnomeCanvasItem *canvasitem, GdkEvent *event, gpointer user_data)
gboolean on_rotation_clicked (GnomeCanvasItem *canvasitem, GdkEvent *event, gpointer user_data)

Define Documentation

#define FIGGC   2848

Definition at line 41 of file gtans_callbacks.c.


Function Documentation

void colselinit ( int  col)
void filselinit ( int  col)
gboolean on_arrow_clicked ( GnomeCanvasItem *  item,
GdkEvent *  event,
gpointer  user_data 
)

Definition at line 285 of file gtans_callbacks.c.

{
  if ((event->type == GDK_BUTTON_PRESS)  
      && (event->button.button == 1)) {
    change_figure((gboolean) GPOINTER_TO_INT(user_data));
    return TRUE;
  }
  return FALSE;
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_outline_clicked ( GnomeCanvasItem *  canvasitem,
GdkEvent *  event,
gpointer  user_data 
)

Definition at line 312 of file gtans_callbacks.c.

{
  if ((event->type == GDK_BUTTON_PRESS)  
      && (event->button.button == 1)) {
    if(!helpoutset){
      helpoutset = TRUE;
      tanredrawgrande();
    }
    return TRUE;
  }
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_rotation_clicked ( GnomeCanvasItem *  canvasitem,
GdkEvent *  event,
gpointer  user_data 
)

Definition at line 347 of file gtans_callbacks.c.

{
  if ((event->type == GDK_BUTTON_PRESS)  
      && (event->button.button == 1)) {
    gint angle = 0;

    if (selectedgrande==TRUE){
      switch (GPOINTER_TO_INT(user_data)){
      case 0:
       angle = -rotstepnbr;
       break;
      case 1:
       angle = rotstepnbr;
       break;
      case 2:
       angle = -4*rotstepnbr;
       break;
      case 3:
       angle = 4*rotstepnbr;
       break;
      }
      figgrande.piecepos[PIECENBR-1].rot += angle;

      tandrawselect(0,0,0);
      return TRUE;
    }
  }
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_show_clicked ( GnomeCanvasItem *  canvasitem,
GdkEvent *  event,
gpointer  user_data 
)

Definition at line 298 of file gtans_callbacks.c.

{
  if ((event->type == GDK_BUTTON_PRESS)  
      && (event->button.button == 1)) {
  helptanset = (helptanset+1)%PIECENBR;
  tanredrawpetite();
  return TRUE;
  }
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_symetry_clicked ( GnomeCanvasItem *  canvasitem,
GdkEvent *  event,
gpointer  user_data 
)

Definition at line 328 of file gtans_callbacks.c.

{
  if ((event->type == GDK_BUTTON_PRESS)  
      && (event->button.button == 1)) {
    if (selectedgrande==TRUE){
      if (figgrande.piecepos[PIECENBR-1].type==3)
       figgrande.piecepos[PIECENBR-1].flipped^=1;
      else
       figgrande.piecepos[PIECENBR-1].rot=(figgrande.piecepos[PIECENBR-1].rot+TOUR/2)%TOUR;
      tandrawselect(0,0,0);
      return TRUE;
    }
  }
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_wdrawareagrande_button_press_event ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)

Definition at line 110 of file gtans_callbacks.c.

{
  int x,y;
  int piece;

  if (!selpossible || event->type!=GDK_BUTTON_PRESS)     /* double-click ou deja trouve */
    return TRUE;
  
  if (actiongrande != AN_none)      /* le button release event a ete avale */
    tanreleaseifrot();

  x=event->x;
  y=event->y;

  if ( event->button!=3){
    if ( (piece=tanwichisselect(x,y))>=0 ){
      taninitselect(piece, FALSE);
      selectedgrande=TRUE;
      actiongrande=AN_move;
      xold=x;
      yold=y;
      tandrawselect(0,0,0);
    }
    else{
      if (selectedgrande){
       actiongrande=AN_rot;
       xact=(gint16)(ARON+figgrande.piecepos[PIECENBR-1].posx*
                    widgetgrande->allocation.width*figgrande.zoom);
       yact=(gint16)(ARON+figgrande.piecepos[PIECENBR-1].posy*
                    widgetgrande->allocation.width*figgrande.zoom);
       xoth=xold=x;
       yoth=yold=y;
       rotact=tanangle((double)(xact-x),(double)(y-yact));
       rotold=0;
       
       invx2=x;
       invy2=y;
       gdk_draw_line (widgetgrande->window,
                     invertgc,
                     xact,yact,invx2,invy2);
       
      }
    }
  }
  
  if (event->button==3 && selectedgrande==TRUE){
    if (figgrande.piecepos[PIECENBR-1].type==3)
      figgrande.piecepos[PIECENBR-1].flipped^=1;
    else
      figgrande.piecepos[PIECENBR-1].rot=(figgrande.piecepos[PIECENBR-1].rot+TOUR/2)%TOUR;
    tandrawselect(0,0,0);
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_wdrawareagrande_button_release_event ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)

Definition at line 170 of file gtans_callbacks.c.

{
  tanreleaseifrot();

  /* actiongrande=AN_none; dans releaseifrot */

  if ( selpossible && figtabsize ){
    tanmaketinytabnotr(&figgrande,tinytabgr);
    tantranstinytab(tinytabgr);
    if (tantinytabcompare(tinytabgr, tinytabpe, accuracy)){
      tanunselect();
      selpossible=FALSE;
      tansetreussiactual();
      tanredrawpetite();
      /* hide widget because of gnomecanvaswidget on top of bonus image */
      gtk_widget_hide(widgetgrande);
      gtk_widget_hide(widgetpetite);
      gc_bonus_display( TRUE, BONUS_RANDOM);
    }
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_wdrawareagrande_configure_event ( GtkWidget *  widget,
GdkEventConfigure *  event,
gpointer  user_data 
)

Definition at line 61 of file gtans_callbacks.c.

{
  double izoom;
  tanpiecepos *piecepos;
  int i;

  widgetgrande=widget;
  if (!initcbgr)
    taninitcbgr();

  if (pixmapgrande1!=NULL){
    gdk_pixmap_unref(pixmapgrande1);
    gdk_pixmap_unref(pixmapgrande2);
  }

  pixmapgrande1 = gdk_pixmap_new(widget->window,
                             widget->allocation.width,
                             widget->allocation.height,
                             -1);
  pixmapgrande2 = gdk_pixmap_new(widget->window,
                             widget->allocation.width,
                             widget->allocation.height,
                             -1);
   
  if ( !editmode ){
    izoom=(widgetgrande->allocation.width*figgrande.zoom);
    piecepos=figgrande.piecepos;
    for (i=0; i<PIECENBR; i++){
      piecepos->posx=floor((piecepos->posx*izoom)+ARON)/izoom;
      piecepos->posy=floor((piecepos->posy*izoom)+ARON)/izoom;
      piecepos++;
    }
  }

  gdk_gc_set_line_attributes(tabgc[GCPIECEHLP],
                          widget->allocation.width>340 ? 2 : 1,
                          GDK_LINE_SOLID,
                          GDK_CAP_ROUND,
                          GDK_JOIN_ROUND);

  tanredrawgrande();

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_wdrawareagrande_expose_event ( GtkWidget *  widget,
GdkEventExpose *  event,
gpointer  user_data 
)

Definition at line 44 of file gtans_callbacks.c.

{
  if (pixmapgrande1!=NULL)
    gdk_draw_pixmap(widget->window,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  pixmapgrande1,
                  event->area.x, event->area.y,
                  event->area.x, event->area.y,
                  event->area.width, event->area.height);

  return FALSE;
}

Here is the caller graph for this function:

gboolean on_wdrawareagrande_motion_notify_event ( GtkWidget *  widget,
GdkEventMotion *  event,
gpointer  user_data 
)

Definition at line 198 of file gtans_callbacks.c.

{
  int x,y;
  GdkModifierType state;
  int rot;

  if (event->is_hint)
    gdk_window_get_pointer (event->window, &x, &y, &state);
  else{
    x=event->x;
    y=event->y;
    state=event->state;
  }

  if (actiongrande==AN_move){
    tandrawselect(x-xold,y-yold,0);
    xold=x;
    yold=y;
  }

  if (actiongrande==AN_rot){
    gdk_draw_line (widgetgrande->window,
                 invertgc,
                 xact,yact,invx2,invy2);

    rot=(rotact-tanangle((double)(xact-x),(double)(y-yact))+rotstepnbr/2+TOUR*3)%TOUR;
    rot=(int)(rot/rotstepnbr)*rotstepnbr;
    if (rot!=rotold){
      rotold=rot;
      tandrawselect(0,0,rot);
    }

    invx2=x;
    invy2=y;
    gdk_draw_line (widgetgrande->window,
                 invertgc,
                 xact,yact,invx2,invy2);

  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_wdrawareapetite_configure_event ( GtkWidget *  widget,
GdkEventConfigure *  event,
gpointer  user_data 
)

Definition at line 245 of file gtans_callbacks.c.

{
  widgetpetite=widget;
  if (!initcbpe)
    taninitcbpe();

  if (pixmappetite!=NULL)
    gdk_pixmap_unref(pixmappetite);
  
  pixmappetite = gdk_pixmap_new(widget->window,
                            widget->allocation.width,
                            widget->allocation.height,
                            -1);

  tanredrawpetite();

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean on_wdrawareapetite_expose_event ( GtkWidget *  widget,
GdkEventExpose *  event,
gpointer  user_data 
)

Definition at line 268 of file gtans_callbacks.c.

{
  if (pixmappetite!=NULL)
    gdk_draw_pixmap(widget->window,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  pixmappetite,
                  event->area.x, event->area.y,
                  event->area.x, event->area.y,
                  event->area.width, event->area.height);

  return FALSE;
}

Here is the caller graph for this function: