pychess.widgets.BoardView
index
/home/thomas/Programmering/python/skak/svn/lib/pychess/widgets/BoardView.py

# -*- coding: UTF-8 -*-

 
Modules
       
cairo
gtk
pango
pygtk
pychess.Utils.validator

 
Classes
       
gtk.DrawingArea(gtk.Widget)
BoardView

 
class BoardView(gtk.DrawingArea)
    
Method resolution order:
BoardView
gtk.DrawingArea
gtk.Widget
gtk.Object
gobject.GObject
atk.ImplementorIface
gobject.GInterface
__builtin__.object

Methods defined here:
__init__(self)
cord2Point(self, cord)
cord2Rect(self, cord)
draw(self, context, r)
drawArrows(self, context)
drawBoard(self, context, r)
drawCords(self, context, r)
drawLastMove(self, context, redrawn)
drawPieces(self, context, pieces, r)
drawSpecial(self, context, redrawn)
expose(self, widget, event)
fcord2Rect(self, x, y)
isLight(self, cord)
move(self, history)
redraw_canvas(self, r=None)
reset(self, history)
runAnimation(self, redrawMisc=False)
The animationsystem in pychess is very loosely inspired by the one of chessmonk. The idea is, that every piece has a place in an array (the board.data one) for where to be drawn. If a piece is to be animated, it can set its x and y properties, to some cord (or part cord like 0.42 for 42% right to file 0). Each time runAnimation is run, it will set those x and y properties a little closer to the location in the array. When it has reached its final location, x and y will be set to None.
_set_shown, which starts the animation, also sets a timestamp for the acceleration to work properply.
runWhenReady(self, func, *args)
As some pieces of pychess are quite eager to set the attributes of
BoardView, we can't always be sure, that BoardView has been painted once
before, and therefore self.sqaure has been set.
This might be doable in a smarter way...
startAnimation(self)

Properties defined here:
active
get = _get_active(self)
set = _set_active(self, cord)
bluearrow
get = _get_bluearrow(self)
set = _set_bluearrow(self, cords)
fromWhite
get = _get_fromWhite(self)
set = _set_fromWhite(self, fromWhite)
greenarrow
get = _get_greenarrow(self)
set = _set_greenarrow(self, cords)
hover
get = _get_hover(self)
set = _set_hover(self, cord)
redarrow
get = _get_redarrow(self)
set = _set_redarrow(self, cords)
selected
get = _get_selected(self)
set = _set_selected(self, cord)
showCords
get = _get_showCords(self)
set = _set_showCords(self, showCords)
shown
get = _get_shown(self)
set = _set_shown(self, shown)

Data and other attributes defined here:
__gtype__ = <GType pychess+widgets+BoardView+BoardView (151976376)>

Methods inherited from gtk.DrawingArea:
size(...)

Methods inherited from gtk.Widget:
activate(...)
add_accelerator(...)
add_events(...)
add_mnemonic_label(...)
can_activate_accel(...)
child_focus(...)
child_notify(...)
class_path(...)
create_pango_context(...)
create_pango_layout(...)
destroy(...)
drag_begin(...)
drag_check_threshold(...)
drag_dest_add_image_targets(...)
drag_dest_add_text_targets(...)
drag_dest_add_uri_targets(...)
drag_dest_find_target(...)
drag_dest_get_target_list(...)
drag_dest_get_track_motion(...)
drag_dest_set(...)
drag_dest_set_proxy(...)
drag_dest_set_target_list(...)
drag_dest_set_track_motion(...)
drag_dest_unset(...)
drag_get_data(...)
drag_highlight(...)
drag_source_add_image_targets(...)
drag_source_add_text_targets(...)
drag_source_add_uri_targets(...)
drag_source_get_target_list(...)
drag_source_set(...)
drag_source_set_icon(...)
drag_source_set_icon_name(...)
drag_source_set_icon_pixbuf(...)
drag_source_set_icon_stock(...)
drag_source_set_target_list(...)
drag_source_unset(...)
drag_unhighlight(...)
ensure_style(...)
event(...)
freeze_child_notify(...)
get_accessible(...)
get_action(...)
get_allocation(...)
get_ancestor(...)
get_child_requisition(...)
get_child_visible(...)
get_clipboard(...)
get_colormap(...)
get_composite_name(...)
get_direction(...)
get_display(...)
get_events(...)
get_extension_events(...)
get_modifier_style(...)
get_name(...)
get_no_show_all(...)
get_pango_context(...)
get_parent(...)
get_parent_window(...)
get_pointer(...)
get_root_window(...)
get_screen(...)
get_settings(...)
get_size_request(...)
get_style(...)
get_toplevel(...)
get_visual(...)
grab_add(...)
grab_default(...)
grab_focus(...)
grab_remove(...)
has_screen(...)
hide(...)
hide_all(...)
hide_on_delete(...)
input_shape_combine_mask(...)
intersect(...)
is_ancestor(...)
is_composited(...)
is_focus(...)
list_mnemonic_labels(...)
map(...)
menu_get_for_attach_widget(...)
mnemonic_activate(...)
modify_base(...)
modify_bg(...)
modify_fg(...)
modify_font(...)
modify_style(...)
modify_text(...)
path(...)
queue_clear(...)
queue_clear_area(...)
queue_draw(...)
queue_draw_area(...)
queue_resize(...)
queue_resize_no_redraw(...)
rc_get_style(...)
realize(...)
region_intersect(...)
remove_accelerator(...)
remove_mnemonic_label(...)
render_icon(...)
reparent(...)
reset_rc_styles(...)
reset_shapes(...)
selection_add_target(...)
selection_add_targets(...)
selection_clear_targets(...)
selection_convert(...)
selection_owner_set(...)
selection_remove_all(...)
send_expose(...)
set_accel_path(...)
set_app_paintable(...)
set_child_visible(...)
set_colormap(...)
set_composite_name(...)
set_direction(...)
set_double_buffered(...)
set_events(...)
set_extension_events(...)
set_name(...)
set_no_show_all(...)
set_parent(...)
set_parent_window(...)
set_redraw_on_allocate(...)
set_scroll_adjustments(...)
set_sensitive(...)
set_size_request(...)
set_state(...)
set_style(...)
set_uposition(...)
set_usize(...)
shape_combine_mask(...)
show(...)
show_all(...)
show_now(...)
size_allocate(...)
size_request(...)
style_get_property(...)
thaw_child_notify(...)
translate_coordinates(...)
unmap(...)
unparent(...)
unrealize(...)

Data and other attributes inherited from gtk.Widget:
allocation = <attribute 'allocation' of 'gtk.Widget' objects>
do_button_press_event = <built-in method do_button_press_event of GObjectMeta object>
do_button_release_event = <built-in method do_button_release_event of GObjectMeta object>
do_can_activate_accel = <built-in method do_can_activate_accel of GObjectMeta object>
do_client_event = <built-in method do_client_event of GObjectMeta object>
do_composited_changed = <built-in method do_composited_changed of GObjectMeta object>
do_configure_event = <built-in method do_configure_event of GObjectMeta object>
do_delete_event = <built-in method do_delete_event of GObjectMeta object>
do_destroy_event = <built-in method do_destroy_event of GObjectMeta object>
do_direction_changed = <built-in method do_direction_changed of GObjectMeta object>
do_drag_begin = <built-in method do_drag_begin of GObjectMeta object>
do_drag_data_delete = <built-in method do_drag_data_delete of GObjectMeta object>
do_drag_data_get = <built-in method do_drag_data_get of GObjectMeta object>
do_drag_data_received = <built-in method do_drag_data_received of GObjectMeta object>
do_drag_drop = <built-in method do_drag_drop of GObjectMeta object>
do_drag_end = <built-in method do_drag_end of GObjectMeta object>
do_drag_leave = <built-in method do_drag_leave of GObjectMeta object>
do_drag_motion = <built-in method do_drag_motion of GObjectMeta object>
do_enter_notify_event = <built-in method do_enter_notify_event of GObjectMeta object>
do_event = <built-in method do_event of GObjectMeta object>
do_expose_event = <built-in method do_expose_event of GObjectMeta object>
do_focus = <built-in method do_focus of GObjectMeta object>
do_focus_in_event = <built-in method do_focus_in_event of GObjectMeta object>
do_focus_out_event = <built-in method do_focus_out_event of GObjectMeta object>
do_get_accessible = <built-in method do_get_accessible of GObjectMeta object>
do_grab_broken_event = <built-in method do_grab_broken_event of GObjectMeta object>
do_grab_focus = <built-in method do_grab_focus of GObjectMeta object>
do_grab_notify = <built-in method do_grab_notify of GObjectMeta object>
do_hide = <built-in method do_hide of GObjectMeta object>
do_hide_all = <built-in method do_hide_all of GObjectMeta object>
do_hierarchy_changed = <built-in method do_hierarchy_changed of GObjectMeta object>
do_key_press_event = <built-in method do_key_press_event of GObjectMeta object>
do_key_release_event = <built-in method do_key_release_event of GObjectMeta object>
do_leave_notify_event = <built-in method do_leave_notify_event of GObjectMeta object>
do_map = <built-in method do_map of GObjectMeta object>
do_map_event = <built-in method do_map_event of GObjectMeta object>
do_mnemonic_activate = <built-in method do_mnemonic_activate of GObjectMeta object>
do_motion_notify_event = <built-in method do_motion_notify_event of GObjectMeta object>
do_no_expose_event = <built-in method do_no_expose_event of GObjectMeta object>
do_parent_set = <built-in method do_parent_set of GObjectMeta object>
do_popup_menu = <built-in method do_popup_menu of GObjectMeta object>
do_property_notify_event = <built-in method do_property_notify_event of GObjectMeta object>
do_proximity_in_event = <built-in method do_proximity_in_event of GObjectMeta object>
do_proximity_out_event = <built-in method do_proximity_out_event of GObjectMeta object>
do_realize = <built-in method do_realize of GObjectMeta object>
do_screen_changed = <built-in method do_screen_changed of GObjectMeta object>
do_scroll_event = <built-in method do_scroll_event of GObjectMeta object>
do_selection_clear_event = <built-in method do_selection_clear_event of GObjectMeta object>
do_selection_get = <built-in method do_selection_get of GObjectMeta object>
do_selection_notify_event = <built-in method do_selection_notify_event of GObjectMeta object>
do_selection_received = <built-in method do_selection_received of GObjectMeta object>
do_selection_request_event = <built-in method do_selection_request_event of GObjectMeta object>
do_show = <built-in method do_show of GObjectMeta object>
do_show_all = <built-in method do_show_all of GObjectMeta object>
do_show_help = <built-in method do_show_help of GObjectMeta object>
do_size_allocate = <built-in method do_size_allocate of GObjectMeta object>
do_size_request = <built-in method do_size_request of GObjectMeta object>
do_state_changed = <built-in method do_state_changed of GObjectMeta object>
do_style_set = <built-in method do_style_set of GObjectMeta object>
do_unmap = <built-in method do_unmap of GObjectMeta object>
do_unmap_event = <built-in method do_unmap_event of GObjectMeta object>
do_unrealize = <built-in method do_unrealize of GObjectMeta object>
do_visibility_notify_event = <built-in method do_visibility_notify_event of GObjectMeta object>
do_window_state_event = <built-in method do_window_state_event of GObjectMeta object>
get_activate_signal = <built-in method get_activate_signal of GObjectMeta object>
name = <attribute 'name' of 'gtk.Widget' objects>
parent = <attribute 'parent' of 'gtk.Widget' objects>
saved_state = <attribute 'saved_state' of 'gtk.Widget' objects>
set_activate_signal = <built-in method set_activate_signal of GObjectMeta object>
set_set_scroll_adjustments_signal = <built-in method set_set_scroll_adjustments_signal of GObjectMeta object>
state = <attribute 'state' of 'gtk.Widget' objects>
style = <attribute 'style' of 'gtk.Widget' objects>
window = <attribute 'window' of 'gtk.Widget' objects>

Methods inherited from gtk.Object:
flags(...)
remove_data(...)
remove_no_notify(...)
set_flags(...)
unset_flags(...)

Data and other attributes inherited from gtk.Object:
do_destroy = <built-in method do_destroy of GObjectMeta object>

