more minor fixes, stabalizations, etc.
Added example of wxTaskBarIcon to the demo git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7978 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -65,6 +65,7 @@ _treeList = [
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class wxPythonDemo(wxFrame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, -1, title, size = (800, 600),
|
||||
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
@@ -73,8 +74,17 @@ class wxPythonDemo(wxFrame):
|
||||
self.curOverview = ""
|
||||
|
||||
if wxPlatform == '__WXMSW__':
|
||||
self.icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
|
||||
self.SetIcon(self.icon)
|
||||
icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
|
||||
self.SetIcon(icon)
|
||||
|
||||
# setup a taskbar icon, and catch some events from it
|
||||
self.tbicon = wxTaskBarIcon()
|
||||
self.tbicon.SetIcon(icon, "wxPython Demo")
|
||||
EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
|
||||
EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
|
||||
EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
|
||||
EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
|
||||
|
||||
|
||||
self.otherWin = None
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
@@ -307,7 +317,7 @@ class wxPythonDemo(wxFrame):
|
||||
|
||||
#---------------------------------------------
|
||||
# Menu methods
|
||||
def OnFileExit(self, event):
|
||||
def OnFileExit(self, *event):
|
||||
self.Close()
|
||||
|
||||
|
||||
@@ -323,8 +333,11 @@ class wxPythonDemo(wxFrame):
|
||||
self.dying = true
|
||||
self.window = None
|
||||
self.mainmenu = None
|
||||
if hasattr(self, "tbicon"):
|
||||
del self.tbicon
|
||||
self.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnIdle(self, event):
|
||||
if self.otherWin:
|
||||
@@ -342,6 +355,36 @@ class wxPythonDemo(wxFrame):
|
||||
self.tree.SelectItem(selectedDemo)
|
||||
self.tree.EnsureVisible(selectedDemo)
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnTaskBarActivate(self, evt):
|
||||
if self.IsIconized():
|
||||
self.Iconize(false)
|
||||
if not self.IsShown():
|
||||
self.Show(true)
|
||||
self.Raise()
|
||||
|
||||
#---------------------------------------------
|
||||
|
||||
TBMENU_RESTORE = 1000
|
||||
TBMENU_CLOSE = 1001
|
||||
|
||||
def OnTaskBarMenu(self, evt):
|
||||
menu = wxMenu()
|
||||
menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo")
|
||||
menu.Append(self.TBMENU_CLOSE, "Close")
|
||||
self.tbicon.PopupMenu(menu)
|
||||
menu.Destroy()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnTaskBarClose(self, evt):
|
||||
self.Close()
|
||||
|
||||
# because of the way wxTaskBarIcon.PopupMenu is implemented we have to
|
||||
# prod the main idle handler a bit to get the window to actually close
|
||||
wxGetApp().ProcessIdle()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
//
|
||||
// Created: 17-March-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 by Total Control Software
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
if (m_myInst.findCallback(#CBNAME)) \
|
||||
m_myInst.callCallback( \
|
||||
Py_BuildValue("(Oii)", \
|
||||
wxPyConstructObject((void*)attr, "_wxGridCellAttr_p"), \
|
||||
wxPyConstructObject((void*)attr, "wxGridCellAttr"), \
|
||||
a, b)); \
|
||||
else \
|
||||
PCLASS::CBNAME(attr, a, b); \
|
||||
@@ -92,7 +92,7 @@
|
||||
if (m_myInst.findCallback(#CBNAME)) \
|
||||
m_myInst.callCallback( \
|
||||
Py_BuildValue("(Oi)", \
|
||||
wxPyConstructObject((void*)attr, "_wxGridCellAttr_p"), \
|
||||
wxPyConstructObject((void*)attr, "wxGridCellAttr"), \
|
||||
val)); \
|
||||
else \
|
||||
PCLASS::CBNAME(attr, val); \
|
||||
@@ -451,6 +451,8 @@ class wxGridCellRenderer
|
||||
{
|
||||
public:
|
||||
void SetParameters(const wxString& params);
|
||||
void IncRef();
|
||||
void DecRef();
|
||||
|
||||
virtual void Draw(wxGrid& grid,
|
||||
wxGridCellAttr& attr,
|
||||
@@ -600,6 +602,8 @@ public:
|
||||
void SetControl(wxControl* control);
|
||||
|
||||
void SetParameters(const wxString& params);
|
||||
void IncRef();
|
||||
void DecRef();
|
||||
|
||||
virtual void Create(wxWindow* parent,
|
||||
wxWindowID id,
|
||||
@@ -612,6 +616,7 @@ public:
|
||||
virtual void SetSize(const wxRect& rect);
|
||||
virtual void Show(bool show, wxGridCellAttr *attr = NULL);
|
||||
virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
|
||||
virtual bool IsAcceptedKey(wxKeyEvent& event);
|
||||
virtual void StartingKey(wxKeyEvent& event);
|
||||
virtual void StartingClick();
|
||||
virtual void HandleReturn(wxKeyEvent& event);
|
||||
@@ -687,7 +692,7 @@ public:
|
||||
if (m_myInst.findCallback("Show"))
|
||||
m_myInst.callCallback(
|
||||
Py_BuildValue("(iO)", show,
|
||||
wxPyConstructObject((void*)attr, "_wxGridCellAttr_p")));
|
||||
wxPyConstructObject((void*)attr, "wxGridCellAttr")));
|
||||
else
|
||||
wxGridCellEditor::Show(show, attr);
|
||||
wxPySaveThread(doSave);
|
||||
@@ -702,8 +707,8 @@ public:
|
||||
if (m_myInst.findCallback("PaintBackground"))
|
||||
m_myInst.callCallback(
|
||||
Py_BuildValue("(OO)",
|
||||
wxPyConstructObject((void*)&rectCell, "_wxRect_p"),
|
||||
wxPyConstructObject((void*)attr, "_wxGridCellAttr_p")));
|
||||
wxPyConstructObject((void*)&rectCell, "wxRect"),
|
||||
wxPyConstructObject((void*)attr, "wxGridCellAttr")));
|
||||
else
|
||||
wxGridCellEditor::PaintBackground(rectCell, attr);
|
||||
wxPySaveThread(doSave);
|
||||
@@ -715,6 +720,7 @@ public:
|
||||
|
||||
DEC_PYCALLBACK___pure(Reset);
|
||||
DEC_PYCALLBACK__constany(SetSize, wxRect);
|
||||
DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
|
||||
DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
|
||||
DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
|
||||
DEC_PYCALLBACK__(StartingClick);
|
||||
@@ -728,6 +734,7 @@ public:
|
||||
IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
|
||||
IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
|
||||
IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
|
||||
IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
|
||||
IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
|
||||
IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
|
||||
IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
|
||||
@@ -1269,15 +1276,14 @@ public:
|
||||
int GetNumberCols();
|
||||
|
||||
|
||||
|
||||
#ifdef NOTNEEDED // ????
|
||||
// ------ display update functions
|
||||
//
|
||||
void CalcRowLabelsExposed( wxRegion& reg );
|
||||
|
||||
void CalcColLabelsExposed( wxRegion& reg );
|
||||
void CalcCellsExposed( wxRegion& reg );
|
||||
|
||||
|
||||
#ifdef NOTNEEDED // ????
|
||||
// ------ event handlers
|
||||
//
|
||||
void ProcessRowLabelMouseEvent( wxMouseEvent& event );
|
||||
@@ -1338,7 +1344,7 @@ public:
|
||||
|
||||
void GetTextBoxSize( wxDC& dc,
|
||||
wxArrayString& lines,
|
||||
long *width, long *height );
|
||||
long *OUTPUT, long *OUTPUT );
|
||||
|
||||
|
||||
// ------
|
||||
@@ -1577,10 +1583,6 @@ public:
|
||||
wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
|
||||
const wxGridCellCoords & bottomRight );
|
||||
|
||||
// This function returns the rectangle that encloses the selected cells
|
||||
// in device coords and clipped to the client size of the grid window.
|
||||
//
|
||||
wxRect SelectionToDeviceRect();
|
||||
|
||||
// Access or update the selection fore/back colours
|
||||
wxColour GetSelectionBackground() const;
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "SciLexer.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// constants and stuff
|
||||
@@ -75,6 +75,8 @@ const int wxSTC_INDIC_MAX = 7;
|
||||
const int wxSTC_INDIC_PLAIN = 0;
|
||||
const int wxSTC_INDIC_SQUIGGLE = 1;
|
||||
const int wxSTC_INDIC_TT = 2;
|
||||
const int wxSTC_INDIC_DIAGONAL = 3;
|
||||
const int wxSTC_INDIC_STRIKE = 4;
|
||||
const int wxSTC_INDIC0_MASK = 32;
|
||||
const int wxSTC_INDIC1_MASK = 64;
|
||||
const int wxSTC_INDIC2_MASK = 128;
|
||||
@@ -150,6 +152,8 @@ enum wxSTC_LEX {
|
||||
wxSTC_LEX_ERRORLIST,
|
||||
wxSTC_LEX_MAKEFILE,
|
||||
wxSTC_LEX_BATCH,
|
||||
wxSTC_LEX_XCODE,
|
||||
wxSTC_LEX_LATEX
|
||||
};
|
||||
|
||||
|
||||
@@ -178,7 +182,7 @@ public:
|
||||
wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const char* name = wxSTCNameStr);
|
||||
const char* name = "styledtext");
|
||||
#else
|
||||
wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
@@ -233,6 +237,7 @@ public:
|
||||
wxSTC_UndoType GetUndoCollection();
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
void SetSavePoint();
|
||||
|
||||
|
||||
// Selection and information
|
||||
@@ -323,12 +328,13 @@ public:
|
||||
void StyleSetForeground(int styleNum, const wxColour& colour);
|
||||
void StyleSetBackground(int styleNum, const wxColour& colour);
|
||||
void StyleSetFont(int styleNum, wxFont& font);
|
||||
void StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold, bool italic);
|
||||
void StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold=FALSE, bool italic=FALSE, bool underline=FALSE);
|
||||
void StyleSetBold(int styleNum, bool bold);
|
||||
void StyleSetItalic(int styleNum, bool italic);
|
||||
void StyleSetFaceName(int styleNum, const wxString& faceName);
|
||||
void StyleSetSize(int styleNum, int pointSize);
|
||||
void StyleSetEOLFilled(int styleNum, bool fillEOL);
|
||||
void StyleSetUnderline(int styleNum, bool underline);
|
||||
|
||||
|
||||
// Margins in the edit area
|
||||
@@ -458,6 +464,13 @@ public:
|
||||
void SetFoldFlags(int flags);
|
||||
|
||||
|
||||
// Zooming
|
||||
void ZoomIn();
|
||||
void ZoomOut();
|
||||
void SetZoom(int zoom);
|
||||
int GetZoom();
|
||||
|
||||
|
||||
// Long Lines
|
||||
int GetEdgeColumn();
|
||||
void SetEdgeColumn(int column);
|
||||
@@ -475,6 +488,10 @@ public:
|
||||
void SetKeywords(int keywordSet, const wxString& keywordList);
|
||||
|
||||
|
||||
// Event mask for Modified Event
|
||||
void SetModEventMask(int mask);
|
||||
//int GetModEventMask();
|
||||
|
||||
#ifndef SWIG
|
||||
private:
|
||||
// Event handlers
|
||||
@@ -584,7 +601,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Event types
|
||||
enum {
|
||||
wxEVT_STC_CHANGE = 1650,
|
||||
wxEVT_STC_STYLENEEDED,
|
||||
@@ -601,6 +618,20 @@ enum {
|
||||
wxEVT_STC_NEEDSHOWN
|
||||
};
|
||||
|
||||
// Modification and action types
|
||||
const int wxSTC_MOD_INSERTTEXT = 0x1;
|
||||
const int wxSTC_MOD_DELETETEXT = 0x2;
|
||||
const int wxSTC_MOD_CHANGESTYLE = 0x4;
|
||||
const int wxSTC_MOD_CHANGEFOLD = 0x8;
|
||||
const int wxSTC_PERFORMED_USER = 0x10;
|
||||
const int wxSTC_PERFORMED_UNDO = 0x20;
|
||||
const int wxSTC_PERFORMED_REDO = 0x40;
|
||||
const int wxSTC_LASTSTEPINUNDOREDO = 0x100;
|
||||
const int wxSTC_MOD_CHANGEMARKER = 0x200;
|
||||
const int wxSTC_MOD_BEFOREINSERT = 0x400;
|
||||
const int wxSTC_MOD_BEFOREDELETE = 0x800;
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
|
||||
|
||||
|
@@ -92,6 +92,11 @@ class TestListCtrlPanel(wxPanel):
|
||||
|
||||
self.list.SetItemState(5, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED)
|
||||
|
||||
# show how to change the colour of an item
|
||||
item = self.list.GetItem(1)
|
||||
item.SetTextColour(wxBLUE)
|
||||
self.list.SetItem(item)
|
||||
|
||||
self.currentItem = 0
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)
|
||||
|
@@ -10,7 +10,9 @@ class CustomStatusBar(wxStatusBar):
|
||||
wxStatusBar.__init__(self, parent, -1)
|
||||
self.SetFieldsCount(3)
|
||||
self.log = log
|
||||
self.sizeChanged = false
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
|
||||
self.SetStatusText("A Custom StatusBar...", 0)
|
||||
|
||||
@@ -18,12 +20,8 @@ class CustomStatusBar(wxStatusBar):
|
||||
EVT_CHECKBOX(self, 1001, self.OnToggleClock)
|
||||
self.cb.SetValue(true)
|
||||
|
||||
# figure out how tall to make it.
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.GetFont())
|
||||
(w,h) = dc.GetTextExtent('X')
|
||||
h = int(h * 1.8)
|
||||
self.SetSize(wxSize(100, h))
|
||||
# set the initial position of the checkbox
|
||||
self.Reposition()
|
||||
|
||||
# start our timer
|
||||
self.timer = wxPyTimer(self.Notify)
|
||||
@@ -38,6 +36,7 @@ class CustomStatusBar(wxStatusBar):
|
||||
self.SetStatusText(st, 2)
|
||||
self.log.WriteText("tick...\n")
|
||||
|
||||
|
||||
# the checkbox was clicked
|
||||
def OnToggleClock(self, event):
|
||||
if self.cb.GetValue():
|
||||
@@ -47,11 +46,26 @@ class CustomStatusBar(wxStatusBar):
|
||||
self.timer.Stop()
|
||||
|
||||
|
||||
def OnSize(self, evt):
|
||||
self.Reposition() # for normal size events
|
||||
|
||||
# Set a flag so the idle time handler will also do the repositioning.
|
||||
# It is done this way to get around a buglet where GetFieldRect is not
|
||||
# accurate during the EVT_SIZE resulting from a frame maximize.
|
||||
self.sizeChanged = true
|
||||
|
||||
|
||||
def OnIdle(self, evt):
|
||||
if self.sizeChanged:
|
||||
self.Reposition()
|
||||
|
||||
|
||||
# reposition the checkbox
|
||||
def OnSize(self, event):
|
||||
def Reposition(self):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.cb.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.cb.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
self.sizeChanged = false
|
||||
|
||||
|
||||
|
||||
@@ -89,28 +103,4 @@ def runTest(frame, nb, log):
|
||||
|
||||
overview = """\
|
||||
A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information. It can contain one or more fields, one or more of which can be variable length according to the size of the window.
|
||||
|
||||
wxStatusBar()
|
||||
----------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
|
||||
|
||||
Constructor, creating the window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The window parent, usually a frame.
|
||||
|
||||
id = The window identifier. It may take a value of -1 to indicate a default value.
|
||||
|
||||
pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
|
||||
|
||||
size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
|
||||
|
||||
style = The window style. See wxStatusBar.
|
||||
|
||||
name = The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.
|
||||
"""
|
||||
|
@@ -127,6 +127,7 @@ class PythonSTC(wxStyledTextCtrl):
|
||||
# Code completion
|
||||
else:
|
||||
self.AutoCompShow('I love wxPython a b c')
|
||||
self.AutoCompSelect('wx')
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user