25 |
class MyModule(module.Module): |
class MyModule(module.Module): |
26 |
"""Test Window Frame class""" |
"""Test Window Frame class""" |
27 |
|
|
28 |
my_events = [X.Expose] |
my_events = [X.Expose, X.ButtonPress] |
29 |
my_actions = { |
my_actions = { |
30 |
"win_move" : "move", |
"win_move" : "move", |
31 |
"win_toggle_iconified" : "win_toggle_maximize", |
"win_toggle_iconified" : "win_toggle_maximize", |
90 |
|
|
91 |
bg_color = self.colormap.alloc_named_color("#ffec8b") |
bg_color = self.colormap.alloc_named_color("#ffec8b") |
92 |
border_color = self.colormap.alloc_named_color("#666666") |
border_color = self.colormap.alloc_named_color("#666666") |
93 |
|
text_color = self.colormap.alloc_named_color("#000000") |
94 |
|
unfocused_bg_color = self.colormap.alloc_named_color("#003184") |
95 |
|
unfocused_border_color = self.colormap.alloc_named_color("#003184") |
96 |
|
unfocused_text_color = self.colormap.alloc_named_color("#000000") |
97 |
|
|
98 |
# This surrounds the app window and titlebar |
# This surrounds the app window and titlebar |
99 |
frame = self.display.screen().root.create_window(appwin_x, appwin_y, |
frame = self.display.screen().root.create_window(appwin_x, appwin_y, |
100 |
appwin_width, appwin_height + titlebar_height + (border_width * 2), 1, |
appwin_width, appwin_height + titlebar_height + (border_width * 3), |
101 |
self.display.screen().root_depth, |
border_width, self.display.screen().root_depth, |
102 |
X.InputOutput, X.CopyFromParent, |
X.InputOutput, X.CopyFromParent, |
103 |
background_pixel = bg_color.pixel, |
background_pixel = bg_color.pixel, |
104 |
border_pixel = border_color.pixel, |
border_pixel = border_color.pixel, |
105 |
event_mask = (X.ButtonMotionMask | X.ButtonPressMask)) |
event_mask = (X.ButtonMotionMask | X.ButtonPressMask)) |
106 |
|
|
107 |
# titlebar |
# titlebar |
108 |
titlebar = frame.create_window(1, 1, |
titlebar = frame.create_window(border_width, border_width, |
109 |
appwin_width, titlebar_height, 1, |
appwin_width - (4 * border_width), titlebar_height, border_width, |
110 |
self.display.screen().root_depth, |
self.display.screen().root_depth, |
111 |
X.CopyFromParent, X.CopyFromParent, |
X.CopyFromParent, X.CopyFromParent, |
112 |
background_pixel = bg_color.pixel, |
background_pixel = bg_color.pixel, |
115 |
frame.map_sub_windows() |
frame.map_sub_windows() |
116 |
frame.map() |
frame.map() |
117 |
|
|
118 |
appwin.reparent(frame, 0, titlebar_height) |
appwin.reparent(frame, 0, titlebar_height + (border_width * 3)) |
119 |
|
|
120 |
|
|
121 |
def move(self, event): |
def move(self, dest_x, dest_y, win): |
122 |
win.configure(x = dest_x, y = dest_y) |
win.configure(x = dest_x, y = dest_y) |
123 |
|
|
124 |
def unload(self): |
def unload(self): |
125 |
pass |
pass |
126 |
|
|
127 |
def handle_event(self, event): |
def handle_event(self, event): |
128 |
|
|
129 |
if event.type == X.Expose: |
if event.type == X.Expose: |
130 |
print "EXPOSE" |
print "EXPOSE" |
131 |
|
|
132 |
|
if event.type == X.ButtonPress: |
133 |
|
focus_win = self.display.get_input_focus().focus |
134 |
|
# focus_win = self.display.create_resourIce_object('window', focus_win_id) |
135 |
|
print focus_win |
136 |
|
print X.NONE |
137 |
|
print X.PointerRoot |
138 |
|
if X.PointerRoot == focus_win: |
139 |
|
print "ITS THE ROOT WINDOW" |
140 |
|
#print focus_win.get_geometry().x |
141 |
|
#self.move(focus_win.get_geometry().x + 1, focus_win.get_geometry().y + 1, focus_win) |
142 |
|
|
143 |
|
print "Button Press" |
144 |
|
|
145 |
def win_toggle_maximize(self, win): |
def win_toggle_maximize(self, win): |
146 |
pass |
pass |
147 |
|
|