Methods inherited from gobject.GObject:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__gobject_init__(...)
__hash__(...)
x.__hash__() <==> hash(x)
__repr__(...)
x.__repr__() <==> repr(x)
chain(...)
connect(...)
connect_after(...)
connect_object(...)
connect_object_after(...)
disconnect(...)
disconnect_by_func(...)
emit(...)
emit_stop_by_name(...)
freeze_notify(...)
get_data(...)
get_property(...)
handler_block(...)
handler_block_by_func(...)
handler_disconnect(...)
handler_is_connected(...)
handler_unblock(...)
handler_unblock_by_func(...)
notify(...)
set_data(...)
set_property(...)
stop_emission(...)
thaw_notify(...)

Data and other attributes inherited from gobject.GObject:
__dict__ = <dictproxy object>
__gdoc__ = 'Object pychess+widgets+BoardView+BoardView\n\nSign...-peger\n\nSignals from GObject:\n notify (GParam)\n\n'
__grefcount__ = <attribute '__grefcount__' of 'gobject.GObject' objects>
__new__ = <built-in method __new__ of GObjectMeta object>
T.__new__(S, ...) -> a new object with type S, a subtype of T
props = <gobject.GProps object>

Methods inherited from atk.ImplementorIface:
ref_accessible(...)

 
Functions
       
add_emission_hook(...)
ceil(...)
ceil(x)
 
Return the ceiling of x as a float.
This is the smallest integral value >= x.
child_watch_add(...)
contains(r0, r1)
filename_display_basename(...)
filename_display_name(...)
filename_from_utf8(...)
floor(...)
floor(x)
 
Return the floor of x as a float.
This is the largest integral value <= x.
get_current_time(...)
idle_add(...)
intersects(r0, r1)
io_add_watch(...)
join(r0, r1)
Take (x, y, w, [h]) squares
list_properties(...)
main_context_default(...)
main_depth(...)
markup_escape_text(...)
new(...)
rect(r)
remove_emission_hook(...)
signal_accumulator_true_handled(...)
signal_list_ids(...)
signal_list_names(...)
signal_lookup(...)
signal_name(...)
signal_new(...)
signal_query(...)
sleep(...)
sleep(seconds)
 
Delay execution for a given number of seconds.  The argument may be
a floating point number for subsecond precision.
source_remove(...)
spawn_async(...)
threads_init(...)
time(...)
time() -> floating point number
 
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.
timeout_add(...)
type_children(...)
type_from_name(...)
type_interfaces(...)
type_is_a(...)
type_name(...)
type_parent(...)
type_register(...)

 
Data
        AN = 3
ANIMATION_TIME = 0.5
ARTIFICIAL = 1
BISHOP = 3
BLACK = 1
BLACKWON = 3
BLACK_CASTLED = 32
BLACK_OO = 4
BLACK_OOO = 8
DRAW = 1
DRAW_50MOVES = 1
DRAW_ACCEPTION = 3
DRAW_AGREE = 3
DRAW_INSUFFICIENT = 4
DRAW_OFFER = 2
DRAW_REPITITION = 0
DRAW_STALEMATE = 2
FAN = 2
FLAG_CALL = 1
HINT = 0
IO_ERR = 8
IO_FLAG_APPEND = 1
IO_FLAG_GET_MASK = 31
IO_FLAG_IS_READABLE = 4
IO_FLAG_IS_SEEKABLE = 16
IO_FLAG_IS_WRITEABLE = 8
IO_FLAG_MASK = 31
IO_FLAG_NONBLOCK = 2
IO_FLAG_SET_MASK = 3
IO_HUP = 16
IO_IN = 1
IO_NVAL = 32
IO_OUT = 4
IO_PRI = 2
IO_STATUS_AGAIN = 3
IO_STATUS_EOF = 2
IO_STATUS_ERROR = 0
IO_STATUS_NORMAL = 1
KING = 0
KNIGHT = 4
LAN = 1
LOCAL = 0
NAME = 'PyChess'
OPTION_ERROR_BAD_VALUE = 1
OPTION_ERROR_FAILED = 2
OPTION_ERROR_UNKNOWN_OPTION = 0
OPTION_FLAG_FILENAME = 16
OPTION_FLAG_HIDDEN = 1
OPTION_FLAG_IN_MAIN = 2
OPTION_FLAG_NOALIAS = 64
OPTION_FLAG_NO_ARG = 8
OPTION_FLAG_OPTIONAL_ARG = 32
OPTION_FLAG_REVERSE = 4
OPTION_REMAINING = ''
PARAM_CONSTRUCT = 4
PARAM_CONSTRUCT_ONLY = 8
PARAM_LAX_VALIDATION = 16
PARAM_READABLE = 1
PARAM_READWRITE = 3
PARAM_WRITABLE = 2
PAWN = 5
PREFIX = '/home/thomas/Programmering/python/skak/svn'
PRIORITY_DEFAULT = 0
PRIORITY_DEFAULT_IDLE = 200
PRIORITY_HIGH = -100
PRIORITY_HIGH_IDLE = 100
PRIORITY_LOW = 300
QUEEN = 1
REMOTE = 2
RESIGNATION = 0
ROOK = 2
RUNNING = 0
SAN = 0
SIGNAL_ACTION = 32
SIGNAL_DETAILED = 16
SIGNAL_NO_HOOKS = 64
SIGNAL_NO_RECURSE = 8
SIGNAL_RUN_CLEANUP = 4
SIGNAL_RUN_FIRST = 1
SIGNAL_RUN_LAST = 2
SPAWN_CHILD_INHERITS_STDIN = 32
SPAWN_DO_NOT_REAP_CHILD = 2
SPAWN_FILE_AND_ARGV_ZERO = 64
SPAWN_LEAVE_DESCRIPTORS_OPEN = 1
SPAWN_SEARCH_PATH = 4
SPAWN_STDERR_TO_DEV_NULL = 16
SPAWN_STDOUT_TO_DEV_NULL = 8
SPY = 1
TYPE_BOOLEAN = <GType gboolean (20)>
TYPE_BOXED = <GType GBoxed (72)>
TYPE_CHAR = <GType gchar (12)>
TYPE_DOUBLE = <GType gdouble (60)>
TYPE_ENUM = <GType GEnum (48)>
TYPE_FLAGS = <GType GFlags (52)>
TYPE_FLOAT = <GType gfloat (56)>
TYPE_GSTRING = <GType GString (151107840)>
TYPE_INT = <GType gint (24)>
TYPE_INT64 = <GType gint64 (40)>
TYPE_INTERFACE = <GType GInterface (8)>
TYPE_INVALID = <GType invalid (0)>
TYPE_LONG = <GType glong (32)>
TYPE_NONE = <GType void (4)>
TYPE_OBJECT = <GType GObject (80)>
TYPE_PARAM = <GType GParam (76)>
TYPE_POINTER = <GType gpointer (68)>
TYPE_PYOBJECT = <GType PyObject (151107896)>
TYPE_STRING = <GType gchararray (64)>
TYPE_UCHAR = <GType guchar (16)>
TYPE_UINT = <GType guint (28)>
TYPE_UINT64 = <GType guint64 (44)>
TYPE_ULONG = <GType gulong (36)>
TYPE_UNICHAR = <GType guint (28)>
VERSION = '0.6.0_beta'
WHITE = 0
WHITEWON = 2
WHITE_CASTLED = 16
WHITE_OO = 1
WHITE_OOO = 2
WON_CALLFLAG = 6
WON_MATE = 7
WON_RESIGN = 5
chr2Sign = {'b': 3, 'k': 0, 'n': 4, 'p': 5, 'q': 1, 'r': 2}
glib_version = (2, 12, 3)
hashfALPHA = 0
hashfBETA = 1
hashfEXACT = 2
localePrefixes = ('/usr/share/locale', '/usr/local/share/locale')
prefixes = ('/usr/share', '/usr/local/share', '/usr/share/games', '/usr/local/share/games')
pygobject_version = (2, 12, 3)
pygtk_version = (2, 12, 3)
range8 = [0, 1, 2, 3, 4, 5, 6, 7]
reprColor = ['White', 'Black']
reprMode = ['hint', 'spy']
reprPiece = ['King', 'Queen', 'Rook', 'Bishop', 'Knight', 'Pawn']
reprResult = ['*', '1/2-1/2', '1-0', '0-1']
reprSign = ['K', 'Q', 'R', 'B', 'N', 'P']