Added color setting tool to the RichTextCtrl sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		| @@ -335,6 +335,7 @@ class RichTextFrame(wx.Frame): | ||||
|  | ||||
|         r = self.rtc.GetSelectionRange() | ||||
|         fontData = wx.FontData() | ||||
|         fontData.EnableEffects(False) | ||||
|         attr = rt.RichTextAttr() | ||||
|         attr.SetFlags(rt.TEXT_ATTR_FONT) | ||||
|         if self.rtc.GetStyle(self.rtc.GetInsertionPoint(), attr): | ||||
| @@ -351,6 +352,29 @@ class RichTextFrame(wx.Frame): | ||||
|         dlg.Destroy() | ||||
|  | ||||
|  | ||||
|     def OnColour(self, evt): | ||||
|         colourData = wx.ColourData() | ||||
|         attr = rt.RichTextAttr() | ||||
|         attr.SetFlags(rt.TEXT_ATTR_TEXT_COLOUR) | ||||
|         if self.rtc.GetStyle(self.rtc.GetInsertionPoint(), attr): | ||||
|             colourData.SetColour(attr.GetTextColour()) | ||||
|  | ||||
|         dlg = wx.ColourDialog(self, colourData) | ||||
|         if dlg.ShowModal() == wx.ID_OK: | ||||
|             colourData = dlg.GetColourData() | ||||
|             colour = colourData.GetColour() | ||||
|             if colour: | ||||
|                 if not self.rtc.HasSelection(): | ||||
|                     self.rtc.BeginTextColour(colour) | ||||
|                 else: | ||||
|                     r = self.rtc.GetSelectionRange() | ||||
|                     attr.SetFlags(rt.TEXT_ATTR_TEXT_COLOUR) | ||||
|                     attr.SetTextColour(colour) | ||||
|                     self.rtc.SetStyle(r, attr) | ||||
|         dlg.Destroy() | ||||
|          | ||||
|  | ||||
|  | ||||
|     def OnUpdateBold(self, evt): | ||||
|         evt.Check(self.rtc.IsSelectionBold()) | ||||
|      | ||||
| @@ -498,6 +522,8 @@ class RichTextFrame(wx.Frame): | ||||
|         tbar.AddSeparator() | ||||
|         doBind( tbar.AddTool(-1, images.get_rt_fontBitmap(), | ||||
|                             shortHelpString="Font"), self.OnFont) | ||||
|         doBind( tbar.AddTool(-1, images.get_rt_colourBitmap(), | ||||
|                             shortHelpString="Font Colour"), self.OnColour) | ||||
|  | ||||
|         tbar.Realize() | ||||
|  | ||||
|   | ||||
							
								
								
									
										59
									
								
								wxPython/demo/bmp_source/rt_colour.xpm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								wxPython/demo/bmp_source/rt_colour.xpm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| /* XPM */ | ||||
