📄 kr_option.h
字号:
/***************************************************************************
KR_Option.h -
-------------------
begin : Tue Mar 3 2004
copyright : (C) 2004 by DigitalAirways
email : info@digitalairways.com
***************************************************************************/
/*
* Copyright (c) 2000-2004 DigitalAirways, sarl. All Rights Reserved.
*
* This software is the confidential and proprietary information of
* DigitalAirways, sarl. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with DigitalAirways.
* A copy of this license is included in the licence.txt file included
* in this software package.
*/
/*
**************************************************************
* TODO
**************************************************************
-
**************************************************************
* HISTORY
**************************************************************
-
*/
#ifndef __KR_OPTION__
#define __KR_OPTION__
#include "KR_KRuntime.h"
#include "KR_Object.h"
#include "KR_Group.h"
#include "KR_KPage.h"
#include "KR_Messages.h"
#include "KR_Resources.h"
#define NO_OWNERSHIP 0
#define BINDINGSONFOCUS_OWNERSHIP 0x000000002
#define BINDINGSONACCEPT_OWNERSHIP 0x000000004
#define BGSRCOFF_OWNERSHIP 0x000000008
#define BGSRCON_OWNERSHIP 0x000000010
#define PARAM_OWNERSHIP 0x000000020
#define LINK_OWNERSHIP 0x000000040
#define CAPTIONON_OWNERSHIP 0x000000080
#define CAPTIONOFF_OWNERSHIP 0x000000100
class Slot;
class KREBDLIBS_API Option : public Plugin {
friend class KPage;
friend class Group;
protected:
char* fAlt;
#ifdef DEV_CONSISTENCY
char* fVersion;
#endif
Group* fGroup;
long fGroupId;
int fOwnership; // track ownership of field members
boolean fInitialOption;
long fOutdatedStamp;
// Image sources
char* fBgSrcOn;
char* fBgSrcOff;
// In order to instanciate it only once...
// Note that to save memory, we decided that the same JitMapper was shared by both off/on states.
JitMapper* fJitmap ;
void* fCaptionOn;
void* fCaptionOff;
char* fLink;
char* fLinkAccept;
char* fLinkUserAgent;
long fAccessKey;
SmallArrayList* /* Group* */ fBindingsOnFocus;
SmallArrayList* /* Group* */ fBindingsOnAccept;
char* fOptionParam;
long fGroupIndex;
boolean fDimmed;
private:
void safeFreeCaptionOn();
void safeFreeCaptionOff();
void setOwnershipBit(int bit) {
fOwnership |= bit;
}
void clearOwnershipBit(int bit) {
fOwnership &= ~bit;
}
int testOwnershipBit(int bit) {
return fOwnership & bit;
}
void zetOptionParam(char* optionParam) {
SAFE_FREE(fOptionParam);
fOptionParam = optionParam;
}
void activateGroupsOnFocus();
void activateGroupsOnAccept() ;
void zetLink(char* link, char* accept, char* useragent) {
SAFE_FREE(fLink);
fLink = link;
SAFE_FREE(fLinkAccept);
fLinkAccept = accept;
SAFE_FREE(fLinkUserAgent);
fLinkUserAgent = useragent;
}
virtual void marshalRestore(ObjectReader* reader, long version, Group** previousGroup, View** previousView, Option** previousOption);
void marshalRestoreCurrent(ObjectReader* reader, long version, Group** previousGroup, View** previousView, Option** previousOption);
void marshalRestore30(ObjectReader* reader, long version);
virtual void complete(Serializer* serializer);
Option* getClone();
public:
DEFINE_NEW(Option);
DEFINE_DELETE(Option);
Option(GContext* newGContext) ;
virtual ~Option() ;
static Option* instanciatePlugin(GContext* newGContext) {return XNEW(Option) (newGContext);}
boolean isInitialOption() {
return fInitialOption;
}
virtual void setCaptionOff(void* s) {
safeFreeCaptionOff();
fCaptionOff=s;
}
virtual void* getCaptionOff() {
return fCaptionOff;
}
void setDimmed(boolean b) {
fDimmed=b;
}
boolean isDimmed() {
return fDimmed;
}
virtual void setCaptionOn(void* s) {
safeFreeCaptionOn();
fCaptionOn=s;
}
virtual void* getCaptionOn() {
return fCaptionOn == NULL ? getCaptionOff() : fCaptionOn;
}
// DEPRECATED BEGIN
long getAccessKeyAction() {
return fAccessKey;
}
void setAccessKeyAction(long accessKeyAction) {
fAccessKey = accessKeyAction;
}
// DEPRECATED END
long getAccessKey() {
return fAccessKey;
}
void setAccessKey(long key) {
fAccessKey = key;
}
virtual char* getOptionParam() {
return fOptionParam;
}
void setOptionParam(char* value, boolean takeownership=true);
boolean isOutdated();
void setUpdated();
void setOutdated() {
fOutdatedStamp=-1;
}
long getGroupIndex() {
return fGroupIndex;
}
void setGroupIndex(long groupIndex) {
fGroupIndex = groupIndex;
}
boolean hasFocus();
boolean bindedOnAccept() {
if(!fBindingsOnAccept) return false;
return fBindingsOnAccept->size()>0;
}
SmallArrayList* getBindingsOnFocus() {
return fBindingsOnFocus;
}
void setBindingsOnFocus(SmallArrayList* bindingsOnFocus, boolean takeownership=true);
SmallArrayList* getBindingsOnAccept() {// may be NULL because lazy allocated.
return fBindingsOnAccept;
}
void setBindingsOnAccept(SmallArrayList* bindingsOnAccept, boolean takeownership=true);
void setBgSrcOff(char* bgsrcOff, boolean takeownership=true);
void zetBgSrcOff(char* bgsrcOff);
void setBgSrcOn(char* value, boolean takeownership=true);
void zetBgSrcOn(char* bgsrcOn);
virtual char* getBgSrcOff();
virtual char* getBgSrcOn();
#ifdef USE_DEPRECATED
void setImgOff(PFWImage* img) {
setBgOff(img);
}
void setImgOn(PFWImage* img) {
setBgOn(img);
}
#endif
Group* getGroup() {
return fGroup;
}
void setGroup(Group* g) {
fGroup = g;
}
#ifdef USE_DEPRECATED
boolean isCacheOptionImages() {
return false;
}
void setCacheOptionImages(boolean cacheOptionImages) {
}
#endif
JitMapper* getImg(boolean isOn) ;
JitMapper* getJitMapper(boolean isOn) ;
JitMapper* getJitMapper(){
return fJitmap;
}
void setJitMapper(JitMapper* jitmap);
void setJitmap(void* captionOff, void* captionOn, boolean takeownership=true){ //silently deprecated
setCaptions(captionOff, captionOn, takeownership);
}
virtual void setCaptions(void* captionOff, void* captionOn, boolean takeownership=true);
void setJitmap(char* bgsrcOff, void* captionOff, char* bgsrcOn, void* captionOn, boolean takeownership=true);
void addBindingOnFocus(Group* g) {
if(!fBindingsOnFocus)
fBindingsOnFocus = XNEW(SmallArrayList) (1);
fBindingsOnFocus->add(g);
}
Group* getBindingOnFocus(long i) {
if(!fBindingsOnFocus) return NULL;
return (Group*)fBindingsOnFocus->get(i);
}
void addBindingOnAccept(Group* g, long /*optionAccept*/) {
if(!fBindingsOnAccept)
fBindingsOnAccept = XNEW(SmallArrayList) (1);
fBindingsOnAccept->add(g);
}
Group* getBindingOnAccept(long i) {
if(!fBindingsOnAccept) return NULL;
return (Group*)fBindingsOnAccept->get(i);
}
virtual boolean doAction(long /*actionid*/, char* /*value*/) {
#ifdef KREB_COMPATIBILITY1
doAccept();
#endif
return false;
}
virtual void doAccept() ;
virtual void focusOn() {}
virtual void focusOff() {}
virtual void doFocus() {} // deprecated
virtual void loseFocus() {} // deprecated
void setAlt(char* alt) {
SAFE_FREE(fAlt);
fAlt = xstrdup(alt);
}
char* getAlt() {
return (fAlt == NULL ? (char*)fCaptionOff : fAlt);
}
char* getLink() {
return fLink;
}
KPage* getPage();
Slot* getSlot();
/*
<kaleidoc>
<filename>Option</filename>
<page>
<api>
<class>Option</class>
<method>slottedOn</method>
<java></java>
<cpp>virtual void slottedOn(Slot*) {}</cpp>
<descr>
<p>This virtual method can be overriden to get control when the Option is put in a slot in the render phase.
The slot is passed as a parameter (It can already be retrieved using Option.getSlot() but this call uses a for loop over the slot list).
The default implementation does nothing.
Option.slottedOff() can also be overriden to get control when the Option is replaced by another option in the slot or when the Slot est freed.</p>
</descr>
</api>
</page>
</kaleidoc>
*/
virtual void slottedOn(Slot*) {}
/*
<kaleidoc>
<filename>Option</filename>
<page>
<api>
<class>Option</class>
<method>slottedOff</method>
<java></java>
<cpp>virtual void slottedOff(Slot*)</cpp>
<descr>
<p>This virtual method can be overriden to get control when the Option is replaced by another option in the slot or when the Slot est freed.
The slot is passed as a parameter (It can already be retrieved using Option.getSlot() but this call uses a for loop over the slot list).
The default implementation does nothing.
Option.slottedOff() can also be overriden to get control when the Option is put in a slot in the render phase.</p>
</descr>
</api>
</page>
</kaleidoc>
*/
virtual void slottedOff(Slot*){}
void setLink(char* link, char* accept, char* useragent, boolean takeownership=true);
char* getLinkAccept() {
return fLinkAccept;
}
char* getLinkUserAgent() {
return fLinkUserAgent;
}
virtual boolean isHandleAccept();
virtual boolean isConsumeAction(long actionid) ;
// virtual void setInfo(JitMapper* fJitmap, PFWImage* newBackground, char* newCaption, int newState);
Group* isActivatingBinding(boolean onAccept=true, boolean onFocus=true);
#ifdef DEV_CONSISTENCY
char* getVersion() { return fVersion; }
#endif // def DEV_CONSISTENCY
};
//
typedef Option* pOption ;
typedef pOption (*OptionInstanciator)(GContext* newGContext) ;
#endif // ndef __KR_OPTION__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -