hi,
this problem is to difficult to me, so i have to
ask yours another newbie question...
i think that robin answer me, so i say thx for
all of your advices. Also thx to all others of ya
Basics:
I have a TextCtrl with an Polygon like a triangle
drawed with ClientDc in an upper corner.
if the user moves the mouse over this triangle a
little Dialog without a caption appears and show
a comment. Like an Excel comment.
Because its difficult to close the commentwindow
without any button or a caption i decide to use
EVT_ENTER_WINDOW and LEAVE_WINDOW
to determine the closefunc. It's all for test. Later
there should be more ways to let disappear the win
if i enter the cwindow(resp. the panel). with my
mousecursor the EVT_LEAVE_Handler be
initialized and if i leave the commentwindow
it disappears.
Fine.
But after the commentwindow disappears another
open app (z.B. IE or any other open) gets active
for one second - change to foreground on my
desktop and then my app gets active again and
change to foreground… (???)
if the commentwindow was lying over the statusbar
(which was owned by the TopWindow) of my app
this will also happen, but my App übernimmt capture
immediatly the active status back. the other app will
only get for a ms the activestate…
Its very confuse to me…
i tried to refresh my window (better only one pixel) after
the closing of the commentwin to get my App showing and
not hiding, but that doesnt work...
=(
Thanx, reen
Rene Freund
rene@meder.de
Here's the code...
class CommentTextCtrl(wxTextCtrl):
def __init__(self, parent, ID, value, pos, size, style):
wxTextCtrl.__init__(self, parent, ID, value, pos, size, style)
if style == 32:
self.multiline=1
else:
self.multiline=0
self.window=storedata.GetTopWindow()
self.rect=wxRect(self.window.GetPosition().x,self.window.GetPosition().y,se
lf.window.GetSize().GetWidth(),self.window.GetSize().GetHeight())
self.comment=''
self.modal=None
self.parent=parent
self.doDraw = false
self.commentwin=None
EVT_PAINT(self, self.OnPaint)
self.SetHotspotArea()
EVT_IDLE(self, self.OnCheckDraw)
EVT_MOTION(self, self.CheckMousePos)
def CheckMousePos(self,event):
self.SetHotspotArea()
if self.checkhotspot(event.GetPosition()):
if not self.commentwin:
# init
# Size ist fest vorgegeben, muss variabel
#sein und an SetCommentwinPosition() weitergegeben werden.
self.commentwin = frametools.MyMiniFrame(self.parent,
-1, "Kommentar",
self.SetCommentwinPos(), wxSize(100, 100),
wxSIMPLE_BORDER)
self.panel=wxPanel(self.commentwin,-1)
self.panel.SetBackgroundColour(wxNamedColour(dbuser.GetbgFarbe()))
self.panel.SetForegroundColour(wxNamedColour(dbuser.GetTextFarbe()))
#inhalt
item1 = wxStaticBox( self.panel, -1, "Kommentar" )
self.item0 = wxStaticBoxSizer( item1, wxVERTICAL )
self.text=wxStaticText(self.panel,
-1, "standard comment.",
wxDefaultPosition )
EVT_ENTER_WINDOW(self.panel, self.InitOnExitEvent )
# i've tried another solutions to close the cwin, but i don'T
#now what panel or area i have to choose for the evt_handler.
#My target is to close the window if the user clicks on any place
# but not in the commentwin to close the cwin
EVT_LEFT_UP(self.panel, self.DelThisOnClick)
EVT_LEFT_UP(self, self.DelThisOnClick)
EVT_LEFT_UP(self.window, self.DelThisOnClick)
···
#---
self.item0.AddWindow(self.text, 15,
wxALIGN_CENTRE|wxALL, 20 )
#anzeige und ausrichtung des inhalts
self.panel.SetAutoLayout( true )
self.panel.SetSizer( self.item0 )
self.item0.Fit( self.panel )
self.commentwin.SetSize(self.panel.GetSize())
self.modal=self.commentwin.ShowModal()
self.commentwin.Destroy()
self.commentwin=None
self.doDraw=true
self.DrawNew()
self.window.Refresh(rect=(30,30,1,1))
else:
pass
def InitOnExitEvent(self,event):
EVT_LEAVE_WINDOW(self.panel,self.DelThis)
def DelThis(self,event):
if self.checkifoutside(event.GetPosition()):
self.commentwin.EndModal(self.commentwin.GetReturnCode())
else:
pass
def DelThisOnClick(self,event):
if self.checkifoutside(event.GetPosition()):
self.commentwin.EndModal(self.commentwin.GetReturnCode())
def checkifoutside(self,pos):
if pos.x >self.commentwin.GetPosition().x:
if pos.x <
self.commentwin.GetPosition().x+self.commentwin.GetSize().GetWidth():
if pos.y >self.commentwin.GetPosition().y:
if pos.y <
self.commentwin.GetPosition().y+self.commentwin.GetSize().GetHeight():
return 0
return 1
def wait(self,sek):
time.sleep(sek)
def SetCommentwinPos(self):
#Positionsbestimmung
windowSize=self.window.GetSize()
windowPos=self.window.GetPosition()
pos=self.GetPosition()
pos=self.ClientToScreen(pos)
position=wxPoint(pos.x+self.GetSize().GetWidth(),pos.y-50)-self.GetPosition
()
if position.y < windowPos.y:
position.y=windowPos.y
elif position.y > windowPos.y+windowSize.GetHeight():
position.y=windowPos.y+windowSize.GetHeight()-130
if position.x < windowPos.x:
position.x=windowPos.x
elif position.x > windowPos.x+windowSize.GetWidth()-100:
position.x=windowPos.x+windowSize.GetWidth()-160
return position
def OnPaint(self, evt):
# just set a flag so the drawing is done later after
# CommentTextCtrl is done
self.doDraw = true
evt.Skip()
def OnCheckDraw(self, evt):
if self.doDraw:
self.doDraw = false
self.DrawNew()
def DrawNew(self):
dc = wxClientDC(self)
dc.BeginDrawing()
dc.SetPen(wxRED_PEN)
dc.SetBrush(wxRED_BRUSH)
# is this needed??
dc.SetBackground(wxRED_BRUSH)
#----
dc.DrawPolygon([self.upperleft,self.rightdown,self.corner],0,0,wxODDEVEN_RU
LE)
dc.EndDrawing()
## Now draw your triangle hotspot in the corner using dc
#dc.DrawRectangle(1, 1, 10, 10)
def checkhotspot(self,pos):
if (pos.x > self.upperleft.x):
if (pos.y <self.rightdown.y):
return 1
return 0
def SetHotspotArea(self):
boxSize=self.GetSize()
if boxSize.GetHeight()>50:
boxSize.SetHeight(50)
if self.multiline:
boxSize.SetWidth(boxSize.GetWidth()-17)
self.corner=wxPoint(boxSize.GetWidth()-7,0)
self.rightdown=wxPoint(boxSize.GetWidth()-7,(boxSize.GetHeight()/3))
self.upperleft=wxPoint(boxSize.GetWidth()-7-(boxSize.GetHeight()/3),0)
System:
Win98 II all (required) Updates
Python 2.0
win32extensions for Python
wxpython 2.2
thx