And more text entry stuff.
This commit is contained in:
parent
105c66f25b
commit
5aa820d72f
@ -4,9 +4,12 @@ _system_colors = {
|
|||||||
'toolbar-background' : '#414141',
|
'toolbar-background' : '#414141',
|
||||||
'frame-border' : '#D1D1D2',
|
'frame-border' : '#D1D1D2',
|
||||||
'entry-background-focused' : '#FFFFFF',
|
'entry-background-focused' : '#FFFFFF',
|
||||||
'entry-background-unfocused' : '#D1D1D2',
|
'entry-background-unfocused' : '#414141',
|
||||||
'entry-selection-focused' : '#D1D1D2',
|
'entry-selection-focused' : '#D1D1D2',
|
||||||
'entry-selection-unfocused' : '#00FF00'
|
'entry-selection-unfocused' : '#00FF00',
|
||||||
|
'entry-text-focused' : '#000000',
|
||||||
|
'entry-text-unfocused' : '#FFFFFF',
|
||||||
|
'entry-border' : '#D1D1D2'
|
||||||
}
|
}
|
||||||
|
|
||||||
def _html_to_rgb(html_color):
|
def _html_to_rgb(html_color):
|
||||||
@ -64,3 +67,6 @@ class Color(object):
|
|||||||
ENTRY_BACKGROUND_UNFOCUSED = SystemColor('entry-background-unfocused')
|
ENTRY_BACKGROUND_UNFOCUSED = SystemColor('entry-background-unfocused')
|
||||||
ENTRY_SELECTION_FOCUSED = SystemColor('entry-selection-focused')
|
ENTRY_SELECTION_FOCUSED = SystemColor('entry-selection-focused')
|
||||||
ENTRY_SELECTION_UNFOCUSED = SystemColor('entry-selection-unfocused')
|
ENTRY_SELECTION_UNFOCUSED = SystemColor('entry-selection-unfocused')
|
||||||
|
ENTRY_TEXT_FOCUSED = SystemColor('entry-text-focused')
|
||||||
|
ENTRY_TEXT_UNFOCUSED = SystemColor('entry-text-unfocused')
|
||||||
|
ENTRY_BORDER = SystemColor('entry-border')
|
||||||
|
@ -32,6 +32,8 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
gobject.PARAM_READWRITE)
|
gobject.PARAM_READWRITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_BORDER_WIDTH = 3
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
hippo.CanvasBox.__init__(self)
|
hippo.CanvasBox.__init__(self)
|
||||||
|
|
||||||
@ -60,33 +62,37 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
def do_paint_below_children(self, cr, damaged_box):
|
def do_paint_below_children(self, cr, damaged_box):
|
||||||
[width, height] = self._canvas_widget.get_allocation()
|
[width, height] = self._canvas_widget.get_allocation()
|
||||||
|
|
||||||
x = 0
|
x = self.props.padding_left
|
||||||
y = 0
|
y = self.props.padding_top - self._BORDER_WIDTH / 2
|
||||||
|
|
||||||
cr.move_to(self._radius, 0);
|
cr.move_to(x, y - self._BORDER_WIDTH / 2);
|
||||||
cr.arc(width - self._radius, self._radius,
|
cr.arc(x + width + self._BORDER_WIDTH / 2, y - self._BORDER_WIDTH / 2 + self._radius,
|
||||||
self._radius, math.pi * 1.5, math.pi * 2);
|
self._radius, math.pi * 1.5, math.pi * 0.5)
|
||||||
cr.arc(width - self._radius, height - self._radius,
|
cr.arc(x, y + self._radius - self._BORDER_WIDTH / 2, self._radius,
|
||||||
self._radius, 0, math.pi * 0.5);
|
math.pi * 0.5, math.pi * 1.5)
|
||||||
cr.arc(self._radius, height - self._radius,
|
|
||||||
self._radius, math.pi * 0.5, math.pi);
|
|
||||||
cr.arc(self._radius, self._radius, self._radius,
|
|
||||||
math.pi, math.pi * 1.5);
|
|
||||||
|
|
||||||
cr.set_source_rgba(*self._background_color.get_rgba())
|
cr.set_source_rgba(*self._background_color.get_rgba())
|
||||||
cr.fill();
|
cr.fill_preserve();
|
||||||
|
|
||||||
|
cr.set_line_width(self._BORDER_WIDTH)
|
||||||
|
cr.set_source_rgba(*Color.ENTRY_BORDER.get_rgba())
|
||||||
|
cr.stroke()
|
||||||
|
|
||||||
def do_allocate(self, width, height, origin_changed):
|
def do_allocate(self, width, height, origin_changed):
|
||||||
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
|
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
|
||||||
|
|
||||||
[width, height] = self._canvas_widget.get_request()
|
[w_width, w_height] = self._canvas_widget.get_request()
|
||||||
radius = min(width, height) / 2
|
radius = min(w_width, w_height) / 2 + self._BORDER_WIDTH
|
||||||
if radius != self._radius:
|
if radius != self._radius:
|
||||||
self._radius = radius
|
self._radius = radius
|
||||||
self._canvas_widget.props.padding_left = self._radius - 2
|
self.props.padding_top = height / 2 - w_height / 2 - self._BORDER_WIDTH / 2
|
||||||
self._canvas_widget.props.padding_right = self._radius - 2
|
self.props.padding_left = self._radius + self._BORDER_WIDTH / 2
|
||||||
|
self.props.padding_right = self._radius + self._BORDER_WIDTH / 2
|
||||||
|
|
||||||
self._canvas_widget.do_allocate(self._canvas_widget, width, height,
|
# Make the entry expand horizontally
|
||||||
|
w_width = width - (self.props.padding_left + self.props.padding_right)
|
||||||
|
|
||||||
|
self._canvas_widget.do_allocate(self._canvas_widget, w_width, w_height,
|
||||||
origin_changed)
|
origin_changed)
|
||||||
|
|
||||||
def _entry_focus_in_event_cb(self, widget, event):
|
def _entry_focus_in_event_cb(self, widget, event):
|
||||||
@ -105,6 +111,8 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
Color.ENTRY_BACKGROUND_FOCUSED.get_gdk_color())
|
Color.ENTRY_BACKGROUND_FOCUSED.get_gdk_color())
|
||||||
self._entry.modify_base(gtk.STATE_SELECTED,
|
self._entry.modify_base(gtk.STATE_SELECTED,
|
||||||
Color.ENTRY_SELECTION_FOCUSED.get_gdk_color())
|
Color.ENTRY_SELECTION_FOCUSED.get_gdk_color())
|
||||||
|
self._entry.modify_text(gtk.STATE_NORMAL,
|
||||||
|
Color.ENTRY_TEXT_FOCUSED.get_gdk_color())
|
||||||
else:
|
else:
|
||||||
self._background_color = Color.ENTRY_BACKGROUND_UNFOCUSED
|
self._background_color = Color.ENTRY_BACKGROUND_UNFOCUSED
|
||||||
|
|
||||||
@ -112,3 +120,5 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
Color.ENTRY_BACKGROUND_UNFOCUSED.get_gdk_color())
|
Color.ENTRY_BACKGROUND_UNFOCUSED.get_gdk_color())
|
||||||
self._entry.modify_base(gtk.STATE_SELECTED,
|
self._entry.modify_base(gtk.STATE_SELECTED,
|
||||||
Color.ENTRY_SELECTION_UNFOCUSED.get_gdk_color())
|
Color.ENTRY_SELECTION_UNFOCUSED.get_gdk_color())
|
||||||
|
self._entry.modify_text(gtk.STATE_NORMAL,
|
||||||
|
Color.ENTRY_TEXT_UNFOCUSED.get_gdk_color())
|
||||||
|
@ -37,11 +37,8 @@ canvas.set_root(vbox)
|
|||||||
toolbar = Toolbar()
|
toolbar = Toolbar()
|
||||||
vbox.append(toolbar)
|
vbox.append(toolbar)
|
||||||
|
|
||||||
frame = Frame()
|
|
||||||
toolbar.append(frame)
|
|
||||||
|
|
||||||
button = Button('theme:stock-close')
|
button = Button('theme:stock-close')
|
||||||
frame.append(button)
|
toolbar.append(button)
|
||||||
|
|
||||||
entry = Entry()
|
entry = Entry()
|
||||||
entry.props.text = 'mec mac'
|
entry.props.text = 'mec mac'
|
||||||
@ -51,4 +48,12 @@ entry2 = Entry()
|
|||||||
entry2.props.text = 'moc muc'
|
entry2.props.text = 'moc muc'
|
||||||
toolbar.append(entry2, hippo.PACK_EXPAND)
|
toolbar.append(entry2, hippo.PACK_EXPAND)
|
||||||
|
|
||||||
|
gtk_entry = gtk.Entry()
|
||||||
|
gtk_entry.props.has_frame = False
|
||||||
|
#gtk_entry.connect("activate", self._entry_activate_cb)
|
||||||
|
|
||||||
|
gtk_entry_widget = hippo.CanvasWidget()
|
||||||
|
gtk_entry_widget.props.widget = gtk_entry
|
||||||
|
toolbar.append(gtk_entry_widget, hippo.PACK_EXPAND)
|
||||||
|
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user