Sunday, August 15, 2010

Making a SfxTabPage

So before you even try fiddling with UI components, try adding this to your gdbinit: http://pastebin.com/RETfw2up

Yeah, it's not the prettiest, but it works. This GDB macro prints all size & position of a window and all its children.
Making a UI component without a SRC file is quite tricky - there's just too many things to be careful about.
Now here's a doc of the SfxTabPage: http://docs.go-oo.org/sfx2/html/classSfxTabPage.html
What's actually used in the project is a SvxTabPage - the difference is in one letter only :) but the usage is different as well. Not only to mention that the SvxTabPage lies in a different project!! I first started extending the SfxTabPage and that caused a lot of problems until I extended the right class - the SVX one.
Some functions are core for this class:
- DeactivatePage: although you won't see it on the first page of the documentation (it's inherited from higher up), it's very important. It defines what happens when you try clicking a diffenre tab. To be able to switch to other tabs, you have to set it to return LEAVE_PAGE. It is also handy to fill in the SfxItemSet with whatever data you have associated with that tab page
- FillItemSet: populate the SfxItemSet (in this case, the stylesheet) with the data collected from the UI
- Reset(): called when pressing the reset button, but also when loading the tab page for the first time. You can use this to set the buttons on your tab page to reflect the current (existing) values in the ItemSet.

These are very important for the functionality. The rest is just make-up for the tabpage to look pretty and show the appropriate UI.

No comments:

Post a Comment