| static char *rt_colour[] = { | ||||
| /* columns rows colors chars-per-pixel */ | ||||
| "16 16 37 1", | ||||
| "  c black", | ||||
| ". c #727D329BA5CF", | ||||
| "X c #4CF6357BDDD0", | ||||
| "o c #45CE2E66FA02", | ||||
| "O c #45FF2D19FF52", | ||||
| "+ c #45452C2FFFFF", | ||||
| "@ c #47B22F3CFDC3", | ||||
| "# c #45EF3E00EB43", | ||||
| "$ c #456C3C9FF054", | ||||
| "% c #45663A49F28D", | ||||
| "& c #45B75BB5D2B6", | ||||
| "* c #4B8899247615", | ||||
| "= c #5F619039673F", | ||||
| "- c #476EFFCA362C", | ||||
| "; c #4747FFFF3633", | ||||
| ": c #4F3EF55734F1", | ||||
| "> c #4899D8B04EEE", | ||||
| ", c #46F6DED055CF", | ||||
| "< c #46EEDBB758C1", | ||||
| "1 c #4720F01B4555", | ||||
| "2 c #4724F1E8439E", | ||||
| "3 c #5EEBE9D75212", | ||||
| "4 c #46338EE4A1F3", | ||||
| "5 c #ACF030145603", | ||||
| "6 c #D9A917AD3776", | ||||
| "7 c #DF82157232D4", | ||||
| "8 c #FFD3091A193C", | ||||
| "9 c #FFFF090A191B", | ||||
| "0 c #FD590DB41D4A", | ||||
| "q c #E46E13912EEF", | ||||
| "w c #EC61108728A3", | ||||
| "e c #C21E1CD652E5", | ||||
| "r c #A38E1A6E8B66", | ||||
| "t c #A37584C127AE", | ||||
| "y c #A59D81DF2756", | ||||
| "u c #B4A389EF830A", | ||||
| "i c None", | ||||
| /* pixels */ | ||||
| "iiiiiiiiiiiiiiii", | ||||
| "iiiiii999999iiii", | ||||
| "iiiii999w9999iii", | ||||
| "iiii9999999999ii", | ||||
| "iiii9999999999ii", | ||||
| "iiii9999999999ii", | ||||
| "iiii9999999999ii", | ||||
| "iiiituq999909iii", | ||||
| "iii--*=567e.++++", | ||||
| "ii--3>-:yrXo++++", | ||||
| "i-------2$@+++++", | ||||
| "--------,%@+++++", | ||||
| "--------<#++++++", | ||||
| "--------1&++++++", | ||||
| "---------4++++++", | ||||
| "i--------i++++++" | ||||
| }; | ||||
| @@ -73,6 +73,7 @@ command_lines = [ | ||||
|     "-a -u -n _rt_alignright bmp_source/rt_alignright.xpm images.py", | ||||
|     "-a -u -n _rt_bold bmp_source/rt_bold.xpm images.py", | ||||
|     "-a -u -n _rt_centre bmp_source/rt_centre.xpm images.py", | ||||
|     "-a -u -n _rt_colour bmp_source/rt_colour.xpm images.py", | ||||
|     "-a -u -n _rt_copy bmp_source/rt_copy.xpm images.py", | ||||
|     "-a -u -n _rt_cut bmp_source/rt_cut.xpm images.py", | ||||
|     "-a -u -n _rt_font bmp_source/rt_font.xpm images.py", | ||||
|   | ||||
| @@ -10208,6 +10208,30 @@ def get_rt_centreImage(): | ||||
|     stream = cStringIO.StringIO(get_rt_centreData()) | ||||
|     return ImageFromStream(stream) | ||||
|  | ||||
| #---------------------------------------------------------------------- | ||||
| def get_rt_colourData(): | ||||
|     return \ | ||||
| '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ | ||||
| \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ | ||||
| \x00\x00\xf6IDAT8\x8dcddbf\xa0\x04\xb0\xe0\x92\xf8\xc7.\xf6\x1f\x9b8\xd3\xcf\ | ||||
| W\x8c(|B\x9a\xdf\xb2\xf3\xe35\x98\x11\xdd\x0b\xb8l\xc6\xe5\x12\xac. \x05\x0c\ | ||||
| B\x03\x96T\xf31lm\xc8bx\xca%\x8a\xa1\xf8\x1f\x0b$\xd2\x90c\x02%\x10\xdd\xfe\ | ||||
| \x1a\xffg````\x99\xe5\xc0 \xf2\xfd#\x83\xef\x82\xf7\x0c\xba\xcf\x1f2\xb0\xfd\ | ||||
| \xfb\xcd\xf0\x98]\x81a\x83X0\xc3\xe5_Q(\x86\xc2\r\x80i\x16\x7f%\xc3\xf0\xea\ | ||||
| \xfd\x1f\x86\xff\xea/\x188\xbe\xfdc\x08\xeb\xf9\xcc\xf0of\n\xc3J\xe9 \x86\ | ||||
| \x9f?e\x19\x18\xfe\xb1b\x1a\x00\xd3\x8c\x15|\xe2e\xf8\xe7\xbd\x96\x81\xe93/\ | ||||
| \xc3\xbf\xbf\x98A\xc6\x84W3\x03\x03\xc3\xff\xb7B\x0c\x0c\xffp\x875\xe1X\xf8\ | ||||
| \xcb\xcc\xc0\xc0\xf2\x13\xab\xedD\x19\xc0(\xfa\x96\x81A\xf69\x05.\xe0\xff\ | ||||
| \xc8\xc0h|\x1e\xb7\x05\x04\x03\x91\x81\x81a\x17\xf3YF\x17\xad?X\xd5\x00\x00\ | ||||
| \xac\x08RO\x1e0;\xef\x00\x00\x00\x00IEND\xaeB`\x82'  | ||||
|  | ||||
| def get_rt_colourBitmap(): | ||||
|     return BitmapFromImage(get_rt_colourImage()) | ||||
|  | ||||
| def get_rt_colourImage(): | ||||
|     stream = cStringIO.StringIO(get_rt_colourData()) | ||||
|     return ImageFromStream(stream) | ||||
|  | ||||
| #---------------------------------------------------------------------- | ||||
| def get_rt_copyData(): | ||||
|     return \ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user